org.apache.openjpa.kernel
Class DelegatingBroker

java.lang.Object
  extended by org.apache.openjpa.kernel.DelegatingBroker
All Implemented Interfaces:
CallbackModes, AutoClear, AutoDetach, Broker, ConnectionRetainModes, DetachState, LockLevels, RestoreState, StoreContext, Closeable

public class DelegatingBroker
extends Object
implements Broker

Delegating broker that can also perform exception translation for use in facades.

Since:
0.4.0
Author:
Abe White

Field Summary
 
Fields inherited from interface org.apache.openjpa.kernel.StoreContext
EXCLUDE_ALL, OID_ALLOW_NEW, OID_COPY, OID_NODELETED, OID_NOVALIDATE
 
Fields inherited from interface org.apache.openjpa.kernel.ConnectionRetainModes
CONN_RETAIN_ALWAYS, CONN_RETAIN_DEMAND, CONN_RETAIN_TRANS
 
Fields inherited from interface org.apache.openjpa.kernel.DetachState
DETACH_ALL, DETACH_FETCH_GROUPS, DETACH_FGS, DETACH_LOADED
 
Fields inherited from interface org.apache.openjpa.kernel.LockLevels
LOCK_NONE, LOCK_READ, LOCK_WRITE
 
Fields inherited from interface org.apache.openjpa.kernel.RestoreState
RESTORE_ALL, RESTORE_IMMUTABLE, RESTORE_NONE
 
Fields inherited from interface org.apache.openjpa.kernel.AutoClear
CLEAR_ALL, CLEAR_DATASTORE
 
Fields inherited from interface org.apache.openjpa.kernel.AutoDetach
DETACH_CLOSE, DETACH_COMMIT, DETACH_NONTXREAD, DETACH_ROLLBACK
 
Fields inherited from interface org.apache.openjpa.event.CallbackModes
CALLBACK_FAIL_FAST, CALLBACK_IGNORE, CALLBACK_LOG, CALLBACK_RETHROW, CALLBACK_ROLLBACK
 
Constructor Summary
DelegatingBroker(Broker broker)
          Constructor; supply delegate.
DelegatingBroker(Broker broker, RuntimeExceptionTranslator trans)
          Constructor; supply delegate and exception translator.
 
