org.apache.openjpa.xmlstore
Class XMLStoreManager

java.lang.Object
  extended by org.apache.openjpa.abstractstore.AbstractStoreManager
      extended by org.apache.openjpa.xmlstore.XMLStoreManager
All Implemented Interfaces:
StoreManager, Closeable

public class XMLStoreManager
extends AbstractStoreManager

Store manager to a back-end consisting of XML files. This implementation accesses data through the XMLStore associated with its XMLConfiguration. Configuration instances are shared by all store managers owned by all brokers created with the same factory.

See Also:
AbstractStoreManager

Field Summary
 
Fields inherited from class org.apache.openjpa.abstractstore.AbstractStoreManager
ctx
 
Fields inherited from interface org.apache.openjpa.kernel.StoreManager
FORCE_LOAD_ALL, FORCE_LOAD_DFG, FORCE_LOAD_NONE, FORCE_LOAD_REFRESH, VERSION_DIFFERENT, VERSION_EARLIER, VERSION_LATER, VERSION_SAME
 
Constructor Summary
XMLStoreManager()
           
 
Method Summary
 void begin()
          OpenJPA assumes that after this method is invoked, all data accesses through this store manager will be part of a single unit of work that can be rolled back.
 void commit()
          This is a no-op implementation.
 ResultObjectProvider executeExtent(ClassMetaData meta, boolean subclasses, FetchConfiguration fetch)
          Create a ResultObjectProvider that can return all instances of type, optionally including subclasses as defined by subclasses.
 boolean exists(OpenJPAStateManager sm, Object context)
          Verify that the given instance exists in the data store; return false if it does not.
protected  Collection flush(Collection pNew, Collection pNewUpdated, Collection pNewFlushedDeleted, Collection pDirty, Collection pDeleted)
          Responsible for writing modifications happened back to the data store.
protected  Collection getUnsupportedOptions()
          Returns a set of option names that this store manager does not support.
 boolean initialize(OpenJPAStateManager sm, PCState state, FetchConfiguration fetch, Object context)
          This method is invoked when OpenJPA needs to load an object whose identity is known but which has not yet been loaded from the data store.
 boolean isCached(List<Object> oids, BitSet edata)
          Verify that the given instance exists in the data store in memory; return false if it does not.
 boolean load(OpenJPAStateManager sm, BitSet fields, FetchConfiguration fetch, int lockLevel, Object context)
          This method is invoked when OpenJPA needs to load additional data into an object that has already been at least partially loaded by a previous AbstractStoreManager.initialize(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.kernel.PCState, org.apache.openjpa.kernel.FetchConfiguration, java.lang.Object) invocation.
protected  OpenJPAConfiguration newConfiguration()
          Return a new configuration instance for this runtime.
protected  void open()
          No-op implementation.
 void rollback()
          This is a no-op implementation.
 boolean syncVersion(OpenJPAStateManager sm, Object context)
          Since this store manager does not provide optimistic locking support, this method always returns true.
 
Methods inherited from class org.apache.openjpa.abstractstore.AbstractStoreManager
assignDataStoreId, assignField, assignObjectId, beforeStateChange, beginOptimistic, cancelAll, close, compareVersion, copyDataStoreId, flush, getClientConnection, getContext, getDataStoreIdSequence, getDataStoreIdType, getManagedType, getPlatform, getValueSequence, loadAll, newDataStoreId, newFetchConfiguration, newQuery, releaseConnection, retainConnection, rollbackOptimistic, setContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLStoreManager

public XMLStoreManager()
Method Detail

getUnsupportedOptions

protected Collection getUnsupportedOptions()
Description copied from class: AbstractStoreManager
Returns a set of option names that this store manager does not support. By default, returns the following:

Overrides:
getUnsupportedOptions in class AbstractStoreManager

newConfiguration

protected OpenJPAConfiguration newConfiguration()
Description copied from class: AbstractStoreManager
Return a new configuration instance for this runtime. Configuration data is maintained at the factory level and is available to all OpenJPA components; therefore it is a good place to maintain shared resources such as connection pools, etc.

