org.apache.jdo.impl.pm
Class PersistenceManagerFactoryImpl

java.lang.Object
  extended by org.apache.jdo.impl.pm.PersistenceManagerFactoryImpl
All Implemented Interfaces:
java.io.Serializable, javax.jdo.PersistenceManagerFactory, PersistenceManagerFactoryInternal
Direct Known Subclasses:
FOStorePMF

public abstract class PersistenceManagerFactoryImpl
extends java.lang.Object
implements PersistenceManagerFactoryInternal

This is an abstract PersistenceManagerFactoryImpl class that provides the StoreManager independent implementation of javax.jdo.PersistenceManager interface.

Subclasses must override the following methods declared abstract:

Version:
0.1
Author:
Marina Vatkina
See Also:
Serialized Form

Nested Class Summary
static interface PersistenceManagerFactoryImpl.PMFAccessor
          The preferred way of getting & restoring a PMF in JNDI is to do so via a Properties object.
 
Field Summary
protected  boolean closed
          These are used for implementing close().
protected  java.lang.Object closeLock
          The closeLock protects the close flag and pmSet.
protected  java.lang.String password
           
protected static java.util.HashMap pmfAccessors
          Tables which map from names to PMFAccessors.
protected  java.util.Set pmSet
          The set of all PersistenceManagers that are not closed.
protected static java.util.HashMap propsAccessors
          These PMFAccessors are for configuring non-connection properties.
 
Constructor Summary
PersistenceManagerFactoryImpl()
          Creates new PersistenceManagerFactoryImpl without any user info.
PersistenceManagerFactoryImpl(java.lang.String URL, java.lang.String userName, java.lang.String password, java.lang.String driverName)
          Creates new PersistenceManagerFactoryImpl with user info
 
Method Summary
protected  void assertNotClosed()
          Assert that this PersistenceManagerFactory is not closed.
 void close()
          Close this PersistenceManagerFactory.
protected  void closeOpenPersistenceManagers()
          Close all open PersistenceManagers.
protected abstract  javax.jdo.PersistenceManager createPersistenceManager(java.lang.String userid, java.lang.String password)
          Creates a new instance of PersistenceManager from this factory.
protected abstract  java.lang.String decrypt(java.lang.String s)
          Provides a decrypted version of the given (encrypted) string.
protected  void deregisterPersistenceManager(PersistenceManagerImpl pm, java.lang.Object t)
          Deregisters PersistenceManager that is not associated with a JTA transaction any more.
protected  void doReadObject(java.io.ObjectInputStream ois)
          Read this object from a stream.
protected  void doWriteObject(java.io.ObjectOutputStream oos)
          Write this object to a stream.
protected abstract  java.lang.String encrypt(java.lang.String s)
          Provides an encrypted version of the given string.
 boolean equals(java.lang.Object o)
           
static void filterProperties(java.util.Properties props, java.util.Properties filtered, java.util.Map accessors)
          Given an input Properties instance, add to the output Properties instance only the non-default entries of the input Properties, based on the Accessor map provided.
protected  java.util.List getActivePersistenceManagers()
          Get all active PersistenceManagers.
 java.util.Properties getAsProperties()
          Returns a Properties representation of this PMF.
protected  java.util.Properties getAsPropertiesInternal()
          Does not do assertConfigurable validation
protected abstract  void getCFFromProperties(java.util.Properties p)
          Create a ConnectionFactory for this PMF.
 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()
          Return the non-transactional connection factory for optimistic transactions.
 java.lang.String getConnectionFactory2Name()
          Get the name of the connection factory for non-transactional connections.
 java.lang.String getConnectionFactoryName()
          Get the name for the data store connection factory.
protected  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 getIgnoreCache()
          Get the default IgnoreCache setting for all PersistenceManager instances obtained from this factory.
