JSlim  


com.gtcgroup.jslim
Class Cacher

java.lang.Object
  extended bycom.gtcgroup.jslim.Cacher

final class Cacher
extends java.lang.Object

This singleton class provides caching.

For details please review the example jslim.xml.

Copyright (c) 1999 - 2004 by Global Technology Consulting Group, Inc. at gtcGroup.com.
Use is authorized, provided the source is acknowledged by inclusion of this copyright notice.

Since:
v. 1.0
Author:
MDT (MarvinToll@gtcGroup.com)

Field Summary
private static java.util.ArrayList alDocumentPaths
          Cached collection of fully-qualified descriptor document paths.
private static boolean blnDocumentLoaded
          Indicates if the default descriptor document(s) were loaded.
private static boolean blnDocumentValidated
          Indicates if the default descriptor document(s) were validated.
private static Cacher cacher
          This singleton providing caching.
private static java.util.HashMap hmCache
          Nested cache of all cached and pooled service (type) objects.
private static java.util.logging.Logger logger
          A Logger object is used to log messages for a specific system or application component.
private static ServicesVO servicesVO_Current
          Immutable class caching a ServiceTypeVO collection.
private static ServicesVO servicesVO_Original
          Immutable class caching a ServiceTypeVO collection.
private static java.lang.String strDescriptorDoc
          The default descriptor document(s) loaded upon instantiation of the singleton.
 
Constructor Summary
private Cacher()
          Singleton Constructor.
 
Method Summary
(package private) static int cacheCount(int intServiceType)
          Returns the collection size.
(package private) static int cacheNewDocumentPath(java.lang.String strDocumentPath)
          Returns the collection index value representing the descriptor document path.
(package private) static void cacheServiceCached(ServiceKeyVO serviceKeyVO, IJSlimCachable ijSlimCachable, java.lang.Object object)
          This method manages the cache for service (type) objects where thread-safety is not a concern.
(package private) static void cacheServicePooled(ServiceKeyVO serviceKeyVO, IJSlimPoolable ijSlimPoolable)
          This method manages the pools for service (type) objects where thread-safety may be a concern.
(package private) static void clearCache()
          Clears all cache.
(package private) static ServicesVO configureLogger(ServicesVO servicesVO)
          Returns verification that the Logger has been successfully configured or reconfigured.
private static void constructCacher(DocumentPortfolioVO documentPortfolioVO)
           
(package private) static boolean containsCachedServiceKey(int intServiceType, java.lang.String strServiceKey)
          Determines whether or not a service type object has been cached.
(package private) static boolean containsServiceKeyVO(int intServiceType, java.lang.String strServiceKey)
          Determines whether or not a service was specified in a descriptor document(s).
(package private) static java.lang.Object getCached(int intServiceType, java.lang.String strServiceKey)
          Returns a cached service (type) object.
(package private) static java.lang.String getDocumentPath(int intDocumentPath)
          Returns the fully-qualified descriptor document path.
(package private) static Cacher getInstance()
          This singleton getInstance() method verifies a clean load of descriptor documents.
(package private)  java.util.logging.Logger getLogger()
          Returns the Logger object from a non-static context.
(package private) static java.util.logging.Logger getLoggerInternal()
          Returns the Logger object from a static context.
(package private) static java.lang.Object getPooled(int intServiceType, java.lang.String strServiceKey)
          Returns a pooled service (type) object.
(package private) static ServiceKeyVO getServiceKeyVO(int intServiceType, java.lang.String strServiceKey)
          Returns a ServiceKeyVO object.
(package private) static java.util.LinkedHashMap getServiceKeyVOs(int intServiceType)
          Returns the collection of ServiceKeyVO objects.
(package private) static ServicesVO getServicesVO4Testing()
          Returns the current ServicesVO object.
private static boolean isCachable(ServiceKeyVO serviceKeyVO, IJSlimCachable ijSlimCachable)
           
(package private) static boolean isDocumentValidated()
          Returns whether or not the descriptor document was validated.
(package private) static void setUpNewDescriptors(ServicesVO servicesVO)
          Replaces the current descriptor services and clears the cache.
(package private) static ServicesVO tearDown()
          Replaces the current descriptor document state with the original and clears cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cacher

private static final Cacher cacher
This singleton providing caching.


strDescriptorDoc

private static java.lang.String strDescriptorDoc
The default descriptor document(s) loaded upon instantiation of the singleton.


blnDocumentValidated

private static boolean blnDocumentValidated
Indicates if the default descriptor document(s) were validated.


blnDocumentLoaded

private static boolean blnDocumentLoaded
Indicates if the default descriptor document(s) were loaded.


logger

private static java.util.logging.Logger logger
A Logger object is used to log messages for a specific system or application component.


servicesVO_Original

private static ServicesVO servicesVO_Original
Immutable class caching a ServiceTypeVO collection. This object represents the original state after loading the default descriptor documents(s).


servicesVO_Current

private static ServicesVO servicesVO_Current
Immutable class caching a ServiceTypeVO collection. This object represents the current state including any descriptor documents(s) loaded dynamically for unit testing.


alDocumentPaths

private static final java.util.ArrayList alDocumentPaths
Cached collection of fully-qualified descriptor document paths.


hmCache

private static final java.util.HashMap hmCache
Nested cache of all cached and pooled service (type) objects.

Constructor Detail

Cacher

private Cacher()
Singleton Constructor.

Method Detail

constructCacher

private static final void constructCacher(DocumentPortfolioVO documentPortfolioVO)
                                   throws JSlimException
Throws:
JSlimException

getInstance

static final Cacher getInstance()
                         throws JSlimRuntimeException
This singleton getInstance() method verifies a clean load of descriptor documents.

