org.apache.jdo.impl.fostore
Class FOStorePMF

java.lang.Object
  extended by org.apache.jdo.impl.pm.PersistenceManagerFactoryImpl
      extended by org.apache.jdo.impl.fostore.FOStorePMF
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, javax.jdo.PersistenceManagerFactory, javax.naming.Referenceable, PersistenceManagerFactoryInternal

public class FOStorePMF
extends PersistenceManagerFactoryImpl
implements java.io.Externalizable, javax.naming.Referenceable

The File/Object Store's implementation of a PersistenceManagerFactory.

This class is public so that clients can create instances of it with new.

Author:
Dave Bristor
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.jdo.impl.pm.PersistenceManagerFactoryImpl
PersistenceManagerFactoryImpl.PMFAccessor
 
Field Summary
protected static java.util.HashMap fostorePropsAccessors
          Properties accessors hash map for fostore-specific properties.
protected static java.util.HashMap hashMapByFilteredProperties
          A HashMap that associates PersistenceManagerFactory instances with a Properties instance.
 
Fields inherited from class org.apache.jdo.impl.pm.PersistenceManagerFactoryImpl
closed, closeLock, password, pmfAccessors, pmSet, propsAccessors
 
Constructor Summary
FOStorePMF()
           
 
Method Summary
 void close()
          Close this PersistenceManagerFactory.
 boolean close(boolean force)
          Closes the database unless there are any active store managers.
protected  javax.jdo.PersistenceManager createPersistenceManager(java.lang.String userid, java.lang.String password)
          Create a new instance of PersistenceManager with the specific user name and password.
protected  java.lang.String decrypt(java.lang.String s)
          Uses rot13 algorithm.
protected  java.lang.String encrypt(java.lang.String s)
          Uses rot13 algorithm.
protected  void getCFFromProperties(java.util.Properties p)
          Create a ConnectionFactory for this PMF.
 boolean getConnectionCreate()
           
 java.lang.Object getConnectionFactory()
          Override PersistenceManagerFactoryImpl's method so that we can get a handle on the connection factory to close the database at close() time.
 JDOQLQueryFactory getJDOQLQueryFactory()
          Returns the JDOQLQueryFactory bound to this FOStorePMF.
protected  java.util.HashMap getLocalAccessors()
          Return the FOStore-specific accessors (the properties that are not in the JDO specification).
 org.apache.jdo.impl.fostore.FOStoreModel getModel()
          Returns metadata associated with this PersistenceManagerFactory.
 java.lang.Class getObjectIdClass(java.lang.Class cls)
          If parameter is non-null and implements PersistenceCapable, returns OID.class.
protected  java.lang.String[] getOptionArray()
          Returns an array of Strings indicating which options are supported by this PersistenceManagerFactory.
static PersistenceManagerFactoryImpl getPersistenceManagerFactory(java.util.Properties props)
          Construct a Properties instance from the given Properties.
 javax.naming.Reference getReference()
          Uses StringRefAddr's to store the information
 StoreManager getStoreManager(javax.jdo.PersistenceManager pm)
          Provides a StoreManager that is ready to accept operations on it such as insert, etc.
 java.lang.Class getTrackedClass(java.lang.Class type)
          Returns store-specific mapping between Java classes and tracked SCO classes supported by this PMF.
 TranscriberFactory getTranscriberFactory()
          Provides the factory which can make Transcribers for this PMF.
static void initPropsAccessors()
          Initialize fostorePropsAccessors.
protected  boolean isConnectionFactoryConfigured()
          Verifies that the associated connection factory is configured (at least the URL is specified).
 QueryTree newQueryTree()
          Returns a new QueryTree instance.
 void readExternal(java.io.ObjectInput in)
          Reads this PMF's state from the given object input.
 void releaseStoreManager(javax.jdo.PersistenceManager pm)
          Allows the PMF to release any resources associated with the given PM's store manager.
