org.datanucleus.jdo
Class AbstractPersistenceManagerFactory

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

public abstract class AbstractPersistenceManagerFactory
extends ObjectManagerFactoryImpl

Factory used to obtain PersistenceManager instances. The factory is configurable up to a point when it is frozen. Thereafter nothing can be changed.


Field Summary
protected  java.util.List lifecycleListeners
          Lifecycle Listeners
protected static Localiser LOCALISER_JDO
          Localisation utility for output messages from jdo.
 
Fields inherited from class org.datanucleus.ObjectManagerFactoryImpl
cache, omfContext
 
Fields inherited from class org.datanucleus.PersistenceConfiguration
configurable, LOCALISER
 
Constructor Summary
AbstractPersistenceManagerFactory()
          Constructor.
 
Method Summary
 void addFetchGroups(javax.jdo.FetchGroup[] groups)
           
 void addInstanceLifecycleListener(javax.jdo.listener.InstanceLifecycleListener listener, java.lang.Class[] classes)
          Method to add lifecycle listeners for particular classes.
 void addSequenceForFactoryClass(java.lang.String factoryClassName, javax.jdo.datastore.Sequence sequence)
          Method to register a sequence for a particular factory class.
protected  void assertConfigurable()
          Asserts that a change to a configuration property is allowed.
protected  void assertIsOpen()
          Asserts that the PMF is open.
 void close()
          Close this PersistenceManagerFactory.
protected  void freezeConfiguration()
          Freezes the current configuration.
 java.lang.String getCatalog()
          Accessor for the catalog to use for this persistence factory.
 java.lang.String getConnectionDriverName()
          Get the driver name for the data store connection.
 java.lang.Object getConnectionFactory()
          Get the data store connection factory.
 java.lang.Object getConnectionFactory2()
          Get the second data store connection factory.
 java.lang.String getConnectionFactory2Name()
          Get the name for the second data store connection factory.
 java.lang.String getConnectionFactoryName()
          Get the name for the data store connection factory.
 java.lang.String getConnectionPassword()
          Get the password for the data store connection.
 java.lang.String getConnectionURL()
          Get the URL for the data store connection.
 java.lang.String getConnectionUserName()
          Get the user name for the data store connection.
 boolean getCopyOnAttach()
          Accessor for the CopyOnAttach setting.
 javax.jdo.datastore.DataStoreCache getDataStoreCache()
          Accessor for the DataStore (level 2) Cache
 boolean getDetachAllOnCommit()
          Accessor for the DetachAllOnCommit setting.
 javax.jdo.FetchGroup getFetchGroup(java.lang.Class cls, java.lang.String name)
           
 java.util.Set getFetchGroups()
           
 boolean getIgnoreCache()
          Get the default IgnoreCache setting for all PersistenceManager instances obtained from this factory.
 java.util.List getLifecycleListenerSpecifications()
           
 java.lang.String getMapping()
          Get the name for any mapping, used in retrieving metadata files for ORM/Query data.
 boolean getMultithreaded()
          Get the default Multithreaded setting for all PersistenceManager instances obtained from this factory.
 java.lang.String getName()
          Accessor for the name of the persistence factory (if any).
 boolean getNontransactionalRead()
          Get the default NontransactionalRead setting for all PersistenceManager instances obtained from this factory.
 boolean getNontransactionalWrite()
          Get the default NontransactionalWrite setting for all PersistenceManager instances obtained from this factory.
 boolean getOptimistic()
          Get the default Optimistic setting for all PersistenceManager instances obtained from this factory.
 java.lang.String getPersistenceUnitName()
          Accessor for the name of the persistence unit
 java.lang.String getPersistenceXmlFilename()
          Accessor for the filename of the persistence.xml file.
