org.jboss.cache.aop
Class TreeCacheAop
java.lang.Object
org.jboss.mx.util.JBossNotificationBroadcasterSupport
org.jboss.system.ServiceMBeanSupport
org.jboss.cache.TreeCache
org.jboss.cache.aop.TreeCacheAop
- All Implemented Interfaces:
- java.lang.Cloneable, javax.management.MBeanRegistration, org.jgroups.MembershipListener, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, org.jboss.system.Service, org.jboss.system.ServiceMBean, TreeCacheAopIfc, TreeCacheAopMBean, TreeCacheMBean
- public class TreeCacheAop
- extends TreeCache
- implements TreeCacheAopMBean, TreeCacheAopIfc
Implementation of the cache using dynamic aop interceptors. The basic idea is that the caller only
uses the putObject(String,Object)
, getObject(String)
and
removeObject(String)
methods.
When putting an object into the cache, the cache essentially takes care of how the object
will be replicated. It 'breaks' the object apart to map it onto the tree, and adds an
interceptor recursively for each object reachable from the root object. Those interceptor
'know' to which part of the tree they are mapped. Whenever there is state change
("set*" interceptors), the tree is modified using the superclass. All "get*" operations
to the object are intercepted and redirected to the tree.
Bottom line is that a user simply puts any object into the cache, and the object
will be replicated to all caches in the cluster. The only requirement on cachable objects
is that they access all state through getters and setters.
- Author:
- Harald Gliebe, Ben Wang
Fields inherited from class org.jboss.cache.TreeCache |
activationChangeNodes, addChildMethodLocal, cache_mode, cacheLoaderConfig, cacheLoaderManager, channel, cloaderConfig, cluster_name, cluster_props, clusteredGetMethod, commitMethod, coordinator, DEFAULT_REPLICATION_VERSION, disp, enqueueMethodCallMethod, evictConfig_, eviction_policy_class, eviction_policy_provider, evictionRegionManager_, evictNodeMethodLocal, evictVersionedNodeMethodLocal, existsMethod, fetchInMemoryState, getChildrenNamesMethodLocal, getDataMapMethodLocal, getKeysMethodLocal, getKeyValueMethodLocal, getNodeMethodLocal, getPartialStateMethod, hasListeners, inactiveOnStartup, interceptor_chain, INVALIDATION_ASYNC, INVALIDATION_SYNC, isolationLevel, isStandalone, isStateSet, LOCAL, lock_acquisition_timeout, lockMethodLocal, log, marshaller_, members, ml, nodeLockingOptimistic, notifyCallOnInactiveMethod, optimisticPrepareMethod, prepareMethod, printMethodLocal, putDataEraseMethodLocal, putDataMethodLocal, putFailFastKeyValueMethodLocal, putKeyValMethodLocal, region_msg_queues, regionManager_, releaseAllLocksMethodLocal, removeDataMethodLocal, removeKeyMethodLocal, removeNodeMethodLocal, REPL_ASYNC, repl_queue, repl_queue_interval, repl_queue_max_elements, REPL_SYNC, replicateAllMethod, replicateMethod, replication_handler, rollbackMethod, root, SEPARATOR, setStateException, state_fetch_timeout, sync_commit_phase, sync_repl_timeout, sync_rollback_phase, tm, tm_lookup, tm_lookup_class, UNINITIALIZED, use_interceptor_mbeans, use_repl_queue, useCreateService, useMarshalling_ |
Fields inherited from class org.jboss.system.ServiceMBeanSupport |
server, SERVICE_CONTROLLER_SIG, serviceName |
Fields inherited from interface org.jboss.system.ServiceMBean |
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED |
Method Summary |
protected java.lang.Object |
_evictObject(Fqn fqn)
|
protected void |
_evictSubtree(Fqn subtree)
Evicts the node at subtree along with all descendant nodes. |
protected java.util.Map |
_findObjects(Fqn fqn)
|
protected java.lang.Object |
_getObject(Fqn fqn)
|
protected java.lang.Object |
_putObject(Fqn fqn,
java.lang.Object obj)
|
protected java.lang.Object |
_removeObject(Fqn fqn,
boolean removeCacheInterceptor)
|
protected void |
acquireLocksForStateTransfer(DataNode root,
java.lang.Object lockOwner,
long timeout,
boolean force)
Overrides the superclass version by additionally acquiring locks
on the internal reference map nodes used for tracking shared objects. |
void |
activateRegion(java.lang.String subtreeFqn)
Overrides the superclass method by
ensuring that the internal region where information on shared object is stored
has been activated. |
protected void |
endTransaction(Fqn fqn)
|
void |
evict(Fqn fqn)
Override to provide aop specific eviction. |
java.util.Map |
findObjects(Fqn fqn)
Query all managed pojo objects under the fqn recursively. |
java.util.Map |
findObjects(java.lang.String fqn)
Query all managed pojo objects under the fqn recursively. |
CachedType |
getCachedType(java.lang.Class clazz)
Obtain a cache aop type for user to traverse the defined "primitive" types in aop. |
java.lang.Object |
getObject(Fqn fqn)
Retrieve the aop-enabled object from the cache. |
java.lang.Object |
getObject(java.lang.String fqn)
Retrieve the aop-enabled object from the cache. |
protected boolean |
hasCurrentTransaction()
|
protected void |
init()
|
java.lang.Object |
putObject(Fqn fqn,
java.lang.Object obj)
Insert an aop-enabled object into the cache. |
java.lang.Object |
putObject(java.lang.String fqn,
java.lang.Object obj)
Insert an aop-enabled object into the cache. |
protected void |
releaseStateTransferLocks(DataNode root,
java.lang.Object lockOwner)
Overrides the superclass version by additionally releasing locks
on the internal reference map nodes used for tracking shared objects. |
java.lang.Object |
removeObject(Fqn fqn)
Remove aop-enabled object from the cache. |
java.lang.Object |
removeObject(java.lang.String fqn)
Remove aop-enabled object from the cache. |
void |
setEvictionPolicyClass(java.lang.String eviction_policy_class)
Over-ride to make sure we are using an eviction policy specific to aop. |
Methods inherited from class org.jboss.cache.TreeCache |
_addChild, _clusteredGet, _createService, _enqueueMethodCall, _evict, _evict, _get, _get, _getAssociatedState, _getChildrenNames, _getData, _getKeys, _getState, _lock, _print, _put, _put, _put, _put, _put, _put, _releaseAllLocks, _remove, _remove, _remove, _remove, _remove, _remove, _remove, _removeData, _removeData, _removeData, _removeData, _removeData, _replicate, _replicate, acquireLocksForStateTransfer, addTreeCacheListener, addUndoOperation, block, callRemoteMethods, callRemoteMethods, callRemoteMethods, callRemoteMethods, commit, createService, createSubtreeRootNode, destroyService, determineCoordinator, dumpTransactionTable, exists, exists, exists, exists, fetchState, fetchStateOnStartup, forceAcquireLock, get, get, get, get, get, get, get, get, getCacheLoader, getCacheLoaderAsynchronous, getCacheLoaderClass, getCacheLoaderConfig, getCacheLoaderConfiguration, getCacheLoaderFetchPersistentState, getCacheLoaderFetchTransientState, getCacheLoaderManager, getCacheLoaderPassivation, getCacheLoaderPreload, getCacheLoaderShared, getCacheMode, getCacheModeInternal, getChildrenNames, getChildrenNames, getChildrenNames, getClusterName, getClusterProperties, getCoordinator, getCurrentTransaction, getCurrentTransaction, getCurrentTransaction, getCurrentTransaction, getDeadlockDetection, getDefaultProperties, getEvictionPolicyClass, getEvictionPolicyConfig, getEvictionRegionManager, getEvictionThreadWakeupIntervalSeconds, getFetchInMemoryState, getFetchStateOnStartup, getInitialStateRetrievalTimeout, getInstance, getInterceptorChain, getInterceptors, getInvocationContext, getIsolationLevel, getIsolationLevelClass, getKeys, getKeys, getLocalAddress, getLocalTransaction, getLockAcquisitionTimeout, getLockTable, getMembers, getMessageListener, getNodeLockingScheme, getNumberOfAttributes, getNumberOfAttributes, getNumberOfLocksHeld, getNumberOfNodes, getOwnerForLock, getRegionManager, getReplicationVersion, getReplicationVersionShort, getReplQueue, getReplQueueInterval, getReplQueueMaxElements, getRoot, getStateBytes, getStateTransferVersion, getSyncCommitPhase, getSyncReplTimeout, getSyncRollbackPhase, getTransactionManager, getTransactionManagerLookupClass, getTransactionTable, getTreeCacheListeners, getUseInterceptorMbeans, getUseMarshalling, getUseReplQueue, getVersion, hasChild, inactivateRegion, invokeMethod, isCoordinator, isCrudMethod, isInactiveOnStartup, isNodeLockingOptimistic, load, loadClass, notifyAllNodesCreated, notifyCacheStarted, notifyCacheStopped, notifyCallForInactiveSubtree, notifyNodeActivate, notifyNodeCreated, notifyNodeEvict, notifyNodeEvicted, notifyNodeLoaded, notifyNodeModified, notifyNodeModify, notifyNodePassivate, notifyNodeRemove, notifyNodeRemoved, notifyNodeVisited, notifyViewChange, optimisticPrepare, peek, peek, prepare, print, print, printDetails, printLockInfo, put, put, put, put, put, put, putFailFast, putFailFast, registerClassLoader, releaseAllLocks, releaseAllLocks, releaseStateTransferLocks, remove, remove, remove, remove, remove, remove, removeData, removeData, removeTreeCacheListener, rollback, setCacheLoader, setCacheLoaderAsynchronous, setCacheLoaderClass, setCacheLoaderConfig, setCacheLoaderConfiguration, setCacheLoaderFetchPersistentState, setCacheLoaderFetchTransientState, setCacheLoaderManager, setCacheLoaderPassivation, setCacheLoaderPreload, setCacheLoaderShared, setCacheMode, setCacheMode, setClusterConfig, setClusterName, setClusterProperties, setDeadlockDetection, setEvictionListener, setEvictionPolicyConfig, setEvictionPolicyProvider, setFetchInMemoryState, setFetchStateOnStartup, setInactiveOnStartup, setInitialStateRetrievalTimeout, setInterceptorChain, setInvocationContext, setIsolationLevel, setIsolationLevel, setLockAcquisitionTimeout, setNodeLockingOptimistic, setNodeLockingScheme, setReplication_handler, setReplicationVersion, setReplQueueInterval, setReplQueueMaxElements, setStateBytes, setStateTransferVersion, setSyncCommitPhase, setSyncReplTimeout, setSyncRollbackPhase, setTransactionManagerLookup, setTransactionManagerLookupClass, setUseInterceptorMbeans, setUseMarshalling, setUseReplQueue, startService, stopService, string2Mode, suspect, toString, toString, unregisterClassLoader, viewAccepted |
Methods inherited from class org.jboss.system.ServiceMBeanSupport |
create, destroy, getDeploymentInfo, getLog, getName, getNextNotificationSequenceNumber, getObjectName, getServer, getServiceName, getState, getStateString, jbossInternalCreate, jbossInternalDescription, jbossInternalDestroy, jbossInternalLifecycle, jbossInternalStart, jbossInternalStop, postDeregister, postRegister, preDeregister, preRegister, start, stop |
Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport |
addNotificationListener, getNotificationInfo, handleNotification, nextNotificationSequenceNumber, removeNotificationListener, removeNotificationListener, sendNotification |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.jboss.cache.TreeCacheMBean |
_put, _put, _put, _put, _put, _remove, _remove, _remove, _remove, addTreeCacheListener, callRemoteMethods, callRemoteMethods, createService, destroyService, dumpTransactionTable, exists, exists, exists, exists, fetchState, get, get, get, get, get, get, get, getCacheLoader, getCacheLoaderAsynchronous, getCacheLoaderClass, getCacheLoaderConfig, getCacheLoaderConfiguration, getCacheLoaderFetchPersistentState, getCacheLoaderFetchTransientState, getCacheLoaderPassivation, getCacheLoaderPreload, getCacheLoaderShared, getCacheMode, getChildrenNames, getChildrenNames, getChildrenNames, getClusterName, getClusterProperties, getDeadlockDetection, getEvictionPolicyClass, getEvictionThreadWakeupIntervalSeconds, getFetchInMemoryState, getFetchStateOnStartup, getInitialStateRetrievalTimeout, getInstance, getInterceptorChain, getInterceptors, getIsolationLevel, getKeys, getKeys, getLocalAddress, getLockAcquisitionTimeout, getMembers, getNodeLockingScheme, getNumberOfAttributes, getNumberOfLocksHeld, getNumberOfNodes, getReplicationVersion, getReplQueueInterval, getReplQueueMaxElements, getStateTransferVersion, getSyncCommitPhase, getSyncReplTimeout, getSyncRollbackPhase, getTransactionManager, getTransactionManagerLookupClass, getUseInterceptorMbeans, getUseMarshalling, getUseReplQueue, getVersion, inactivateRegion, isCoordinator, isInactiveOnStartup, load, print, print, printDetails, printLockInfo, put, put, put, put, put, put, registerClassLoader, releaseAllLocks, releaseAllLocks, remove, remove, remove, remove, remove, remove, removeData, removeData, removeTreeCacheListener, setCacheLoader, setCacheLoaderAsynchronous, setCacheLoaderClass, setCacheLoaderConfig, setCacheLoaderConfiguration, setCacheLoaderFetchPersistentState, setCacheLoaderFetchTransientState, setCacheLoaderPassivation, setCacheLoaderPreload, setCacheLoaderShared, setCacheMode, setClusterConfig, setClusterName, setClusterProperties, setDeadlockDetection, setEvictionPolicyConfig, setFetchInMemoryState, setFetchStateOnStartup, setInactiveOnStartup, setInitialStateRetrievalTimeout, setIsolationLevel, setLockAcquisitionTimeout, setNodeLockingScheme, setReplicationVersion, setReplQueueInterval, setReplQueueMaxElements, setStateTransferVersion, setSyncCommitPhase, setSyncReplTimeout, setSyncRollbackPhase, setTransactionManagerLookup, setTransactionManagerLookupClass, setUseInterceptorMbeans, setUseMarshalling, setUseReplQueue, startService, stopService, toString, unregisterClassLoader |
Methods inherited from interface org.jboss.system.ServiceMBean |
getName, getState, getStateString, jbossInternalLifecycle |
Methods inherited from interface org.jboss.system.Service |
create, destroy, start, stop |
cachedTypes
protected java.util.Map cachedTypes
DUMMY
public static final java.lang.String DUMMY
- See Also:
- Constant Field Values
delegate_
protected TreeCacheAopDelegate delegate_
TreeCacheAop
public TreeCacheAop(java.lang.String cluster_name,
java.lang.String props,
long state_fetch_timeout)
throws java.lang.Exception
TreeCacheAop
public TreeCacheAop()
throws java.lang.Exception
TreeCacheAop
public TreeCacheAop(org.jgroups.JChannel channel)
throws java.lang.Exception
init
protected void init()
setEvictionPolicyClass
public void setEvictionPolicyClass(java.lang.String eviction_policy_class)
- Over-ride to make sure we are using an eviction policy specific to aop.
- Specified by:
setEvictionPolicyClass
in interface TreeCacheAopMBean
- Overrides:
setEvictionPolicyClass
in class TreeCache
evict
public void evict(Fqn fqn)
throws CacheException
- Override to provide aop specific eviction.
Called by eviction policy provider. Note that eviction is done only in local mode,
that is, it doesn't replicate the node removal. This is will cause the replcation nodes
not synchronizing, but it is ok since user is supposed to add the node again when get is
null. After that, the contents will be in sync.
- Specified by:
evict
in interface TreeCacheAopMBean
- Overrides:
evict
in class TreeCache
- Parameters:
fqn
- Will remove everythign assoicated with this fqn.
- Throws:
CacheException
_evictSubtree
protected void _evictSubtree(Fqn subtree)
throws CacheException
- Description copied from class:
TreeCache
- Evicts the node at
subtree
along with all descendant nodes.
- Overrides:
_evictSubtree
in class TreeCache
- Parameters:
subtree
- Fqn indicating the uppermost node in the
portion of the tree that should be evicted.
- Throws:
CacheException
activateRegion
public void activateRegion(java.lang.String subtreeFqn)
throws RegionNotEmptyException,
RegionNameConflictException,
CacheException
- Overrides the
superclass method
by
ensuring that the internal region where information on shared object is stored
has been activated.
- Specified by:
activateRegion
in interface TreeCacheMBean
- Overrides:
activateRegion
in class TreeCache
- Parameters:
subtreeFqn
- Fqn string indicating the uppermost node in the
portion of the tree that should be activated.
- Throws:
RegionNotEmptyException
- if the node subtreeFqn
exists and has either data or children
RegionNameConflictException
CacheException
acquireLocksForStateTransfer
protected void acquireLocksForStateTransfer(DataNode root,
java.lang.Object lockOwner,
long timeout,
boolean force)
throws java.lang.Exception
- Overrides the superclass version by additionally acquiring locks
on the internal reference map nodes used for tracking shared objects.
- Throws:
java.lang.Exception
releaseStateTransferLocks
protected void releaseStateTransferLocks(DataNode root,
java.lang.Object lockOwner)
- Overrides the superclass version by additionally releasing locks
on the internal reference map nodes used for tracking shared objects.
getCachedType
public CachedType getCachedType(java.lang.Class clazz)
- Obtain a cache aop type for user to traverse the defined "primitive" types in aop.
- Specified by:
getCachedType
in interface TreeCacheAopMBean
- Parameters:
clazz
- The original pojo class
- Returns:
- CachedType
getObject
public java.lang.Object getObject(java.lang.String fqn)
throws CacheException
- Retrieve the aop-enabled object from the cache.
- Specified by:
getObject
in interface TreeCacheAopMBean
- Parameters:
fqn
- String name that associates with this node.
- Returns:
- Current content value. Null if does not exist.
- Throws:
CacheException
getObject
public java.lang.Object getObject(Fqn fqn)
throws CacheException
- Retrieve the aop-enabled object from the cache. Return null if object does not exist in the cache.
- Specified by:
getObject
in interface TreeCacheAopMBean
- Parameters:
fqn
- Instance that associates with this node.
- Returns:
- Current content value. Null if does not exist.
- Throws:
CacheException
putObject
public java.lang.Object putObject(java.lang.String fqn,
java.lang.Object obj)
throws CacheException
- Insert an aop-enabled object into the cache.
It will also recursively put the any sub-object that is
declared as aop-capable (i.e., in
jboss-aop.xml
).
Note that List
, Map
, Set
attributes are aop-enabled, by default, as well.
- Specified by:
putObject
in interface TreeCacheAopMBean
- Parameters:
fqn
- The fqn string name to associate with the object in the cache.obj
- aop-enabled object to be inerted into the cache. If null,
it will nullify the fqn node.
- Throws:
CacheException
putObject
public java.lang.Object putObject(Fqn fqn,
java.lang.Object obj)
throws CacheException
- Insert an aop-enabled object into the cache.
It will also recursively put the any sub-object that is
declared as aop-capable (i.e., in
jboss-aop.xml
).
Note that List
, Map
, Set
attributes are aop-enabled, by default, as well.
- Specified by:
putObject
in interface TreeCacheAopMBean
- Parameters:
fqn
- The fqn instance to associate with the object in the cache.obj
- aop-enabled object to be inerted into the cache. If null,
it will nullify the fqn node.
- Throws:
CacheException
removeObject
public java.lang.Object removeObject(java.lang.String fqn)
throws CacheException
- Remove aop-enabled object from the cache.
- Specified by:
removeObject
in interface TreeCacheAopMBean
- Parameters:
fqn
- String name that associates with this node.
- Returns:
- Value object from this node.
- Throws:
CacheException
removeObject
public java.lang.Object removeObject(Fqn fqn)
throws CacheException
- Remove aop-enabled object from the cache.
- Specified by:
removeObject
in interface TreeCacheAopMBean
- Parameters:
fqn
- Instance that associates with this node.
- Returns:
- Original value object from this node.
- Throws:
CacheException
findObjects
public java.util.Map findObjects(java.lang.String fqn)
throws CacheException
- Query all managed pojo objects under the fqn recursively. Note that this will not return the sub-object pojos,
e.g., if Person has a sub-object of Address, it won't return Address pojo. Note also that this operation is
not thread-safe now. In addition, it assumes that once a pojo is found with a fqn, no more pojo is stored
under the children of the fqn. That is, we don't mixed the fqn with different pojos.
- Specified by:
findObjects
in interface TreeCacheAopMBean
- Parameters:
fqn
- The starting place to find all pojos.
- Returns:
- Map of all pojos found with (fqn, pojo) pair. Return size of 0, if not found.
- Throws:
CacheException
findObjects
public java.util.Map findObjects(Fqn fqn)
throws CacheException
- Query all managed pojo objects under the fqn recursively. Note that this will not return the sub-object pojos,
e.g., if Person has a sub-object of Address, it won't return Address pojo. Note also that this operation is
not thread-safe now. In addition, it assumes that once a pojo is found with a fqn, no more pojo is stored
under the children of the fqn. That is, we don't mixed the fqn with different pojos.
- Specified by:
findObjects
in interface TreeCacheAopMBean
- Parameters:
fqn
- The starting place to find all pojos.
- Returns:
- Map of all pojos found with (fqn, pojo) pair. Return size of 0, if not found.
- Throws:
CacheException
hasCurrentTransaction
protected boolean hasCurrentTransaction()
endTransaction
protected void endTransaction(Fqn fqn)
_getObject
protected java.lang.Object _getObject(Fqn fqn)
throws CacheException
- Throws:
CacheException
_putObject
protected java.lang.Object _putObject(Fqn fqn,
java.lang.Object obj)
throws CacheException
- Throws:
CacheException
_removeObject
protected java.lang.Object _removeObject(Fqn fqn,
boolean removeCacheInterceptor)
throws CacheException
- Throws:
CacheException
_evictObject
protected java.lang.Object _evictObject(Fqn fqn)
throws CacheException
- Throws:
CacheException
_findObjects
protected java.util.Map _findObjects(Fqn fqn)
throws CacheException
- Throws:
CacheException
Copyright ? 1998-2005 JBoss Inc . All Rights Reserved.