net.sf.farrago.namespace.util
Class FarragoDataWrapperCache

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

public class FarragoDataWrapperCache
extends FarragoPluginCache

FarragoDataWrapperCache serves as a private cache of FarragoMedDataWrapper and FarragoMedDataServer instances. It requires an underlying shared FarragoObjectCache.

Version:
$Id: //open/dev/farrago/src/net/sf/farrago/namespace/util/FarragoDataWrapperCache.java#33 $
Author:
John V. Sichi

Nested Class Summary
private  class FarragoDataWrapperCache.ServerFactory
           
private  class FarragoDataWrapperCache.WrapperFactory
           
 
Field Summary
private  FennelDbHandle fennelDbHandle
           
private  DataSource loopbackDataSource
           
 
Fields inherited from class org.eigenbase.util.CompoundClosableAllocation
allocations
 
Constructor Summary
FarragoDataWrapperCache(FarragoAllocationOwner owner, FarragoObjectCache sharedCache, FarragoPluginClassLoader classLoader, FarragoRepos repos, FennelDbHandle fennelDbHandle, DataSource loopbackDataSource)
          Creates an empty cache.
 
Method Summary
 void closeAllocation()
          Closes this object.
 Properties getStorageOptionsAsProperties(FemElementWithStorageOptions element)
          Extracts the storage options for an element into a Properties.
 FarragoMedColumnSet loadColumnSetFromCatalog(FemBaseColumnSet baseColumnSet, FarragoTypeFactory typeFactory)
          Loads a FarragoMedColumnSet from its catalog definition.
 FarragoMedDataServer loadServer(String mofId, FarragoMedDataWrapper dataWrapper, Properties options)
          Loads a data server, or uses a cached instance.
 FarragoMedDataServer loadServerFromCatalog(FemDataServer femServer)
          Loads a data server based on its catalog definition.
 FarragoMedDataWrapper loadWrapper(String mofId, String libraryName, Properties options)
          Loads a data wrapper, or uses a cached instance.
 FarragoMedDataWrapper loadWrapperFromCatalog(FemDataWrapper femWrapper)
          Loads a data wrapper based on its catalog definition.
 
Methods inherited from class net.sf.farrago.plugin.FarragoPluginCache
addToPrivateCache, getMapMofIdToPlugin, getRepos, getSharedCache, initializePlugin, searchPrivateCache
 
Methods inherited from class org.eigenbase.util.CompoundClosableAllocation
addAllocation, 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
 

Field Detail

fennelDbHandle

private FennelDbHandle fennelDbHandle

loopbackDataSource

private DataSource loopbackDataSource
Constructor Detail

FarragoDataWrapperCache

public FarragoDataWrapperCache(FarragoAllocationOwner owner,
                               FarragoObjectCache sharedCache,
                               FarragoPluginClassLoader classLoader,
                               FarragoRepos repos,
                               FennelDbHandle fennelDbHandle,
                               DataSource loopbackDataSource)
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
fennelDbHandle - FennelDbHandle for wrapper initialization
loopbackDataSource - a DataSource for establishing a loopback connection into Farrago, or null if none is available
Method Detail

loadWrapper

public FarragoMedDataWrapper loadWrapper(String mofId,
                                         String libraryName,
                                         Properties options)
Loads a data wrapper, or uses a cached instance. If the requested wrapper is already available in this private or in the shared cache, it can be used directly. Otherwise, the wrapper is loaded, initialized, and cached at both levels.

Parameters:
mofId - key by which the wrapper can be uniquely identified (Farrago uses the MofId of the catalog object representing the wrapper)
libraryName - name of the library containing the wrapper implementation
options - wrapper-specific options
Returns:
loaded wrapper

loadServer

public FarragoMedDataServer loadServer(String mofId,
                                       FarragoMedDataWrapper dataWrapper,
                                       Properties options)
Loads a data server, or uses a cached instance.

Parameters:
mofId - key by which the server can be uniquely identified (Farrago uses the MofId of the catalog object representing the server)
dataWrapper - FarragoMedDataWrapper which provides access to the server
options - server-specific options
Returns:
loaded server

loadWrapperFromCatalog

public FarragoMedDataWrapper loadWrapperFromCatalog(FemDataWrapper femWrapper)
Loads a data wrapper based on its catalog definition.

Parameters:
femWrapper - catalog definition for data wrapper to load
Returns:
loaded data wrapper

loadServerFromCatalog

public FarragoMedDataServer loadServerFromCatalog(FemDataServer femServer)
Loads a data server based on its catalog definition.

Parameters:
femServer - catalog definition for data server to load
Returns:
loaded data server

loadColumnSetFromCatalog

public FarragoMedColumnSet loadColumnSetFromCatalog(FemBaseColumnSet baseColumnSet,
                                                    FarragoTypeFactory typeFactory)
Loads a FarragoMedColumnSet from its catalog definition.

Parameters:
baseColumnSet - column set definition
typeFactory - factory for column types
Returns:
loaded column set

getStorageOptionsAsProperties

public Properties getStorageOptionsAsProperties(FemElementWithStorageOptions element)
Extracts the storage options for an element into a Properties. No duplicate property names are allowed. Inline property references (such as ${varname} get expanded on read.

Parameters:
element - FemElement we want the options from
Returns:
Properties object populated with the storage options

closeAllocation

public void closeAllocation()
Description copied from interface: ClosableAllocation
Closes this object.

Specified by:
closeAllocation in interface ClosableAllocation
Overrides:
closeAllocation in class CompoundClosableAllocation