Method Summary
 void addLifecycleListener(Object listener, Class[] classes)
          Register a listener for lifecycle-related events on the specified classes.
 void addTransactionListener(Object listener)
          Register a listener for transaction-related events.
 void afterCompletion(int status)
           
 void assertActiveTransaction()
          Throw an exception if there is no active transaction.
 void assertNontransactionalRead()
          Throw an exception if there is no transaction active and nontransactional reading is not enabled.
 void assertOpen()
          Throw an exception if this broker has been closed.
 void assertWriteOperation()
          Throw an exception if a write operation is not permitted (there is no active transaction and nontransactional writing is not enabled).
 Object attach(Object obj, boolean copyNew, OpCallbacks call)
          Import the specified detached object into the broker.
 Object[] attachAll(Collection objs, boolean copyNew, OpCallbacks call)
          Import the specified objects into the broker.
 void beforeCompletion()
           
 void begin()
          Begin a transaction.
 boolean beginOperation(boolean read)
          Begin a logical operation.
 void beginStore()
          Begin a data store transaction.
 boolean cancelAll()
          Cancel all pending data store statements.
 void close()
          Close the broker.
 void commit()
          Commit the current transaction.
 void commitAndResume()
          Issue a commit and then start a new transaction.
 void delete(Object obj, OpCallbacks call)
          Delete the given object.
 void deleteAll(Collection objs, OpCallbacks call)
          Delete the given objects.
 Object detach(Object obj, OpCallbacks call)
          Detach the specified object from the broker.
 Object[] detachAll(Collection objs, OpCallbacks call)
          Detach the specified objects from the broker.
 void detachAll(OpCallbacks call)
          Detach all objects in place.
 void detachAll(OpCallbacks call, boolean flush)
          Detach all objects in place, with the option of performing a flush before doing the detachment.
 void dirtyType(Class cls)
          Mark the given class as dirty within the current transaction.
 OpenJPAStateManager embed(Object obj, Object id, OpenJPAStateManager owner, ValueMetaData ownerMeta)
          Make the given instance embedded.
 boolean endOperation()
          End a logical operation.
 boolean equals(Object other)
           
 void evict(Object obj, OpCallbacks call)
          Evict the given object.
 void evictAll(Collection objs, OpCallbacks call)
          Evict the given objects.
 void evictAll(Extent extent, OpCallbacks call)
          Evict all persistent-clean and persistent-nontransactional instances in the given Extent.
 void evictAll(OpCallbacks call)
          Evict all clean objects.
 Iterator extentIterator(Class cls, boolean subs, FetchConfiguration fetch, boolean ignoreChanges)
          Return an iterator over all instances of the given type.
 Object find(Object oid, boolean validate, FindCallbacks call)
          Find the persistence object with the given oid.
 Object find(Object oid, FetchConfiguration fetch, BitSet exclude, Object edata, int flags)
          Return the object with the given oid.
 Object[] findAll(Collection oids, boolean validate, FindCallbacks call)
          Return the objects with the given oids.
 Object[] findAll(Collection oids, FetchConfiguration fetch, BitSet exclude, Object edata, int flags)
          Return the objects with the given oids.
 Object findCached(Object oid, FindCallbacks call)
          Return the cached instance for the given oid/object, or null if not cached.
 void flush()
          Flush all transactional instances to the data store.
 int getAutoClear()
          Whether objects clear when entering transactions.
 int getAutoDetach()
          Bit flags marked in AutoDetach which indicate when persistent managed objects should be automatically detached in-place.
 Broker getBroker()
          Return the broker for this context, if possible.
 BrokerFactory getBrokerFactory()
          Return the factory that produced this broker.
 ClassLoader getClassLoader()
          Return the current thread's class loader at the time this context was obtained.
 OpenJPAConfiguration getConfiguration()
          Return the configuration associated with this context.
 Object getConnection()
          Return the connection in use by the context, or a new connection if none.
 String getConnectionPassword()
          Return the connection password.
 int getConnectionRetainMode()
          Return the connection retain mode for this broker.
 String getConnectionUserName()
          Return the connection user name.
 Broker getDelegate()
          Return the direct delegate.
 Collection getDeletedTypes()
          Return the set of classes that have been deleted in the current transaction.
 int getDetachState()
          Detach mode constant to determine which fields are part of the detached graph.
 Collection getDirtyObjects()
          Return a list of current dirty instances.
 boolean getEvictFromDataCache()
          Whether to also evict an object from the store cache when it is evicted through this broker.
 FetchConfiguration getFetchConfiguration()
          Return the (mutable) fetch configuration for loading objects from this context.
 Seq getIdentitySequence(ClassMetaData meta)
          Returns a Seq for the datastore identity values of the specified persistent class, or null if the class' identity cannot be represented as a sequence.
 boolean getIgnoreChanges()
          Whether to take into account changes in the transaction when executing a query or iterating an extent.
 Broker getInnermostDelegate()
          Return the native delegate.
 InverseManager getInverseManager()
          Return the inverse manager in use.
 LifecycleEventManager getLifecycleEventManager()
          Return the lifecycle event manager associated with the broker.
 int getLifecycleListenerCallbackMode()
          The callback mode for handling exceptions from lifecycle event listeners.
 int getLockLevel(Object obj)
          Return the lock level of the specified object.
 LockManager getLockManager()
          Return the lock manager in use.
 Collection getManagedObjects()
          Return a list of all managed instances.
 ManagedRuntime getManagedRuntime()
          Return the managed runtime in use.
 boolean getMultithreaded()
          Whether the broker or its managed instances are used in a multithreaded environment.
 boolean getNontransactionalRead()
          Whether to allow nontransactional access to persistent state.
 boolean getNontransactionalWrite()
          Whether to allow nontransactional changes to persistent state.
 Object getObjectId(Object obj)
          Return the oid of the given instance.
 Class getObjectIdType(Class cls)
          Return the application or datastore identity class the given persistent class uses for object ids.
 boolean getOptimistic()
          Whether to use optimistic transactional semantics.
 boolean getOrderDirtyObjects()
          Whether to maintain the order in which objects are dirtied for StoreContext.getDirtyObjects().
 Collection getPendingTransactionalObjects()
          Return a list of instances which will become transactional upon the next transaction.
 Collection getPersistedTypes()
          Return the set of classes that have been made persistent in the current transaction.
 boolean getPopulateDataCache()
          Whether objects accessed during this transaction will be added to the store cache.
 int getRestoreState()
          Whether to restore an object's original state on rollback.
 boolean getRetainState()
          Whether objects retain their persistent state on transaction commit.
 Throwable getRollbackCause()
          Returns the Throwable that caused the transaction to be marked for rollback.
 boolean getRollbackOnly()
          Return whether the current transaction has been marked for rollback.
 OpenJPAStateManager getStateManager(Object obj)
          Return the state manager for the given instance.
 DelegatingStoreManager getStoreManager()
          Return the store manager in use.
 boolean getSyncWithManagedTransactions()
          Whether to check for a global transaction upon every managed, non-transactional operation.
 Collection getTransactionalObjects()
          Return a list of current transaction instances.
 int getTransactionListenerCallbackMode()
          The callback mode for handling exceptions from transaction event listeners.
 Collection getUpdatedTypes()
          Return the set of classes for objects that have been modified in the current transaction.
 Object getUserObject(Object key)
          Get the value for the specified key from the map of user objects.
 Seq getValueSequence(FieldMetaData fmd)
          Returns a Seq for the generated values of the specified field, or null if the field is not generated.
 Object getVersion(Object obj)
          Returns the current version indicator for o.
 boolean hasConnection()
          Whether the broker has a dedicated connection based on the configured connection retain mode and transaction status.
 int hashCode()
           
 boolean isActive()
          Whether a logical transaction is active.
 boolean isClosed()
          Whether the broker is closed.
 boolean isCloseInvoked()
          Whether Broker.close() has been invoked, though the broker might remain open until the current managed transaction completes.
 boolean isDeleted(Object obj)
          Return whether the given object is deleted.
 boolean isDetached(Object obj)
          Returns true if obj is a detached object (one that can be reattached to a Broker via a call to Broker.attach(java.lang.Object, boolean, org.apache.openjpa.kernel.OpCallbacks)); otherwise returns false.
 boolean isDetachedNew()
          Whether to treat relations to detached instances during persist operations as new or as pseudo-hollow instances.
 boolean isDirty(Object obj)
          Return whether the given object is dirty.
 boolean isManaged()
          Whether this context is using managed transactions.
 boolean isNew(Object obj)
          Return whether the given object is a newly-created instance registered with broker.
 boolean isPersistent(Object obj)
          Return whether the given object is persistent.
 boolean isStoreActive()
          Whether a data store transaction is active.
 boolean isTrackChangesByType()
          Whether memory usage is reduced during this transaction at the expense of tracking changes at the type level instead of the instance level, resulting in more aggressive cache invalidation.
 boolean isTransactional(Object obj)
          Return whether the given object is transactional.
 void lock()
          Synchronizes on an internal lock if the Multithreaded flag is set to true.
 void lock(Object obj, int level, int timeout, OpCallbacks call)
          Ensure that the given instance is locked at the given lock level.
 void lock(Object obj, OpCallbacks call)
          Ensure that the given instance is locked at the current lock level, as set in the FetchConfiguration for the broker.
 void lockAll(Collection objs, int level, int timeout, OpCallbacks call)
          Ensure that the given instances are locked at the given lock level.
 void lockAll(Collection objs, OpCallbacks call)
          Ensure that the given instances are locked at the current lock level, as set in the FetchConfiguration for the broker.
 Extent newExtent(Class cls, boolean subs)
          Return an extent of the given class, optionally including subclasses.
 Object newInstance(Class cls)
          Create a new instance of type cls.
 Object newObjectId(Class cls, Object val)
          Create a new object id instance from the given value.
 Query newQuery(String language, Class cls, Object query)
          Create a new query from the given data, with the given candidate class and language.
 Query newQuery(String language, Object query)
          Create a new query in the given language.
 void nontransactional(Object pc, OpCallbacks call)
          Make the given object nontransactional.
 void nontransactionalAll(Collection objs, OpCallbacks call)
          Make the given objects nontransactional.
 OpenJPAStateManager persist(Object obj, Object id, OpCallbacks call)
          Make the given instance persistent.
 void persist(Object obj, OpCallbacks call)
          Persist the given object.
 void persistAll(Collection objs, OpCallbacks call)
          Persist the given objects.
 void preFlush()
          Run pre-flush actions on transactional objects, including persistence-by-reachability, inverse relationship management, deletion of dependent instances, and instance callbacks.
 Object putUserObject(Object key, Object val)
          Put the specified key-value pair into the map of user objects.
 void refresh(Object obj, OpCallbacks call)
          Refresh the state of the given object.
 void refreshAll(Collection objs, OpCallbacks call)
          Refresh the state of the given objects.
 void release(Object obj, OpCallbacks call)
          Release the given object from management.
 void releaseAll(Collection objs, OpCallbacks call)
          Release the given objects from management.
 void releaseSavepoint()
          Release the last set savepoint and any resources associated with it.
 void releaseSavepoint(String name)
          Release the savepoint and any resources associated with it.
 void removeLifecycleListener(Object listener)
          Remove a listener for lifecycle-related events.
 void removeTransactionListener(Object listener)
          Remove a listener for transaction-related events.
 void retrieve(Object obj, boolean fgOnly, OpCallbacks call)
          Immediately load the given object's persistent fields.
 void retrieveAll(Collection objs, boolean fgOnly, OpCallbacks call)
          Retrieve the given objects' persistent state.
 void rollback()
          Rollback the current transaction.
 void rollbackAndResume()
          Issue a rollback and then start a new transaction.
 void rollbackToSavepoint()
          Rollback the current transaction to the last savepoint.
 void rollbackToSavepoint(String name)
          Rollback the current transaction to the given savepoint name.
 void setAutoClear(int clear)
          Whether objects clear when entering transactions.
 void setAutoDetach(int flags)
          Bit flags marked in AutoDetach which indicate when persistent managed objects should be automatically detached in-place.
 void setAutoDetach(int flag, boolean on)
          Bit flags marked in AutoDetach which indicate when persistent managed objects should be automatically detached in-place.
 void setDetachedNew(boolean isNew)
          Whether to treat relations to detached instances as new.
 void setDetachState(int mode)
          Detach mode constant to determine which fields are part of the detached graph.
 void setEvictFromDataCache(boolean evict)
          Whether to also evict an object from the store cache when it is evicted through this broker.
 void setIgnoreChanges(boolean ignore)
          Whether to take into account changes in the transaction when executing a query or iterating an extent.
 void setImplicitBehavior(OpCallbacks call, RuntimeExceptionTranslator ex)
          Set the broker's behavior for implicit actions such as flushing, automatic detachment, and exceptions thrown by managed instances outside a broker operation.
 void setLifecycleListenerCallbackMode(int mode)
          The callback mode for handling exceptions from lifecycle event listeners.
 void setMultithreaded(boolean multi)
          Whether the broker or its managed instances are used in a multithreaded environment.
 void setNontransactionalRead(boolean read)
          Whether to allow nontransactional access to persistent state.
 void setNontransactionalWrite(boolean write)
          Whether to allow nontransactional changes to persistent state.
 void setOptimistic(boolean opt)
          Whether to use optimistic transactional semantics.
 void setOrderDirtyObjects(boolean order)
          Whether to maintain the order in which objects are dirtied for StoreContext.getDirtyObjects().
 void setPopulateDataCache(boolean cache)
          Whether to populate the store cache with objects used by this transaction.
 void setRestoreState(int restore)
          Whether to restore an object's original state on rollback.
 void setRetainState(boolean retain)
          Whether objects retain their persistent state on transaction commit.
 void setRollbackOnly()
          Mark the current transaction for rollback.
 void setRollbackOnly(Throwable cause)
          Mark the current transaction for rollback with the specified cause of the rollback.
 void setSavepoint(String name)
          Set a transactional savepoint where operations after this savepoint will be rolled back.
 void setSyncWithManagedTransactions(boolean sync)
          Whether to check for a global transaction upon every managed, non-transactional operation.
 void setTrackChangesByType(boolean largeTransaction)
          If a large number of objects will be created, modified, or deleted during this transaction setting this option to true will reduce memory usage if you perform periodic flushes by tracking changes at the type level instead of the instance level, resulting in more aggressive cache invalidation.
 void setTransactionListenerCallbackMode(int mode)
          The callback mode for handling exceptions from transaction event listeners.
 boolean syncWithManagedTransaction()
          Attempt to synchronize with a current managed transaction, returning true if successful, false if no managed transaction is active.
 void transactional(Object pc, boolean updateVersion, OpCallbacks call)
          Make the given object transactional.
 void transactionalAll(Collection objs, boolean updateVersion, OpCallbacks call)
          Make the given objects transactional.