protected  java.util.HashMap getLocalAccessors()
          Get JDO implementation-specific properties (not specified by JDO specification).
 int getMaxPool()
          Get the default MaxPool setting for all PersistenceManager instances obtained from this factory.
 int getMinPool()
          Get the default MinPool setting for all PersistenceManager instances obtained from this factory.
 int getMsWait()
          Get the default MsWait setting for all PersistenceManager instances obtained from this factory.
 boolean getMultithreaded()
          Get the default Multithreaded setting for all PersistenceManager instances obtained from this factory.
 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.
protected abstract  java.lang.String[] getOptionArray()
          Returns an array of Strings indicating which options are supported by this PersistenceManagerFactory.
 javax.jdo.PersistenceManager getPersistenceManager()
          Get an instance of PersistenceManager from this factory.
 javax.jdo.PersistenceManager getPersistenceManager(java.lang.String userid, java.lang.String password)
          Get an instance of PersistenceManager from this factory.
 java.util.Properties getProperties()
          Return "static" properties of this PersistenceManagerFactory.
 int getQueryTimeout()
          Get the default QueryTimeout 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.
 int getUpdateTimeout()
          Get the default UpdateTimeout setting for all PersistenceManager instances obtained from this factory.
 int hashCode()
          The returned value can change before this PMF is configured.
static void initPropsAccessors()
          Initialize the Accessor hashmaps for connection and non-connection properties.
protected abstract  boolean isConnectionFactoryConfigured()
          Returns if a connection factory is configured for this PersistenceManagerFactory.
protected  void registerPersistenceManager(PersistenceManagerImpl pm, java.lang.Object t)
          Registers PersistenceManager in the transactional cache in managed environment in case of BMT with JDO Transaction.
protected  void releasePersistenceManager(PersistenceManagerImpl pm, java.lang.Object t)
          Releases closed PersistenceManager that is not in use
protected abstract  void setCFProperties(java.util.Properties p)
          Set the PMF-specific ConnectionFactory's properties.
protected  void setConfigured()
          Set the configurable flag false so this PersistenceManagerFactory can no longer be configured.
 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 non-transactional connection factory for optimistic transactions.
 void setConnectionFactory2Name(java.lang.String connectionFactoryName)
          Set the name of the connection factory for non-transactional connections.
 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 setFromProperties(java.util.Properties p)
          Configures a PMF from the given Properties.
 void setIgnoreCache(boolean flag)
          Set the default IgnoreCache setting for all PersistenceManager instances obtained from this factory.
 void setMaxPool(int maxPool)
          Set the default MaxPool setting for all PersistenceManager instances obtained from this factory.
 void setMinPool(int minPool)
          Set the default MinPool setting for all PersistenceManager instances obtained from this factory.
 void setMsWait(int msWait)
          Set the default MsWait setting for all PersistenceManager instances obtained from this factory.
 void setMultithreaded(boolean flag)
          Set the default Multithreaded setting for all PersistenceManager instances obtained from this factory.
protected  void setNonconfigured()
          Set the configurable flag true so this PersistenceManagerFactory can be again configured.
 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.
protected abstract  void setPMFClassProperty(java.util.Properties props)
          Set the PMF class property for this PMF.
 void setQueryTimeout(int queryTimeout)
          Set the default QueryTimeout 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 setUpdateTimeout(int updateTimeout)
          Set the default UpdateTimeout setting for all PersistenceManager instances obtained from this factory.
protected  void shutdown()
          Method called by the shudown hook to close pmf instances left open when the JVM exits.
 java.util.Collection supportedOptions()
          The application can determine from the results of this method which optional features are supported by the JDO implementation.
protected static int toInt(java.lang.String s)
          It should *never* be the case that our translation process encounters a NumberFormatException.
 java.lang.String toString()
          The String representation of this PMF.
protected  void verifyConfiguration()
          Verify that the connection URL has been configured.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.jdo.pm.PersistenceManagerFactoryInternal
getObjectIdClass, getStoreManager, getTrackedClass, getTranscriberFactory, releaseStoreManager
 

Field Detail

password

protected java.lang.String password

closed

protected boolean closed
These are used for implementing close().


closeLock