protected  void setCFProperties(java.util.Properties p)
          Set the PMF-specific ConnectionFactory's properties.
 void setConnectionCreate(boolean create)
           
 void setConnectionCreate(java.lang.String create)
           
 void setConnectionFactory(java.lang.Object cf)
          Override PersistenceManagerFactoryImpl's method so we can use our own cf variable.
 void setJDOQLQueryFactoryClassName(java.lang.String jdoqlQueryFactoryClassName)
          Sets the JDOQLQueryFactory class name used by getJDOQLQueryFactory.
protected  void setPMFClassProperty(java.util.Properties props)
          Set the PMF class property for this PMF.
protected  void shutdown()
          Method called by the shudown hook to close pmf instances left open when the JVM exits.
 java.lang.String toString()
          The String representation of this PMF.
 void writeExternal(java.io.ObjectOutput out)
          Writes this PMF's state to the given object output.
 
Methods inherited from class org.apache.jdo.impl.pm.PersistenceManagerFactoryImpl
assertNotClosed, closeOpenPersistenceManagers, deregisterPersistenceManager, doReadObject, doWriteObject, equals, filterProperties, getActivePersistenceManagers, getAsProperties, getAsPropertiesInternal, getConnectionDriverName, getConnectionFactory2, getConnectionFactory2Name, getConnectionFactoryName, getConnectionPassword, getConnectionURL, getConnectionUserName, getIgnoreCache, getMaxPool, getMinPool, getMsWait, getMultithreaded, getNontransactionalRead, getNontransactionalWrite, getOptimistic, getPersistenceManager, getPersistenceManager, getProperties, getQueryTimeout, getRestoreValues, getRetainValues, getUpdateTimeout, hashCode, registerPersistenceManager, releasePersistenceManager, setConfigured, setConnectionDriverName, setConnectionFactory2, setConnectionFactory2Name, setConnectionFactoryName, setConnectionPassword, setConnectionURL, setConnectionUserName, setFromProperties, setIgnoreCache, setMaxPool, setMinPool, setMsWait, setMultithreaded, setNonconfigured, setNontransactionalRead, setNontransactionalWrite, setOptimistic, setQueryTimeout, setRestoreValues, setRetainValues, setUpdateTimeout, supportedOptions, toInt, verifyConfiguration
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

fostorePropsAccessors

protected static java.util.HashMap fostorePropsAccessors
Properties accessors hash map for fostore-specific properties.


hashMapByFilteredProperties

protected static java.util.HashMap hashMapByFilteredProperties
A HashMap that associates PersistenceManagerFactory instances with a Properties instance.

Constructor Detail

FOStorePMF

public FOStorePMF()
Method Detail

initPropsAccessors

public static void initPropsAccessors()
Initialize fostorePropsAccessors.


setJDOQLQueryFactoryClassName

public void setJDOQLQueryFactoryClassName(java.lang.String jdoqlQueryFactoryClassName)
Sets the JDOQLQueryFactory class name used by getJDOQLQueryFactory.

Parameters:
jdoqlQueryFactoryClassName - the name of the JDOQLQueryFactory class.

getJDOQLQueryFactory

public JDOQLQueryFactory getJDOQLQueryFactory()
Returns the JDOQLQueryFactory bound to this FOStorePMF.

Returns:
JDOQLQueryFactory

newQueryTree

public QueryTree newQueryTree()
Returns a new QueryTree instance. This instance allows to specify a query with an API (see QueryTree and ExpressionFactory) rather than as JDOQL strings. To run you create a query object from the QueryTree (see PersistenceManager.newQuery(Object compiled)) and call the execute method on the Query object.

Returns:
new QueryTree instance.

getLocalAccessors

protected java.util.HashMap getLocalAccessors()
Return the FOStore-specific accessors (the properties that are not in the JDO specification).

Overrides:
getLocalAccessors in class PersistenceManagerFactoryImpl
Returns:
the hash map of FOStore accessors

createPersistenceManager

protected javax.jdo.PersistenceManager createPersistenceManager(java.lang.String userid,
                                                                java.lang.String password)