protected  RuntimeException translate(RuntimeException re)
          Translate the OpenJPA exception.
 void unlock()
          Releases the internal lock.
 void validateChanges()
          Validate the changes made in this transaction, reporting any optimistic violations, constraint violations, etc.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelegatingBroker

public DelegatingBroker(Broker broker)
Constructor; supply delegate.


DelegatingBroker

public DelegatingBroker(Broker broker,
                        RuntimeExceptionTranslator trans)
Constructor; supply delegate and exception translator.

Method Detail

getDelegate

public Broker getDelegate()
Return the direct delegate.


getInnermostDelegate

public Broker getInnermostDelegate()
Return the native delegate.


hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object other)
Overrides:
equals in class Object

translate

protected RuntimeException translate(RuntimeException re)
Translate the OpenJPA exception.


getBroker

public Broker getBroker()
Description copied from interface: StoreContext
Return the broker for this context, if possible. Note that a broker will be unavailable in remote contexts, and this method may throw an exception to that effect.

Specified by:
getBroker in interface StoreContext

getConfiguration

public OpenJPAConfiguration getConfiguration()
Description copied from interface: StoreContext
Return the configuration associated with this context.

Specified by:
getConfiguration in interface StoreContext

getFetchConfiguration

public FetchConfiguration getFetchConfiguration()
Description copied from interface: StoreContext
Return the (mutable) fetch configuration for loading objects from this context.

Specified by:
getFetchConfiguration in interface StoreContext

getClassLoader

public ClassLoader getClassLoader()
Description copied from interface: StoreContext
Return the current thread's class loader at the time this context was obtained.

Specified by:
getClassLoader in interface StoreContext

getLockManager

public LockManager getLockManager()
Description copied from interface: StoreContext
Return the lock manager in use.

Specified by:
getLockManager in interface StoreContext

getStoreManager

public DelegatingStoreManager getStoreManager()
Description copied from interface: StoreContext
Return the store manager in use. This will be a wrapper around the native store manager, which you can retrieve via DelegatingStoreManager.getInnermostDelegate().

Specified by:
getStoreManager in interface StoreContext

getConnectionUserName

public String getConnectionUserName()
Description copied from interface: StoreContext
Return the connection user name.

Specified by:
getConnectionUserName in interface StoreContext

getConnectionPassword

public String getConnectionPassword()
Description copied from interface: StoreContext
Return the connection password.

Specified by:
getConnectionPassword in interface StoreContext

find

public Object find(Object oid,
                   boolean validate,
                   FindCallbacks call)
Description copied from interface: StoreContext
Find the persistence object with the given oid. If validate is true, the broker will check the store for the object, and return null if it does not exist. If validate is false, this method never returns null. The broker will either return its cached instance, attempt to create a hollow instance, or throw an ObjectNotFoundException if unable to return a hollow instance.

Specified by:
find in interface StoreContext
validate - if true, validate that the instance exists in the store and load fetch group fields, otherwise return any cached or hollow instance

findAll

public Object[] findAll(Collection oids,
                        boolean validate,
                        FindCallbacks call)
Description copied from interface: StoreContext
Return the objects with the given oids.

Specified by:
findAll in interface StoreContext
Parameters:
oids - the oids of the objects to return
Returns:
the objects that were looked up, in the same order as the oids parameter
See Also:
StoreContext.find(Object,boolean,FindCallbacks)

findCached

public Object findCached(Object oid,
                         FindCallbacks call)
Description copied from interface: StoreContext
Return the cached instance for the given oid/object, or null if not cached.

