public interface Broker extends Synchronization, Closeable, StoreContext, ConnectionRetainModes, DetachState, LockLevels, RestoreState, AutoClear, AutoDetach, CallbackModes
EXCLUDE_ALL, OID_ALLOW_NEW, OID_COPY, OID_NODELETED, OID_NOVALIDATE
CONN_RETAIN_ALWAYS, CONN_RETAIN_DEMAND, CONN_RETAIN_TRANS
DETACH_ALL, DETACH_FETCH_GROUPS, DETACH_FGS, DETACH_LOADED
LOCK_NONE, LOCK_READ, LOCK_WRITE
RESTORE_ALL, RESTORE_IMMUTABLE, RESTORE_NONE
CLEAR_ALL, CLEAR_DATASTORE
DETACH_CLOSE, DETACH_COMMIT, DETACH_NONE, DETACH_NONTXREAD, DETACH_ROLLBACK, names, values
CALLBACK_FAIL_FAST, CALLBACK_IGNORE, CALLBACK_LOG, CALLBACK_RETHROW, CALLBACK_ROLLBACK
Modifier and Type | Method and Description |
---|---|
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 |
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 pc,
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 |
begin()
Begin a transaction.
|
boolean |
beginOperation(boolean syncTrans)
Begin a logical operation.
|
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 pc,
OpCallbacks call)
Delete the given object.
|
void |
deleteAll(Collection objs,
OpCallbacks call)
Delete the given objects.
|
Object |
detach(Object pc,
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.
|
boolean |
endOperation()
End a logical operation.
|
void |
evict(Object pc,
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.
|
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. |
BrokerFactory |
getBrokerFactory()
Return the factory that produced this broker.
|
boolean |
getCachePreparedQuery()
Affirms if this receiver is caching prepared queries.
|
int |
getConnectionRetainMode()
Return the connection retain mode for this broker.
|
boolean |
getEvictFromDataCache()
Whether to also evict an object from the store cache when it is
evicted through this broker.
|
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.
|
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.
|
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.
|
boolean |
getOptimistic()
Whether to use optimistic transactional semantics.
|
Map<String,Object> |
getProperties()
Retrieve the current properties for this broker Some of these properties
may have been changed from the original configuration.
|
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.
|
Set<String> |
getSupportedProperties()
Return the supported properties for this broker as property keys.
|
boolean |
getSyncWithManagedTransactions()
Whether to check for a global transaction upon every managed,
non-transactional operation.
|
int |
getTransactionListenerCallbackMode()
The callback mode for handling exceptions from transaction event
listeners.
|
Collection<Object> |
getTransactionListeners()
Gets an umodifiable collection of currently registered lsteners.
|
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. |
boolean |
isClosed()
Whether the broker is closed.
|
boolean |
isCloseInvoked()
Whether
close() has been invoked, though the broker might
remain open until the current managed transaction completes. |
boolean |
isDetached(Object obj)
Returns
true if obj is a detached object
(one that can be reattached to a Broker via a call to
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.
|
void |
lock(Object pc,
int level,
int timeout,
OpCallbacks call)
Ensure that the given instance is locked at the given lock level.
|
void |
lock(Object pc,
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 . |
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.
|
OpenJPAStateManager |
persist(Object pc,
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 pc,
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 pc,
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 |
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 |
setCachePreparedQuery(boolean flag)
Sets whether this receiver will cache prepared queries during its
lifetime.
|
void |
setDetachedNew(boolean isNew)
Whether to treat relations to detached instances as new.
|
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 |
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 resync)
Whether to check for a global transaction upon every managed,
non-transactional operation.
|
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 |
validateChanges()
Validate the changes made in this transaction, reporting any optimistic
violations, constraint violations, etc.
|
afterCompletion, beforeCompletion
beginStore, embed, extentIterator, find, find, findAll, findAll, findCached, getAllowReferenceToSiblingContext, getBroker, getClassLoader, getConfiguration, getConnection, getConnectionFactory, getConnectionFactory2, getConnectionFactory2Name, getConnectionFactoryName, getConnectionPassword, getConnectionUserName, getDeletedTypes, getDetachState, getDirtyObjects, getFetchConfiguration, getLockLevel, getLockManager, getManagedObjects, getObjectId, getObjectIdType, getOrderDirtyObjects, getPendingTransactionalObjects, getPersistedTypes, getPopulateDataCache, getPostLoadOnMerge, getStateManager, getStoreManager, getTransactionalObjects, getUpdatedTypes, getVersion, hasConnection, isActive, isCached, isDeleted, isDirty, isManaged, isNew, isPersistent, isStoreActive, isTrackChangesByType, isTransactional, lock, newObjectId, nontransactional, nontransactionalAll, popFetchConfiguration, pushFetchConfiguration, pushFetchConfiguration, retrieve, retrieveAll, setAllowReferenceToSiblingContext, setConnectionFactory2Name, setConnectionFactoryName, setDetachState, setOrderDirtyObjects, setPopulateDataCache, setPostLoadOnMerge, setTrackChangesByType, transactional, transactionalAll, unlock
void setImplicitBehavior(OpCallbacks call, RuntimeExceptionTranslator ex)
BrokerFactory getBrokerFactory()
int getConnectionRetainMode()
ManagedRuntime getManagedRuntime()
InverseManager getInverseManager()
boolean getMultithreaded()
void setMultithreaded(boolean multi)
boolean getIgnoreChanges()
void setIgnoreChanges(boolean ignore)
boolean getNontransactionalRead()
void setNontransactionalRead(boolean read)
boolean getNontransactionalWrite()
void setNontransactionalWrite(boolean write)
int getRestoreState()
void setRestoreState(int restore)
boolean getOptimistic()
void setOptimistic(boolean opt)
boolean getRetainState()
void setRetainState(boolean retain)
int getAutoClear()
void setAutoClear(int clear)
boolean getSyncWithManagedTransactions()
void setSyncWithManagedTransactions(boolean resync)
int getAutoDetach()
AutoDetach
which indicate when persistent
managed objects should be automatically detached in-place.void setAutoDetach(int flags)
AutoDetach
which indicate when persistent
managed objects should be automatically detached in-place.void setAutoDetach(int flag, boolean on)
AutoDetach
which indicate when persistent
managed objects should be automatically detached in-place.Map<String,Object> getProperties()
Set<String> getSupportedProperties()
boolean isDetachedNew()
void setDetachedNew(boolean isNew)
boolean getEvictFromDataCache()
void setEvictFromDataCache(boolean evict)
Object putUserObject(Object key, Object val)
Object getUserObject(Object key)
void addTransactionListener(Object listener)
void removeTransactionListener(Object listener)
Collection<Object> getTransactionListeners()
int getTransactionListenerCallbackMode()
void setTransactionListenerCallbackMode(int mode)
void addLifecycleListener(Object listener, Class[] classes)
void removeLifecycleListener(Object listener)
LifecycleEventManager getLifecycleEventManager()
int getLifecycleListenerCallbackMode()
void setLifecycleListenerCallbackMode(int mode)
boolean getCachePreparedQuery()
void setCachePreparedQuery(boolean flag)
void begin()
void commit()
void rollback()
boolean syncWithManagedTransaction()
void commitAndResume()
broker.commit (); broker.begin ();except that the broker's internal atomic lock is utilized, so this method can be safely executed from multiple threads.
void rollbackAndResume()
broker.rollback (); broker.begin ();except that the broker's internal atomic lock is utilized, so this method can be safely executed from multiple threads.
rollback()
,
begin()
boolean getRollbackOnly()
void setRollbackOnly()
void setRollbackOnly(Throwable cause)
Throwable getRollbackCause()
void setSavepoint(String name)
void rollbackToSavepoint()
void rollbackToSavepoint(String name)
void releaseSavepoint()
void releaseSavepoint(String name)
void flush()
void preFlush()
void validateChanges()
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.void persist(Object obj, OpCallbacks call)
void persistAll(Collection objs, OpCallbacks call)
OpenJPAStateManager persist(Object pc, Object id, OpCallbacks call)
ValueMetaData.CASCADE_IMMEDIATE
.pc
- the instance to persistid
- the id to give the state manager; may be null for defaultvoid delete(Object pc, OpCallbacks call)
void deleteAll(Collection objs, OpCallbacks call)
void release(Object pc, OpCallbacks call)
void releaseAll(Collection objs, OpCallbacks call)
void refresh(Object pc, OpCallbacks call)
void refreshAll(Collection objs, OpCallbacks call)
void evict(Object pc, OpCallbacks call)
void evictAll(Collection objs, OpCallbacks call)
void evictAll(OpCallbacks call)
void evictAll(Extent extent, OpCallbacks call)
Extent
.void detachAll(OpCallbacks call)
void detachAll(OpCallbacks call, boolean flush)
call
- Persistence operation callbacksflush
- boolean value to indicate whether to perform a
flush before detaching the entities (true, do the flush;
false, don't do the flush)Object detach(Object pc, OpCallbacks call)
pc
- the instance to detachObject[] detachAll(Collection objs, OpCallbacks call)
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
.objs
- the instances to detachObject attach(Object pc, boolean copyNew, OpCallbacks call)
pc
- instance to importcopyNew
- whether to copy new instancesObject[] attachAll(Collection objs, boolean copyNew, OpCallbacks call)
objs
- array of instances to importcopyNew
- whether to copy new instancesObject newInstance(Class cls)
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, if cls
is a managed type, this will return an
instance of the specified class.IllegalArgumentException
- if cls
is not a managed
type or interface.boolean isDetached(Object obj)
true
if obj
is a detached object
(one that can be reattached to a Broker
via a call to
attach(java.lang.Object, boolean, org.apache.openjpa.kernel.OpCallbacks)
); otherwise returns false
.Extent newExtent(Class cls, boolean subs)
Query newQuery(String language, Class cls, Object query)
Seq getIdentitySequence(ClassMetaData meta)
Seq
for the datastore identity values of the
specified persistent class, or null if the class' identity cannot be
represented as a sequence.Seq getValueSequence(FieldMetaData fmd)
Seq
for the generated values of the specified
field, or null if the field is not generated.void lock(Object pc, int level, int timeout, OpCallbacks call)
pc
- the object to locklevel
- the lock level to usetimeout
- the number of milliseconds to wait for the lock before
giving up, or -1 for no limitvoid lock(Object pc, OpCallbacks call)
FetchConfiguration
for the broker.void lockAll(Collection objs, int level, int timeout, OpCallbacks call)
objs
- the objects to locklevel
- the lock level to usetimeout
- the number of milliseconds to wait for the lock before
giving up, or -1 for no limitvoid lockAll(Collection objs, OpCallbacks call)
FetchConfiguration
for the broker.boolean cancelAll()
void dirtyType(Class cls)
boolean beginOperation(boolean syncTrans)
endOperation()
is called.syncTrans
- whether instances may be loaded/modified during
this operation requiring a re-check of global txboolean endOperation()
boolean isClosed()
boolean isCloseInvoked()
close()
has been invoked, though the broker might
remain open until the current managed transaction completes.void assertOpen()
void assertActiveTransaction()
void assertNontransactionalRead()
void assertWriteOperation()
Copyright © 2006–2018 Apache Software Foundation. All rights reserved.