Create a new instance of PersistenceManager with the specific user name and password.

Specified by:
createPersistenceManager in class PersistenceManagerFactoryImpl
Parameters:
userid - the user name
password - the password
Returns:
the Persistencemanager
See Also:
PersistenceManagerFactoryImpl.createPersistenceManager(String userid, String password)

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
Overrides:
close in class PersistenceManagerFactoryImpl

close

public boolean close(boolean force)
Closes the database unless there are any active store managers.

Parameters:
force - If true, forces the database to close anyway, regardless of whether or not any store managers are still active.
Returns:
true if the database was closed, false if not (i.e., force is false and there are active store managers).
See Also:
PersistenceManagerFactory.getPersistenceManager()

setConnectionFactory

public void setConnectionFactory(java.lang.Object cf)
Override PersistenceManagerFactoryImpl's method so we can use our own cf variable.

Specified by:
setConnectionFactory in interface javax.jdo.PersistenceManagerFactory
Overrides:
setConnectionFactory in class PersistenceManagerFactoryImpl
Parameters:
cf - the connection factory

getConnectionFactory

public java.lang.Object getConnectionFactory()
Override PersistenceManagerFactoryImpl's method so that we can get a handle on the connection factory to close the database at close() time.

Specified by:
getConnectionFactory in interface javax.jdo.PersistenceManagerFactory
Overrides:
getConnectionFactory in class PersistenceManagerFactoryImpl
Returns:
the connection factory
See Also:
PersistenceManagerFactoryImpl.getConnectionFactory()

isConnectionFactoryConfigured

protected boolean isConnectionFactoryConfigured()
Verifies that the associated connection factory is configured (at least the URL is specified).

Specified by:
isConnectionFactoryConfigured in class PersistenceManagerFactoryImpl
Returns:
if the connection factory is properly configured

getTranscriberFactory

public TranscriberFactory getTranscriberFactory()
Description copied from interface: PersistenceManagerFactoryInternal
Provides the factory which can make Transcribers for this PMF.

Specified by:
getTranscriberFactory in interface PersistenceManagerFactoryInternal
Returns:
The PersistenceManagerFactory's transcriber factory.
See Also:
PersistenceManagerFactoryInternal.getTranscriberFactory()

getObjectIdClass

public java.lang.Class getObjectIdClass(java.lang.Class cls)
If parameter is non-null and implements PersistenceCapable, returns OID.class.

Specified by:
getObjectIdClass in interface PersistenceManagerFactoryInternal
Parameters:
cls - the PersistenceCapable Class
Returns:
the Class of the ObjectId of the parameter
See Also:
PersistenceManagerFactoryInternal.getObjectIdClass( Class cls)

getStoreManager

public StoreManager getStoreManager(javax.jdo.PersistenceManager pm)
Description copied from interface: PersistenceManagerFactoryInternal
Provides a StoreManager that is ready to accept operations on it such as insert, etc.

Specified by:
getStoreManager in interface PersistenceManagerFactoryInternal
Parameters:
pm - PersistenceManager that is requesting a StoreManager.
See Also:
PersistenceManagerFactoryInternal.getStoreManager( PersistenceManager pm)

releaseStoreManager

public void releaseStoreManager(javax.jdo.PersistenceManager pm)
Description copied from interface: PersistenceManagerFactoryInternal
Allows the PMF to release any resources associated with the given PM's store manager.

Specified by:
releaseStoreManager in interface PersistenceManagerFactoryInternal
Parameters:
pm - PersistenceManager that is releasing a StoreManager.
See Also:
PersistenceManagerFactoryInternal.releaseStoreManager( PersistenceManager pm)

getTrackedClass

public java.lang.Class getTrackedClass(java.lang.Class type)
Description copied from interface: PersistenceManagerFactoryInternal
Returns store-specific mapping between Java classes and tracked SCO classes supported by this PMF. Called by PersistenceManager inside requests for a new tracked instance.