protected java.lang.Object closeLock
The closeLock protects the close flag and pmSet.


pmSet

protected java.util.Set pmSet
The set of all PersistenceManagers that are not closed. In order for this to work, it is important that PersistenceManager implement equals to be equivalent to Object.equals.


pmfAccessors

protected static java.util.HashMap pmfAccessors
Tables which map from names to PMFAccessors. The names are the same as the PMF's property names. These PMFAccessors are particular to the case when the connection properties are configured as PersistenceManagerFactory properties; neither a connection factory nor connection factory name has been configured.


propsAccessors

protected static java.util.HashMap propsAccessors
These PMFAccessors are for configuring non-connection properties.

Constructor Detail

PersistenceManagerFactoryImpl

public PersistenceManagerFactoryImpl()
Creates new PersistenceManagerFactoryImpl without any user info.


PersistenceManagerFactoryImpl

public PersistenceManagerFactoryImpl(java.lang.String URL,
                                     java.lang.String userName,
                                     java.lang.String password,
                                     java.lang.String driverName)
Creates new PersistenceManagerFactoryImpl with user info

Parameters:
URL - URL for the data store connection
userName - user name for the data store connection
password - password for the data store connection
driverName - driver name for the data store connection
Method Detail

setConnectionUserName

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

Specified by:
setConnectionUserName in interface javax.jdo.PersistenceManagerFactory
Parameters:
userName - the user name for the data store connection.

getConnectionUserName

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

Specified by:
getConnectionUserName in interface javax.jdo.PersistenceManagerFactory
Returns:
the user name for the data store connection.

setConnectionPassword

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

Specified by:
setConnectionPassword in interface javax.jdo.PersistenceManagerFactory
Parameters:
password - the password for the data store connection.

getConnectionPassword

protected java.lang.String getConnectionPassword()
Get the password for the data store connection. Protected so not just anybody can get the password.

Returns:
password the password for the data store connection.

setConnectionURL

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

Specified by:
setConnectionURL in interface javax.jdo.PersistenceManagerFactory
Parameters:
URL - the URL for the data store connection.

getConnectionURL

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

Specified by:
getConnectionURL in interface javax.jdo.PersistenceManagerFactory
Returns:
the URL for the data store connection.

setConnectionDriverName

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

Specified by:
setConnectionDriverName in interface javax.jdo.PersistenceManagerFactory
Parameters:
driverName - the driver name for the data store connection.

getConnectionDriverName

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

Specified by:
getConnectionDriverName in interface javax.jdo.PersistenceManagerFactory
Returns:
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.

Specified by:
setConnectionFactoryName in interface javax.jdo.PersistenceManagerFactory
Parameters:
connectionFactoryName - the name of the data store connection factory.

getConnectionFactoryName

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

Specified by:
getConnectionFactoryName in interface javax.jdo.PersistenceManagerFactory
Returns:
the 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.

Specified by:
setConnectionFactory in interface javax.jdo.PersistenceManagerFactory
Parameters:
connectionFactory - the data store connection factory.

getConnectionFactory

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

Specified by:
getConnectionFactory in interface javax.jdo.PersistenceManagerFactory
Returns:
the data store connection factory.

setConnectionFactory2Name

public void setConnectionFactory2Name(java.lang.String connectionFactoryName)
Set the name of the connection factory for non-transactional connections.

Specified by:
setConnectionFactory2Name in interface javax.jdo.PersistenceManagerFactory
Parameters:
connectionFactoryName - the name of the connection factory for non-transactional connections.
See Also:
PersistenceManagerFactory.setConnectionFactory2Name(java.lang.String)

getConnectionFactory2Name

public java.lang.String getConnectionFactory2Name()
Get the name of the connection factory for non-transactional connections.

Specified by:
getConnectionFactory2Name in interface javax.jdo.PersistenceManagerFactory
Returns:
the name of the connection factory for non-transactional connections.
See Also:
PersistenceManagerFactory.getConnectionFactory2Name()

