org.datanucleus
Class ObjectManagerFactoryImpl

java.lang.Object
  extended by org.datanucleus.ObjectManagerFactoryImpl
Direct Known Subclasses:
JDOPersistenceManagerFactory

public class ObjectManagerFactoryImpl
extends java.lang.Object

ObjectManagerFactory responsible for creation of ObjectManagers for persistence of objects to datastores. Will typically be either extended or utilised by PersistenceManagerFactory (JDO) or EntityManagerFactory (JPA).


Field Summary
protected static Localiser LOCALISER
          Localisation of messages.
protected  OMFContext omfContext
          The context that this ObjectManagerFactory uses.
 
Constructor Summary
ObjectManagerFactoryImpl()
          Constructor.
 
Method Summary
protected  void addInternalFetchGroup(FetchGroup grp)
          Method to add a dynamic FetchGroup for use by this OMF.
protected  void assertConfigurable()
          Asserts that a change to a configuration property is allowed.
 void close()
          Close the ObjectManagerFactory.
protected  FetchGroup createInternalFetchGroup(java.lang.Class cls, java.lang.String name)
          Method to create a new internal fetch group for the class+name.
 PersistenceConfiguration getConfiguration()
          Accessor for the persistence configuration.
protected  FetchGroupManager getFetchGroupManager()
          Convenience accessor for the FetchGroupManager.
 java.util.Set<FetchGroup> getFetchGroupsWithName(java.lang.String name)
          Accessor for the fetch groups for the specified name.
protected  FetchGroup getInternalFetchGroup(java.lang.Class cls, java.lang.String name)
          Accessor for an internal fetch group for the specified class.
 Level2Cache getLevel2Cache()
          Accessor for the DataStore (level 2) Cache
 OMFContext getOMFContext()
          Gets the context for this ObjectManagerFactory
 StoreManager getStoreManager()
          Convenience accessor for the StoreManager.
static java.lang.String getVersionNumber()
          Utility to get the version of DataNucleus.
 boolean hasLevel2Cache()
          Return whether there is an L2 cache.
protected  void initialiseOMFContext()
          Method to initialise the OMFContext.
protected  void initialiseStoreManager(ClassLoaderResolver clr)
          Method to initialise the StoreManager used by this factory.
protected  boolean isConfigurable()
          Accessor for whether this is still configurable (can set more properties etc).
protected  void logConfiguration()
          Method to log the configuration of this factory.
protected  void removeInternalFetchGroup(FetchGroup grp)
          Method to remove a dynamic FetchGroup from use by this OMF.
protected  void setIsNotConfigurable()
          Method to set that this is no longer configurable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALISER

protected static final Localiser LOCALISER
Localisation of messages.


omfContext

protected OMFContext omfContext
The context that this ObjectManagerFactory uses.

Constructor Detail

ObjectManagerFactoryImpl

public ObjectManagerFactoryImpl()
Constructor.

Method Detail

logConfiguration

protected void logConfiguration()
Method to log the configuration of this factory.


initialiseOMFContext

protected void initialiseOMFContext()
Method to initialise the OMFContext. This should be performed after setting any persistence properties that affect the content of the OMFContext (e.g PluginRegistry, ClassLoaderResolver, etc).


initialiseStoreManager

protected void initialiseStoreManager(ClassLoaderResolver clr)
Method to initialise the StoreManager used by this factory.

Parameters:
clr - ClassLoaderResolver to use for class loading issues

getStoreManager

public StoreManager getStoreManager()
Convenience accessor for the StoreManager. This is for public access to DataNucleus APIs. TODO Rework this when there is a FederationManager.

Returns:
The StoreManager

close

public void close()
Close the ObjectManagerFactory. Cleans out all objects in the Level2 cache and closes the context, marking the factory as closed.


getOMFContext

public OMFContext getOMFContext()
Gets the context for this ObjectManagerFactory

Returns:
Returns the context.

getConfiguration

public PersistenceConfiguration getConfiguration()
Accessor for the persistence configuration.

Returns:
Returns the configuration.

hasLevel2Cache

public boolean hasLevel2Cache()
Return whether there is an L2 cache.

Returns:
Whether the L2 cache is enabled

getLevel2Cache

public Level2Cache getLevel2Cache()
Accessor for the DataStore (level 2) Cache

Returns:
The datastore cache

getVersionNumber

public static java.lang.String getVersionNumber()
Utility to get the version of DataNucleus.

Returns:
Version number for DataNucleus.

getFetchGroupManager

protected FetchGroupManager getFetchGroupManager()
Convenience accessor for the FetchGroupManager. Creates it if not yet existing.

Returns:
The FetchGroupManager

addInternalFetchGroup

protected void addInternalFetchGroup(FetchGroup grp)
Method to add a dynamic FetchGroup for use by this OMF.

Parameters:
grp - The group

removeInternalFetchGroup

protected void removeInternalFetchGroup(FetchGroup grp)
Method to remove a dynamic FetchGroup from use by this OMF.

Parameters:
grp - The group

createInternalFetchGroup

protected FetchGroup createInternalFetchGroup(java.lang.Class cls,
                                              java.lang.String name)
Method to create a new internal fetch group for the class+name.

Parameters:
cls - Class that it applies to
name - Name of group
Returns:
The group

getInternalFetchGroup

protected FetchGroup getInternalFetchGroup(java.lang.Class cls,
                                           java.lang.String name)
Accessor for an internal fetch group for the specified class.

Parameters:
cls - The class
name - Name of the group
Returns:
The FetchGroup
Throws:
NucleusUserException - if the class is not persistable

getFetchGroupsWithName

public java.util.Set<FetchGroup> getFetchGroupsWithName(java.lang.String name)
Accessor for the fetch groups for the specified name.

Parameters:
name - Name of the group
Returns:
The FetchGroup

isConfigurable

protected boolean isConfigurable()
Accessor for whether this is still configurable (can set more properties etc).

Returns:
Whether it is configurable

setIsNotConfigurable

protected void setIsNotConfigurable()
Method to set that this is no longer configurable. Can no longer become configurable.


assertConfigurable

protected void assertConfigurable()
Asserts that a change to a configuration property is allowed.

Throws:
NucleusUserException - if not configurable. Override in subclass if wanting other exception


Copyright © 2011. All Rights Reserved.