Specified by:
getTrackedClass in interface PersistenceManagerFactoryInternal
Parameters:
type - Class to find mapping for.
Returns:
A Class for the tracked SCO or null if this Java class is not supported as tracked SCO.
See Also:
PersistenceManagerFactoryInternal.getTrackedClass( Class type)

getModel

public org.apache.jdo.impl.fostore.FOStoreModel getModel()
Returns metadata associated with this PersistenceManagerFactory.


writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Writes this PMF's state to the given object output.

Specified by:
writeExternal in interface java.io.Externalizable
Parameters:
out - ObjectOutput to which this PMF's state is written.
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Reads this PMF's state from the given object input.

Specified by:
readExternal in interface java.io.Externalizable
Parameters:
in - ObjectInput from which this PMF's state is read.
Throws:
java.io.IOException
java.lang.ClassNotFoundException

encrypt

protected java.lang.String encrypt(java.lang.String s)
Uses rot13 algorithm.

Specified by:
encrypt in class PersistenceManagerFactoryImpl
Parameters:
s - the String to be encrypted
Returns:
the encrypted String
See Also:
PersistenceManagerFactoryImpl.encrypt(java.lang.String)

decrypt

protected java.lang.String decrypt(java.lang.String s)
Uses rot13 algorithm.

Specified by:
decrypt in class PersistenceManagerFactoryImpl
Parameters:
s - the String to be decrypted
Returns:
the decrypted String
See Also:
PersistenceManagerFactoryImpl.decrypt(java.lang.String)

setConnectionCreate

public void setConnectionCreate(boolean create)
Parameters:
create - specifies whether to create the database

setConnectionCreate

public void setConnectionCreate(java.lang.String create)
Parameters:
create - tells whether to create the database

getConnectionCreate

public boolean getConnectionCreate()
Returns:
whether to create the database

setCFProperties

protected void setCFProperties(java.util.Properties p)
Description copied from class: PersistenceManagerFactoryImpl
Set the PMF-specific ConnectionFactory's properties.

Specified by:
setCFProperties in class PersistenceManagerFactoryImpl
Parameters:
p - Properties object in which the PMF's ConnectioFactory's properties are to be set.
See Also:
PersistenceManagerFactoryImpl.setCFProperties(java.util.Properties)

getCFFromProperties

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

Specified by:
getCFFromProperties in class PersistenceManagerFactoryImpl
Parameters:
p - Properties from which the ConnectionFactory is to be created.
See Also:
PersistenceManagerFactoryImpl.getCFFromProperties(java.util.Properties)

getReference

public javax.naming.Reference getReference()
                                    throws javax.naming.NamingException
Uses StringRefAddr's to store the information

Specified by:
getReference in interface javax.naming.Referenceable
Throws:
javax.naming.NamingException

toString

public java.lang.String toString()
Description copied from class: PersistenceManagerFactoryImpl
The String representation of this PMF.

Overrides:
toString in class PersistenceManagerFactoryImpl
Returns:
configuration information

getOptionArray

protected java.lang.String[] getOptionArray()
Description copied from class: PersistenceManagerFactoryImpl
Returns an array of Strings indicating which options are supported by this PersistenceManagerFactory.

Specified by:
getOptionArray in class PersistenceManagerFactoryImpl
Returns:
the option array.
See Also:
PersistenceManagerFactoryImpl.getOptionArray()

getPersistenceManagerFactory

public static PersistenceManagerFactoryImpl getPersistenceManagerFactory(java.util.Properties props)
Construct a Properties instance from the given Properties. Only those property entries recognized by this implementation will be stored in the internal Properties instance.

This method attempts to find an existing PersistenceManagerFactory with the properties as specified in the parameter. Only the non-default properties are considered when trying to find a match.

This method cannot be implemented by the superclass because


setPMFClassProperty

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

Specified by:
setPMFClassProperty in class PersistenceManagerFactoryImpl
Parameters:
props - the Properties to which to add the PMF class property

shutdown

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

Overrides:
shutdown in class PersistenceManagerFactoryImpl


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