Java Doc for AbstractService.java in  » GIS » GeoServer » org » vfny » geoserver » servlets » 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 » GeoServer » org.vfny.geoserver.servlets 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


javax.servlet.http.HttpServlet
   org.vfny.geoserver.servlets.AbstractService

All known Subclasses:   org.vfny.geoserver.wms.servlets.WMService,  org.vfny.geoserver.sld.servlets.PutStyles,  org.vfny.geoserver.wcs.servlets.WCService,
AbstractService
abstract public class AbstractService extends HttpServlet implements ApplicationContextAware(Code)
Represents a service that all others extend from. Subclasses should provide response and exception handlers as appropriate.

It is really important to adhere to the following workflow:

  1. get a Request reader
  2. ask the Request Reader for the Request object
  3. Provide the resulting Request with the ServletRequest that generated it
  4. get the appropiate ResponseHandler
  5. ask it to execute the Request
  6. set the response content type
  7. write to the http response's output stream
  8. pending - call Response cleanup

If anything goes wrong a ServiceException can be thrown and will be written to the output stream instead.

This is because we have to be sure that no exception have been produced before setting the response's content type, so we can set the exception specific content type; and that Response.getContentType is called AFTER Response.execute, since the MIME type can depend on any request parameter or another kind of desission making during the execute process. (i.e. FORMAT in WMS GetMap)

TODO: We need to call Response.abort() if anything goes wrong to allow the Response a chance to cleanup after itself.


author:
   Gabriel Rold?n
author:
   Chris Holmes
author:
   Jody Garnett, Refractions Research
version:
   $Id: AbstractService.java 8443 2008-02-25 13:18:59Z groldan $


Field Summary
protected static  LoggerLOGGER
    
 Datacatalog
     Reference to the catalog.
 WebApplicationContextcontext
    
 GeoServergeoServer
     Reference to the global geoserver instnace.
 intpartialBufferSize
    
 Stringrequest
    
 Stringservice
    
 ServiceserviceRef
    
 StringserviceStrategy
     Id of the service strategy to use.

Constructor Summary
public  AbstractService(String service, String request, Service serviceRef)
     Constructor for abstract service.

Method Summary
protected  ServiceStrategycreateServiceStrategy()
     Gets the strategy for outputting the response.
public  voiddoGet(HttpServletRequest request, HttpServletResponse response)
    
public  voiddoPost(HttpServletRequest request, HttpServletResponse response)
     Performs the post method.
public  voiddoPost(HttpServletRequest request, HttpServletResponse response, Reader requestXml)
     Performs the post method.
protected  voiddoService(HttpServletRequest request, HttpServletResponse response, Request serviceRequest)
     Peforms service according to ServiceStrategy.
public  WebApplicationContextgetApplicationContext()
    
public  DatagetCatalog()
    
abstract protected  ExceptionHandlergetExceptionHandler()
     Gets the exception handler for this service.
public  GeoServergetGeoServer()
    
protected  KvpRequestReadergetKvpReader(Map params)
     Gets a reader that will figure out the correct Key Vaule Pairs for this service.

Subclasses should override to supply a specific kvp reader.

public  StringgetKvpString()
    
protected  StringgetMimeType()
    
public  StringgetRequest()
    
final public  ResponsegetResponse()
     This method was added in order to adapt the old style servlet services to the new ows dispatching interface, without having to modify the services themselves.
protected  ResponsegetResponseHandler()
     Gets the response class that should handle the request of this service.
public  StringgetService()
    
public  ServicegetServiceRef()
    
public  StringgetServiceStrategy()
    
public  ServletContextgetServletContext()
     Override and use spring set servlet context.
protected  XmlRequestReadergetXmlRequestReader()
     Gets a reader that will handle a posted xml request for this servlet.

Subclasses should override to supply a specific xml reader.

protected  booleanisServiceEnabled(HttpServletRequest req)
     Determines if the service is enabled.
protected  booleanrequestSupportsGzip(HttpServletRequest request)
     Checks if the client requests supports gzipped responses by quering it's 'accept-encoding' header.
protected  voidsend(HttpServletResponse response, CharSequence content)
    
protected  voidsend(HttpServletResponse response, CharSequence content, String mimeType)
    
protected  voidsend(HttpServletRequest httpRequest, HttpServletResponse response, Response result)
    
protected  voidsendDisabledServiceError(HttpServletResponse response)
     Sends the standard disabled service error message (a 503 error followed by an english description).
protected  voidsendError(HttpServletRequest request, HttpServletResponse response, Throwable t)
     Send error produced during getService opperation.

Some errors know how to write themselves out WfsTransactionException for instance.

protected  voidsendError(HttpServletRequest request, HttpServletResponse response, ServiceException se)
     Send a serviceException produced during getService opperation.
public  voidsetApplicationContext(ApplicationContext context)
     Sets the application context.
public  voidsetCatalog(Data catalog)
     Sets the reference to the global catalog instance.