Overrides:
newConfiguration in class AbstractStoreManager

open

protected void open()
Description copied from class: AbstractStoreManager
No-op implementation. Ready this store manager for persistent operations.

Overrides:
open in class AbstractStoreManager

exists

public boolean exists(OpenJPAStateManager sm,
                      Object context)
Description copied from interface: StoreManager
Verify that the given instance exists in the data store; return false if it does not.


initialize

public boolean initialize(OpenJPAStateManager sm,
                          PCState state,
                          FetchConfiguration fetch,
                          Object context)
Description copied from class: AbstractStoreManager
This method is invoked when OpenJPA needs to load an object whose identity is known but which has not yet been loaded from the data store. sm is a partially-set-up state manager for this object. The ID and least-derived type information for the instance to load can be obtained by invoking sm.getObjectId() and sm.getMetaData(). When implementing this method, load the data for this object from the data store, determine the most-derived subclass of the newly-loaded data, and then use the OpenJPAStateManager.initialize(java.lang.Class, org.apache.openjpa.kernel.PCState) method to populate sm with a new instance of the appropriate type. Once OpenJPAStateManager.initialize(java.lang.Class, org.apache.openjpa.kernel.PCState) has been invoked, proceed to load field data into sm as in the AbstractStoreManager.load(org.apache.openjpa.kernel.OpenJPAStateManager, java.util.BitSet, org.apache.openjpa.kernel.FetchConfiguration, int, java.lang.Object) method, by using OpenJPAStateManager.store(int, java.lang.Object) (or the appropriate OpenJPAStateManager.storetype method) to put the data into the object.

Specified by:
initialize in interface StoreManager
Specified by:
initialize in class AbstractStoreManager
Parameters:
sm - the instance to initialize
state - the lifecycle state to initialize the state manager with
fetch - configuration for how to load the instance
context - the current execution data, or null if not given to the calling method of the broker
Returns:
true if the matching instance exists in the data store, false otherwise

load

public boolean load(OpenJPAStateManager sm,
                    BitSet fields,
                    FetchConfiguration fetch,
                    int lockLevel,
                    Object context)
Description copied from class: AbstractStoreManager
This method is invoked when OpenJPA needs to load additional data into an object that has already been at least partially loaded by a previous AbstractStoreManager.initialize(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.kernel.PCState, org.apache.openjpa.kernel.FetchConfiguration, java.lang.Object) invocation. Load data into sm by using OpenJPAStateManager.store(int, java.lang.Object) (or the appropriate OpenJPAStateManager.storetype method) to put the data into the object.

Specified by:
load in interface StoreManager
Specified by:
load in class AbstractStoreManager
Parameters:
sm - the instance to load
fields - set of fields to load; all field indexes in this set must be loaded; this set is mutable
fetch - the fetch configuration to use when loading related objects
lockLevel - attempt to load simple fields at this lock level; relations should be loaded at the read lock level of the fetch configuration
context - the current execution data, or null if not given to the calling method of the broker
Returns:
false if the object no longer exists in the database, true otherwise

syncVersion

public boolean syncVersion(OpenJPAStateManager sm,
                           Object context)
Description copied from class: AbstractStoreManager
Since this store manager does not provide optimistic locking support, this method always returns true.

Specified by:
syncVersion in interface StoreManager
Overrides:
syncVersion in class AbstractStoreManager
Parameters:
sm - the instance to check
context - the current execution data, or null if not given to the calling method of the context
Returns:
true if the instance still exists in the datastore and is up-to-date, false otherwise

begin

public void begin()
Description copied from class: AbstractStoreManager
OpenJPA assumes that after this method is invoked, all data accesses through this store manager will be part of a single unit of work that can be rolled back. This is a no-op implementation. If your data store does not support any concept of locking or transactions, you need not override this method.

Specified by:
begin in interface StoreManager
Overrides:
begin in class AbstractStoreManager

commit

public void commit()
Description copied from class: AbstractStoreManager
This is a no-op implementation. If your data store does not have a concept of transactions or a unit of work, you need not override this method. If it does, then override this method to notify the data store that the current transaction should be committed.