protected  java.util.Set getPmCache()
          Return the Set of PersistenceManagers actually in cache
 java.util.Properties getProperties()
          Return non-configurable properties of this PersistenceManagerFactory.
 boolean getReadOnly()
          Get the default readOnly setting for all PersistenceManager instances obtained from this factory.
 boolean getRestoreValues()
          Get the default RestoreValues setting for all PersistenceManager instances obtained from this factory.
 boolean getRetainValues()
          Get the default RetainValues setting for all PersistenceManager instances obtained from this factory.
 java.lang.String getSchema()
          Accessor for the schema to use for this persistence factory.
 javax.jdo.datastore.Sequence getSequenceForFactoryClass(java.lang.String factoryClassName)
          Accessor for the sequence for a factory class.
 java.lang.String getServerTimeZoneID()
          Accessor for the timezone "id" of the datastore server (if any).
 java.lang.String getTransactionIsolationLevel()
          Accessor for the transaction isolation level default.
 java.lang.String getTransactionType()
          Accessor for the transaction type to use with this persistence factory.
 void releasePersistenceManager(JDOPersistenceManager om)
          Remove a PersistenceManager from the cache Only the PersistenceManager is allowed to call this method
 void removeAllFetchGroups()
           
 void removeFetchGroups(javax.jdo.FetchGroup[] groups)
           
 void removeInstanceLifecycleListener(javax.jdo.listener.InstanceLifecycleListener listener)
          Method to remove a lifecycle listener.
 void setCatalog(java.lang.String catalog)
          Mutator for the catalog to use for this persistence factory.
 void setConnectionDriverName(java.lang.String driverName)
          Set the driver name for the data store connection.
 void setConnectionFactory(java.lang.Object connectionFactory)
          Set the data store connection factory.
 void setConnectionFactory2(java.lang.Object connectionFactory)
          Set the second data store connection factory.
 void setConnectionFactory2Name(java.lang.String connectionFactoryName)
          Set the name for the second data store connection factory.
 void setConnectionFactoryName(java.lang.String connectionFactoryName)
          Set the name for the data store connection factory.
 void setConnectionPassword(java.lang.String password)
          Set the password for the data store connection.
 void setConnectionURL(java.lang.String url)
          Set the URL for the data store connection.
 void setConnectionUserName(java.lang.String userName)
          Set the user name for the data store connection.
 void setCopyOnAttach(boolean flag)
          Mutator for the CopyOnAttach setting.
 void setDetachAllOnCommit(boolean flag)
          Mutator for the DetachAllOnCommit setting.
 void setIgnoreCache(boolean flag)
          Set the default IgnoreCache setting for all PersistenceManager instances obtained from this factory.
 void setMapping(java.lang.String mapping)
          Set the name for any mapping, used in searching for ORM/Query metadata files.
 void setMultithreaded(boolean flag)
          Set the default Multithreaded setting for all PersistenceManager instances obtained from this factory.
 void setName(java.lang.String name)
          Mutator for the name of the persistence factory.
 void setNontransactionalRead(boolean flag)
          Set the default NontransactionalRead setting for all PersistenceManager instances obtained from this factory.
 void setNontransactionalWrite(boolean flag)
          Set the default NontransactionalWrite setting for all PersistenceManager instances obtained from this factory.
 void setOptimistic(boolean flag)
          Set the default Optimistic setting for all PersistenceManager instances obtained from this factory.
 void setPersistenceUnitName(java.lang.String name)
          Mutator for the name of the persistence unit.
 void setPersistenceXmlFilename(java.lang.String name)
          Mutator for the filename of the persistence.xml file.
 void setReadOnly(boolean flag)
          Set the readOnly setting for all PersistenceManager instances obtained from this factory.
 void setRestoreValues(boolean flag)
          Set the default RestoreValues setting for all PersistenceManager instances obtained from this factory.
 void setRetainValues(boolean flag)
          Set the default RetainValues setting for all PersistenceManager instances obtained from this factory.
 void setSchema(java.lang.String schema)
          Mutator for the schema to use for this persistence factory.
 void setServerTimeZoneID(java.lang.String id)
          Mutator for the timezone id of the datastore server.
 void setTransactionIsolationLevel(java.lang.String level)
          Set the default isolation level for transactions.
 void setTransactionType(java.lang.String type)
          Mutator for the transaction type to use for this persistence factory.
 java.util.Collection supportedOptions()
          The application can determine from the results of this method which optional features, and which query languages are supported by the JDO implementation.
 
