net.sf.farrago.plugin
Class FarragoPluginCache

java.lang.Object
  extended by org.eigenbase.util.CompoundClosableAllocation
      extended by net.sf.farrago.util.FarragoCompoundAllocation
          extended by net.sf.farrago.plugin.FarragoPluginCache
All Implemented Interfaces:
FarragoAllocation, FarragoAllocationOwner, ClosableAllocation, ClosableAllocationOwner
Direct Known Subclasses:
FarragoDataWrapperCache

public abstract class FarragoPluginCache
extends FarragoCompoundAllocation

FarragoPluginCache is an abstract private cache for loading instances of FarragoPlugin (and their component sub-objects). It requires an underlying shared FarragoObjectCache.

This class is only a partial implementation. For an example of how to build a full implementation, see FarragoDataWrapperCache.

Version:
$Id: //open/dev/farrago/src/net/sf/farrago/plugin/FarragoPluginCache.java#21 $
Author:
John V. Sichi

Field Summary
private  FarragoPluginClassLoader classLoader
           
private  Map<String,Object> mapMofIdToPlugin
           
private  FarragoRepos repos
           
private  FarragoObjectCache sharedCache
           
 
Fields inherited from class org.eigenbase.util.CompoundClosableAllocation
allocations
 
Constructor Summary
FarragoPluginCache(FarragoAllocationOwner owner, FarragoObjectCache sharedCache, FarragoPluginClassLoader classLoader, FarragoRepos repos)
          Creates an empty cache.
 
Method Summary
protected  Object addToPrivateCache(FarragoObjectCache.Entry entry)
          Adds a plugin object to this cache.
 Map<String,Object> getMapMofIdToPlugin()
           
 FarragoRepos getRepos()
           
 FarragoObjectCache getSharedCache()
           
protected  FarragoPlugin initializePlugin(String libraryName, String jarAttributeName, Properties options)
          Initializes a plugin instance.
protected  Object searchPrivateCache(String mofId)
          Searches this cache for a plugin object identified by its catalog MofId.
 
Methods inherited from class org.eigenbase.util.CompoundClosableAllocation
addAllocation, closeAllocation, forgetAllocation, hasAllocations
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eigenbase.util.ClosableAllocationOwner
addAllocation
 
Methods inherited from interface org.eigenbase.util.ClosableAllocation
closeAllocation
 
Methods inherited from interface org.eigenbase.util.ClosableAllocation
closeAllocation
 

Field Detail

mapMofIdToPlugin

private final Map<String,Object> mapMofIdToPlugin

sharedCache

private final FarragoObjectCache sharedCache

repos

private final FarragoRepos repos

classLoader

private final FarragoPluginClassLoader classLoader
Constructor Detail

FarragoPluginCache

public FarragoPluginCache(FarragoAllocationOwner owner,
                          FarragoObjectCache sharedCache,
                          FarragoPluginClassLoader classLoader,
                          FarragoRepos repos)
Creates an empty cache.

Parameters:
owner - FarragoAllocationOwner for this cache, to make sure everything gets discarded eventually
sharedCache - underlying shared cache
repos - FarragoRepos for wrapper initialization
Method Detail

getRepos

public FarragoRepos getRepos()
Returns:
the underlying repos

getSharedCache

public FarragoObjectCache getSharedCache()
Returns:
the underlying shared cache

getMapMofIdToPlugin

public Map<String,Object> getMapMofIdToPlugin()
Returns:
mapMofIdToPlugin

searchPrivateCache

protected Object searchPrivateCache(String mofId)
Searches this cache for a plugin object identified by its catalog MofId.

Parameters:
mofId - MofId of plugin object being loaded
Returns:
cached instance or null if not yet cached

addToPrivateCache

protected Object addToPrivateCache(FarragoObjectCache.Entry entry)
Adds a plugin object to this cache.

Parameters:
entry - pinned entry from underlying shared cache; key must be plugin object's catalog MofId
Returns:
cached plugin object

initializePlugin

protected FarragoPlugin initializePlugin(String libraryName,
                                         String jarAttributeName,
                                         Properties options)
Initializes a plugin instance.

Parameters:
libraryName - filename of jar containing plugin implementation
jarAttributeName - name of jar attribute to use to determine class name
options - options with which to initialize plugin
Returns:
initialized plugin