Specified by:
findCached in interface StoreContext
Parameters:
oid - the object's id
Returns:
the cached object, or null if not cached

find

public Object find(Object oid,
                   FetchConfiguration fetch,
                   BitSet exclude,
                   Object edata,
                   int flags)
Description copied from interface: StoreContext
Return the object with the given oid. If present, the cached instance will be returned. Otherwise, the instance will be initialized through the store as usual; however, in this case the store will be passed the given execution data, and the system will load the object according to the given fetch configuratiion (or the context's configuration, if the given one is null). Fields can optionally be excluded from required loading using the exclude mask. By default this method does not find new unflushed instances, validates, and does not throw an exception if a cached instance has been deleted concurrently. These options are controllable through the given OID_XXX flags.

Specified by:
find in interface StoreContext

findAll

public Object[] findAll(Collection oids,
                        FetchConfiguration fetch,
                        BitSet exclude,
                        Object edata,
                        int flags)
Description copied from interface: StoreContext
Return the objects with the given oids.

Specified by:
findAll in interface StoreContext
See Also:
StoreContext.find(Object,FetchConfiguration,BitSet,Object,int)

extentIterator

public Iterator extentIterator(Class cls,
                               boolean subs,
                               FetchConfiguration fetch,
                               boolean ignoreChanges)
Description copied from interface: StoreContext
Return an iterator over all instances of the given type. The iterator should be closed with ImplHelper.close(java.lang.Object) when no longer needed. This method delegates to StoreManager.executeExtent(org.apache.openjpa.meta.ClassMetaData, boolean, org.apache.openjpa.kernel.FetchConfiguration).

Specified by:
extentIterator in interface StoreContext

retrieve

public void retrieve(Object obj,
                     boolean fgOnly,
                     OpCallbacks call)
Description copied from interface: StoreContext
Immediately load the given object's persistent fields. One might use this action to make sure that an instance's fields are loaded before transitioning it to transient. Note that this action is not recursive. Any related objects that are loaded will not necessarily have their fields loaded. Unmanaged target is ignored.

Specified by:
retrieve in interface StoreContext
fgOnly - indicator as to whether to retrieve only fields in the current fetch groups, or all fields
See Also:
StoreContext.retrieve(java.lang.Object, boolean, org.apache.openjpa.kernel.OpCallbacks)

retrieveAll

public void retrieveAll(Collection objs,
                        boolean fgOnly,
                        OpCallbacks call)
Description copied from interface: StoreContext
Retrieve the given objects' persistent state. Unmanaged targets are ignored.

Specified by:
retrieveAll in interface StoreContext
fgOnly - indicator as to whether to retrieve only fields
See Also:
StoreContext.retrieve(java.lang.Object, boolean, org.apache.openjpa.kernel.OpCallbacks)

embed

public OpenJPAStateManager embed(Object obj,
                                 Object id,
                                 OpenJPAStateManager owner,
                                 ValueMetaData ownerMeta)
Description copied from interface: StoreContext
Make the given instance embedded.

Specified by:
embed in interface StoreContext
Parameters:
obj - the instance to embed; may be null to create a new instance
id - the id to give the embedded state manager; may be null for default
owner - the owning state manager
ownerMeta - the value in which the object is embedded
Returns:
the state manager for the embedded instance

getObjectIdType

public Class getObjectIdType(Class cls)
Description copied from interface: StoreContext
Return the application or datastore identity class the given persistent class uses for object ids.

Specified by:
getObjectIdType in interface StoreContext

newObjectId

public Object newObjectId(Class cls,
                          Object val)
Description copied from interface: StoreContext
Create a new object id instance from the given value.

Specified by:
newObjectId in interface StoreContext
Parameters:
cls - the persitent class that uses this identity value
val - an object id instance, stringified object id, or primary key value

getManagedObjects

public Collection getManagedObjects()
Description copied from interface: StoreContext
Return a list of all managed instances.

Specified by:
getManagedObjects in interface StoreContext

getTransactionalObjects

public Collection getTransactionalObjects()
Description copied from interface: StoreContext
Return a list of current transaction instances.

Specified by:
getTransactionalObjects in interface StoreContext

getPendingTransactionalObjects

public Collection getPendingTransactionalObjects()
Description copied from interface: StoreContext
Return a list of instances which will become transactional upon the next transaction.

Specified by:
getPendingTransactionalObjects in interface StoreContext

getDirtyObjects

public Collection getDirtyObjects()
Description copied from interface: StoreContext
Return a list of current dirty instances.

Specified by:
getDirtyObjects in interface StoreContext

getOrderDirtyObjects

public boolean getOrderDirtyObjects()
Description copied from interface: StoreContext
Whether to maintain the order in which objects are dirtied for StoreContext.getDirtyObjects(). Default is the store manager's decision.

Specified by:
getOrderDirtyObjects in interface StoreContext

setOrderDirtyObjects

public void setOrderDirtyObjects(boolean order)
Description copied from interface: StoreContext
Whether to maintain the order in which objects are dirtied for StoreContext.getDirtyObjects(). Default is the store manager's decision.

Specified by:
setOrderDirtyObjects in interface StoreContext

getPersistedTypes

public Collection getPersistedTypes()
Description copied from interface: StoreContext
Return the set of classes that have been made persistent in the current transaction.

Specified by:
getPersistedTypes in interface StoreContext

getUpdatedTypes

public Collection getUpdatedTypes()
Description copied from interface: StoreContext
Return the set of classes for objects that have been modified in the current transaction.

Specified by:
getUpdatedTypes in interface StoreContext

getDeletedTypes

public Collection getDeletedTypes()
Description copied from interface: StoreContext
Return the set of classes that have been deleted in the current transaction.

Specified by:
getDeletedTypes in interface StoreContext

getStateManager

public OpenJPAStateManager getStateManager(Object obj)
Description copied from interface: StoreContext
Return the state manager for the given instance. Includes objects made persistent in the current transaction. If obj is not a managed type or is managed by another context, throw an exception.

Specified by:
getStateManager in interface StoreContext

getLockLevel

public int getLockLevel(Object obj)
Description copied from interface: StoreContext
Return the lock level of the specified object.

Specified by:
getLockLevel in interface StoreContext

getVersion

public Object getVersion(Object obj)
Description copied from interface: StoreContext
Returns the current version indicator for o.

Specified by:
getVersion in interface StoreContext

isDirty

public boolean isDirty(Object obj)
Description copied from interface: StoreContext
Return whether the given object is dirty.

Specified by:
isDirty in interface StoreContext

isTransactional

public boolean isTransactional(Object obj)
Description copied from interface: StoreContext
Return whether the given object is transactional.

Specified by:
isTransactional in interface StoreContext

isPersistent

public boolean isPersistent(Object obj)
Description copied from interface: StoreContext
Return whether the given object is persistent.

Specified by:
isPersistent in interface StoreContext

isNew

public boolean isNew(Object obj)
Description copied from interface: StoreContext
Return whether the given object is a newly-created instance registered with broker.

Specified by:
isNew in interface StoreContext

isDeleted

public boolean isDeleted(Object obj)
Description copied from interface: StoreContext
Return whether the given object is deleted.

Specified by:
isDeleted in interface StoreContext

getObjectId

public Object getObjectId(Object obj)
Description copied from interface: StoreContext
Return the oid of the given instance.

Specified by:
getObjectId in interface StoreContext

isManaged

public boolean isManaged()
Description copied from interface: StoreContext
Whether this context is using managed transactions.

Specified by:
isManaged in interface StoreContext

isActive

public boolean isActive()
Description copied from interface: StoreContext
Whether a logical transaction is active.

Specified by:
isActive in interface StoreContext

isStoreActive

public boolean isStoreActive()
Description copied from interface: StoreContext
Whether a data store transaction is active.

Specified by:
isStoreActive in interface StoreContext

hasConnection

public boolean hasConnection()
Description copied from interface: StoreContext
Whether the broker has a dedicated connection based on the configured connection retain mode and transaction status.

Specified by:
hasConnection in interface StoreContext

getConnection

public Object getConnection()
Description copied from interface: StoreContext
Return the connection in use by the context, or a new connection if none.

Specified by:
getConnection in interface StoreContext

lock

public void lock()
Description copied from interface: StoreContext
Synchronizes on an internal lock if the Multithreaded flag is set to true. Make sure to call StoreContext.unlock() in a finally clause of the same method.

Specified by:
lock in interface StoreContext

unlock

public void unlock()
Description copied from interface: StoreContext
Releases the internal lock.

Specified by:
unlock in interface StoreContext

beginOperation

public boolean beginOperation(boolean read)
Description copied from interface: Broker
Begin a logical operation. This indicates to the broker the granularity of an operation which may require pre/post operation side-effects, such as non-tx detach. Will lock the broker until the Broker.endOperation() is called.

Specified by:
beginOperation in interface Broker
Parameters:
read - whether instances may be loaded/modified during this operation requiring a re-check of global tx
Returns:
whether this is the outermost operation on the stack

endOperation

public boolean endOperation()
Description copied from interface: Broker
End a logical operation. This indicates to the broker the granularity of an operation which may require pre/post operation side-effects, such as non-tx detach. Unlocks the given broker.

Specified by:
endOperation in interface Broker
Returns:
whether this is the outermost operation on the stack

setImplicitBehavior

public void setImplicitBehavior(OpCallbacks call,
                                RuntimeExceptionTranslator ex)
Description copied from interface: Broker
Set the broker's behavior for implicit actions such as flushing, automatic detachment, and exceptions thrown by managed instances outside a broker operation. A broker's implicit behavior can only be set once; after the first invocation with non-null arguments, subsequent invocations of this method are ignored.

Specified by:
setImplicitBehavior in interface Broker

getBrokerFactory

public BrokerFactory getBrokerFactory()
Description copied from interface: Broker
Return the factory that produced this broker.

Specified by:
getBrokerFactory in interface Broker

getConnectionRetainMode

public int getConnectionRetainMode()
Description copied from interface: Broker
Return the connection retain mode for this broker.

Specified by:
getConnectionRetainMode in interface Broker

getManagedRuntime

public ManagedRuntime getManagedRuntime()
Description copied from interface: Broker
Return the managed runtime in use.

Specified by:
getManagedRuntime in interface Broker

getInverseManager

public InverseManager getInverseManager()
Description copied from interface: Broker
Return the inverse manager in use.

Specified by:
getInverseManager in interface Broker

getMultithreaded

public boolean getMultithreaded()
Description copied from interface: Broker
Whether the broker or its managed instances are used in a multithreaded environment.

Specified by:
getMultithreaded in interface Broker

setMultithreaded

public void setMultithreaded(boolean multi)
Description copied from interface: Broker
Whether the broker or its managed instances are used in a multithreaded environment.

Specified by:
setMultithreaded in interface Broker

getIgnoreChanges

public boolean getIgnoreChanges()
Description copied from interface: Broker
Whether to take into account changes in the transaction when executing a query or iterating an extent.

Specified by:
getIgnoreChanges in interface Broker

setIgnoreChanges

public void setIgnoreChanges(boolean ignore)
Description copied from interface: Broker
Whether to take into account changes in the transaction when executing a query or iterating an extent.

Specified by:
setIgnoreChanges in interface Broker

getNontransactionalRead

public boolean getNontransactionalRead()
Description copied from interface: Broker
Whether to allow nontransactional access to persistent state.

Specified by:
getNontransactionalRead in interface Broker

setNontransactionalRead

public void setNontransactionalRead(boolean read)
Description copied from interface: Broker
Whether to allow nontransactional access to persistent state.

Specified by:
setNontransactionalRead in interface Broker

getNontransactionalWrite

public boolean getNontransactionalWrite()
Description copied from interface: Broker
Whether to allow nontransactional changes to persistent state.

Specified by:
getNontransactionalWrite in interface Broker

setNontransactionalWrite

public void setNontransactionalWrite(boolean write)
Description copied from interface: Broker
Whether to allow nontransactional changes to persistent state.

Specified by:
setNontransactionalWrite in interface Broker

getRestoreState

public int getRestoreState()
Description copied from interface: Broker
Whether to restore an object's original state on rollback.

Specified by:
getRestoreState in interface Broker

setRestoreState

public void setRestoreState(int restore)
Description copied from interface: Broker
Whether to restore an object's original state on rollback.

Specified by:
setRestoreState in interface Broker

getOptimistic

public boolean getOptimistic()
Description copied from interface: Broker
Whether to use optimistic transactional semantics.

Specified by:
getOptimistic in interface Broker

setOptimistic

public void setOptimistic(boolean opt)
Description copied from interface: Broker
Whether to use optimistic transactional semantics.

Specified by:
setOptimistic in interface Broker

getRetainState

public boolean getRetainState()
Description copied from interface: Broker
Whether objects retain their persistent state on transaction commit.

Specified by:
getRetainState in interface Broker

setRetainState

public void setRetainState(boolean retain)
Description copied from interface: Broker
Whether objects retain their persistent state on transaction commit.

Specified by:
setRetainState in interface Broker

getAutoClear

public int getAutoClear()
Description copied from interface: Broker
Whether objects clear when entering transactions.

Specified by:
getAutoClear in interface Broker

setAutoClear

public void setAutoClear(int clear)
Description copied from interface: Broker
Whether objects clear when entering transactions.

Specified by:
setAutoClear in interface Broker

getAutoDetach

public int getAutoDetach()
Description copied from interface: Broker
Bit flags marked in AutoDetach which indicate when persistent managed objects should be automatically detached in-place.

Specified by:
getAutoDetach in interface Broker

setAutoDetach

public void setAutoDetach(int flags)
Description copied from interface: Broker
Bit flags marked in AutoDetach which indicate when persistent managed objects should be automatically detached in-place.

Specified by:
setAutoDetach in interface Broker

setAutoDetach

public void setAutoDetach(int flag,
                          boolean on)
Description copied from interface: Broker
Bit flags marked in AutoDetach which indicate when persistent managed objects should be automatically detached in-place.

Specified by:
setAutoDetach in interface Broker

getDetachState

public int getDetachState()
Description copied from interface: StoreContext
Detach mode constant to determine which fields are part of the detached graph. Defaults to DetachState.DETACH_LOADED.

Specified by:
getDetachState in interface StoreContext

setDetachState

public void setDetachState(int mode)
Description copied from interface: StoreContext
Detach mode constant to determine which fields are part of the detached graph. Defaults to DetachState.DETACH_LOADED.

Specified by:
setDetachState in interface StoreContext

isDetachedNew

public boolean isDetachedNew()
Description copied from interface: Broker
Whether to treat relations to detached instances during persist operations as new or as pseudo-hollow instances.

Specified by:
isDetachedNew in interface Broker

setDetachedNew

public void setDetachedNew(boolean isNew)
Description copied from interface: Broker
Whether to treat relations to detached instances as new.

Specified by:
setDetachedNew in interface Broker

getSyncWithManagedTransactions

public boolean getSyncWithManagedTransactions()
Description copied from interface: Broker
Whether to check for a global transaction upon every managed, non-transactional operation. Defaults to false.

Specified by:
getSyncWithManagedTransactions in interface Broker

setSyncWithManagedTransactions

public void setSyncWithManagedTransactions(boolean sync)
Description copied from interface: Broker
Whether to check for a global transaction upon every managed, non-transactional operation. Defaults to false.

Specified by:
setSyncWithManagedTransactions in interface Broker

getEvictFromDataCache

public boolean getEvictFromDataCache()
Description copied from interface: Broker
Whether to also evict an object from the store cache when it is evicted through this broker.

Specified by:
getEvictFromDataCache in interface Broker

setEvictFromDataCache

public void setEvictFromDataCache(boolean evict)
Description copied from interface: Broker
Whether to also evict an object from the store cache when it is evicted through this broker.

Specified by:
setEvictFromDataCache in interface Broker

getPopulateDataCache

public boolean getPopulateDataCache()
Description copied from interface: StoreContext
Whether objects accessed during this transaction will be added to the store cache. Defaults to true.

Specified by:
getPopulateDataCache in interface StoreContext

setPopulateDataCache

public void setPopulateDataCache(boolean cache)
Description copied from interface: StoreContext
Whether to populate the store cache with objects used by this transaction. Defaults to true.

Specified by:
setPopulateDataCache in interface StoreContext

isTrackChangesByType

public boolean isTrackChangesByType()
Description copied from interface: StoreContext
Whether memory usage is reduced during this transaction at the expense of tracking changes at the type level instead of the instance level, resulting in more aggressive cache invalidation.

Specified by:
isTrackChangesByType in interface StoreContext

setTrackChangesByType

public void setTrackChangesByType(boolean largeTransaction)
Description copied from interface: StoreContext
If a large number of objects will be created, modified, or deleted during this transaction setting this option to true will reduce memory usage if you perform periodic flushes by tracking changes at the type level instead of the instance level, resulting in more aggressive cache invalidation. Upon transaction commit the data cache will have to more aggressively flush objects. The store cache will have to flush instances of objects for each class of object modified during the transaction. A side benefit of large transaction mode is that smaller update messages can be used for RemoteCommitEvents. Defaults to false.

Specified by:
setTrackChangesByType in interface StoreContext

putUserObject

public Object putUserObject(Object key,
                            Object val)
Description copied from interface: Broker
Put the specified key-value pair into the map of user objects. Use a value of null to remove the key.

Specified by:
putUserObject in interface Broker

getUserObject

public Object getUserObject(Object key)
Description copied from interface: Broker
Get the value for the specified key from the map of user objects.

Specified by:
getUserObject in interface Broker

addTransactionListener

public void addTransactionListener(Object listener)
Description copied from interface: Broker
Register a listener for transaction-related events.

Specified by:
addTransactionListener in interface Broker

removeTransactionListener

public void removeTransactionListener(Object listener)
Description copied from interface: Broker
Remove a listener for transaction-related events.

Specified by:
removeTransactionListener in interface Broker

getTransactionListenerCallbackMode

public int getTransactionListenerCallbackMode()
Description copied from interface: Broker
The callback mode for handling exceptions from transaction event listeners.

Specified by:
getTransactionListenerCallbackMode in interface Broker

setTransactionListenerCallbackMode

public void setTransactionListenerCallbackMode(int mode)
Description copied from interface: Broker
The callback mode for handling exceptions from transaction event listeners.

Specified by:
setTransactionListenerCallbackMode in interface Broker

addLifecycleListener

public void addLifecycleListener(Object listener,
                                 Class[] classes)
Description copied from interface: Broker
Register a listener for lifecycle-related events on the specified classes. If the classes are null, all events will be propagated to the listener.

Specified by:
addLifecycleListener in interface Broker

removeLifecycleListener

public void removeLifecycleListener(Object listener)
Description copied from interface: Broker
Remove a listener for lifecycle-related events.

Specified by:
removeLifecycleListener in interface Broker

getLifecycleListenerCallbackMode

public int getLifecycleListenerCallbackMode()
Description copied from interface: Broker
The callback mode for handling exceptions from lifecycle event listeners.

Specified by:
getLifecycleListenerCallbackMode in interface Broker

setLifecycleListenerCallbackMode

public void setLifecycleListenerCallbackMode(int mode)
Description copied from interface: Broker
The callback mode for handling exceptions from lifecycle event listeners.

Specified by:
setLifecycleListenerCallbackMode in interface Broker

getLifecycleEventManager

public LifecycleEventManager getLifecycleEventManager()
Description copied from interface: Broker
Return the lifecycle event manager associated with the broker.

Specified by:
getLifecycleEventManager in interface Broker

begin

public void begin()
Description copied from interface: Broker
Begin a transaction.

Specified by:
begin in interface Broker

commit

public void commit()
Description copied from interface: Broker
Commit the current transaction.

Specified by:
commit in interface Broker

rollback

public void rollback()
Description copied from interface: Broker
Rollback the current transaction.

Specified by:
rollback in interface Broker

syncWithManagedTransaction

public boolean syncWithManagedTransaction()
Description copied from interface: Broker
Attempt to synchronize with a current managed transaction, returning true if successful, false if no managed transaction is active.

Specified by:
syncWithManagedTransaction in interface Broker

commitAndResume

public void commitAndResume()
Description copied from interface: Broker
Issue a commit and then start a new transaction. This is identical to:
 broker.commit (); broker.begin ();
 
except that the broker's internal atomic lock is utilized, so this method can be safely executed from multiple threads.

Specified by:
commitAndResume in interface Broker
See Also:
Broker.commit(), Broker.begin()

rollbackAndResume

public void rollbackAndResume()
Description copied from interface: Broker
Issue a rollback and then start a new transaction. This is identical to:
 broker.rollback (); broker.begin ();
 
except that the broker's internal atomic lock is utilized, so this method can be safely executed from multiple threads.

Specified by:
rollbackAndResume in interface Broker
See Also:
Broker.rollback(), Broker.begin()

setRollbackOnly

public void setRollbackOnly()
Description copied from interface: Broker
Mark the current transaction for rollback.

Specified by:
setRollbackOnly in interface Broker

setRollbackOnly

public void setRollbackOnly(Throwable cause)
Description copied from interface: Broker
Mark the current transaction for rollback with the specified cause of the rollback.

Specified by:
setRollbackOnly in interface Broker

getRollbackCause

public Throwable getRollbackCause()
Description copied from interface: Broker
Returns the Throwable that caused the transaction to be marked for rollback.

Specified by:
getRollbackCause in interface Broker
Returns:
the Throwable, or null if none was given

getRollbackOnly

public boolean getRollbackOnly()
Description copied from interface: Broker
Return whether the current transaction has been marked for rollback.

Specified by:
getRollbackOnly in interface Broker

setSavepoint

public void setSavepoint(String name)
Description copied from interface: Broker
Set a transactional savepoint where operations after this savepoint will be rolled back.

Specified by:
setSavepoint in interface Broker

rollbackToSavepoint

public void rollbackToSavepoint()
Description copied from interface: Broker
Rollback the current transaction to the last savepoint. Savepoints set after this one will become invalid.

Specified by:
rollbackToSavepoint in interface Broker

rollbackToSavepoint

public void rollbackToSavepoint(String name)
Description copied from interface: Broker
Rollback the current transaction to the given savepoint name. Savepoints set after this one will become invalid.

Specified by:
rollbackToSavepoint in interface Broker

releaseSavepoint

public void releaseSavepoint()
Description copied from interface: Broker
Release the last set savepoint and any resources associated with it. The given savepoint and any set after it will become invalid.

Specified by:
releaseSavepoint in interface Broker

releaseSavepoint

public void releaseSavepoint(String name)
Description copied from interface: Broker
Release the savepoint and any resources associated with it. The given savepoint and any set after it will become invalid.

Specified by:
releaseSavepoint in interface Broker

flush

public void flush()
Description copied from interface: Broker
Flush all transactional instances to the data store. This method may set the rollback only flag on the current transaction if it encounters an error.

Specified by:
flush in interface Broker

preFlush

public void preFlush()
Description copied from interface: Broker
Run pre-flush actions on transactional objects, including persistence-by-reachability, inverse relationship management, deletion of dependent instances, and instance callbacks. Transaction listeners are not invoked.

Specified by:
preFlush in interface Broker

validateChanges

public void validateChanges()
Description copied from interface: Broker
Validate the changes made in this transaction, reporting any optimistic violations, constraint violations, etc. In a datastore transaction or a flushed optimistic transaction, this method will act just like Broker.flush(). In an optimistic transaction that has not yet begun a datastore-level transaction, however, it will only report exceptions that would occur on flush, without retaining any datastore resources.

Specified by:
validateChanges in interface Broker

beginStore

public void beginStore()
Description copied from interface: StoreContext
Begin a data store transaction.

Specified by:
beginStore in interface StoreContext

persist

public void persist(Object obj,
                    OpCallbacks call)
Description copied from interface: Broker
Persist the given object.

Specified by:
persist in interface Broker

persistAll

public void persistAll(Collection objs,
                       OpCallbacks call)
Description copied from interface: Broker
Persist the given objects.

Specified by:
persistAll in interface Broker

persist

public OpenJPAStateManager persist(Object obj,
                                   Object id,
                                   OpCallbacks call)
Description copied from interface: Broker
Make the given instance persistent. Unlike other persist operations, this method does not immediately cascade to fields marked ValueMetaData.CASCADE_IMMEDIATE.

Specified by:
persist in interface Broker
Parameters:
obj - the instance to persist
id - the id to give the state manager; may be null for default
Returns:
the state manager for the newly persistent instance

delete

public void delete(Object obj,
                   OpCallbacks call)
Description copied from interface: Broker
Delete the given object.

Specified by:
delete in interface Broker

deleteAll

public void deleteAll(Collection objs,
                      OpCallbacks call)
Description copied from interface: Broker
Delete the given objects.

Specified by:
deleteAll in interface Broker

release

public void release(Object obj,
                    OpCallbacks call)
Description copied from interface: Broker
Release the given object from management. This operation is not recursive.

Specified by:
release in interface Broker

releaseAll

public void releaseAll(Collection objs,
                       OpCallbacks call)
Description copied from interface: Broker
Release the given objects from management. This operation is not recursive.

Specified by:
releaseAll in interface Broker

refresh

public void refresh(Object obj,
                    OpCallbacks call)
Description copied from interface: Broker
Refresh the state of the given object.

Specified by:
refresh in interface Broker

refreshAll

public void refreshAll(Collection objs,
                       OpCallbacks call)
Description copied from interface: Broker
Refresh the state of the given objects.

Specified by:
refreshAll in interface Broker

evict

public void evict(Object obj,
                  OpCallbacks call)
Description copied from interface: Broker
Evict the given object.

Specified by:
evict in interface Broker

evictAll

public void evictAll(Collection objs,
                     OpCallbacks call)
Description copied from interface: Broker
Evict the given objects.

Specified by:
evictAll in interface Broker

evictAll

public void evictAll(OpCallbacks call)
Description copied from interface: Broker
Evict all clean objects.

Specified by:
evictAll in interface Broker

evictAll

public void evictAll(Extent extent,
                     OpCallbacks call)
Description copied from interface: Broker
Evict all persistent-clean and persistent-nontransactional instances in the given Extent.

Specified by:
evictAll in interface Broker

detach

public Object detach(Object obj,
                     OpCallbacks call)
Description copied from interface: Broker
Detach the specified object from the broker.

Specified by:
detach in interface Broker
Parameters:
obj - the instance to detach
Returns:
the detached instance

detachAll

public Object[] detachAll(Collection objs,
                          OpCallbacks call)
Description copied from interface: Broker
Detach the specified objects from the broker. The objects returned can be manipulated and re-attached with Broker.attachAll(java.util.Collection, boolean, org.apache.openjpa.kernel.OpCallbacks). The detached instances will be unmanaged copies of the specified parameters, and are suitable for serialization and manipulation outside of a OpenJPA environment. When detaching instances, only fields in the current FetchConfiguration will be traversed. Thus, to detach a graph of objects, relations to other persistent instances must either be in the default-fetch-group, or in the current custom FetchConfiguration.

Specified by:
detachAll in interface Broker
Parameters:
objs - the instances to detach
Returns:
the detached instances

detachAll

public void detachAll(OpCallbacks call)
Description copied from interface: Broker
Detach all objects in place. A flush will be performed before detaching the entities.

Specified by:
detachAll in interface Broker

detachAll

public void detachAll(OpCallbacks call,
                      boolean flush)
Description copied from interface: Broker
Detach all objects in place, with the option of performing a flush before doing the detachment.

Specified by:
detachAll in interface Broker
Parameters:
call - Persistence operation callbacks
flush - boolean value to indicate whether to perform a flush before detaching the entities (true, do the flush; false, don't do the flush)

attach

public Object attach(Object obj,
                     boolean copyNew,
                     OpCallbacks call)
Description copied from interface: Broker
Import the specified detached object into the broker.

Specified by:
attach in interface Broker
Parameters:
obj - instance to import
copyNew - whether to copy new instances
Returns:
the re-attached instance

attachAll

public Object[] attachAll(Collection objs,
                          boolean copyNew,
                          OpCallbacks call)
Description copied from interface: Broker
Import the specified objects into the broker. Instances that were previously detached from this or another broker will have their changed merged into the persistent instances. Instances that are new will be persisted as new instances.

Specified by:
attachAll in interface Broker
Parameters:
objs - array of instances to import
copyNew - whether to copy new instances
Returns:
the re-attached instances

transactional

public void transactional(Object pc,
                          boolean updateVersion,
                          OpCallbacks call)
Description copied from interface: StoreContext
Make the given object transactional.

Specified by:
transactional in interface StoreContext
Parameters:
pc - instance to make transactional
updateVersion - if true, the instance's version will be incremented at the next flush

transactionalAll

public void transactionalAll(Collection objs,
                             boolean updateVersion,
                             OpCallbacks call)
Description copied from interface: StoreContext
Make the given objects transactional.

Specified by:
transactionalAll in interface StoreContext
Parameters:
objs - instances to make transactional
updateVersion - if true, the instance's version will be incremented at the next flush

nontransactional

public void nontransactional(Object pc,
                             OpCallbacks call)
Description copied from interface: StoreContext
Make the given object nontransactional.

Specified by:
nontransactional in interface StoreContext

nontransactionalAll

public void nontransactionalAll(Collection objs,
                                OpCallbacks call)
Description copied from interface: StoreContext
Make the given objects nontransactional.

Specified by:
nontransactionalAll in interface StoreContext

newExtent

public Extent newExtent(Class cls,
                        boolean subs)
Description copied from interface: Broker
Return an extent of the given class, optionally including subclasses.

Specified by:
newExtent in interface Broker

newQuery

public Query newQuery(String language,
                      Class cls,
                      Object query)
Description copied from interface: Broker
Create a new query from the given data, with the given candidate class and language.

Specified by:
newQuery in interface Broker

newQuery

public Query newQuery(String language,
                      Object query)
Description copied from interface: Broker
Create a new query in the given language.

Specified by:
newQuery in interface Broker

getIdentitySequence

public Seq getIdentitySequence(ClassMetaData meta)
Description copied from interface: Broker
Returns a Seq for the datastore identity values of the specified persistent class, or null if the class' identity cannot be represented as a sequence.

Specified by:
getIdentitySequence in interface Broker

getValueSequence

public Seq getValueSequence(FieldMetaData fmd)
Description copied from interface: Broker
Returns a Seq for the generated values of the specified field, or null if the field is not generated.

Specified by:
getValueSequence in interface Broker

lock

public void lock(Object obj,
                 int level,
                 int timeout,
                 OpCallbacks call)
Description copied from interface: Broker
Ensure that the given instance is locked at the given lock level.

Specified by:
lock in interface Broker
Parameters:
obj - the object to lock
level - the lock level to use
timeout - the number of milliseconds to wait for the lock before giving up, or -1 for no limit

lock

public void lock(Object obj,
                 OpCallbacks call)
Description copied from interface: Broker
Ensure that the given instance is locked at the current lock level, as set in the FetchConfiguration for the broker.

Specified by:
lock in interface Broker

lockAll

public void lockAll(Collection objs,
                    int level,
                    int timeout,
                    OpCallbacks call)
Description copied from interface: Broker
Ensure that the given instances are locked at the given lock level.

Specified by:
lockAll in interface Broker
Parameters:
objs - the objects to lock
level - the lock level to use
timeout - the number of milliseconds to wait for the lock before giving up, or -1 for no limit

lockAll

public void lockAll(Collection objs,
                    OpCallbacks call)
Description copied from interface: Broker
Ensure that the given instances are locked at the current lock level, as set in the FetchConfiguration for the broker.

Specified by:
lockAll in interface Broker

cancelAll

public boolean cancelAll()
Description copied from interface: Broker
Cancel all pending data store statements. If statements are cancelled while a flush is in progress, the transaction rollback only flag will be set.

Specified by:
cancelAll in interface Broker
Returns:
true if any statements were cancelled, false otherwise

dirtyType

public void dirtyType(Class cls)
Description copied from interface: Broker
Mark the given class as dirty within the current transaction.

Specified by:
dirtyType in interface Broker

close

public void close()
Description copied from interface: Broker
Close the broker.

Specified by:
close in interface Broker
Specified by:
close in interface Closeable

isClosed

public boolean isClosed()
Description copied from interface: Broker
Whether the broker is closed.

Specified by:
isClosed in interface Broker

isCloseInvoked

public boolean isCloseInvoked()
Description copied from interface: Broker
Whether Broker.close() has been invoked, though the broker might remain open until the current managed transaction completes.

Specified by:
isCloseInvoked in interface Broker

assertOpen

public void assertOpen()
Description copied from interface: Broker
Throw an exception if this broker has been closed.

Specified by:
assertOpen in interface Broker

assertActiveTransaction

public void assertActiveTransaction()
Description copied from interface: Broker
Throw an exception if there is no active transaction.

Specified by:
assertActiveTransaction in interface Broker

assertNontransactionalRead

public void assertNontransactionalRead()
Description copied from interface: Broker
Throw an exception if there is no transaction active and nontransactional reading is not enabled.

Specified by:
assertNontransactionalRead in interface Broker

assertWriteOperation

public void assertWriteOperation()
Description copied from interface: Broker
Throw an exception if a write operation is not permitted (there is no active transaction and nontransactional writing is not enabled).

Specified by:
assertWriteOperation in interface Broker

beforeCompletion

public void beforeCompletion()

afterCompletion

public void afterCompletion(int status)

newInstance

public Object newInstance(Class cls)
Description copied from interface: Broker
Create a new instance of type cls. If cls is an interface or an abstract class whose abstract methods follow the JavaBeans convention, this method will create a concrete implementation according to the metadata that defines the class. Otherwise, this will return an instance of the specified class.

Specified by:
newInstance in interface Broker

isDetached

public boolean isDetached(Object obj)
Description copied from interface: Broker
Returns true if obj is a detached object (one that can be reattached to a Broker via a call to Broker.attach(java.lang.Object, boolean, org.apache.openjpa.kernel.OpCallbacks)); otherwise returns false.

Specified by:
isDetached in interface Broker


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