setConnectionFactory2

public void setConnectionFactory2(java.lang.Object connectionFactory)
Set the non-transactional connection factory for optimistic transactions.

Specified by:
setConnectionFactory2 in interface javax.jdo.PersistenceManagerFactory
Parameters:
connectionFactory - the non-transactional connection factory.
See Also:
PersistenceManagerFactory.setConnectionFactory2(java.lang.Object)

getConnectionFactory2

public java.lang.Object getConnectionFactory2()
Return the non-transactional connection factory for optimistic transactions.

Specified by:
getConnectionFactory2 in interface javax.jdo.PersistenceManagerFactory
Returns:
the non-transactional connection factory for optimistic transactions
See Also:
PersistenceManagerFactory.getConnectionFactory2()

setMultithreaded

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

Specified by:
setMultithreaded in interface javax.jdo.PersistenceManagerFactory
Parameters:
flag - the default Multithreaded setting.

getMultithreaded

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

Specified by:
getMultithreaded in interface javax.jdo.PersistenceManagerFactory
Returns:
the default Multithreaded setting.

setOptimistic

public void setOptimistic(boolean flag)
Set the default Optimistic setting for all PersistenceManager instances obtained from this factory. Setting Optimistic to true also sets NontransactionalRead to true.

Specified by:
setOptimistic in interface javax.jdo.PersistenceManagerFactory
Parameters:
flag - the default Optimistic setting.

getOptimistic

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

Specified by:
getOptimistic in interface javax.jdo.PersistenceManagerFactory
Returns:
the default Optimistic setting.

setRetainValues

public void setRetainValues(boolean flag)
Set the default RetainValues setting for all PersistenceManager instances obtained from this factory. Setting RetainValues to true also sets NontransactionalRead to true.

Specified by:
setRetainValues in interface javax.jdo.PersistenceManagerFactory
Parameters:
flag - the default RetainValues setting.

getRetainValues

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

Specified by:
getRetainValues in interface javax.jdo.PersistenceManagerFactory
Returns:
the default RetainValues setting.

setRestoreValues

public void setRestoreValues(boolean flag)
Set the default RestoreValues setting for all PersistenceManager instances obtained from this factory. Setting RestoreValues to true also sets NontransactionalRead to true.

Specified by:
setRestoreValues in interface javax.jdo.PersistenceManagerFactory
Parameters:
flag - the default RestoreValues setting.

getRestoreValues

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

Specified by:
getRestoreValues in interface javax.jdo.PersistenceManagerFactory
Returns:
the default RestoreValues setting.

setNontransactionalRead

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

Specified by:
setNontransactionalRead in interface javax.jdo.PersistenceManagerFactory
Parameters:
flag - the default NontransactionalRead setting.

getNontransactionalRead

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

Specified by:
getNontransactionalRead in interface javax.jdo.PersistenceManagerFactory
Returns:
the default NontransactionalRead setting.

setNontransactionalWrite

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

Specified by:
setNontransactionalWrite in interface javax.jdo.PersistenceManagerFactory
Parameters:
flag - the default NontransactionalWrite setting.

getNontransactionalWrite

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

Specified by:
getNontransactionalWrite in interface javax.jdo.PersistenceManagerFactory
Returns:
the default NontransactionalWrite setting.

setIgnoreCache

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

Specified by:
setIgnoreCache in interface javax.jdo.PersistenceManagerFactory
Parameters:
flag - the default IgnoreCache setting.

getIgnoreCache

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

Specified by:
getIgnoreCache in interface javax.jdo.PersistenceManagerFactory
Returns:
the default IngoreCache setting.

setMsWait

public void setMsWait(int msWait)
Set the default MsWait setting for all PersistenceManager instances obtained from this factory.

Parameters:
msWait - the default MsWait setting.

getMsWait

public int getMsWait()
Get the default MsWait setting for all PersistenceManager instances obtained from this factory.

Returns:
the default MsWait setting.

setMinPool