public  voidsetGeoServer(GeoServer geoServer)
     Sets the reference to the global geoserver instance.
public  voidsetKvpString(String kvpString)
    
public  voidsetServiceRef(Service serviceRef)
     Sets a refeference to the global service instance.
public  voidsetServiceStrategy(String serviceStrategy)
     Sets the id used to identify the service strategy to be used.

Field Detail
LOGGER
protected static Logger LOGGER(Code)
Class logger



catalog
Data catalog(Code)
Reference to the catalog.



context
WebApplicationContext context(Code)
Application context used to look up "Services"



geoServer
GeoServer geoServer(Code)
Reference to the global geoserver instnace.



partialBufferSize
int partialBufferSize(Code)
buffer size to use when PARTIAL-BUFFER is being used



request
String request(Code)
Request type (maps to 'REQUEST' parameter in OGC service urls)



service
String service(Code)
Servivce group (maps to 'SERVICE' parameter in OGC service urls)



serviceRef
Service serviceRef(Code)
Reference to the service



serviceStrategy
String serviceStrategy(Code)
Id of the service strategy to use.




Constructor Detail
AbstractService
public AbstractService(String service, String request, Service serviceRef)(Code)
Constructor for abstract service.
Parameters:
  service - The service group the service falls into (WFS,WMS,...)
Parameters:
  request - The service being requested (GetCapabilities, GetMap, ...)
Parameters:
  serviceRef - The global service this "servlet" falls into




Method Detail
createServiceStrategy
protected ServiceStrategy createServiceStrategy() throws ServiceException(Code)
Gets the strategy for outputting the response. This method gets the strategy from the serviceStrategy param in the web.xml file. This is sort of odd behavior, as all other such parameters are set in the services and catalog xml files, and this param may move there. But as it is much more of a programmer configuration than a user configuration there is no rush to move it.

Subclasses may choose to override this method in order to get a strategy more suited to their response. Currently only Transaction will do this, since the commit is only called after writeTo, and it often messes up, so we want to be able to see the error message (SPEED writes the output directly, so errors in writeTo do not show up.)

Most subclasses should not override, this method will most always return the SPEED strategy, since it is the fastest response and should work fine if everything is well tested. FILE and BUFFER should be used when there are errors in writeTo methods of child classes, set by the programmer in the web.xml file.

The service strategy found in the web.xml serviceStrategyparameter. The code that finds this is in the init method
throws:
  ServiceException - If the service strategy set in #init() is notvalid.
See Also:   AbstractService.init()
See Also:    for the code that sets the serviceStrategy.



doGet
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException(Code)
DOCUMENT ME!
Parameters:
  request - DOCUMENT ME!
Parameters:
  response - DOCUMENT ME!
throws:
  ServletException - DOCUMENT ME!
throws:
  IOException - DOCUMENT ME!



doPost
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException(Code)
Performs the post method. Simply passes itself on to the three argument doPost method, with null for the reader, because the request.getReader() will not have been used if this servlet is called directly.
Parameters:
  request - DOCUMENT ME!
Parameters:
  response - DOCUMENT ME!
throws:
  ServletException - DOCUMENT ME!
throws:
  IOException - DOCUMENT ME!



doPost
public void doPost(HttpServletRequest request, HttpServletResponse response, Reader requestXml) throws ServletException, IOException(Code)
Performs the post method. Gets the appropriate xml reader and determines the request from that, and then passes the request on to doService.
Parameters:
  request - The request made.
Parameters:
  response - The response to be returned.
Parameters:
  requestXml - A reader of the xml to be read. This is only used bythe dispatcher, everyone else should just pass in null. This isneeded because afaik HttpServletRequest.getReader() can not beused twice. So in a dispatched case we write it to a temp file,which we can then read in twice.
throws:
  ServletException - DOCUMENT ME!
throws:
  IOException - DOCUMENT ME!



doService
protected void doService(HttpServletRequest request, HttpServletResponse response, Request serviceRequest) throws ServletException(Code)
Peforms service according to ServiceStrategy.

This method has very strict requirements, please see the class description for the specifics.

It has a lot of try/catch blocks, but they are fairly necessary to handle things correctly and to avoid as many ugly servlet responses, so that everything is wrapped correctly.


Parameters:
  request - The httpServlet of the request.
Parameters:
  response - The response to be returned.
Parameters:
  serviceRequest - The OGC request to service.
throws:
  ServletException - if the strategy can't be instantiated



getApplicationContext
public WebApplicationContext getApplicationContext()(Code)
The application context.



getCatalog
public Data getCatalog()(Code)
The reference to the global catalog instance.



getExceptionHandler
abstract protected ExceptionHandler getExceptionHandler()(Code)
Gets the exception handler for this service. The correct ExceptionHandler



getGeoServer
public GeoServer getGeoServer()(Code)
the reference to the global geoserver instance.



getKvpReader
protected KvpRequestReader getKvpReader(Map params)(Code)
Gets a reader that will figure out the correct Key Vaule Pairs for this service.