Specified by:
commit in interface StoreManager
Overrides:
commit in class AbstractStoreManager

rollback

public void rollback()
Description copied from class: AbstractStoreManager
This is a no-op implementation. If your data store does not have a concept of transactions or a unit of work, you need not override this method. If it does, then override this method to notify the data store that the current transaction should be rolled back.

Specified by:
rollback in interface StoreManager
Overrides:
rollback in class AbstractStoreManager

flush

protected Collection flush(Collection pNew,
                           Collection pNewUpdated,
                           Collection pNewFlushedDeleted,
                           Collection pDirty,
                           Collection pDeleted)
Description copied from class: AbstractStoreManager
Responsible for writing modifications happened back to the data store. If you do not remove the OpenJPAConfiguration.OPTION_INC_FLUSH option in AbstractStoreManager.getUnsupportedOptions(), this will be called only once at the end of a transaction. Otherwise, it may be called periodically throughout the course of a transaction. If this store manager supports optimistic transactions, datastore version information should be updated during flush, and the state manager's version indicator should be updated through the OpenJPAStateManager.setNextVersion(java.lang.Object) method. This method will only be invoked if there are meaningful changes to store. This differs from the behavior of StoreManager.flush(java.util.Collection), which may be invoked with a collection of objects in states that do not require any datastore action (for example, objects in the transient-transactional state).

Specified by:
flush in class AbstractStoreManager
Parameters:
pNew - Objects that should be added to the store, and that have not previously been flushed.
pNewUpdated - New objects that have been modified since they were initially flushed. These were in persistentNew in an earlier flush invocation.
pNewFlushedDeleted - New objects that have been deleted since they were initially flushed. These were in persistentNew in an earlier flush invocation.
pDirty - Objects that were loaded from the data store and have since been modified.
pDeleted - Objects that were loaded from the data store and have since been deleted. These may have been in a previous flush invocation's persistentDirty list.
Returns:
a collection of exceptions encountered during flushing.

executeExtent

public ResultObjectProvider executeExtent(ClassMetaData meta,
                                          boolean subclasses,
                                          FetchConfiguration fetch)
Description copied from class: AbstractStoreManager
Create a ResultObjectProvider that can return all instances of type, optionally including subclasses as defined by subclasses. The implementation of the result provider will typically execute some sort of data store query to find all the applicable objects, loop through the results, extracting object IDs from the data, and invoke StoreContext.find(Object,FetchConfiguration,BitSet,Object,int) on each OID. When invoking this method, the first argument is the OID. The second is the given fetch configuration. The third argument is a mask of fields to exclude from loading; it will typically be null. The fourth argument is an object that will be passed through to AbstractStoreManager.initialize(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.kernel.PCState, org.apache.openjpa.kernel.FetchConfiguration, java.lang.Object) or AbstractStoreManager.load(org.apache.openjpa.kernel.OpenJPAStateManager, java.util.BitSet, org.apache.openjpa.kernel.FetchConfiguration, int, java.lang.Object), and typically will contain the actual data to load. For example, for a JDBC-based store manager, this might be the result set that is being iterated over. If this argument is null, then the AbstractStoreManager.initialize(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.kernel.PCState, org.apache.openjpa.kernel.FetchConfiguration, java.lang.Object) or AbstractStoreManager.load(org.apache.openjpa.kernel.OpenJPAStateManager, java.util.BitSet, org.apache.openjpa.kernel.FetchConfiguration, int, java.lang.Object) method will have to issue another command to the data store in order to fetch the data to be loaded.

Specified by:
executeExtent in interface StoreManager
Specified by:
executeExtent in class AbstractStoreManager

isCached

public boolean isCached(List<Object> oids,
                        BitSet edata)
Description copied from interface: StoreManager
Verify that the given instance exists in the data store in memory; return false if it does not. When an object is found in memory the corresponding element of the BitSet is set to 1.



Copyright © 2006-2010 Apache Software Foundation. All Rights Reserved.