SOAj Consolidated


info.soaj.core.util.internal
Class SjCacher

java.lang.Object
  extended by info.soaj.core.util.internal.SjCacher

public class SjCacher
extends java.lang.Object

This singleton class provides caching and holds reference instances of plugins.

Copyright (c) 2006 - 2009 by Global Technology Consulting Group, Inc. at gtcGroup.com .

Since:
v. 1.0
Author:
MarvinToll@gtcGroup.com

Field Summary
private  java.util.Map<java.lang.String,SjPluginProperties> activeProperties
          Map of properties with an "active" declaration.
private  java.util.Map<java.lang.String,SjBasePlugin> alwaysInstantiatePlugins
          Map of plugins with an "always instantiate" declaration.
private static SjCacher cacher
          Singleton's private instance.
private static java.lang.String CLASS_NAME
          Class name.
private  java.util.List<java.lang.String> inactivePluginKeyList
          List of plugin keys for plugins declared "inactive".
private  java.util.Map<java.lang.String,SjBaseMetadata> pluginMetadata
          Map of metadata with an "active" declaration.
private  java.util.Map<java.lang.String,SjBasePlugin> strongReferencePlugins
          Cache of plugins with a "strong reference" declaration.
 
Constructor Summary
private SjCacher()
          Constructor - Initializes cache.
 
Method Summary
 void clearAllCacheForTestingOnly()
          This method clears all cache.
 boolean containsActivePlugin(SjPopulatedPluginKey populatedPluginKey)
          This method returns whether an active plugin exists.
 boolean containsActiveProperties(SjPopulatedPluginKey populatedPluginKey)
          This method determines whether an active set of properties is cached for a declared plugin key.
private  boolean containsAlwaysInstantiatePlugin(SjPopulatedPluginKey populatedPluginKey)
          This method returns whether a plugin reference copy exists.
 boolean containsInactivePluginKey(SjPopulatedPluginKey populatedPluginKey)
          This method returns whether a plugin key has been declared as inactive.
 boolean containsPluginMetadata(SjPopulatedPluginKey populatedPluginKey)
          This method returns whether plugin metadata is cached for a declared plugin key.
private  boolean containsStrongReferencePlugin(SjPopulatedPluginKey populatedPluginKey)
          This method returns whether cached plugin exists.
<PLUGIN extends SjBasePlugin>
PLUGIN
createActivePlugin(java.lang.Class<PLUGIN> pluginAbstractClass, SjPopulatedPluginKey populatedPluginKey, boolean suppressException)
          This method creates a plugin instance or null.
(package private)  java.util.Map<java.lang.String,SjBasePlugin> getCacheStrongReference()
          This method returns a map for core framework utilization.
 java.util.List<java.lang.String> getInactivePluginKeyList()
          This method returns the inactivePluginKeyList attribute.
static SjCacher getInstance()
          This method returns the reference to the singleton instance.
(package private)  java.util.Map<java.lang.String,SjPluginProperties> getMapActiveProperties()
          This method returns a map for core framework utilization.
(package private)  java.util.Map<java.lang.String,SjBasePlugin> getMapAlwaysInstantiate()
          This method returns a map for core framework utilization.
 void putActivePlugin(SjBasePlugin sjBasePlugin)
          This method puts a plugin instance in a synchronized map.
 void putPluginMetadata(SjPopulatedPluginKey populatedPluginKey, SjBaseMetadata pluginMetadata)
          This method puts a properties instance in a synchronized map.
 void putPluginProperties(SjPluginProperties pluginProperties)
          This method puts a properties instance in a synchronized map.
 SjPluginProperties retrieveActiveProperties(SjPopulatedPluginKey populatedPluginKey)
          This method determines whether an active set of properties is cached for a declared plugin key.
 SjBaseMetadata retrievePluginMetadata(SjPopulatedPluginKey populatedPluginKey)
          This method creates a plugin instance or null.
private  void verifyUniqueActivePluginKey(SjPopulatedPluginKey populatedPluginKey, java.lang.String MethodName)
          This method determines if an active plugin was previously put in a synchronized map and, if so, throws an exception.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_NAME

private static final java.lang.String CLASS_NAME
Class name.


cacher

private static SjCacher cacher
Singleton's private instance.


strongReferencePlugins

private final java.util.Map<java.lang.String,SjBasePlugin> strongReferencePlugins
Cache of plugins with a "strong reference" declaration.


alwaysInstantiatePlugins

private final java.util.Map<java.lang.String,SjBasePlugin> alwaysInstantiatePlugins
Map of plugins with an "always instantiate" declaration.


inactivePluginKeyList

private final java.util.List<java.lang.String> inactivePluginKeyList
List of plugin keys for plugins declared "inactive".


activeProperties

private final java.util.Map<java.lang.String,SjPluginProperties> activeProperties
Map of properties with an "active" declaration.


pluginMetadata

private final java.util.Map<java.lang.String,SjBaseMetadata> pluginMetadata
Map of metadata with an "active" declaration.

Constructor Detail

SjCacher

private SjCacher()
Constructor - Initializes cache.

Method Detail

getInstance

public static SjCacher getInstance()
This method returns the reference to the singleton instance.

Returns:
SjCacher

clearAllCacheForTestingOnly

public void clearAllCacheForTestingOnly()
This method clears all cache. It may be invoked in the context of unit testing (asserting) against an alternate set of active plugins. IT IS *NOT* ADVISABLE TO USE THIS METHOD IN A PRODUCTION CONTEXT.


