| 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:
-
get a Request reader
-
ask the Request Reader for the Request object
-
Provide the resulting Request with the ServletRequest that generated it
-
get the appropiate ResponseHandler
-
ask it to execute the Request
-
set the response content type
-
write to the http response's output stream
-
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 $ |
Method Summary | |
protected ServiceStrategy | createServiceStrategy() Gets the strategy for outputting the response. | public void | doGet(HttpServletRequest request, HttpServletResponse response) | public void | doPost(HttpServletRequest request, HttpServletResponse response) Performs the post method. | public void | doPost(HttpServletRequest request, HttpServletResponse response, Reader requestXml) Performs the post method. | protected void | doService(HttpServletRequest request, HttpServletResponse response, Request serviceRequest) Peforms service according to ServiceStrategy. | public WebApplicationContext | getApplicationContext() | public Data | getCatalog() | abstract protected ExceptionHandler | getExceptionHandler() Gets the exception handler for this service. | public GeoServer | getGeoServer() | protected KvpRequestReader | getKvpReader(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 String | getKvpString() | protected String | getMimeType() | public String | getRequest() | final public Response | getResponse() 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 Response | getResponseHandler() Gets the response class that should handle the request of this service. | public String | getService() | public Service | getServiceRef() | public String | getServiceStrategy() | public ServletContext | getServletContext() Override and use spring set servlet context. | protected XmlRequestReader | getXmlRequestReader() Gets a reader that will handle a posted xml request for this servlet.
Subclasses should override to supply a specific xml reader. | protected boolean | isServiceEnabled(HttpServletRequest req) Determines if the service is enabled. | protected boolean | requestSupportsGzip(HttpServletRequest request) Checks if the client requests supports gzipped responses by quering it's
'accept-encoding' header. | protected void | send(HttpServletResponse response, CharSequence content) | protected void | send(HttpServletResponse response, CharSequence content, String mimeType) | protected void | send(HttpServletRequest httpRequest, HttpServletResponse response, Response result) | protected void | sendDisabledServiceError(HttpServletResponse response) Sends the standard disabled service error message (a 503 error followed by an english description). | protected void | sendError(HttpServletRequest request, HttpServletResponse response, Throwable t) Send error produced during getService opperation.
Some errors know how to write themselves out WfsTransactionException for
instance. | protected void | sendError(HttpServletRequest request, HttpServletResponse response, ServiceException se) Send a serviceException produced during getService opperation. | public void | setApplicationContext(ApplicationContext context) Sets the application context. | public void | setCatalog(Data catalog) Sets the reference to the global catalog instance. | public void | setGeoServer(GeoServer geoServer) Sets the reference to the global geoserver instance. | public void | setKvpString(String kvpString) | public void | setServiceRef(Service serviceRef) Sets a refeference to the global service instance. | public void | setServiceStrategy(String serviceStrategy) Sets the id used to identify the service strategy to be used. |
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)
|
serviceStrategy | String serviceStrategy(Code) | | Id of the service strategy to use.
|
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 |
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. |
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. |
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. |
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, String mimeType)(Code) | | DOCUMENT ME!
Parameters: response - DOCUMENT ME! Parameters: content - DOCUMENT ME! Parameters: mimeType - 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! |
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)
|
|
|