Returns:
The Cacher.
Throws:
JSlimRuntimeException - if an exception is encountered.

cacheCount

static final int cacheCount(int intServiceType)
Returns the collection size. (This method is used for unit testing JSlim.)

Parameters:
intServiceType - Represents the service type read from a descriptor document.
Returns:
The collection index value representing the descriptor document path.

cacheNewDocumentPath

static final int cacheNewDocumentPath(java.lang.String strDocumentPath)
Returns the collection index value representing the descriptor document path.

Parameters:
strDocumentPath - Represents the path of the descriptor document.
Returns:
The collection index value representing the descriptor document path.

cacheServicePooled

static final void cacheServicePooled(ServiceKeyVO serviceKeyVO,
                                     IJSlimPoolable ijSlimPoolable)
                              throws JSlimException
This method manages the pools for service (type) objects where thread-safety may be a concern.

Parameters:
serviceKeyVO - A portion of a descriptor document representing one service.
ijSlimPoolable - Interface implemented for determining if a service object may be pooled.
Throws:
JSlimException - if an exception encountered.

cacheServiceCached

static final void cacheServiceCached(ServiceKeyVO serviceKeyVO,
                                     IJSlimCachable ijSlimCachable,
                                     java.lang.Object object)
                              throws JSlimException
This method manages the cache for service (type) objects where thread-safety is not a concern.

Parameters:
serviceKeyVO - A portion of a descriptor document representing one service.
ijSlimCachable - Interface implemented for determining if a service object may be cached.
object - Cachable Object.
Throws:
JSlimException - if an exception encountered.

clearCache

static final void clearCache()
Clears all cache.


configureLogger

static final ServicesVO configureLogger(ServicesVO servicesVO)
                                 throws JSlimException
Returns verification that the Logger has been successfully configured or reconfigured.

Parameters:
servicesVO - Immutable class caching a ServiceTypeVO collection.
Returns:
A ServicesVO indicating the Logger has been successfully configured or reconfigured.
Throws:
JSlimException - if an exception encountered.

containsCachedServiceKey

static final boolean containsCachedServiceKey(int intServiceType,
                                              java.lang.String strServiceKey)
Determines whether or not a service type object has been cached.

Parameters:
intServiceType - Represents the service type read from a descriptor document.
strServiceKey - Represents the service key read from a descriptor document.
Returns:
Whether or not a service type object has been cached.

containsServiceKeyVO

static final boolean containsServiceKeyVO(int intServiceType,
                                          java.lang.String strServiceKey)
Determines whether or not a service was specified in a descriptor document(s).

Parameters:
intServiceType - Represents the service type read from a descriptor document.
strServiceKey - Represents the service key read from a descriptor document.
Returns:
Whether or not a service was specified in a descriptor document(s).

getCached

static final java.lang.Object getCached(int intServiceType,
                                        java.lang.String strServiceKey)
Returns a cached service (type) object.

Parameters:
intServiceType - Represents the service type read from a descriptor document.
strServiceKey - Represents the service key read from a descriptor document.
Returns:
A cached service (type) object.

getDocumentPath

static final java.lang.String getDocumentPath(int intDocumentPath)
Returns the fully-qualified descriptor document path.

Parameters:
intDocumentPath - Represents the path of the descriptor document.
Returns:
The fully-qualified descriptor document path.

getLogger

final java.util.logging.Logger getLogger()
Returns the Logger object from a non-static context.

Returns:
The Logger object.

getLoggerInternal

static final java.util.logging.Logger getLoggerInternal()
Returns the Logger object from a static context.

Returns:
The Logger object.

getPooled

static final java.lang.Object getPooled(int intServiceType,
                                        java.lang.String strServiceKey)
Returns a pooled service (type) object.

Parameters:
intServiceType - Represents the service type read from a descriptor document.
strServiceKey - Represents the service key read from a descriptor document.
Returns:
A pooled service (type) object.

getServiceKeyVO

static final ServiceKeyVO getServiceKeyVO(int intServiceType,
                                          java.lang.String strServiceKey)
                                   throws JSlimException
Returns a ServiceKeyVO object.

Parameters:
intServiceType - Represents the service type read from a descriptor document.
strServiceKey - Represents the service key read from a descriptor document.
Returns:
A ServiceKeyVO object.
Throws:
JSlimException - if an exception encountered.

getServiceKeyVOs

static final java.util.LinkedHashMap getServiceKeyVOs(int intServiceType)
Returns the collection of ServiceKeyVO objects.

Parameters:
intServiceType - Represents the service type read from a descriptor document.
Returns:
The collection of ServiceKeyVO objects.

getServicesVO4Testing

static final ServicesVO getServicesVO4Testing()
Returns the current ServicesVO object.

Returns:
The current ServicesVO object.

isCachable

private static final boolean isCachable(ServiceKeyVO serviceKeyVO,
                                        IJSlimCachable ijSlimCachable)
                                 throws JSlimException
Throws:
JSlimException

isDocumentValidated

static final boolean isDocumentValidated()
Returns whether or not the descriptor document was validated.

Returns:
Whether or not the descriptor document was validated.

setUpNewDescriptors

static final void setUpNewDescriptors(ServicesVO servicesVO)
Replaces the current descriptor services and clears the cache.

Parameters:
servicesVO - Immutable class caching a ServiceTypeVO collection.

tearDown

static final ServicesVO tearDown()
Replaces the current descriptor document state with the original and clears cache.

Returns:
The original ServicesVO values.

JSlim  


Copyright (c) 1999 - 2004 by Global Technology Consulting Group, Inc. at gtcGroup.com.
Use is authorized, provided the source is acknowledged by inclusion of this copyright notice.