Class RemoteHttpCacheServlet
java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
org.apache.commons.jcs3.auxiliary.remote.http.server.RemoteHttpCacheServlet
- All Implemented Interfaces:
Serializable
,Servlet
,ServletConfig
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:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ICacheEventLogger
Tries to get the event logger.protected RemoteHttpCacheServerAttributes
Configure.protected <K,
V> RemoteHttpCacheService<K, V> createRemoteHttpCacheService
(ICompositeCacheManager cacheManager) Configures the attributes and the event logger and constructs a service.void
destroy()
Release the cache manager.Get servlet informationvoid
init
(ServletConfig config) Initializes the cache.protected RemoteCacheResponse<Object>
Processes the request.protected RemoteCacheRequest<Serializable,
Serializable> readRequest
(HttpServletRequest request) Read the request from the input stream.protected RemoteCacheRequest<Serializable,
Serializable> readRequestFromStream
(InputStream inputStream) Reads the response from the stream and then closes it.void
service
(HttpServletRequest request, HttpServletResponse response) Read the request, call the processor, write the response.protected void
protected void
writeResponse
(HttpServletResponse response, RemoteCacheResponse<Object> 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
-
Constructor Details
-
RemoteHttpCacheServlet
public RemoteHttpCacheServlet()
-
-
Method Details
-
init
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 interfaceServlet
- Overrides:
init
in classGenericServlet
- Parameters:
config
-- Throws:
ServletException
-
service
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException Read the request, call the processor, write the response.- Overrides:
service
in classHttpServlet
- Parameters:
request
-response
-- Throws:
ServletException
IOException
-
readRequest
Read the request from the input stream.- Parameters:
request
-- Returns:
- RemoteHttpCacheRequest
-
readRequestFromStream
protected RemoteCacheRequest<Serializable,Serializable> readRequestFromStream(InputStream inputStream) throws IOException, ClassNotFoundException Reads the response from the stream and then closes it.- Parameters:
inputStream
-- Returns:
- RemoteHttpCacheRequest
- Throws:
IOException
ClassNotFoundException
-
writeResponse
protected void writeResponse(HttpServletResponse response, RemoteCacheResponse<Object> cacheResponse) Write the response to the output stream.- Parameters:
response
-cacheResponse
-
-
processRequest
protected RemoteCacheResponse<Object> processRequest(RemoteCacheRequest<Serializable, Serializable> request) Processes the request. It will call the appropriate method on the service- Parameters:
request
-- Returns:
- RemoteHttpCacheResponse, never null
-
createRemoteHttpCacheService
protected <K,V> RemoteHttpCacheService<K,V> createRemoteHttpCacheService(ICompositeCacheManager cacheManager) Configures the attributes and the event logger and constructs a service.- Parameters:
cacheManager
-- Returns:
- RemoteHttpCacheService
-
configureCacheEventLogger
Tries to get the event logger.- Parameters:
props
-- Returns:
- ICacheEventLogger
-
configureRemoteHttpCacheServerAttributes
Configure.jcs.remotehttpcache.serverattributes.ATTRIBUTENAME=ATTRIBUTEVALUE
- Parameters:
prop
-- Returns:
- RemoteCacheServerAttributesconfigureRemoteCacheServerAttributes
-
setRemoteCacheService
- Parameters:
rcs
- the remoteCacheService to set
-
destroy
Release the cache manager.- Specified by:
destroy
in interfaceServlet
- Overrides:
destroy
in classGenericServlet
-
getServletInfo
Get servlet information- Specified by:
getServletInfo
in interfaceServlet
- Overrides:
getServletInfo
in classGenericServlet
- Returns:
- basic info
-