org.apache.openjpa.slice
Class DistributedBrokerImpl

java.lang.Object
  extended by org.apache.openjpa.kernel.BrokerImpl
      extended by org.apache.openjpa.kernel.FinalizingBrokerImpl
          extended by org.apache.openjpa.slice.DistributedBrokerImpl
All Implemented Interfaces:
Serializable, Cloneable, Synchronization, CallbackModes, AutoClear, AutoDetach, Broker, ConnectionRetainModes, DetachState, FindCallbacks, LockLevels, RestoreState, StoreContext, Closeable, DistributedBroker

public class DistributedBrokerImpl
extends FinalizingBrokerImpl
implements DistributedBroker

A specialized Broker to associate slice identifiers with the StateManagers as they are persisted in a cascade. This intervention helps the user to define distribution policy only for root instances i.e. the instances that are explicit argument to persist() call. The cascaded instances are assigned the same slice to honor collocation constraint.

Author:
Pinaki Poddar
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.openjpa.kernel.BrokerImpl
FLUSH_COMMIT, FLUSH_INC, FLUSH_LOGICAL, FLUSH_ROLLBACK
 
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
DistributedBrokerImpl()
           
 
Method Summary
 Slice addSlice(String name, Map properties)
          Adds the given slice with the given properties.
 void beginStore()
          A virtual datastore need not be opened.
 boolean endOperation()
          Mark the operation over.
 DistributedConfiguration getConfiguration()
          Return the configuration associated with this context.
 DistributedStoreManager getDistributedStoreManager()
           
 void lock()
          Always uses lock irrespective of super's multi-threaded settings.
protected  QueryImpl newQueryImpl(String lang, StoreQuery sq)
          Create a new query.
 OpenJPAStateManager persist(Object pc, Object id, boolean explicit, OpCallbacks call)
          Assigns slice identifier to the resultant StateManager as initialized by the super class implementation.
 void unlock()
          Releases the internal lock.
 
Methods inherited from class org.apache.openjpa.kernel.FinalizingBrokerImpl
finalize
 
Methods inherited from class org.apache.openjpa.kernel.BrokerImpl
addLifecycleListener, addTransactionListener, afterCompletion, assertActiveTransaction, assertNontransactionalRead, assertOpen, assertPersistenceCapable, assertWriteOperation, assignObjectId, attach, attachAll, beforeCompletion, begin, beginOperation, cancelAll, checkForDuplicateId, clone, close, commit, commitAndResume, delete, deleteAll, detach, detachAll, detachAll, detachAll, dirtyType, embed, endTransaction, evict, evictAll, evictAll, evictAll, extentIterator, find, find, find, findAll, findAll, findAll, findCached, flush, flush, free, getAutoClear, getAutoDetach, getBroker, getBrokerFactory, getCacheFinderQuery, getCachePreparedQuery, getClassLoader, getConnection, getConnectionFactory, getConnectionFactory2, getConnectionFactory2Name, getConnectionFactoryName, getConnectionPassword, getConnectionRetainMode, getConnectionUserName, getDeletedTypes, getDetachState, getDirtyObjects, getDirtyStates, getEvictFromDataCache, getFetchConfiguration, getIdentitySequence, getIgnoreChanges, getInverseManager, getLifecycleEventManager, getLifecycleListenerCallbackMode, getLockLevel, getLockManager, getManagedObjects, getManagedRuntime, getManagedStates, getMultithreaded, getNontransactionalRead, getNontransactionalWrite, getObjectId, getObjectIdType, getOperatingSet, getOptimistic, getOrderDirtyObjects, getPendingTransactionalObjects, getPendingTransactionalStates, getPersistedTypes, getPopulateDataCache, getProperties, getRestoreState, getRetainState, getRollbackCause, getRollbackOnly, getStateManager, getStateManagerImpl, getStateManagerImplById, getStoreManager, getSupportedProperties, getSuppressBatchOLELogging, getSynchronization, getSyncWithManagedTransactions, getTransactionalObjects, getTransactionalStates, getTransactionListenerCallbackMode, getTransactionListeners, getUpdatedTypes, getUserObject, getValueSequence, getVersion, hasConnection, initialize, initialize, initialize, isActive, isCached, isClosed, isCloseInvoked, isDeleted, isDetached, isDetachedNew, isDirty, isFromWriteBehindCallback, isManaged, isNew, isPersistent, isStoreActive, isTrackChangesByType, isTransactional, lock, lock, lockAll, lockAll, newExtent, newInstance, newManagedObjectCache, newObjectId, newQuery, newQuery, newStateManagerImpl, nontransactional, nontransactionalAll, persist, persist, persist, persistAll, persistAll, popFetchConfiguration, preFlush, processArgument, processReturn, pushFetchConfiguration, putUserObject, refresh, refreshAll, refreshInternal, refreshInternal, release, releaseAll, releaseSavepoint, releaseSavepoint, removeLifecycleListener, removeTransactionListener, retrieve, retrieveAll, rollback, rollbackAndResume, rollbackToSavepoint, rollbackToSavepoint, setAuthentication, setAutoClear, setAutoDetach, setAutoDetach, setCacheFinderQuery, setCachePreparedQuery, setConnectionFactory2Name, setConnectionFactoryName, setDetachedNew, setDetachState, setEvictFromDataCache, setIgnoreChanges, setImplicitBehavior, setLifecycleListenerCallbackMode, setMultithreaded, setNontransactionalRead, setNontransactionalWrite, setOptimistic, setOrderDirtyObjects, setPopulateDataCache, setRestoreState, setRetainState, setRollbackOnly, setRollbackOnly, setSavepoint, setSuppressBatchOLELogging, setSynchronization, setSyncWithManagedTransactions, setTrackChangesByType, setTransactionListenerCallbackMode, syncWithManagedTransaction, transactional, transactionalAll, validateChanges
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.openjpa.kernel.Broker
addLifecycleListener, addTransactionListener, assertActiveTransaction, assertNontransactionalRead, assertOpen, assertWriteOperation, attach, attachAll, begin, beginOperation, cancelAll, close, commit, commitAndResume, delete, deleteAll, detach, detachAll, detachAll, detachAll, dirtyType, evict, evictAll, evictAll, evictAll, flush, getAutoClear, getAutoDetach, getBrokerFactory, getCachePreparedQuery, getConnectionRetainMode, getEvictFromDataCache, getIdentitySequence, getIgnoreChanges, getInverseManager, getLifecycleEventManager, getLifecycleListenerCallbackMode, getManagedRuntime, getMultithreaded, getNontransactionalRead, getNontransactionalWrite, getOptimistic, getProperties, getRestoreState, getRetainState, getRollbackCause, getRollbackOnly, getSupportedProperties, getSyncWithManagedTransactions, getTransactionListenerCallbackMode, getTransactionListeners, getUserObject, getValueSequence, isClosed, isCloseInvoked, 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, setCachePreparedQuery, setDetachedNew, setEvictFromDataCache, setIgnoreChanges, setImplicitBehavior, setLifecycleListenerCallbackMode, setMultithreaded, setNontransactionalRead, setNontransactionalWrite, setOptimistic, setRestoreState, setRetainState, setRollbackOnly, setRollbackOnly, setSavepoint, setSyncWithManagedTransactions, setTransactionListenerCallbackMode, syncWithManagedTransaction, validateChanges
 