Methods inherited from class org.datanucleus.ObjectManagerFactoryImpl
addInternalFetchGroup, createInternalFetchGroup, getFetchGroupManager, getFetchGroupsWithName, getInternalFetchGroup, getLevel2Cache, getOMFContext, getPersistenceConfiguration, getStoreManager, getVendorName, getVersionNumber, initialiseLevel2Cache, initialiseOMFContext, initialiseStoreManager, isClosed, logConfiguration, removeInternalFetchGroup
 
Methods inherited from class org.datanucleus.PersistenceConfiguration
equals, getBooleanObjectProperty, getBooleanProperty, getCalendarForDateTimezone, getIntProperty, getLongProperty, getOptions, getPrimaryClassLoader, getProperty, getStringProperty, getSupportedOptions, hasProperty, isJcaMode, setDefaultProperties, setJCAMode, setOptions, setPrimaryClassLoader, setPropertiesFile, setProperty
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALISER_JDO

protected static final Localiser LOCALISER_JDO
Localisation utility for output messages from jdo.


lifecycleListeners

protected java.util.List lifecycleListeners
Lifecycle Listeners

Constructor Detail

AbstractPersistenceManagerFactory

public AbstractPersistenceManagerFactory()
Constructor.

Method Detail

freezeConfiguration

protected void freezeConfiguration()
Freezes the current configuration.

Throws:
NucleusException - if the configuration was invalid or inconsistent in some way

getProperties

public java.util.Properties getProperties()
Return non-configurable properties of this PersistenceManagerFactory. Properties with keys VendorName and VersionNumber are required. Other keys are optional.

Returns:
the non-configurable properties of this PersistenceManagerFactory.

supportedOptions

public java.util.Collection supportedOptions()
The application can determine from the results of this method which optional features, and which query languages are supported by the JDO implementation. Se esection 11.6 of the JDO 2 specification.

Returns:
A Collection of String representing the supported options.

getPmCache

protected java.util.Set getPmCache()
Return the Set of PersistenceManagers actually in cache

Returns:
Set this contains instances of PersistenceManagers in the cache

releasePersistenceManager

public void releasePersistenceManager(JDOPersistenceManager om)
Remove a PersistenceManager from the cache Only the PersistenceManager is allowed to call this method

Parameters:
om - the PersistenceManager to be removed from cache

assertIsOpen

protected void assertIsOpen()
Asserts that the PMF is open.

Overrides:
assertIsOpen in class ObjectManagerFactoryImpl
Throws:
javax.jdo.JDOUserException - if it is already closed

close

public void close()
Close this PersistenceManagerFactory. Check for JDOPermission("closePersistenceManagerFactory") and if not authorized, throw SecurityException.

If the authorization check succeeds, check to see that all PersistenceManager instances obtained from this PersistenceManagerFactory have no active transactions. If any PersistenceManager instances have an active transaction, throw a JDOUserException, with one nested JDOUserException for each PersistenceManager with an active Transaction.

If there are no active transactions, then close all PersistenceManager instances obtained from this PersistenceManagerFactory, mark this PersistenceManagerFactory as closed, disallow getPersistenceManager methods, and allow all other get methods. If a set method or getPersistenceManager method is called after close, then JDOUserException is thrown.

Overrides:
close in class ObjectManagerFactoryImpl
See Also:
PersistenceManagerFactory.close()

getDataStoreCache

public javax.jdo.datastore.DataStoreCache getDataStoreCache()
Accessor for the DataStore (level 2) Cache

Returns:
The datastore cache
Since:
1.1