public void setMinPool(int minPool)
Set the default MinPool setting for all PersistenceManager instances obtained from this factory.

Parameters:
minPool - the default MinPool setting.

getMinPool

public int getMinPool()
Get the default MinPool setting for all PersistenceManager instances obtained from this factory.

Returns:
the default MinPool setting.

setMaxPool

public void setMaxPool(int maxPool)
Set the default MaxPool setting for all PersistenceManager instances obtained from this factory.

Parameters:
maxPool - the default MaxPool setting.

getMaxPool

public int getMaxPool()
Get the default MaxPool setting for all PersistenceManager instances obtained from this factory.

Returns:
the default MaxPool setting.

setQueryTimeout

public void setQueryTimeout(int queryTimeout)
Set the default QueryTimeout setting for all PersistenceManager instances obtained from this factory.

Parameters:
queryTimeout - the default QueryTimeout setting.

getQueryTimeout

public int getQueryTimeout()
Get the default QueryTimeout setting for all PersistenceManager instances obtained from this factory.

Returns:
the default QueryTimeout setting.

setUpdateTimeout

public void setUpdateTimeout(int updateTimeout)
Set the default UpdateTimeout setting for all PersistenceManager instances obtained from this factory.

Parameters:
updateTimeout - the default UpdateTimeout setting.

getUpdateTimeout

public int getUpdateTimeout()
Get the default UpdateTimeout setting for all PersistenceManager instances obtained from this factory.

Returns:
the default UpdateTimeout setting.

getProperties

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

Specified by:
getProperties in interface javax.jdo.PersistenceManagerFactory
Returns:
the non-operational properties of this PersistenceManagerFactory.

supportedOptions

public java.util.Collection supportedOptions()
The application can determine from the results of this method which optional features are supported by the JDO implementation.

Each supported JDO optional feature is represented by a String with one of the following values:

javax.jdo.option.TransientTransactional

javax.jdo.option.NontransactionalRead

javax.jdo.option.NontransactionalWrite

javax.jdo.option.RetainValues

javax.jdo.option.Optimistic

javax.jdo.option.ApplicationIdentity

javax.jdo.option.DatastoreIdentity

javax.jdo.option.NonDatastoreIdentity

javax.jdo.option.ArrayList

javax.jdo.option.HashMap

javax.jdo.option.Hashtable

javax.jdo.option.LinkedList

javax.jdo.option.TreeMap

javax.jdo.option.TreeSet

javax.jdo.option.Vector

javax.jdo.option.Map

javax.jdo.option.List

javax.jdo.option.Array

javax.jdo.option.NullCollection

The standard JDO query language is represented by a String:

javax.jdo.query.JDOQL

Specified by:
supportedOptions in interface javax.jdo.PersistenceManagerFactory
Returns:
the Set of String representing the supported Options

getOptionArray

protected abstract java.lang.String[] getOptionArray()
Returns an array of Strings indicating which options are supported by this PersistenceManagerFactory.

Returns:
the option array.

createPersistenceManager

protected abstract javax.jdo.PersistenceManager createPersistenceManager(java.lang.String userid,
                                                                         java.lang.String password)
Creates a new instance of PersistenceManager from this factory. Called by getPersistenceManager(String userid, String password)) if there is no pooled instance that satisfies the request.

Parameters:
userid - The user id of the connection factory.
password - The password of the connection factory.
Returns:
a PersistenceManager instance with default options.

getPersistenceManager

public javax.jdo.PersistenceManager getPersistenceManager()
Get an instance of PersistenceManager from this factory. The instance has default values for options.

If pooling of PersistenceManager instances is supported by this factory, the instance might have been returned to the pool and is being reused.

After the first use of getPersistenceManager, no "set" methods will succeed.

Specified by:
getPersistenceManager in interface javax.jdo.PersistenceManagerFactory
Returns:
a PersistenceManager instance with default options.

getPersistenceManager

public javax.jdo.PersistenceManager getPersistenceManager(java.lang.String userid,
                                                          java.lang.String password)
