org.apache.jcs.auxiliary.remote.http.server
Class RemoteHttpCacheServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.apache.jcs.auxiliary.remote.http.server.RemoteHttpCacheServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class RemoteHttpCacheServlet
extends javax.servlet.http.HttpServlet

This servlet simply reads and writes objects. The requests are packaged in a general wrapper. The processor works on the wrapper object and returns a response wrapper.

See Also:
Serialized Form

Constructor Summary
RemoteHttpCacheServlet()
           
 
Method Summary
 void destroy()
          Release the cache manager.
protected  void ensureCacheManager()
          Make sure we have a cache manager.
 RemoteCacheServiceAdaptor getRemoteHttpCacheServiceAdaptor()
           
 java.lang.String getServletInfo()
          Get servlet information
 void init(javax.servlet.ServletConfig config)
          Initializes the cache.
protected  RemoteCacheRequest readRequest(javax.servlet.http.HttpServletRequest request)
          Read the request from the input stream.
protected  RemoteCacheRequest readRequestFromStream(java.io.InputStream inputStream)
          Reads the response from the stream and then closes it.
 void service(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Read the request, call the processor, write the response.
 void setRemoteHttpCacheServiceAdaptor(RemoteCacheServiceAdaptor remoteHttpCacheProcessor)
           
protected  void writeResponse(javax.servlet.http.HttpServletResponse response, RemoteCacheResponse cacheResponse)
          Write the response to the output stream.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RemoteHttpCacheServlet

public RemoteHttpCacheServlet()
Method Detail

init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException
Initializes the cache.

This provides an easy extension point. Simply extend this servlet and override the init method to change the way the properties are loaded.

Specified by:
init in interface javax.servlet.Servlet
Overrides:
init in class javax.servlet.GenericServlet
Parameters:
config -
Throws:
javax.servlet.ServletException

service

public void service(javax.servlet.http.HttpServletRequest request,
                    javax.servlet.http.HttpServletResponse response)
             throws javax.servlet.ServletException,
                    java.io.IOException
Read the request, call the processor, write the response.

Overrides:
service in class javax.servlet.http.HttpServlet
Parameters:
request -
response -
Throws:
javax.servlet.ServletException
java.io.IOException

readRequest

protected RemoteCacheRequest readRequest(javax.servlet.http.HttpServletRequest request)
Read the request from the input stream.

Parameters:
request -
Returns:
RemoteHttpCacheRequest

readRequestFromStream

protected RemoteCacheRequest readRequestFromStream(java.io.InputStream inputStream)
                                            throws java.io.IOException,
                                                   java.lang.ClassNotFoundException
Reads the response from the stream and then closes it.

Parameters:
inputStream -
Returns:
RemoteHttpCacheRequest
Throws:
java.io.IOException
java.lang.ClassNotFoundException

writeResponse

protected void writeResponse(javax.servlet.http.HttpServletResponse response,
                             RemoteCacheResponse cacheResponse)
Write the response to the output stream.

Parameters:
response -
cacheResponse -

ensureCacheManager

protected void ensureCacheManager()
Make sure we have a cache manager. This should have happened in the init method.


destroy

public void destroy()
Release the cache manager.

Specified by:
destroy in interface javax.servlet.Servlet
Overrides:
destroy in class javax.servlet.GenericServlet

getServletInfo

public java.lang.String getServletInfo()
Get servlet information

Specified by:
getServletInfo in interface javax.servlet.Servlet
Overrides:
getServletInfo in class javax.servlet.GenericServlet
Returns:
basic info

setRemoteHttpCacheServiceAdaptor

public void setRemoteHttpCacheServiceAdaptor(RemoteCacheServiceAdaptor remoteHttpCacheProcessor)
Parameters:
remoteHttpCacheProcessor - the remoteHttpCacheProcessor to set

getRemoteHttpCacheServiceAdaptor

public RemoteCacheServiceAdaptor getRemoteHttpCacheServiceAdaptor()
Returns:
the remoteHttpCacheProcessor


Copyright © 2002-2009 Apache Software Foundation. All Rights Reserved.