|
SolarMetric Kodo JDO 3.3.5 generated on August 31 2005 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--kodo.abstractstore.AbstractStoreManager
Abstract store manager implementation to ease development of custom Kodo back-ends. A concrete subclass must define implementations for the following methods:
StoreManager.exists(kodo.runtime.KodoStateManager, java.lang.Object)
initialize(kodo.runtime.KodoStateManager, kodo.runtime.JDOState, kodo.runtime.FetchConfiguration, java.lang.Object)
load(kodo.runtime.KodoStateManager, java.util.BitSet, kodo.runtime.FetchConfiguration, int, java.lang.Object)
flush(Collection,Collection,Collection,Collection,Collection)
newExtent(java.lang.Class, boolean)
open()
has been called. Store manager instances might be
created to call metadata methods such as newConfiguration()
or
getUnsupportedOptions()
and never opened. These instances should
not consume any data store resources.
Notes:
StoreManager.initialize(kodo.runtime.KodoStateManager, kodo.runtime.JDOState, kodo.runtime.FetchConfiguration, java.lang.Object)
method is responsible
for creating new instances of objects freshly loaded from the
database. The method will be invoked with a KodoStateManager
that the newly-loaded object should be associated with. To create the
new object and set up this association correctly, the implementation
should use the #newInstance
method.begin()
, commit()
,
and rollback()
methods.beginOptimistic()
, rollbackOptimistic()
,
and synchVersion(kodo.runtime.KodoStateManager, java.lang.Object)
.getUnsupportedOptions()
to not include JDOConfiguration.OPTION_OPTIMISTIC
in the list of unsupported
options.KodoStateManager.setNextVersion(java.lang.Object)
method.Comparable
,
override compareVersion(kodo.runtime.KodoStateManager, java.lang.Object, java.lang.Object)
, which relies on the
Comparable.compareTo(java.lang.Object)
method.getSequenceGenerator(kodo.meta.ClassMetaData)
method if you want to use a
long
as your datastore identity type and are
happy with Kodo's Id
class. To use another datastore identity
type, override getPersistenceCapableClass(java.lang.Object)
,
getDataStoreIdClass(kodo.meta.ClassMetaData)
, copyDataStoreId(java.lang.Object, kodo.meta.ClassMetaData)
, and
assignDataStoreId(kodo.runtime.KodoStateManager)
instead. In either case, override
getUnsupportedOptions()
to not include
JDOConfiguration.OPTION_ID_DATASTORE
in the list of
unsupported options.ResultList
. For more details on MethodQL,
see the Kodo JDO Reference Guide.
Fields inherited from interface kodo.runtime.StoreManager |
FORCE_LOAD_ALL, FORCE_LOAD_DFG, FORCE_LOAD_NONE, FORCE_LOAD_REFRESH, VERSION_DIFFERENT, VERSION_EARLIER, VERSION_LATER, VERSION_SAME |
Constructor Summary | |
AbstractStoreManager()
|
Method Summary | |
protected boolean |
assignDataStoreId(KodoStateManager sm)
Assign a new datastore identity to the given instance. |
boolean |
assignObjectId(KodoStateManager sm)
Assign an object id to the given new instance. |
void |
begin()
Kodo 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 |
beginOptimistic()
No-op implementation. |
boolean |
cancelAll()
Returns false . |
void |
changeJDOState(KodoStateManager sm,
JDOState fromState,
JDOState toState)
Notification that the given state manager is about to change its JDO state. |
void |
close()
Free any resources this store manager is using. |
void |
commit()
This is a no-op implementation. |
int |
compareVersion(KodoStateManager state,
Object v1,
Object v2)
Casts v1 and v2 to Comparable , and
invokes v1.compareTo (v2) . |
Object |
copyDataStoreId(Object oid,
ClassMetaData meta)
Copy the given object id value. |
Collection |
flush(Collection states)
Breaks down states based on the objects' current JDO
states, and delegates to
flush(Collection,Collection,Collection,Collection,Collection) . |
protected abstract Collection |
flush(Collection pNew,
Collection pNewUpdated,
Collection pNewFlushedDeleted,
Collection pDirty,
Collection pDeleted)
Responsible for writing modifications happened back to the data store. |
Object |
getConnection()
Returns null . |
Class |
getDataStoreIdClass(ClassMetaData meta)
Return the class used by this StoreManager for datastore identity values. |
Class |
getPersistenceCapableClass(Object oid)
Return the persistent class for the given data store identity value. |
protected KodoPersistenceManagerSPI |
getPersistenceManager()
Returns the KodoPersistenceManagerSPI that this store
manager is associated with. |
protected String |
getPlatform()
Returns a string name to identify the platform of this store manager. |
SequenceGenerator |
getSequenceGenerator(ClassMetaData forClass)
Throws a javax.jdo.JDOUnsupportedOptionException . |
protected Collection |
getUnsupportedOptions()
Returns a set of JDO option names that this store manager does not support. |
boolean |
hasConnection()
Returns false . |
abstract boolean |
initialize(KodoStateManager sm,
JDOState state,
FetchConfiguration fetch,
Object context)
This method is invoked when Kodo needs to load an object whose identity is known but which has not yet been loaded from the data store. |
abstract boolean |
load(KodoStateManager sm,
BitSet fields,
FetchConfiguration fetch,
int lockLevel,
Object context)
This method is invoked when Kodo needs to load additional data into an object that has already been at least partially loaded by a previous initialize(kodo.runtime.KodoStateManager, kodo.runtime.JDOState, kodo.runtime.FetchConfiguration, java.lang.Object) invocation. |
Collection |
loadAll(Collection sms,
JDOState state,
int load,
FetchConfiguration fetch,
Object context)
This implementation just delegates to the proper singular method ( StoreManager.initialize(kodo.runtime.KodoStateManager, kodo.runtime.JDOState, kodo.runtime.FetchConfiguration, java.lang.Object) or StoreManager.load(kodo.runtime.KodoStateManager, java.util.BitSet, kodo.runtime.FetchConfiguration, int, java.lang.Object) )
depending on each state manager's state. |
protected JDOConfiguration |
newConfiguration()
Return a new configuration instance for this runtime. |
Object |
newDataStoreId(Object oidVal,
ClassMetaData meta)
Create a new unique datastore identity for the given type from the given oid value (presumably pk, stringified oid, or oid instance). |
abstract KodoExtent |
newExtent(Class type,
boolean subclasses)
Create an KodoExtent capable of loading all instances
of type , optionally including subclasses as defined
by subclasses . |
FetchConfiguration |
newFetchConfiguration()
Return a fetch configuration suitable for this runtime. |
KodoQuery |
newQuery(String language)
Return a query implementation suitable for this runtime. |
protected void |
open()
No-op implementation. |
void |
rollback()
This is a no-op implementation. |
void |
rollbackOptimistic()
No-op implementation. |
void |
setPersistenceManager(KodoPersistenceManager pm)
Set a reference to the corresponding PersistenceManager. |
boolean |
synchVersion(KodoStateManager sm,
Object context)
Since this store manager does not provide optimistic locking support, this method always returns true . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface kodo.runtime.StoreManager |
exists |
Constructor Detail |
public AbstractStoreManager()
Method Detail |
public final void setPersistenceManager(KodoPersistenceManager pm)
StoreManager
setPersistenceManager
in interface StoreManager
protected void open()
public void beginOptimistic()
beginOptimistic
in interface StoreManager
public void rollbackOptimistic()
begin()
is
invoked.rollbackOptimistic
in interface StoreManager
public void begin()
Kodo 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.
begin
in interface StoreManager
public void commit()
commit
in interface StoreManager
public void rollback()
rollback
in interface StoreManager
public boolean synchVersion(KodoStateManager sm, Object context)
true
.synchVersion
in interface StoreManager
kodo.runtime.StoreManager
sm
- the instance to checkcontext
- the current context information, or null if not
given to the calling method of the persistence
managerpublic abstract boolean initialize(KodoStateManager sm, JDOState state, FetchConfiguration fetch, Object context)
This method is invoked when Kodo 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 #newInstance
method to populate
sm
with a new instance of the appropriate type.
Once #newInstance
has been invoked, proceed to load field
data into sm
as in the load(kodo.runtime.KodoStateManager, java.util.BitSet, kodo.runtime.FetchConfiguration, int, java.lang.Object)
method, by using
KodoStateManager.store(int, java.lang.Object)
(or the appropriate
KodoStateManager.storetype
method) to put the
data into the object.
initialize
in interface StoreManager
kodo.runtime.StoreManager
sm
- the instance to initializestate
- the lifecycle state to initialize the state
manager withfetch
- configuration for how to load the instancecontext
- the current context information, or null if not
given to the calling method of the persistence
managerpublic abstract boolean load(KodoStateManager sm, BitSet fields, FetchConfiguration fetch, int lockLevel, Object context)
This method is invoked when Kodo needs to load additional data
into an object that has already been at least partially loaded by
a previous initialize(kodo.runtime.KodoStateManager, kodo.runtime.JDOState, kodo.runtime.FetchConfiguration, java.lang.Object)
invocation.
Load data into sm
by using KodoStateManager.store(int, java.lang.Object)
(or the appropriate
KodoStateManager.storetype
method) to put the
data into the object.
load
in interface StoreManager
kodo.runtime.StoreManager
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 context information, or null if not
given to the calling method of the persistence
managerpublic Collection loadAll(Collection sms, JDOState state, int load, FetchConfiguration fetch, Object context)
StoreManager.initialize(kodo.runtime.KodoStateManager, kodo.runtime.JDOState, kodo.runtime.FetchConfiguration, java.lang.Object)
or StoreManager.load(kodo.runtime.KodoStateManager, java.util.BitSet, kodo.runtime.FetchConfiguration, int, java.lang.Object)
)
depending on each state manager's state. If your data store provides
bulk loading APIs, overriding this method to be more clever may be
advantageous.loadAll
in interface StoreManager
kodo.runtime.StoreManager
sms
- the state manager instances to loadstate
- the lifecycle state to initialize uninitialized
state managers with; may be null if no uninitialized
instances are included in sms
load
- one of the FORCE_LOAD_* constants describing the
fields to force-load if this is a refresh or
retrieve actionfetch
- the current fetch configuration to use when loading
related objectscontext
- the current context information, or null if not
given to the calling method of the persistence
managerpublic Collection flush(Collection states)
states
based on the objects' current JDO
states, and delegates to
flush(Collection,Collection,Collection,Collection,Collection)
.flush
in interface StoreManager
public void changeJDOState(KodoStateManager sm, JDOState fromState, JDOState toState)
StoreManager
changeJDOState
in interface StoreManager
public Class getPersistenceCapableClass(Object oid)
StoreManager
getPersistenceCapableClass
in interface StoreManager
public boolean assignObjectId(KodoStateManager sm)
StoreManager
assignObjectId
in interface StoreManager
kodo.runtime.StoreManager
kodo.util.ApplicationIds#create
protected boolean assignDataStoreId(KodoStateManager sm)
public Class getDataStoreIdClass(ClassMetaData meta)
StoreManager
getDataStoreIdClass
in interface StoreManager
public Object copyDataStoreId(Object oid, ClassMetaData meta)
StoreManager
copyDataStoreId
in interface StoreManager
public Object newDataStoreId(Object oidVal, ClassMetaData meta)
StoreManager
newDataStoreId
in interface StoreManager
public Object getConnection()
null
. If your data store can provide a
distinct connection object, return it here.getConnection
in interface StoreManager
public boolean hasConnection()
Returns false
. If your data store can provide
a distinct connection object, this should return whether or
not this store manager has a dedicated connection. For
example, after a pessimistic transaction begins, this should
return true
if possible.
Kodo's automatic query flushing capabilities, among other
things, use the return value of this method to determine what
to do. So, if it returns false
, automatic query
flushing will never happen.
hasConnection
in interface StoreManager
public abstract KodoExtent newExtent(Class type, boolean subclasses)
Create an KodoExtent
capable of loading all instances
of type
, optionally including subclasses as defined
by subclasses
.
This will typically return an instance of a class that extends
ExtentImpl
, defining ExtentImpl.getResultObjectProvider(kodo.meta.ClassMetaData)
to return a ResultObjectProvider
capable of
iterating through all the desired objects for a given ClassMetaData
. Note that there might be multiple calls to that method
if type
identifies an interface or abstract class with
multiple persistence-capable implementations.
The implementation of the ExtentImpl.getResultObjectProvider(kodo.meta.ClassMetaData)
method will typically execute some sort of data store query to find all
the applicable objects, loop through the returned data, extracting
object IDs from the data, and invoking #getObjectById(Object,FetchConfiguration,BitSet,Object)
on each OID.
When invoking this method, the first argument is the OID. The second is
the current fetch configuration (this can be null). The third argument
is a mask of fields to exclude from loading; it will typically be null.
The last argument is an object that will be passed through to
initialize(kodo.runtime.KodoStateManager, kodo.runtime.JDOState, kodo.runtime.FetchConfiguration, java.lang.Object)
or load(kodo.runtime.KodoStateManager, java.util.BitSet, kodo.runtime.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 initialize(kodo.runtime.KodoStateManager, kodo.runtime.JDOState, kodo.runtime.FetchConfiguration, java.lang.Object)
or load(kodo.runtime.KodoStateManager, java.util.BitSet, kodo.runtime.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.
newExtent
in interface StoreManager
public KodoQuery newQuery(String language)
StoreManager
newQuery
in interface StoreManager
kodo.runtime.StoreManager
language
- the query language; implementations are only
required to support
javax.jdo.query.JDOQL
public FetchConfiguration newFetchConfiguration()
StoreManager
FetchConfigurationImpl
.newFetchConfiguration
in interface StoreManager
public int compareVersion(KodoStateManager state, Object v1, Object v2)
Casts v1
and v2
to Comparable
, and
invokes v1.compareTo (v2)
. If v1
is less
than v2
, returns StoreManager.VERSION_EARLIER
. If the same,
returns StoreManager.VERSION_SAME
. Otherwise, returns StoreManager.VERSION_LATER
. If either v1
or v2
are
null
, returns StoreManager.VERSION_DIFFERENT
.
compareVersion
in interface StoreManager
kodo.runtime.StoreManager
state
- the state manager for the objectv1
- the first version object to comparev2
- the second version object to compareStoreManager.VERSION_LATER
if v1
is later than v2
StoreManager.VERSION_EARLIER
if v1
is earlier than v2
StoreManager.VERSION_SAME
if v1
is the same as v2
StoreManager.VERSION_DIFFERENT
if v1
is different from v2
, but the time
difference of the versions cannot be determinedpublic SequenceGenerator getSequenceGenerator(ClassMetaData forClass)
javax.jdo.JDOUnsupportedOptionException
. Override
this method to provide datastore identity by using Kodo's Id
class, which uses a long as the per-class identifier. To
use some other sort of datastore identifier (a GUID, string,
or someting of that nature), override
getPersistenceCapableClass(java.lang.Object)
, getDataStoreIdClass(kodo.meta.ClassMetaData)
,
.getSequenceGenerator
in interface StoreManager
public boolean cancelAll()
false
. If your data store supports
cancelling queries, this method should cancel any
currently-running queries and return true
if any
were cancelled.cancelAll
in interface StoreManager
kodo.runtime.StoreManager
public void close()
StoreManager
close
in interface StoreManager
protected abstract Collection flush(Collection pNew, Collection pNewUpdated, Collection pNewFlushedDeleted, Collection pDirty, Collection pDeleted)
Responsible for writing modifications happened back to the data
store. If you do not remove the
JDOConfiguration.OPTION_INC_FLUSH
option in
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
KodoStateManager.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 JDO states that
do not require any datastore action (for example, objects in the
transient-transactional state).
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.OptimisticVerificationException
s
encountered during flushing.protected KodoPersistenceManagerSPI getPersistenceManager()
KodoPersistenceManagerSPI
that this store
manager is associated with.protected JDOConfiguration newConfiguration()
protected Collection getUnsupportedOptions()
Returns a set of JDO option names that this store manager does not support.
This returns [ "javax.jdo.option.Optimistic",
"javax.jdo.option.DatastoreIdentity", "kodo.option.IncrementalFlush" ]
protected String getPlatform()
Returns a string name to identify the platform of this
store manager. This will be used by Kodo to assemble a string
to put into the return value from
PersistenceManagerFactory.getProperties()
.
Returns the class name of this store manager by default.
|
SolarMetric Kodo JDO 3.3.5 generated on August 31 2005 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |