org.apache.jdo.impl.fostore
Class FOStorePMF

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

public class FOStorePMF
extends org.apache.jdo.impl.pm.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 inherited from class org.apache.jdo.impl.pm.PersistenceManagerFactoryImpl
org.apache.jdo.impl.pm.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)
           
 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.
 org.apache.jdo.jdoql.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()
           
static org.apache.jdo.impl.pm.PersistenceManagerFactoryImpl getPersistenceManagerFactory(java.util.Map props)
          This is a hack until a proper implementation of the method can be done.
static org.apache.jdo.impl.pm.PersistenceManagerFactoryImpl getPersistenceManagerFactory(java.util.Properties props)
          Construct a PersistenceManagerFactory instance from the given Properties.
 javax.naming.Reference getReference()
          Uses StringRefAddr's to store the information
 org.apache.jdo.store.StoreManager getStoreManager(javax.jdo.PersistenceManager pm)
           
 java.lang.Class getTrackedClass(java.lang.Class type)
           
 org.apache.jdo.store.TranscriberFactory getTranscriberFactory()
           
static void initPropsAccessors()
          Initialize fostorePropsAccessors.
protected  boolean isConnectionFactoryConfigured()
          Verifies that the associated connection factory is configured (at least the URL is specified).
 org.apache.jdo.jdoql.tree.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)
           
protected  void setCFProperties(java.util.Properties p)
           
 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()
           
 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
addInstanceLifecycleListener, assertNotClosed, closeOpenPersistenceManagers, deregisterPersistenceManager, doReadObject, doWriteObject, equals, filterProperties, getActivePersistenceManagers, getAsProperties, getAsPropertiesInternal, getConnectionDriverName, getConnectionFactory2, getConnectionFactory2Name, getConnectionFactoryName, getConnectionPassword, getConnectionURL, getConnectionUserName, getDataStoreCache, getDetachAllOnCommit, getIgnoreCache, getMapping, getMaxPool, getMinPool, getMsWait, getMultithreaded, getNontransactionalRead, getNontransactionalWrite, getOptimistic, getPersistenceManager, getPersistenceManager, getProperties, getQueryTimeout, getRestoreValues, getRetainValues, getUpdateTimeout, hashCode, isClosed, registerPersistenceManager, releasePersistenceManager, removeInstanceLifecycleListener, setConfigured, setConnectionDriverName, setConnectionFactory2, setConnectionFactory2Name, setConnectionFactoryName, setConnectionPassword, setConnectionURL, setConnectionUserName, setDetachAllOnCommit, setFromProperties, setIgnoreCache, setMapping, 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 org.apache.jdo.jdoql.JDOQLQueryFactory getJDOQLQueryFactory()
Returns the JDOQLQueryFactory bound to this FOStorePMF.

Returns:
JDOQLQueryFactory

newQueryTree

public org.apache.jdo.jdoql.tree.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).

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.

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

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
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
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).

Returns:
if the connection factory is properly configured

getTranscriberFactory

public org.apache.jdo.store.TranscriberFactory getTranscriberFactory()
Specified by:
getTranscriberFactory in interface org.apache.jdo.pm.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 org.apache.jdo.pm.PersistenceManagerFactoryInternal
See Also:
PersistenceManagerFactoryInternal.getObjectIdClass( Class cls)

getStoreManager

public org.apache.jdo.store.StoreManager getStoreManager(javax.jdo.PersistenceManager pm)
Specified by:
getStoreManager in interface org.apache.jdo.pm.PersistenceManagerFactoryInternal
See Also:
PersistenceManagerFactoryInternal.getStoreManager( PersistenceManager pm)

releaseStoreManager

public void releaseStoreManager(javax.jdo.PersistenceManager pm)
Specified by:
releaseStoreManager in interface org.apache.jdo.pm.PersistenceManagerFactoryInternal
See Also:
PersistenceManagerFactoryInternal.releaseStoreManager( PersistenceManager pm)

getTrackedClass

public java.lang.Class getTrackedClass(java.lang.Class type)
Specified by:
getTrackedClass in interface org.apache.jdo.pm.PersistenceManagerFactoryInternal
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.

See Also:
PersistenceManagerFactoryImpl.encrypt(java.lang.String)

decrypt

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

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)
See Also:
PersistenceManagerFactoryImpl.setCFProperties(java.util.Properties)

getCFFromProperties

protected void getCFFromProperties(java.util.Properties p)
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()
Returns:
configuration information

getOptionArray

protected java.lang.String[] getOptionArray()
See Also:
PersistenceManagerFactoryImpl.getOptionArray()

getPersistenceManagerFactory

public static org.apache.jdo.impl.pm.PersistenceManagerFactoryImpl getPersistenceManagerFactory(java.util.Map props)
This is a hack until a proper implementation of the method can be done.


getPersistenceManagerFactory

public static org.apache.jdo.impl.pm.PersistenceManagerFactoryImpl getPersistenceManagerFactory(java.util.Properties props)
Construct a PersistenceManagerFactory 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 it doesn't have any information about the implementation.


setPMFClassProperty

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


shutdown

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



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