setConnectionUserName

public void setConnectionUserName(java.lang.String userName)
Set the user name for the data store connection.

Parameters:
userName - the user name for the data store connection.

setConnectionPassword

public void setConnectionPassword(java.lang.String password)
Set the password for the data store connection.

Parameters:
password - the password for the data store connection.

setConnectionURL

public void setConnectionURL(java.lang.String url)
Set the URL for the data store connection.

Parameters:
url - the URL for the data store connection.

setConnectionDriverName

public void setConnectionDriverName(java.lang.String driverName)
Set the driver name for the data store connection.

Parameters:
driverName - the driver name for the data store connection.

setConnectionFactoryName

public void setConnectionFactoryName(java.lang.String connectionFactoryName)
Set the name for the data store connection factory.

Parameters:
connectionFactoryName - name of the data store connection factory.

setConnectionFactory

public void setConnectionFactory(java.lang.Object connectionFactory)
Set the data store connection factory. JDO implementations will support specific connection factories. The connection factory interfaces are not part of the JDO specification.

Parameters:
connectionFactory - the data store connection factory.

setConnectionFactory2Name

public void setConnectionFactory2Name(java.lang.String connectionFactoryName)
Set the name for the second data store connection factory. This is needed for managed environments to get nontransactional connections for optimistic transactions.

Parameters:
connectionFactoryName - name of the data store connection factory.

setConnectionFactory2

public void setConnectionFactory2(java.lang.Object connectionFactory)
Set the second data store connection factory. This is needed for managed environments to get nontransactional connections for optimistic transactions. JDO implementations will support specific connection factories. The connection factory interfaces are not part of the JDO specification.

Parameters:
connectionFactory - the data store connection factory.

setMultithreaded

public void setMultithreaded(boolean flag)
Set the default Multithreaded setting for all PersistenceManager instances obtained from this factory.

Parameters:
flag - the default Multithreaded setting.

setOptimistic

public void setOptimistic(boolean flag)
Set the default Optimistic setting for all PersistenceManager instances obtained from this factory.

Parameters:
flag - the default Optimistic setting.

setRetainValues

public void setRetainValues(boolean flag)
Set the default RetainValues setting for all PersistenceManager instances obtained from this factory.

Parameters:
flag - the default RetainValues setting.

setRestoreValues

public void setRestoreValues(boolean flag)
Set the default RestoreValues setting for all PersistenceManager instances obtained from this factory.

Parameters:
flag - the default RestoreValues setting.

setNontransactionalRead

public void setNontransactionalRead(boolean flag)
Set the default NontransactionalRead setting for all PersistenceManager instances obtained from this factory.

Parameters:
flag - the default NontransactionalRead setting.

setNontransactionalWrite

public void setNontransactionalWrite(boolean flag)
Set the default NontransactionalWrite setting for all PersistenceManager instances obtained from this factory.

Parameters:
flag - the default NontransactionalWrite setting.

setIgnoreCache

public void setIgnoreCache(boolean flag)
Set the default IgnoreCache setting for all PersistenceManager instances obtained from this factory.

Parameters:
flag - the default IgnoreCache setting.

setDetachAllOnCommit

public void setDetachAllOnCommit(boolean flag)
Mutator for the DetachAllOnCommit setting.

Parameters:
flag - the default DetachAllOnCommit setting.
Since:
1.1

setCopyOnAttach

public void setCopyOnAttach(boolean flag)
Mutator for the CopyOnAttach setting.

Parameters:
flag - the default CopyOnAttach setting.
Since:
1.2

setMapping

public void setMapping(java.lang.String mapping)
Set the name for any mapping, used in searching for ORM/Query metadata files.

Parameters:
mapping - the mapping name

setCatalog

public void setCatalog(java.lang.String catalog)
Mutator for the catalog to use for this persistence factory.

Parameters:
catalog - Name of the catalog
Since:
1.1

setSchema