Subclasses should override to supply a specific kvp reader. Default implementation returns null


Parameters:
  params - A map of the kvp pairs. An initialized KVP reader to decode the request.



getKvpString
public String getKvpString()(Code)



getMimeType
protected String getMimeType()(Code)
DOCUMENT ME! DOCUMENT ME!



getRequest
public String getRequest()(Code)
Returns the "request" this service maps to.



getResponse
final public Response getResponse()(Code)
This method was added in order to adapt the old style servlet services to the new ows dispatching interface, without having to modify the services themselves. A call to AbstractService.getResponseHandler().



getResponseHandler
protected Response getResponseHandler()(Code)
Gets the response class that should handle the request of this service. All subclasses must implement.

This method is not abstract to support subclasses that use the request-response mechanism.

The response that the request read by this servlet should bepassed to.



getService
public String getService()(Code)
Returns the "service group" that this service falls into.



getServiceRef
public Service getServiceRef()(Code)
The reference to the global service instance.



getServiceStrategy
public String getServiceStrategy()(Code)
The id used to identify the service strategy to be used.
See Also:   ServiceStrategy.getId



getServletContext
public ServletContext getServletContext()(Code)
Override and use spring set servlet context.



getXmlRequestReader
protected XmlRequestReader getXmlRequestReader()(Code)
Gets a reader that will handle a posted xml request for this servlet.

Subclasses should override to supply a specific xml reader. Default implementation returns null

An XmlRequestReader appropriate to this service.



isServiceEnabled
protected boolean isServiceEnabled(HttpServletRequest req)(Code)
Determines if the service is enabled.

Subclass should override this method if the service can be turned on/off. This implementation returns true




requestSupportsGzip
protected boolean requestSupportsGzip(HttpServletRequest request)(Code)
Checks if the client requests supports gzipped responses by quering it's 'accept-encoding' header.
Parameters:
  request - the request to query the HTTP header from true if 'gzip' if one of the supported content encodings ofrequest, false otherwise.



send
protected void send(HttpServletResponse response, CharSequence content)(Code)
DOCUMENT ME!
Parameters:
  response - DOCUMENT ME!
Parameters:
  content - DOCUMENT ME!



send
protected void send(HttpServletResponse response, CharSequence content, String mimeType)(Code)
DOCUMENT ME!
Parameters:
  response - DOCUMENT ME!
Parameters:
  content - DOCUMENT ME!
Parameters:
  mimeType - DOCUMENT ME!



send
protected void send(HttpServletRequest httpRequest, HttpServletResponse response, Response result)(Code)
DOCUMENT ME!
Parameters:
  response - DOCUMENT ME!
Parameters:
  result - DOCUMENT ME!



sendDisabledServiceError
protected void sendDisabledServiceError(HttpServletResponse response) throws IOException(Code)
Sends the standard disabled service error message (a 503 error followed by an english description).
Parameters:
  response -
throws:
  IOException -



sendError
protected void sendError(HttpServletRequest request, HttpServletResponse response, Throwable t)(Code)
Send error produced during getService opperation.

Some errors know how to write themselves out WfsTransactionException for instance. It looks like this might be is handled by getExceptionHandler().newServiceException( t, pre, null ). I still would not mind seeing a check for ServiceConfig Exception here.

This code says that it deals with UNCAUGHT EXCEPTIONS, so I think it would be wise to explicitly catch ServiceExceptions.


Parameters:
  response - DOCUMENT ME!
Parameters:
  t - DOCUMENT ME!



sendError
protected void sendError(HttpServletRequest request, HttpServletResponse response, ServiceException se)(Code)
Send a serviceException produced during getService opperation.
Parameters:
  response - DOCUMENT ME!
Parameters:
  se - DOCUMENT ME!



setApplicationContext
public void setApplicationContext(ApplicationContext context) throws BeansException(Code)
Sets the application context.

Used to process the Service extension point.




setCatalog
public void setCatalog(Data catalog)(Code)
Sets the reference to the global catalog instance.



setGeoServer
public void setGeoServer(GeoServer geoServer)(Code)
Sets the reference to the global geoserver instance.



setKvpString
public void setKvpString(String kvpString)(Code)



setServiceRef
public void setServiceRef(Service serviceRef)(Code)
Sets a refeference to the global service instance.



setServiceStrategy
public void setServiceStrategy(String serviceStrategy)(Code)
Sets the id used to identify the service strategy to be used.



Methods inherited from javax.servlet.http.HttpServlet
protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException(Code)(Java Doc)
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException(Code)(Java Doc)
protected void doHead(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException(Code)(Java Doc)
protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException(Code)(Java Doc)
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException(Code)(Java Doc)
protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException(Code)(Java Doc)
protected void doTrace(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException(Code)(Java Doc)
protected long getLastModified(HttpServletRequest req)(Code)(Java Doc)
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException(Code)(Java Doc)
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.