com.voidsearch.voidbase.apps.cache
Class CacheModule

java.lang.Object
  extended by com.voidsearch.voidbase.apps.cache.CacheModule
All Implemented Interfaces:
VoidBaseModule, java.lang.Runnable

public class CacheModule
extends java.lang.Object
implements VoidBaseModule

CacheModule is a generic cache module which implements strategies for containing and routing to cache handlers and handling a high-level atomicity of operations on cache implementations based on individual cache handler configurations.


Field Summary
protected  VoidBaseConfig config
           
protected static java.lang.String CONFIG_PATH
           
protected static VoidBaseResponseType DEFAULT_TYPE
           
protected  java.lang.String defaultHandler
           
protected  java.util.concurrent.ConcurrentHashMap<java.lang.String,VoidBaseCache> handlers
           
protected static org.slf4j.Logger logger
           
protected  java.lang.String name
           
 
Constructor Summary
CacheModule()
          Creates a new instance of CacheModule
 
Method Summary
protected  java.lang.String getContent(java.lang.String content, java.util.Map<java.lang.String,java.lang.String> params)
          Returns a content from request params
protected  java.lang.String getJSON(java.lang.String message, CacheResponseStatus status)
          Builds JSON from a cache result response
protected  java.lang.String getKey(java.util.List<java.lang.String> route, java.util.Map<java.lang.String,java.lang.String> params)
          Returns a key from request params
protected  java.lang.String getResource()
          Returns a CacheModule's resource
protected  java.util.List<java.lang.String> getRoute(java.util.List<java.lang.String> route)
          Returns a Cache specific route from original request route
 CacheResponse handle(java.lang.String method, java.lang.String key, java.lang.String content)
          Handler for all cache requests which are further proxied down to specific cache handler
 CacheResponse handle(java.lang.String handler, java.lang.String method, java.lang.String key, java.lang.String content)
          Handler for all cache requests which are further proxied down to specific cache handler
 CacheResponse handle(java.lang.String handler, java.lang.String method, java.lang.String name, java.lang.String key, java.lang.String content)
          Handler for all cache requests which are further proxied down to specific cache handler
 VoidBaseModuleResponse handle(VoidBaseModuleRequest request)
          Handler for all cache requests which are further proxied down to specific cache handler
 void initialize(java.lang.String name)
          Initializes CacheModule and all configured cache handlers
protected  void initializeCacheModules(java.util.Map<java.lang.String,java.lang.String> modules)
          Initializes specific cache modules/handlers
protected  VoidBaseModuleResponse renderResponse(CacheValue value, java.lang.String format, CacheResponseStatus status)
          Returns rendered Cache response from CacheValue object
protected  VoidBaseModuleResponse renderResponse(java.lang.String message, java.lang.String format, CacheResponseStatus status)
          Returns rendered Cache response
protected  VoidBaseResponseStatus renderStatus(CacheResponseStatus status)
          Returnds response status from a cache response
 void run()
          Currently just logs when CacheModule starts
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected java.lang.String name

defaultHandler

protected java.lang.String defaultHandler

config

protected VoidBaseConfig config

handlers

protected java.util.concurrent.ConcurrentHashMap<java.lang.String,VoidBaseCache> handlers

CONFIG_PATH

protected static final java.lang.String CONFIG_PATH
See Also:
Constant Field Values

DEFAULT_TYPE

protected static final VoidBaseResponseType DEFAULT_TYPE

logger

protected static final org.slf4j.Logger logger
Constructor Detail

CacheModule

public CacheModule()
Creates a new instance of CacheModule

Method Detail

initialize

public void initialize(java.lang.String name)
                throws VoidBaseModuleException
Initializes CacheModule and all configured cache handlers

Specified by:
initialize in interface VoidBaseModule
Parameters:
name -
Throws:
VoidBaseModuleException

handle

public VoidBaseModuleResponse handle(VoidBaseModuleRequest request)
                              throws VoidBaseModuleException
Handler for all cache requests which are further proxied down to specific cache handler

Specified by:
handle in interface VoidBaseModule
Parameters:
request -
Returns:
a response from VoidBaseModule handler
Throws:
VoidBaseModuleException

handle

public CacheResponse handle(java.lang.String method,
                            java.lang.String key,
                            java.lang.String content)
                     throws VoidBaseModuleException
Handler for all cache requests which are further proxied down to specific cache handler

Parameters:
method -
key -
content -
Returns:
Throws:
VoidBaseModuleException

handle

public CacheResponse handle(java.lang.String handler,
                            java.lang.String method,
                            java.lang.String key,
                            java.lang.String content)
                     throws VoidBaseModuleException
Handler for all cache requests which are further proxied down to specific cache handler

Parameters:
handler -
method -
key -
content -
Returns:
Throws:
VoidBaseModuleException

handle

public CacheResponse handle(java.lang.String handler,
                            java.lang.String method,
                            java.lang.String name,
                            java.lang.String key,
                            java.lang.String content)
                     throws VoidBaseModuleException
Handler for all cache requests which are further proxied down to specific cache handler

Parameters:
handler -
method -
name -
key -
content -
Returns:
Throws:
VoidBaseModuleException

run

public void run()
Currently just logs when CacheModule starts

Specified by:
run in interface java.lang.Runnable

initializeCacheModules

protected void initializeCacheModules(java.util.Map<java.lang.String,java.lang.String> modules)
                               throws VoidBaseModuleException
Initializes specific cache modules/handlers

Parameters:
modules -
Throws:
VoidBaseModuleException

getRoute

protected java.util.List<java.lang.String> getRoute(java.util.List<java.lang.String> route)
Returns a Cache specific route from original request route

Parameters:
route -
Returns:
a vector of route

getResource

protected java.lang.String getResource()
Returns a CacheModule's resource

Returns:
a module's resource

renderResponse

protected VoidBaseModuleResponse renderResponse(CacheValue value,
                                                java.lang.String format,
                                                CacheResponseStatus status)
Returns rendered Cache response from CacheValue object

Parameters:
value -
format -
status -
Returns:
rendered response from VoidBaseModule handler

renderResponse

protected VoidBaseModuleResponse renderResponse(java.lang.String message,
                                                java.lang.String format,
                                                CacheResponseStatus status)
Returns rendered Cache response

Parameters:
message -
format -
status -
Returns:
rendered response from VoidBaseModule handler

getKey

protected java.lang.String getKey(java.util.List<java.lang.String> route,
                                  java.util.Map<java.lang.String,java.lang.String> params)
Returns a key from request params

Parameters:
route -
params -
Returns:
a key from a request

getContent

protected java.lang.String getContent(java.lang.String content,
                                      java.util.Map<java.lang.String,java.lang.String> params)
Returns a content from request params

Parameters:
content -
params -
Returns:
a content from a request

getJSON

protected java.lang.String getJSON(java.lang.String message,
                                   CacheResponseStatus status)
Builds JSON from a cache result response

Parameters:
message -
status -
Returns:
serialized JSON

renderStatus

protected VoidBaseResponseStatus renderStatus(CacheResponseStatus status)
Returnds response status from a cache response

Parameters:
status -
Returns:
response status of a VoidBaseModule handler


Copyright © 2009. All Rights Reserved.