Save This Page
Home » apache-openjpa-1.1.0-source » org.apache.openjpa » kernel » [javadoc | source]
org.apache.openjpa.kernel
public interface: Broker [javadoc | source]

All Implemented Interfaces:
    LockLevels, StoreContext, AutoClear, CallbackModes, javax.transaction.Synchronization, Closeable, AutoDetach, ConnectionRetainModes, DetachState, RestoreState

All Known Implementing Classes:
    BrokerImpl, DelegatingBroker, FinalizingBrokerImpl, DistributedBrokerImpl

The broker is the primary interface into the OpenJPA runtime. Each broker maintains an independent object cache and an independent transactional context.
Method from org.apache.openjpa.kernel.Broker Summary:
addLifecycleListener,   addTransactionListener,   assertActiveTransaction,   assertNontransactionalRead,   assertOpen,   assertWriteOperation,   attach,   attachAll,   begin,   beginOperation,   cancelAll,   close,   commit,   commitAndResume,   delete,   deleteAll,   detach,   detachAll,   detachAll,   detachAll,   dirtyType,   endOperation,   evict,   evictAll,   evictAll,   evictAll,   flush,   getAutoClear,   getAutoDetach,   getBrokerFactory,   getConnectionRetainMode,   getEvictFromDataCache,   getIdentitySequence,   getIgnoreChanges,   getInverseManager,   getLifecycleEventManager,   getLifecycleListenerCallbackMode,   getManagedRuntime,   getMultithreaded,   getNontransactionalRead,   getNontransactionalWrite,   getOptimistic,   getRestoreState,   getRetainState,   getRollbackCause,   getRollbackOnly,   getSyncWithManagedTransactions,   getTransactionListenerCallbackMode,   getUserObject,   getValueSequence,   isCloseInvoked,   isClosed,   isDetached,   isDetachedNew,   lock,   lock,   lockAll,   lockAll,   newExtent,   newInstance,   newQuery,   newQuery,   persist,   persist,   persistAll,   preFlush,   putUserObject,   refresh,   refreshAll,   release,   releaseAll,   releaseSavepoint,   releaseSavepoint,   removeLifecycleListener,   removeTransactionListener,   rollback,   rollbackAndResume,   rollbackToSavepoint,   rollbackToSavepoint,   setAutoClear,   setAutoDetach,   setAutoDetach,   setDetachedNew,   setEvictFromDataCache,   setIgnoreChanges,   setImplicitBehavior,   setLifecycleListenerCallbackMode,   setMultithreaded,   setNontransactionalRead,   setNontransactionalWrite,   setOptimistic,   setRestoreState,   setRetainState,   setRollbackOnly,   setRollbackOnly,   setSavepoint,   setSyncWithManagedTransactions,   setTransactionListenerCallbackMode,   syncWithManagedTransaction,   validateChanges
Method from org.apache.openjpa.kernel.Broker Detail:
 public  void addLifecycleListener(Object listener,
    Class[] classes)
    Register a listener for lifecycle-related events on the specified classes. If the classes are null, all events will be propagated to the listener.
 public  void addTransactionListener(Object listener)
    Register a listener for transaction-related events.
 public  void assertActiveTransaction()
    Throw an exception if there is no active transaction.
 public  void assertNontransactionalRead()
    Throw an exception if there is no transaction active and nontransactional reading is not enabled.
 public  void assertOpen()
    Throw an exception if this broker has been closed.
 public  void assertWriteOperation()
    Throw an exception if a write operation is not permitted (there is no active transaction and nontransactional writing is not enabled).
 public Object attach(Object pc,
    boolean copyNew,
    OpCallbacks call)
    Import the specified detached object into the broker.
 public Object[] attachAll(Collection objs,
    boolean copyNew,
    OpCallbacks call)
    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.
 public  void begin()
    Begin a transaction.
 public boolean beginOperation(boolean syncTrans)
    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 #endOperation is called.
 public boolean cancelAll()
    Cancel all pending data store statements. If statements are cancelled while a flush is in progress, the transaction rollback only flag will be set.
 public  void close()
    Close the broker.
 public  void commit()
    Commit the current transaction.
 public  void commitAndResume()
    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.
 public  void delete(Object pc,
    OpCallbacks call)
    Delete the given object.
 public  void deleteAll(Collection objs,
    OpCallbacks call)
    Delete the given objects.
 public Object detach(Object pc,
    OpCallbacks call)
    Detach the specified object from the broker.
 public  void detachAll(OpCallbacks call)
    Detach all objects in place. A flush will be performed before detaching the entities.
 public  void detachAll(OpCallbacks call,
    boolean flush)
    Detach all objects in place, with the option of performing a flush before doing the detachment.
 public Object[] detachAll(Collection objs,
    OpCallbacks call)
    Detach the specified objects from the broker. The objects returned can be manipulated and re-attached with #attachAll . 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 .
 public  void dirtyType(Class cls)
    Mark the given class as dirty within the current transaction.
 public boolean endOperation()
    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.
 public  void evict(Object pc,
    OpCallbacks call)
    Evict the given object.
 public  void evictAll(OpCallbacks call)
    Evict all clean objects.
 public  void evictAll(Collection objs,
    OpCallbacks call)
    Evict the given objects.
 public  void evictAll(Extent extent,
    OpCallbacks call)
    Evict all persistent-clean and persistent-nontransactional instances in the given Extent .
 public  void flush()
    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.
 public int getAutoClear()
    Whether objects clear when entering transactions.
 public int getAutoDetach()
    Bit flags marked in AutoDetach which indicate when persistent managed objects should be automatically detached in-place.
 public BrokerFactory getBrokerFactory()
    Return the factory that produced this broker.
 public int getConnectionRetainMode()
    Return the connection retain mode for this broker.
 public boolean getEvictFromDataCache()
    Whether to also evict an object from the store cache when it is evicted through this broker.
 public 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.
 public boolean getIgnoreChanges()
    Whether to take into account changes in the transaction when executing a query or iterating an extent.
 public InverseManager getInverseManager()
    Return the inverse manager in use.
 public LifecycleEventManager getLifecycleEventManager()
    Return the lifecycle event manager associated with the broker.
 public int getLifecycleListenerCallbackMode()
    The callback mode for handling exceptions from lifecycle event listeners.
 public ManagedRuntime getManagedRuntime()
    Return the managed runtime in use.
 public boolean getMultithreaded()
    Whether the broker or its managed instances are used in a multithreaded environment.
 public boolean getNontransactionalRead()
    Whether to allow nontransactional access to persistent state.
 public boolean getNontransactionalWrite()
    Whether to allow nontransactional changes to persistent state.
 public boolean getOptimistic()
    Whether to use optimistic transactional semantics.
 public int getRestoreState()
    Whether to restore an object's original state on rollback.
 public boolean getRetainState()
    Whether objects retain their persistent state on transaction commit.
 public Throwable getRollbackCause()
    Returns the Throwable that caused the transaction to be marked for rollback.
 public boolean getRollbackOnly()
    Return whether the current transaction has been marked for rollback.
 public boolean getSyncWithManagedTransactions()
    Whether to check for a global transaction upon every managed, non-transactional operation. Defaults to false.
 public int getTransactionListenerCallbackMode()
    The callback mode for handling exceptions from transaction event listeners.
 public Object getUserObject(Object key)
    Get the value for the specified key from the map of user objects.
 public Seq getValueSequence(FieldMetaData fmd)
    Returns a Seq for the generated values of the specified field, or null if the field is not generated.
 public boolean isCloseInvoked()
    Whether #close has been invoked, though the broker might remain open until the current managed transaction completes.
 public boolean isClosed()
    Whether the broker is closed.
 public 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 ); otherwise returns false.
 public boolean isDetachedNew()
    Whether to treat relations to detached instances during persist operations as new or as pseudo-hollow instances.
 public  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.
 public  void lock(Object pc,
    int level,
    int timeout,
    OpCallbacks call)
    Ensure that the given instance is locked at the given lock level.
 public  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.
 public  void lockAll(Collection objs,
    int level,
    int timeout,
    OpCallbacks call)
    Ensure that the given instances are locked at the given lock level.
 public Extent newExtent(Class cls,
    boolean subs)
    Return an extent of the given class, optionally including subclasses.
 public Object newInstance(Class cls)
    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, if cls is a managed type, this will return an instance of the specified class.
 public Query newQuery(String language,
    Object query)
    Create a new query in the given language.
 public Query newQuery(String language,
    Class cls,
    Object query)
    Create a new query from the given data, with the given candidate class and language.
 public  void persist(Object obj,
    OpCallbacks call)
    Persist the given object.
 public OpenJPAStateManager persist(Object pc,
    Object id,
    OpCallbacks call)
    Make the given instance persistent. Unlike other persist operations, this method does not immediately cascade to fields marked ValueMetaData#CASCADE_IMMEDIATE .
 public  void persistAll(Collection objs,
    OpCallbacks call)
    Persist the given objects.
 public  void preFlush()
    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.
 public Object putUserObject(Object key,
    Object val)
    Put the specified key-value pair into the map of user objects. Use a value of null to remove the key.
 public  void refresh(Object pc,
    OpCallbacks call)
    Refresh the state of the given object.
 public  void refreshAll(Collection objs,
    OpCallbacks call)
    Refresh the state of the given objects.
 public  void release(Object pc,
    OpCallbacks call)
    Release the given object from management. This operation is not recursive.
 public  void releaseAll(Collection objs,
    OpCallbacks call)
    Release the given objects from management. This operation is not recursive.
 public  void releaseSavepoint()
    Release the last set savepoint and any resources associated with it. The given savepoint and any set after it will become invalid.
 public  void releaseSavepoint(String name)
    Release the savepoint and any resources associated with it. The given savepoint and any set after it will become invalid.
 public  void removeLifecycleListener(Object listener)
    Remove a listener for lifecycle-related events.
 public  void removeTransactionListener(Object listener)
    Remove a listener for transaction-related events.
 public  void rollback()
    Rollback the current transaction.
 public  void rollbackAndResume()
    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.
 public  void rollbackToSavepoint()
    Rollback the current transaction to the last savepoint. Savepoints set after this one will become invalid.
 public  void rollbackToSavepoint(String name)
    Rollback the current transaction to the given savepoint name. Savepoints set after this one will become invalid.
 public  void setAutoClear(int clear)
    Whether objects clear when entering transactions.
 public  void setAutoDetach(int flags)
    Bit flags marked in AutoDetach which indicate when persistent managed objects should be automatically detached in-place.
 public  void setAutoDetach(int flag,
    boolean on)
    Bit flags marked in AutoDetach which indicate when persistent managed objects should be automatically detached in-place.
 public  void setDetachedNew(boolean isNew)
    Whether to treat relations to detached instances as new.
 public  void setEvictFromDataCache(boolean evict)
    Whether to also evict an object from the store cache when it is evicted through this broker.
 public  void setIgnoreChanges(boolean ignore)
    Whether to take into account changes in the transaction when executing a query or iterating an extent.
 public  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. 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.
 public  void setLifecycleListenerCallbackMode(int mode)
    The callback mode for handling exceptions from lifecycle event listeners.
 public  void setMultithreaded(boolean multi)
    Whether the broker or its managed instances are used in a multithreaded environment.
 public  void setNontransactionalRead(boolean read)
    Whether to allow nontransactional access to persistent state.
 public  void setNontransactionalWrite(boolean write)
    Whether to allow nontransactional changes to persistent state.
 public  void setOptimistic(boolean opt)
    Whether to use optimistic transactional semantics.
 public  void setRestoreState(int restore)
    Whether to restore an object's original state on rollback.
 public  void setRetainState(boolean retain)
    Whether objects retain their persistent state on transaction commit.
 public  void setRollbackOnly()
    Mark the current transaction for rollback.
 public  void setRollbackOnly(Throwable cause)
    Mark the current transaction for rollback with the specified cause of the rollback.
 public  void setSavepoint(String name)
    Set a transactional savepoint where operations after this savepoint will be rolled back.
 public  void setSyncWithManagedTransactions(boolean resync)
    Whether to check for a global transaction upon every managed, non-transactional operation. Defaults to false.
 public  void setTransactionListenerCallbackMode(int mode)
    The callback mode for handling exceptions from transaction event listeners.
 public boolean syncWithManagedTransaction()
    Attempt to synchronize with a current managed transaction, returning true if successful, false if no managed transaction is active.
 public  void validateChanges()
    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 #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.