public void setSchema(java.lang.String schema)
Mutator for the schema to use for this persistence factory.

Parameters:
schema - Name of the schema
Since:
1.1

setTransactionType

public void setTransactionType(java.lang.String type)
Mutator for the transaction type to use for this persistence factory.

Parameters:
type - Transaction type

setPersistenceUnitName

public void setPersistenceUnitName(java.lang.String name)
Mutator for the name of the persistence unit.

Parameters:
name - Name of the persistence unit

setPersistenceXmlFilename

public void setPersistenceXmlFilename(java.lang.String name)
Mutator for the filename of the persistence.xml file. This is for the case where an application has placed the persistence.xml somewhere else maybe outside the CLASSPATH.

Parameters:
name - Filename of the persistence unit

setName

public void setName(java.lang.String name)
Mutator for the name of the persistence factory.

Parameters:
name - Name of the persistence factory (if any)

setServerTimeZoneID

public void setServerTimeZoneID(java.lang.String id)
Mutator for the timezone id of the datastore server. If not set assumes that it is running in the same timezone as this JVM.

Parameters:
id - Timezone Id to use

setReadOnly

public void setReadOnly(boolean flag)
Set the readOnly setting for all PersistenceManager instances obtained from this factory.

Parameters:
flag - the default readOnly setting.

setTransactionIsolationLevel

public void setTransactionIsolationLevel(java.lang.String level)
Set the default isolation level for transactions.

Parameters:
level - Level

getConnectionUserName

public java.lang.String getConnectionUserName()
Get the user name for the data store connection.

Returns:
the user name for the data store connection.

getConnectionPassword

public java.lang.String getConnectionPassword()
Get the password for the data store connection.

Returns:
the password for the data store connection.

getConnectionURL

public java.lang.String getConnectionURL()
Get the URL for the data store connection.

Returns:
the URL for the data store connection.

getConnectionDriverName

public java.lang.String getConnectionDriverName()
Get the driver name for the data store connection.

Returns:
the driver name for the data store connection.

getConnectionFactoryName

public java.lang.String getConnectionFactoryName()
Get the name for the data store connection factory.

Returns:
the name of the data store connection factory.

getConnectionFactory2Name

public java.lang.String getConnectionFactory2Name()
Get the name for the second data store connection factory. This is needed for managed environments to get nontransactional connections for optimistic transactions.

Returns:
the name of the data store connection factory.

getConnectionFactory

public java.lang.Object getConnectionFactory()
Get the data store connection factory.

Returns:
the data store connection factory.

getConnectionFactory2

public java.lang.Object getConnectionFactory2()
Get the second data store connection factory. This is needed for managed environments to get nontransactional connections for optimistic transactions.

Returns:
the data store connection factory.

getMultithreaded

public boolean getMultithreaded()
Get the default Multithreaded setting for all PersistenceManager instances obtained from this factory.

Returns:
the default Multithreaded setting.

getOptimistic

public boolean getOptimistic()
Get the default Optimistic setting for all PersistenceManager instances obtained from this factory.

Returns:
the default Optimistic setting.

getRetainValues

public boolean getRetainValues()
Get the default RetainValues setting for all PersistenceManager instances obtained from this factory.

Returns:
the default RetainValues setting.

getRestoreValues

public boolean getRestoreValues()
Get the default RestoreValues setting for all PersistenceManager instances obtained from this factory.

Returns:
the default RestoreValues setting.

getNontransactionalRead

public boolean getNontransactionalRead()
Get the default NontransactionalRead setting for all PersistenceManager instances obtained from this factory.

Returns:
the default NontransactionalRead setting.

getNontransactionalWrite

public boolean getNontransactionalWrite()
Get the default NontransactionalWrite setting for all PersistenceManager instances obtained from this factory.

Returns:
the default NontransactionalWrite setting.

getIgnoreCache

public boolean getIgnoreCache()
Get the default IgnoreCache setting for all PersistenceManager instances obtained from this factory.

