Package org.apache.openjpa.xmlstore
Class XMLStoreManager
java.lang.Object
org.apache.openjpa.abstractstore.AbstractStoreManager
org.apache.openjpa.xmlstore.XMLStoreManager
- All Implemented Interfaces:
StoreManager
,Closeable
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:
-
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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.executeExtent
(ClassMetaData meta, boolean subclasses, FetchConfiguration fetch) Create aResultObjectProvider
that can return all instances oftype
, optionally including subclasses as defined bysubclasses
.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<OpenJPAStateManager> pNew, Collection<OpenJPAStateManager> pNewUpdated, Collection<OpenJPAStateManager> pNewFlushedDeleted, Collection<OpenJPAStateManager> pDirty, Collection<OpenJPAStateManager> pDeleted) Responsible for writing modifications happened back to the data store.protected Collection
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
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 previousAbstractStoreManager.initialize(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.kernel.PCState, org.apache.openjpa.kernel.FetchConfiguration, java.lang.Object)
invocation.protected OpenJPAConfiguration
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 returnstrue
.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
-
Constructor Details
-
XMLStoreManager
public XMLStoreManager()
-
-
Method Details
-
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 classAbstractStoreManager
-
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 classAbstractStoreManager
-
open
protected void open()Description copied from class:AbstractStoreManager
No-op implementation. Ready this store manager for persistent operations.- Overrides:
open
in classAbstractStoreManager
-
exists
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 invokingsm.getObjectId()
andsm.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 theOpenJPAStateManager.initialize(java.lang.Class, org.apache.openjpa.kernel.PCState)
method to populatesm
with a new instance of the appropriate type. OnceOpenJPAStateManager.initialize(java.lang.Class, org.apache.openjpa.kernel.PCState)
has been invoked, proceed to load field data intosm
as in theAbstractStoreManager.load(org.apache.openjpa.kernel.OpenJPAStateManager, java.util.BitSet, org.apache.openjpa.kernel.FetchConfiguration, int, java.lang.Object)
method, by usingOpenJPAStateManager.store(int, java.lang.Object)
(or the appropriateOpenJPAStateManager.storetype
method) to put the data into the object.- Specified by:
initialize
in interfaceStoreManager
- Specified by:
initialize
in classAbstractStoreManager
- Parameters:
sm
- the instance to initializestate
- the lifecycle state to initialize the state manager withfetch
- configuration for how to load the instancecontext
- 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 previousAbstractStoreManager.initialize(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.kernel.PCState, org.apache.openjpa.kernel.FetchConfiguration, java.lang.Object)
invocation. Load data intosm
by usingOpenJPAStateManager.store(int, java.lang.Object)
(or the appropriateOpenJPAStateManager.storetype
method) to put the data into the object.- Specified by:
load
in interfaceStoreManager
- Specified by:
load
in classAbstractStoreManager
- Parameters:
sm
- the instance to loadfields
- set of fields to load; all field indexes in this set must be loaded; this set is mutablefetch
- the fetch configuration to use when loading related objectslockLevel
- attempt to load simple fields at this lock level; relations should be loaded at the read lock level of the fetch configurationcontext
- 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
Description copied from class:AbstractStoreManager
Since this store manager does not provide optimistic locking support, this method always returnstrue
.- Specified by:
syncVersion
in interfaceStoreManager
- Overrides:
syncVersion
in classAbstractStoreManager
- Parameters:
sm
- the instance to checkcontext
- 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 interfaceStoreManager
- Overrides:
begin
in classAbstractStoreManager
-
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 interfaceStoreManager
- Overrides:
commit
in classAbstractStoreManager
-
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 interfaceStoreManager
- Overrides:
rollback
in classAbstractStoreManager
-
flush
protected Collection flush(Collection<OpenJPAStateManager> pNew, Collection<OpenJPAStateManager> pNewUpdated, Collection<OpenJPAStateManager> pNewFlushedDeleted, Collection<OpenJPAStateManager> pDirty, Collection<OpenJPAStateManager> pDeleted) Description copied from class:AbstractStoreManager
Responsible for writing modifications happened back to the data store. If you do not remove theOpenJPAConfiguration.OPTION_INC_FLUSH
option inAbstractStoreManager.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 theOpenJPAStateManager.setNextVersion(java.lang.Object)
method. This method will only be invoked if there are meaningful changes to store. This differs from the behavior ofStoreManager.flush(java.util.Collection<org.apache.openjpa.kernel.OpenJPAStateManager>)
, 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 classAbstractStoreManager
- 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 inpersistentNew
in an earlier flush invocation.pNewFlushedDeleted
- New objects that have been deleted since they were initially flushed. These were inpersistentNew
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 aResultObjectProvider
that can return all instances oftype
, optionally including subclasses as defined bysubclasses
. 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 invokeStoreContext.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 toAbstractStoreManager.initialize(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.kernel.PCState, org.apache.openjpa.kernel.FetchConfiguration, java.lang.Object)
orAbstractStoreManager.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 isnull
, then theAbstractStoreManager.initialize(org.apache.openjpa.kernel.OpenJPAStateManager, org.apache.openjpa.kernel.PCState, org.apache.openjpa.kernel.FetchConfiguration, java.lang.Object)
orAbstractStoreManager.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 interfaceStoreManager
- Specified by:
executeExtent
in classAbstractStoreManager
-
isCached
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.
-