Get an instance of PersistenceManager from this factory. The instance has default values for options. The parameters userid and password are used when obtaining datastore connections from the connection pool.

If pooling of PersistenceManager instances is supported by this factory, the instance might have been returned to the pool and is being reused.

After the first use of getPersistenceManager, no "set" methods will succeed.

Specified by:
getPersistenceManager in interface javax.jdo.PersistenceManagerFactory
Parameters:
userid - The user id of the connection factory.
password - The password of the connection factory.
Returns:
a PersistenceManager instance with default options.

registerPersistenceManager

protected void registerPersistenceManager(PersistenceManagerImpl pm,
                                          java.lang.Object t)
Registers PersistenceManager in the transactional cache in managed environment in case of BMT with JDO Transaction. There is no javax.transaction.Transaction available before the user starts the transaction.

Parameters:
pm - the PersistenceManager
t - the Transaction used as the hashmap key

deregisterPersistenceManager

protected void deregisterPersistenceManager(PersistenceManagerImpl pm,
                                            java.lang.Object t)
Deregisters PersistenceManager that is not associated with a JTA transaction any more.

Parameters:
pm - the PersistenceManager
t - the Transaction used as the hashmap key

releasePersistenceManager

protected void releasePersistenceManager(PersistenceManagerImpl pm,
                                         java.lang.Object t)
Releases closed PersistenceManager that is not in use

Parameters:
pm - the PersistenceManager
t - the Transaction used as the hashmap key

doWriteObject

protected void doWriteObject(java.io.ObjectOutputStream oos)
                      throws java.io.IOException
Write this object to a stream. This method is provided so it can be called from outside the class (explicitly by a subclass).

Parameters:
oos - the ObjectOutputStream
Throws:
java.io.IOException - on errors writing to the stream

doReadObject

protected void doReadObject(java.io.ObjectInputStream ois)
                     throws java.io.IOException,
                            java.lang.ClassNotFoundException
Read this object from a stream. This method is provided so it can be called from outside the class (explicitly by a subclass).

Parameters:
ois - the ObjectInputStream
Throws:
java.io.IOException - on errors reading from the stream
java.lang.ClassNotFoundException - if a referenced class cannot be loaded

getLocalAccessors

protected java.util.HashMap getLocalAccessors()
Get JDO implementation-specific properties (not specified by JDO specification).

Returns:
a hashmap of accessors

initPropsAccessors