Returns:
the IgnoreCache setting.

getDetachAllOnCommit

public boolean getDetachAllOnCommit()
Accessor for the DetachAllOnCommit setting.

Returns:
the DetachAllOnCommit setting.

getCopyOnAttach

public boolean getCopyOnAttach()
Accessor for the CopyOnAttach setting.

Returns:
the CopyOnAttach setting.

getMapping

public java.lang.String getMapping()
Get the name for any mapping, used in retrieving metadata files for ORM/Query data.

Returns:
the name for the mapping.

getCatalog

public java.lang.String getCatalog()
Accessor for the catalog to use for this persistence factory.

Returns:
the name of the catalog

getSchema

public java.lang.String getSchema()
Accessor for the schema to use for this persistence factory.

Returns:
the name of the schema

getName

public java.lang.String getName()
Accessor for the name of the persistence factory (if any).

Returns:
the name of the persistence factory

getPersistenceUnitName

public java.lang.String getPersistenceUnitName()
Accessor for the name of the persistence unit

Returns:
the name of the persistence unit

getPersistenceXmlFilename

public java.lang.String getPersistenceXmlFilename()
Accessor for the filename of the persistence.xml file. This is for the case where an application has placed the persistence.xml somewhere else maybe outside the CLASSPATH.

Returns:
the filename of the persistence unit

getServerTimeZoneID

public java.lang.String getServerTimeZoneID()
Accessor for the timezone "id" of the datastore server (if any). If not set assumes the same as the JVM we are running in.

Returns:
Server timezone id

getReadOnly

public boolean getReadOnly()
Get the default readOnly setting for all PersistenceManager instances obtained from this factory.

Returns:
the default readOnly setting.

getTransactionType

public java.lang.String getTransactionType()
Accessor for the transaction type to use with this persistence factory.

Returns:
transaction type

getTransactionIsolationLevel

public java.lang.String getTransactionIsolationLevel()
Accessor for the transaction isolation level default.

Returns:
Transaction isolation level

assertConfigurable

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

Overrides:
assertConfigurable in class PersistenceConfiguration

getLifecycleListenerSpecifications

public java.util.List getLifecycleListenerSpecifications()
Returns:
Returns either null or a List with instances of LifecycleListenerSpecification.

addInstanceLifecycleListener

public void addInstanceLifecycleListener(javax.jdo.listener.InstanceLifecycleListener listener,
                                         java.lang.Class[] classes)
Method to add lifecycle listeners for particular classes. Adds the listener to all PMs already created.

Parameters:
listener - The listener
classes - The classes that the listener relates to
Since:
1.1

removeInstanceLifecycleListener

public void removeInstanceLifecycleListener(javax.jdo.listener.InstanceLifecycleListener listener)
Method to remove a lifecycle listener. Removes the listener from all PM's as well.

Parameters:
listener - The Listener
Since:
1.1

addSequenceForFactoryClass

public void addSequenceForFactoryClass(java.lang.String factoryClassName,
                                       javax.jdo.datastore.Sequence sequence)
Method to register a sequence for a particular factory class.

Parameters:
factoryClassName - Name of the factory class
sequence - The sequence

getSequenceForFactoryClass

public javax.jdo.datastore.Sequence getSequenceForFactoryClass(java.lang.String factoryClassName)
Accessor for the sequence for a factory class.

Parameters:
factoryClassName - The name of the factory class
Returns:
The sequence

getFetchGroups

public java.util.Set getFetchGroups()

getFetchGroup

public javax.jdo.FetchGroup getFetchGroup(java.lang.Class cls,
                                          java.lang.String name)

addFetchGroups

public void addFetchGroups(javax.jdo.FetchGroup[] groups)

removeFetchGroups

public void removeFetchGroups(javax.jdo.FetchGroup[] groups)

removeAllFetchGroups

public void removeAllFetchGroups()


Copyright © 2009. All Rights Reserved.