containsActiveProperties

public boolean containsActiveProperties(SjPopulatedPluginKey populatedPluginKey)
This method determines whether an active set of properties is cached for a declared plugin key.

Parameters:
populatedPluginKey - The 'Key' defined in the descriptor document.
Returns:
boolean - 'True' indicates the existence of an active set of properties.

containsPluginMetadata

public boolean containsPluginMetadata(SjPopulatedPluginKey populatedPluginKey)
This method returns whether plugin metadata is cached for a declared plugin key.

Parameters:
populatedPluginKey - The 'Key' defined in the descriptor document.
Returns:
boolean - 'True' indicates the existence of plugin metadata.

containsInactivePluginKey

public boolean containsInactivePluginKey(SjPopulatedPluginKey populatedPluginKey)
This method returns whether a plugin key has been declared as inactive.

Parameters:
populatedPluginKey - The 'Key' defined in the descriptor document.
Returns:
boolean - 'True' indicates at least one active plugin exists with the key specified.

containsActivePlugin

public boolean containsActivePlugin(SjPopulatedPluginKey populatedPluginKey)
This method returns whether an active plugin exists.

Parameters:
populatedPluginKey - The 'Key' defined in the descriptor document.
Returns:
boolean - 'True' indicates an active plugin is available for creation.

putPluginProperties

public void putPluginProperties(SjPluginProperties pluginProperties)
This method puts a properties instance in a synchronized map.

Parameters:
pluginProperties - Base properties class for all SOAj plugins.

putPluginMetadata

public void putPluginMetadata(SjPopulatedPluginKey populatedPluginKey,
                              SjBaseMetadata pluginMetadata)
This method puts a properties instance in a synchronized map.

Parameters:
populatedPluginKey - The 'Key' defined in the descriptor document.
pluginMetadata - Base metadata class for all SOAj plugins.

putActivePlugin

public void putActivePlugin(SjBasePlugin sjBasePlugin)
This method puts a plugin instance in a synchronized map.

Parameters:
sjBasePlugin - Base class for all SOAj plugins.

retrieveActiveProperties

public SjPluginProperties retrieveActiveProperties(SjPopulatedPluginKey populatedPluginKey)
This method determines whether an active set of properties is cached for a declared plugin key.

Parameters:
populatedPluginKey - The 'Key' defined in the descriptor document.
Returns:
SjPluginProperties - 'True' indicates the existence of an active set of properties.

retrievePluginMetadata

public SjBaseMetadata retrievePluginMetadata(SjPopulatedPluginKey populatedPluginKey)
This method creates a plugin instance or null.

Parameters:
populatedPluginKey - The 'Key' defined in the descriptor document.
Returns:
SjBaseMetadata

createActivePlugin

public <PLUGIN extends SjBasePlugin> PLUGIN createActivePlugin(java.lang.Class<PLUGIN> pluginAbstractClass,
                                                               SjPopulatedPluginKey populatedPluginKey,
                                                               boolean suppressException)
This method creates a plugin instance or null.

Type Parameters:
PLUGIN -
Parameters:
pluginAbstractClass - Typically the plugin's abstract super class.
populatedPluginKey - The 'Key' defined in the descriptor document.
suppressException - Indicates whether an exception is thrown, or null returned, if the plugin can not be created.
Returns:
PLUGIN or null.

getCacheStrongReference

java.util.Map<java.lang.String,SjBasePlugin> getCacheStrongReference()
This method returns a map for core framework utilization.

Returns:
Map - Returns the strongReferencePlugins attribute.

getMapAlwaysInstantiate

java.util.Map<java.lang.String,SjBasePlugin> getMapAlwaysInstantiate()
This method returns a map for core framework utilization.

Returns:
Map - Returns the alwaysInstantiatePlugins attribute.

getInactivePluginKeyList

public java.util.List<java.lang.String> getInactivePluginKeyList()
This method returns the inactivePluginKeyList attribute.

Returns:
List - A class-scoped attribute.

getMapActiveProperties

java.util.Map<java.lang.String,SjPluginProperties> getMapActiveProperties()
This method returns a map for core framework utilization.

Returns:
Map - Returns the activeProperties attribute.

verifyUniqueActivePluginKey

private void verifyUniqueActivePluginKey(SjPopulatedPluginKey populatedPluginKey,
                                         java.lang.String MethodName)
                                  throws SjCoreExceptionDuplicatePluginKey
This method determines if an active plugin was previously put in a synchronized map and, if so, throws an exception. Active plugins must have a unique key.

Parameters:
populatedPluginKey - The 'Key' defined in the descriptor document.
MethodName - Method name used for throwing an exception.
Throws:
SjCoreExceptionDuplicatePluginKey

containsStrongReferencePlugin

private boolean containsStrongReferencePlugin(SjPopulatedPluginKey populatedPluginKey)
This method returns whether cached plugin exists.

Parameters:
populatedPluginKey - The 'Key' defined in the descriptor document.
Returns:
boolean - 'True' indicates an cached plugin is available for creation.

containsAlwaysInstantiatePlugin

private boolean containsAlwaysInstantiatePlugin(SjPopulatedPluginKey populatedPluginKey)
This method returns whether a plugin reference copy exists.

Parameters:
populatedPluginKey - The 'Key' defined in the descriptor document.
Returns:
boolean - 'True' indicates an plugin reference copy is available for creation.

SOAj Consolidated


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