public static void initPropsAccessors()
Initialize the Accessor hashmaps for connection and non-connection properties.
XXX: Jikes bug
If this is protected, FOStorePMF.initPropsAccessors cannot invoke it, due to a bug in jikes (http://www-124.ibm.com/developerworks/bugs/?func=detailbug&bug_id=213&group_id=10)


toInt

protected static int toInt(java.lang.String s)
It should *never* be the case that our translation process encounters a NumberFormatException. If so, tell the user in the JDO-approved manner.

Parameters:
s - the input String
Returns:
the int representation of the String

getAsProperties

public java.util.Properties getAsProperties()
Returns a Properties representation of this PMF. Only allow Properties representation if the caller configured this PersistenceManagerFactory. Otherwise, this is a security exposure.

Returns:
the Properties representing the non-default properties

getAsPropertiesInternal

protected java.util.Properties getAsPropertiesInternal()
Does not do assertConfigurable validation

See Also:
getAsProperties()

setPMFClassProperty

protected abstract void setPMFClassProperty(java.util.Properties props)
Set the PMF class property for this PMF.

Parameters:
props - the Properties to which to add the PMF class property

setFromProperties

public void setFromProperties(java.util.Properties p)
Configures a PMF from the given Properties.

Parameters:
p - the Properties used to configure this PMF

encrypt

protected abstract java.lang.String encrypt(java.lang.String s)
Provides an encrypted version of the given string. NOTE: Be very sure that you implement this method using the kind of security that is appropriate for your JDO implementation!!! Note that this method is not static, because it must be overridden by the specialized subclass. But it should be written as if it were static. That is, it should not use any state in the PersistenceManagerFactoryImpl instance.

Parameters:
s - the String to be encrypted
Returns:
the encrypted String

decrypt

protected abstract java.lang.String decrypt(java.lang.String s)
Provides a decrypted version of the given (encrypted) string. NOTE: Be very sure that you implement this method using the kind of security that is appropriate for your JDO implementation!!!

Parameters:
s - the String to be decrypted
Returns:
the decrypted String

setCFProperties

protected abstract void setCFProperties(java.util.Properties p)
Set the PMF-specific ConnectionFactory's properties.

Parameters:
p - Properties object in which the PMF's ConnectioFactory's properties are to be set.

getCFFromProperties

protected abstract void getCFFromProperties(java.util.Properties p)
Create a ConnectionFactory for this PMF. The method's implementation should set the PMF's connection factory with the newly created object.

Parameters:
p - Properties from which the ConnectionFactory is to be created.

isConnectionFactoryConfigured

protected abstract boolean isConnectionFactoryConfigured()
Returns if a connection factory is configured for this PersistenceManagerFactory. This is used to determine whether this PersistenceManagerFactory has been configured with a ConnectionFactory, a ConnectionFactoryName, or a ConnectionURL.

Returns:
if a connection factory is configured

toString

public java.lang.String toString()
The String representation of this PMF.

Overrides:
toString in class java.lang.Object
Returns:
the String representation of this PMF

verifyConfiguration

protected void verifyConfiguration()
Verify that the connection URL has been configured. This might be done by the PMF property ConnectionURL, or by the connection factory property URL, or by configuring a connection factory name.


setConfigured

protected void setConfigured()
Set the configurable flag false so this PersistenceManagerFactory can no longer be configured. No value is provided, because a PersistenceManagerFactory can never become re-configurable. Once invoked, the hashCode() of this PMF will never change, except if setNonconfigured is called.

See Also:
hashCode(), setNonconfigured()

setNonconfigured

protected void setNonconfigured()
Set the configurable flag true so this PersistenceManagerFactory can be again configured. Called only if the action caused change to be non-configurable failed.


filterProperties

public static void filterProperties(java.util.Properties props,
                                    java.util.Properties filtered,
                                    java.util.Map accessors)
Given an input Properties instance, add to the output Properties instance only the non-default entries of the input Properties, based on the Accessor map provided. The output instance can be used as the key for the PersistenceManagerFactory hashMap.

A properties instance will typically be filtered a number of times: once for the JDO standard PersistenceManagerFactory properties, another for the JDO implementation properties, and another for the implementation ConnectionFactory properties.

A properties accessor map is passed as an argument. The map contains the PMFAccessors, keyed by property name.

Parameters:
props - the input Properties
filtered - the output properties
accessors - the hashmap of accessors to filter for

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
The returned value can change before this PMF is configured. Once configured it will never change (well...)

Overrides:
hashCode in class java.lang.Object
See Also:
setConfigured(), setNonconfigured()

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.

Specified by:
close in interface javax.jdo.PersistenceManagerFactory

assertNotClosed

protected void assertNotClosed()
Assert that this PersistenceManagerFactory is not closed. This assertion precedes all getPersistenceManager calls. "set" methods are already protected by the configured flag. This method is synchronized so if another thread is calling close at the same time, this thread will wait for the close to complete.


getActivePersistenceManagers

protected java.util.List getActivePersistenceManagers()
Get all active PersistenceManagers. This is all PersistenceManagers that have active transactions.


closeOpenPersistenceManagers

protected void closeOpenPersistenceManagers()
Close all open PersistenceManagers. Only the PersistenceManagers in the non-transactional set are considered; there cannot be any inactive PersistenceManagers in the transactional cache. We do forceClose because we don't care if there are active wrappers.


shutdown

protected void shutdown()
Method called by the shudown hook to close pmf instances left open when the JVM exits.



Copyright © 2005-2012 Apache Software Foundation. All Rights Reserved.