Methods inherited from interface javax.transaction.Synchronization
afterCompletion, beforeCompletion
 
Methods inherited from interface org.apache.openjpa.kernel.StoreContext
embed, extentIterator, find, find, findAll, findAll, findCached, getBroker, getClassLoader, getConnection, getConnectionFactory, getConnectionFactory2, getConnectionFactory2Name, getConnectionFactoryName, getConnectionPassword, getConnectionUserName, getDeletedTypes, getDetachState, getDirtyObjects, getFetchConfiguration, getLockLevel, getLockManager, getManagedObjects, getObjectId, getObjectIdType, getOrderDirtyObjects, getPendingTransactionalObjects, getPersistedTypes, getPopulateDataCache, getStateManager, getStoreManager, getTransactionalObjects, getUpdatedTypes, getVersion, hasConnection, isActive, isCached, isDeleted, isDirty, isManaged, isNew, isPersistent, isStoreActive, isTrackChangesByType, isTransactional, newObjectId, nontransactional, nontransactionalAll, popFetchConfiguration, pushFetchConfiguration, retrieve, retrieveAll, setConnectionFactory2Name, setConnectionFactoryName, setDetachState, setOrderDirtyObjects, setPopulateDataCache, setTrackChangesByType, transactional, transactionalAll
 

Constructor Detail

DistributedBrokerImpl

public DistributedBrokerImpl()
Method Detail

getConfiguration

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

Specified by:
getConfiguration in interface StoreContext
Overrides:
getConfiguration in class BrokerImpl

getDistributedStoreManager

public DistributedStoreManager getDistributedStoreManager()

addSlice

public Slice addSlice(String name,
                      Map properties)
Description copied from interface: DistributedBroker
Adds the given slice with the given properties. This newly added slice will participate in the current and subsequent transaction.

Specified by:
addSlice in interface DistributedBroker
Parameters:
name - logical name of the to be added slice. Must be different from any currently available slices.
properties - key-value pair of configuration for the slice to be added. The keys must have openjpa.slice.<name>.* as prefix.
See Also:
DistributedConfiguration.getAvailableSliceNames(), DistributedConfiguration.addSlice(String, Map)

persist

public OpenJPAStateManager persist(Object pc,
                                   Object id,
                                   boolean explicit,
                                   OpCallbacks call)
Assigns slice identifier to the resultant StateManager as initialized by the super class implementation. The slice identifier is decided by DistributionPolicy for given pc if it is a root instance i.e. the argument of the user application's persist() call. The cascaded instances are detected by non-empty status of the current operating set. The slice is assigned only if a StateManager has never been assigned before.

Overrides:
persist in class BrokerImpl

endOperation

public boolean endOperation()
Description copied from class: BrokerImpl
Mark the operation over. If outermost caller of stack, returns true and will detach managed instances if necessary.

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

newQueryImpl

protected QueryImpl newQueryImpl(String lang,
                                 StoreQuery sq)
Create a new query.

Overrides:
newQueryImpl in class BrokerImpl

lock

public void lock()
Always uses lock irrespective of super's multi-threaded settings.

Specified by:
lock in interface StoreContext
Overrides:
lock in class BrokerImpl

unlock

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

Specified by:
unlock in interface StoreContext
Overrides:
unlock in class BrokerImpl

beginStore

public void beginStore()
A virtual datastore need not be opened.

Specified by:
beginStore in interface StoreContext
Overrides:
beginStore in class BrokerImpl


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