Source Code Cross Referenced for WMService.java in  » GIS » deegree » org » deegree » ogcwebservices » wms » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » deegree » org.deegree.ogcwebservices.wms 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // $HeadURL: /cvsroot/deegree/src/org/deegree/ogcwebservices/wms/WMService.java,v
002:        // 1.3 2004/07/12 06:12:11 ap Exp $
003:        /*----------------    FILE HEADER  ------------------------------------------
004:
005:         This file is part of deegree.
006:         Copyright (C) 2001-2008 by:
007:         EXSE, Department of Geography, University of Bonn
008:         http://www.giub.uni-bonn.de/deegree/
009:         lat/lon GmbH
010:         http://www.lat-lon.de
011:
012:         This library is free software; you can redistribute it and/or
013:         modify it under the terms of the GNU Lesser General Public
014:         License as published by the Free Software Foundation; either
015:         version 2.1 of the License, or (at your option) any later version.
016:
017:         This library is distributed in the hope that it will be useful,
018:         but WITHOUT ANY WARRANTY; without even the implied warranty of
019:         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
020:         Lesser General Public License for more details.
021:
022:         You should have received a copy of the GNU Lesser General Public
023:         License along with this library; if not, write to the Free Software
024:         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
025:
026:         Contact:
027:
028:         Andreas Poth
029:         lat/lon GmbH
030:         Aennchenstr. 19
031:         53115 Bonn
032:         Germany
033:         E-Mail: poth@lat-lon.de
034:
035:         Prof. Dr. Klaus Greve
036:         Department of Geography
037:         University of Bonn
038:         Meckenheimer Allee 166
039:         53115 Bonn
040:         Germany
041:         E-Mail: greve@giub.uni-bonn.de
042:
043:        
044:         ---------------------------------------------------------------------------*/
045:        package org.deegree.ogcwebservices.wms;
046:
047:        import java.lang.reflect.Constructor;
048:        import java.lang.reflect.InvocationTargetException;
049:
050:        import org.deegree.enterprise.Proxy;
051:        import org.deegree.framework.log.ILogger;
052:        import org.deegree.framework.log.LoggerFactory;
053:        import org.deegree.framework.trigger.TriggerProvider;
054:        import org.deegree.ogcwebservices.CurrentUpdateSequenceException;
055:        import org.deegree.ogcwebservices.InvalidUpdateSequenceException;
056:        import org.deegree.ogcwebservices.OGCWebService;
057:        import org.deegree.ogcwebservices.OGCWebServiceException;
058:        import org.deegree.ogcwebservices.OGCWebServiceRequest;
059:        import org.deegree.ogcwebservices.OGCWebServiceResponse;
060:        import org.deegree.ogcwebservices.getcapabilities.OGCCapabilities;
061:        import org.deegree.ogcwebservices.wms.configuration.WMSConfigurationType;
062:        import org.deegree.ogcwebservices.wms.operation.DescribeLayer;
063:        import org.deegree.ogcwebservices.wms.operation.GetFeatureInfo;
064:        import org.deegree.ogcwebservices.wms.operation.GetLegendGraphic;
065:        import org.deegree.ogcwebservices.wms.operation.GetLegendGraphicResult;
066:        import org.deegree.ogcwebservices.wms.operation.GetMap;
067:        import org.deegree.ogcwebservices.wms.operation.GetStyles;
068:        import org.deegree.ogcwebservices.wms.operation.GetStylesResult;
069:        import org.deegree.ogcwebservices.wms.operation.PutStyles;
070:        import org.deegree.ogcwebservices.wms.operation.WMSGetCapabilities;
071:        import org.deegree.ogcwebservices.wms.operation.WMSGetCapabilitiesResult;
072:        import org.deegree.ogcwebservices.wms.operation.WMSProtocolFactory;
073:
074:        /**
075:         * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
076:         * @author last edited by: $Author: aschmitz $
077:         * 
078:         * @version 1.0. $Revision: 10168 $, $Date: 2008-02-19 08:02:37 -0800 (Tue, 19 Feb 2008) $
079:         * 
080:         * @since 1.1
081:         * 
082:         */
083:
084:        public class WMService implements  OGCWebService {
085:
086:            private static final ILogger LOG = LoggerFactory
087:                    .getLogger(WMService.class);
088:
089:            private static final TriggerProvider TP = TriggerProvider
090:                    .create(WMService.class);
091:
092:            private WMSConfigurationType configuration = null;
093:
094:            /**
095:             * Creates a new WMService object.
096:             * 
097:             * @param configuration
098:             */
099:            public WMService(WMSConfigurationType configuration) {
100:                this .configuration = configuration;
101:                Proxy proxy = configuration.getDeegreeParams().getProxy();
102:                if (proxy != null) {
103:                    proxy.setProxy(true);
104:                }
105:            }
106:
107:            /**
108:             * 
109:             */
110:            public OGCCapabilities getCapabilities() {
111:                // should a class implement the WMSConfigurationType and not be an instance
112:                // of OGCCapabilities, here's where it'll fail ;-)
113:                return (OGCCapabilities) configuration;
114:            }
115:
116:            /**
117:             * the method performs the handling of the passed OGCWebServiceEvent directly and returns the
118:             * result to the calling class/method
119:             * 
120:             * @param request
121:             *            request to perform
122:             * 
123:             * @throws OGCWebServiceException
124:             */
125:            public Object doService(OGCWebServiceRequest request)
126:                    throws OGCWebServiceException {
127:
128:                request = (OGCWebServiceRequest) TP.doPreTrigger(this , request)[0];
129:
130:                LOG.logDebug("Handling WMS request with ID ", request.getId());
131:
132:                Object result = null;
133:                if (request instanceof  GetMap) {
134:                    GetMapHandler gmh = (GetMapHandler) createHandler(request,
135:                            GetMap.class, HandlerMapping
136:                                    .getString("WMService.GETMAP"));
137:                    result = gmh.performGetMap();
138:                } else if (request instanceof  GetFeatureInfo) {
139:                    GetFeatureInfoHandler gmh = (GetFeatureInfoHandler) createHandler(
140:                            request, GetFeatureInfo.class, HandlerMapping
141:                                    .getString("WMService.GETFEATUREINFO"));
142:                    result = gmh.performGetFeatureInfo();
143:                } else if (request instanceof  WMSGetCapabilities) {
144:                    result = handleGetCapabilities((WMSGetCapabilities) request);
145:                } else if (request instanceof  GetStyles) {
146:                    handleGetStyles((GetStyles) request);
147:                } else if (request instanceof  PutStyles) {
148:                    handlePutStyles((PutStyles) request);
149:                } else if (request instanceof  DescribeLayer) {
150:                    result = new DescribeLayerHandler().perform(
151:                            (DescribeLayer) request, configuration);
152:                } else if (request instanceof  GetLegendGraphic) {
153:                    result = handleGetLegendGraphic((GetLegendGraphic) request);
154:                }
155:
156:                LOG.logDebug("Handled WMS request with ID ", request.getId());
157:
158:                return TP.doPostTrigger(this , result)[0];
159:            }
160:
161:            /**
162:             * creates a handler class for performing the incomming request. The instance that will be
163:             * created depends on the responsible class the for the submitted request in the WMS
164:             * capabilities/configuration.
165:             * 
166:             * @param request
167:             *            request to be performed
168:             * @param requestClass
169:             *            of the request (GetStyles, WMSFeatureInfoRequest etc.)
170:             * @param operationType
171:             *            type of the operation to perform by the handler
172:             */
173:            private Object createHandler(OGCWebServiceRequest request,
174:                    Class<?> requestClass, String className)
175:                    throws OGCWebServiceException {
176:                // describes the signature of the required constructor
177:                Class[] cl = new Class[2];
178:                cl[0] = WMSConfigurationType.class;
179:                cl[1] = requestClass;
180:
181:                // set parameter to submitt to the constructor
182:                Object[] o = new Object[2];
183:                o[0] = configuration;
184:                o[1] = request;
185:
186:                Object handler = null;
187:
188:                try {
189:                    // get constructor
190:                    Class<?> creator = Class.forName(className);
191:                    Constructor<?> con = creator.getConstructor(cl);
192:
193:                    // call constructor and instantiate a new DataStore
194:                    handler = con.newInstance(o);
195:                } catch (ClassNotFoundException cce) {
196:                    throw new OGCWebServiceException("Couldn't instantiate "
197:                            + className + "! \n" + cce.toString());
198:                } catch (NoSuchMethodException nsme) {
199:                    throw new OGCWebServiceException("Couldn't instantiate "
200:                            + className + "! \n" + nsme.toString());
201:                } catch (InstantiationException ie) {
202:                    throw new OGCWebServiceException("Couldn't instantiate "
203:                            + className + "! \n" + ie.toString());
204:                } catch (IllegalAccessException iae) {
205:                    throw new OGCWebServiceException("Couldn't instantiate "
206:                            + className + "! \n" + iae.toString());
207:                } catch (InvocationTargetException ite) {
208:                    // causes need not be OGCWebService exceptions
209:                    Throwable cause = ite.getCause();
210:                    if (cause instanceof  OGCWebServiceException) {
211:                        throw (OGCWebServiceException) cause;
212:                    }
213:                    LOG.logError("Unknown error", cause);
214:                    throw new OGCWebServiceException(getClass().getName(),
215:                            cause.getMessage());
216:                } catch (Exception e) {
217:                    throw new OGCWebServiceException("Couldn't instantiate "
218:                            + className + "! \n" + e.toString());
219:                }
220:
221:                return handler;
222:            }
223:
224:            /**
225:             * reads/creates the capabilities of the WMS.
226:             * 
227:             * @param request
228:             *            capabilities request
229:             */
230:            private WMSGetCapabilitiesResult handleGetCapabilities(
231:                    WMSGetCapabilities request) throws OGCWebServiceException {
232:
233:                String rUp = request.getUpdateSequence();
234:                String cUp = configuration.getUpdateSequence();
235:
236:                if ((rUp != null) && (cUp != null) && (rUp.compareTo(cUp) == 0)) {
237:                    throw new CurrentUpdateSequenceException(
238:                            "request update sequence (" + rUp
239:                                    + ") is equal to capabilities"
240:                                    + " update sequence " + cUp);
241:                }
242:
243:                if ((rUp != null) && (cUp != null) && (rUp.compareTo(cUp) > 0)) {
244:                    throw new InvalidUpdateSequenceException(
245:                            "request update sequence: " + rUp
246:                                    + " is higher than the "
247:                                    + "capabilities update sequence " + cUp);
248:                }
249:
250:                WMSGetCapabilitiesResult res = null;
251:                res = WMSProtocolFactory.createGetCapabilitiesResponse(request,
252:                        null, configuration);
253:
254:                return res;
255:            }
256:
257:            /**
258:             * @param request
259:             *            get styles request (WMS 1.1.1 - SLD)
260:             */
261:            private GetStylesResult handleGetStyles(GetStyles request) {
262:                throw new UnsupportedOperationException("handleGetStyles("
263:                        + request.getClass().getSimpleName()
264:                        + ") not implemented");
265:            }
266:
267:            /**
268:             * @param request
269:             *            put styles request (WMS 1.1.1 - SLD)
270:             */
271:            private void handlePutStyles(PutStyles request) {
272:                throw new UnsupportedOperationException("handlePutStyles("
273:                        + request.getClass().getSimpleName()
274:                        + ") not implemented");
275:            }
276:
277:            /**
278:             * @param request
279:             * 
280:             * @return the response
281:             * @throws WebServiceException
282:             */
283:            private OGCWebServiceResponse handleGetLegendGraphic(
284:                    GetLegendGraphic request) throws OGCWebServiceException {
285:                OGCWebServiceResponse result;
286:
287:                Object o = createHandler(request, GetLegendGraphic.class,
288:                        HandlerMapping.getString("WMService.GETLEGENDGRAPHIC"));
289:                GetLegendGraphicHandler glgh = (GetLegendGraphicHandler) o;
290:                result = glgh.performGetLegendGraphic();
291:                if (((GetLegendGraphicResult) result).getLegendGraphic() != null) {
292:                    // cache.push(request, ((GetLegendGraphicResult) result).getLegendGraphic());
293:                }
294:
295:                return result;
296:            }
297:
298:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.