[jboss-cvs] JBossCache/src/org/jboss/cache ...
Manik Surtani
msurtani at jboss.com
Tue Jul 18 06:50:46 EDT 2006
User: msurtani
Date: 06/07/18 06:50:46
Modified: src/org/jboss/cache Cache.java
CacheException.java CacheListener.java
CacheLoader.java CacheSPI.java ConsoleListener.java
Node.java PropertyConfigurator.java Region.java
TreeCache.java TreeCacheMBean.java
TreeCacheView.java TreeCacheView2.java
Added: src/org/jboss/cache
AbstractCacheListener.java RegionImpl.java
TreeCacheProxyImpl.java
Removed: src/org/jboss/cache
AbstractTreeCacheListener.java
ConfigureException.java TreeCacheListener.java
Log:
Checked in new Habanero interfaces
Updated codebase to deal with new interfaces
Revision Changes Path
1.2 +5 -5 JBossCache/src/org/jboss/cache/Cache.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Cache.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/Cache.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- Cache.java 21 Jun 2006 11:17:25 -0000 1.1
+++ Cache.java 18 Jul 2006 10:50:46 -0000 1.2
@@ -7,6 +7,7 @@
package org.jboss.cache;
import java.util.List;
+import java.util.Set;
/**
* Along with {@link Node}, this is the central construct of JBoss Cache.
@@ -46,8 +47,7 @@
* Retrieves an immutable {@link List} of {@link CacheListener}s attached to the cache.
* @return an immutable {@link List} of {@link CacheListener}s attached to the cache.
*/
- //List<CacheListener> getCacheListeners();
- List getCacheListeners();
+ Set<CacheListener> getCacheListeners();
/**
* Convenience method that allows for direct access to the data in a {@link Node}.
@@ -82,19 +82,19 @@
* Retrieves a {@link Region} for a given {@link Fqn}. If the region does not exist, one is created.
* @return a Region
* @throws UnsupportedOperationException if the region cannot be defined.
- * @see org.jboss.cache.eviction.RegionManager
+ * @see org.jboss.cache.Region
*/
Region getRegion(Fqn fqn);
/**
* Lifecycle method
*/
- void create();
+ void create() throws Exception;
/**
* Lifecycle method
*/
- void start();
+ void start() throws Exception;
/**
* Lifecycle method
1.3 +21 -15 JBossCache/src/org/jboss/cache/CacheException.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CacheException.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/CacheException.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- CacheException.java 13 Feb 2006 16:22:07 -0000 1.2
+++ CacheException.java 18 Jul 2006 10:50:46 -0000 1.3
@@ -1,4 +1,4 @@
-// $Id: CacheException.java,v 1.2 2006/02/13 16:22:07 bela Exp $
+// $Id: CacheException.java,v 1.3 2006/07/18 10:50:46 msurtani Exp $
/*
* JBoss, the OpenSource J2EE webOS
@@ -12,25 +12,31 @@
/**
* CacheException, mother of all cache exceptions
*
- * @author <a href="mailto:bela at jboss.org">Bela Ban</a>.
- * @version $Revision: 1.2 $
+ * @author <a href="mailto:bela at jboss.org">Bela Ban</a>
+ * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
+ * @version $Revision: 1.3 $
* <p/>
* <p><b>Revisions:</b>
* <p/>
* <p>Dec 27 2002 Bela Ban: first implementation
* <p>Jan 20 2003 Bela Ban: extend NestedException (otherwise build with JDK 1.3 fails)
+ * <p>Jul 17 2006 Manik Surtani: extends RuntimeException
*/
-public class CacheException extends Exception {
+public class CacheException extends RuntimeException
+{
- public CacheException() {
+ public CacheException()
+ {
super();
}
- public CacheException(String msg) {
+ public CacheException(String msg)
+ {
super(msg);
}
- public CacheException(String msg, Throwable cause) {
+ public CacheException(String msg, Throwable cause)
+ {
super(msg, cause);
}
}
1.2 +15 -0 JBossCache/src/org/jboss/cache/CacheListener.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CacheListener.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/CacheListener.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- CacheListener.java 21 Jun 2006 11:17:25 -0000 1.1
+++ CacheListener.java 18 Jul 2006 10:50:46 -0000 1.2
@@ -82,6 +82,20 @@
void nodeLoaded(Fqn fqn, boolean pre, Map data);
/**
+ * Called when a {@link Node} is activated.
+ * @param fqn
+ * @param pre
+ */
+ void nodeActivated(Fqn fqn, boolean pre);
+
+ /**
+ * Called when a {@link Node} is passivated.
+ * @param fqn
+ * @param pre
+ */
+ void nodePassivated(Fqn fqn, boolean pre);
+
+ /**
* Called when the {@link Cache} is started.
* @param cache
*/
@@ -99,4 +113,5 @@
* @param new_view
*/
void viewChange(View new_view); // might be MergeView after merging
+
}
1.2 +9 -13 JBossCache/src/org/jboss/cache/CacheLoader.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CacheLoader.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/CacheLoader.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- CacheLoader.java 21 Jun 2006 11:17:25 -0000 1.1
+++ CacheLoader.java 18 Jul 2006 10:50:46 -0000 1.2
@@ -62,8 +62,7 @@
* @return Set<String> a set of children. Returns null if no children nodes are
* present, or the parent is not present
*/
- //Set<String> getChildrenNames(Fqn fqn) throws Exception;
- Set getChildrenNames(Fqn fqn) throws Exception;
+ Set<String> getChildrenNames(Fqn fqn) throws Exception;
/**
* Returns all keys and values from the persistent store, given a fully qualified name.
@@ -105,17 +104,13 @@
*/
void put(Fqn name, Map attributes) throws Exception;
-
-
/**
* Applies all modifications to the backend store.
* Changes may be applied in a single operation.
*
* @param modifications A List<Modification> of modifications
*/
- //void put(List<Modification> modifications) throws Exception;
- void put(List modifications) throws Exception;
-
+ void put(List<Modification> modifications) throws Exception;
/**
* Removes the given key and value from the attributes of the given node.
@@ -197,6 +192,7 @@
* @param state state to store
*/
void storeEntireState(byte[] state) throws Exception;
+
/**
* Fetch a portion of the state for this cache from secondary storage
* (disk, database) and return it as a byte buffer.
1.2 +9 -4 JBossCache/src/org/jboss/cache/CacheSPI.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CacheSPI.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/CacheSPI.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- CacheSPI.java 21 Jun 2006 11:17:25 -0000 1.1
+++ CacheSPI.java 18 Jul 2006 10:50:46 -0000 1.2
@@ -10,7 +10,9 @@
import org.jboss.cache.config.Configuration;
import org.jboss.cache.interceptors.Interceptor;
import org.jboss.cache.loader.CacheLoader;
+import org.jgroups.Address;
+import javax.management.ObjectName;
import java.util.List;
/**
@@ -33,8 +35,7 @@
*
* @return an immutable {@link List} of {@link Interceptor}s configured for this cache.
*/
- //List<Interceptor> getInterceptorChain();
- List getInterceptorChain();
+ List<Interceptor> getInterceptorChain();
/**
* Retrieves the configured {@link CacheLoader}. If more than one {@link CacheLoader} is configured, this method
@@ -65,8 +66,7 @@
*
* @return a {@link List} of members in the cluster. Null if running in local mode.
*/
- //List<Address> getMembers();
- List getMembers();
+ List<Address> getMembers();
/**
*
@@ -95,4 +95,9 @@
// everything that is not already represented by Cache
// that is used by either an interceptor, or eviction policy
// should be added to this interface, provided they are public.
+
+ /**
+ * Gets the service name if this is registered in the MBean server.
+ */
+ ObjectName getServiceName();
}
1.6 +25 -38 JBossCache/src/org/jboss/cache/ConsoleListener.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ConsoleListener.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/ConsoleListener.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- ConsoleListener.java 2 Sep 2005 18:32:41 -0000 1.5
+++ ConsoleListener.java 18 Jul 2006 10:50:46 -0000 1.6
@@ -4,6 +4,7 @@
import java.util.Iterator;
import java.util.Set;
+import java.util.Map;
/**
* This class provides a non-graphical view of <em>JBossCache</em> replication
@@ -18,7 +19,7 @@
*
* @author Jimmy Wilson 12-2004
*/
-public class ConsoleListener extends AbstractTreeCacheListener
+public class ConsoleListener implements CacheListener
{
private TreeCache _cache;
private boolean _startCache;
@@ -106,37 +107,27 @@
* TreeCacheListener implementation.
*/
- public void cacheStarted(TreeCache cache)
+ public void cacheStarted(CacheSPI cache)
{
printEvent("Cache started.");
}
- public void cacheStopped(TreeCache cache)
+ public void cacheStopped(CacheSPI cache)
{
printEvent("Cache stopped.");
}
- public void nodeCreated(Fqn fqn)
+ public void nodeCreated(Fqn fqn, boolean pre, boolean isLocal)
{
- printNode(fqn, "created");
+ if (pre) printNode(fqn, "created");
}
- public void nodeEvicted(Fqn fqn)
+ public void nodeLoaded(Fqn fqn, boolean pre, Map data)
{
- printEvent("DataNode evicted: " + fqn);
- }
-
- public void nodeLoaded(Fqn fqn)
- {
- printNode(fqn, "loaded");
- }
-
- public void nodeModified(Fqn fqn)
- {
- printNode(fqn, "modified");
+ if (pre) printNode(fqn, "loaded");
}
- public void nodeModify(Fqn fqn, boolean pre, boolean isLocal)
+ public void nodeModified(Fqn fqn, boolean pre, boolean isLocal, Map data)
{
if(pre)
printEvent("DataNode about to be modified: " + fqn);
@@ -144,14 +135,19 @@
printEvent("DataNode modified: " + fqn);
}
- public void nodeRemoved(Fqn fqn)
+ public void nodeRemoved(Fqn fqn, boolean pre, boolean isLocal, Map data)
{
+ if (pre) {
+ printEvent("DataNode about to be removed: " + fqn);
+ } else {
printEvent("DataNode removed: " + fqn);
}
- public void nodeVisited(Fqn fqn)
+ }
+
+ public void nodeVisited(Fqn fqn, boolean pre)
{
- printEvent("DataNode visited: " + fqn);
+ if (pre) printEvent("DataNode visited: " + fqn);
}
public void viewChange(View new_view)
@@ -159,7 +155,7 @@
printEvent("View change: " + new_view);
}
- public void nodeEvict(Fqn fqn, boolean pre)
+ public void nodeEvicted(Fqn fqn, boolean pre, boolean isLocal)
{
if (pre) {
printEvent("DataNode about to be evicted: " + fqn);
@@ -168,16 +164,7 @@
}
}
- public void nodeRemove(Fqn fqn, boolean pre, boolean isLocal)
- {
- if (pre) {
- printEvent("DataNode about to be removed: " + fqn);
- } else {
- printEvent("DataNode removed: " + fqn);
- }
- }
-
- public void nodeActivate(Fqn fqn, boolean pre)
+ public void nodeActivated(Fqn fqn, boolean pre)
{
if (pre) {
printEvent("DataNode about to be activated: " + fqn);
@@ -186,7 +173,7 @@
}
}
- public void nodePassivate(Fqn fqn, boolean pre)
+ public void nodePassivated(Fqn fqn, boolean pre)
{
if (pre) {
printEvent("DataNode about to be evicted: " + fqn);
1.41 +1 -2 JBossCache/src/org/jboss/cache/Node.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Node.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/Node.java,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -b -r1.40 -r1.41
--- Node.java 21 Jun 2006 11:17:25 -0000 1.40
+++ Node.java 18 Jul 2006 10:50:46 -0000 1.41
@@ -32,8 +32,7 @@
*
* @return an immutable {@link Collection} of child nodes. Empty {@link Collection} if there aren't any children.
*/
- //Collection<Node> getChildren();
- Collection getChildren();
+ Collection<Node> getChildren();
/**
* @return a {@link Map} containing the data in this {@link Node}. If there is no data, an empty {@link Map} is returned. The {@link Map} returned is always immutable.
1.6 +15 -14 JBossCache/src/org/jboss/cache/PropertyConfigurator.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PropertyConfigurator.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/PropertyConfigurator.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- PropertyConfigurator.java 10 Jan 2006 12:55:14 -0000 1.5
+++ PropertyConfigurator.java 18 Jul 2006 10:50:46 -0000 1.6
@@ -6,6 +6,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.util.propertyeditor.PropertyEditors;
+import org.jboss.cache.config.ConfigurationException;
import org.w3c.dom.*;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
@@ -71,7 +72,7 @@
}
}
- protected Element loadDocument(String location) throws ConfigureException {
+ protected Element loadDocument(String location) throws ConfigurationException {
URL url=null;
try {
url=new URL("file", "", 80, location); // Use for Main
@@ -90,7 +91,7 @@
return null;
}
- protected Element loadDocument(InputStream is) throws ConfigureException {
+ protected Element loadDocument(InputStream is) throws ConfigurationException {
Document doc=null;
try {
InputSource xmlInp=new InputSource(is);
@@ -117,14 +118,14 @@
return null;
}
- protected Element getMBeanElement(Element root) throws ConfigureException {
+ protected Element getMBeanElement(Element root) throws ConfigurationException {
// This is following JBoss convention.
NodeList list=root.getElementsByTagName(ROOT);
if(list == null)
- throw new ConfigureException("Can't find " + ROOT + " tag");
+ throw new ConfigurationException("Can't find " + ROOT + " tag");
if(list.getLength() > 1)
- throw new ConfigureException("Has multiple " + ROOT + " tag");
+ throw new ConfigurationException("Has multiple " + ROOT + " tag");
Node node=list.item(0);
Element element=null;
@@ -132,7 +133,7 @@
element=(Element)node;
}
else {
- throw new ConfigureException("Can't find " + ROOT + " element");
+ throw new ConfigurationException("Can't find " + ROOT + " element");
}
return element;
}
@@ -144,7 +145,7 @@
* @param configFile xml file name that exists in the class path.
* @throws ConfigureException when the configuration attempt fails.
*/
- public void configure(Object objToConfigure, String configFile) throws ConfigureException {
+ public void configure(Object objToConfigure, String configFile) throws ConfigurationException {
// step x. load document
ClassLoader cl=Thread.currentThread().getContextClassLoader();
InputStream is=cl.getResourceAsStream(configFile);
@@ -157,7 +158,7 @@
}
}
if(is == null)
- throw new ConfigureException("could not find resource " + configFile);
+ throw new ConfigurationException("could not find resource " + configFile);
configure(objToConfigure, is);
}
@@ -168,11 +169,11 @@
* @param is InputStream for the configuration xml file.
* @throws ConfigureException when the configuration attempt fails.
*/
- public void configure(Object objToConfigure, InputStream is) throws ConfigureException {
+ public void configure(Object objToConfigure, InputStream is) throws ConfigurationException {
objToConfigure_=objToConfigure;
if(is == null)
- throw new ConfigureException("input stream is null for property xml");
+ throw new ConfigurationException("input stream is null for property xml");
Element root=loadDocument(is);
Element mbeanElement=getMBeanElement(root);
@@ -217,7 +218,7 @@
}
catch(Exception ex) {
ex.printStackTrace();
- throw new ConfigureException("configure(): can't invoke " + methodName + " to configure " +
+ throw new ConfigurationException("configure(): can't invoke " + methodName + " to configure " +
"TreeCache properties. Exception: " + ex);
}
}
@@ -232,7 +233,7 @@
method=methods[i];
Class[] clz=method.getParameterTypes(); // size should be 1
if(clz.length != 1)
- throw new ConfigureException("Parameter size of " + methodName +
+ throw new ConfigurationException("Parameter size of " + methodName +
" is not 1 but " + clz.length);
Class classParam=clz[0];
@@ -242,7 +243,7 @@
if(editor == null) {
String str="Could not find PropertyEditor for type class " +
classParam;
- throw new ConfigureException(str);
+ throw new ConfigurationException(str);
}
if(valueObj != null) { // means there is a sub element
@@ -262,7 +263,7 @@
break;
}
catch(Exception ex) {
- throw new ConfigureException("can't invoke " + methodName + " to configure TreeCache", ex);
+ throw new ConfigurationException("can't invoke " + methodName + " to configure TreeCache", ex);
}
}
}
1.2 +9 -5 JBossCache/src/org/jboss/cache/Region.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Region.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/Region.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- Region.java 21 Jun 2006 11:17:25 -0000 1.1
+++ Region.java 18 Jul 2006 10:50:46 -0000 1.2
@@ -8,9 +8,11 @@
import org.w3c.dom.Element;
import org.jboss.cache.eviction.EvictionPolicyConfig;
+import org.jboss.cache.marshall.RegionNameConflictException;
+import org.jboss.cache.marshall.RegionNotFoundException;
/**
- * //TODO: MANIK: Javadoc this class
+ * Represents a section of the cache, and characteristics such as class loading and activaton can be applied to regions.
*
* @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
*/
@@ -21,25 +23,25 @@
* @param fqn
* @param classLoader
*/
- void registerContextClassLoader(ClassLoader classLoader);
+ void registerContextClassLoader(ClassLoader classLoader) throws RegionNameConflictException;
/**
* Unregisters any specific {@link ClassLoader}s from a region.
* @param fqn
*/
- void unregisterContextClassLoader();
+ void unregisterContextClassLoader() throws RegionNotFoundException;
/**
* Activates a region for replication (by default, the entire cache is activated)
* @param fqn
*/
- void activate();
+ void activate() throws RegionNameConflictException;
/**
* Deactivates a region from being replicated.
* @param fqn
*/
- void deactivate();
+ void deactivate() throws RegionNameConflictException;
boolean isActive();
@@ -57,4 +59,6 @@
void setEvictionPolicy(EvictionPolicyConfig evictionPolicyConfig);
EvictionPolicyConfig getEvictionPolicyConfig();
+
+ Fqn getFqn();
}
1.199 +82 -99 JBossCache/src/org/jboss/cache/TreeCache.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TreeCache.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/TreeCache.java,v
retrieving revision 1.198
retrieving revision 1.199
diff -u -b -r1.198 -r1.199
--- TreeCache.java 22 Jun 2006 11:12:02 -0000 1.198
+++ TreeCache.java 18 Jul 2006 10:50:46 -0000 1.199
@@ -79,11 +79,11 @@
* @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
* @author Brian Stansberry
* @author Daniel Huang (dhuang at jboss.org)
- * @version $Id: TreeCache.java,v 1.198 2006/06/22 11:12:02 msurtani Exp $
+ * @version $Id: TreeCache.java,v 1.199 2006/07/18 10:50:46 msurtani Exp $
* <p/>
* @see <a href="http://labs.jboss.com/portal/jbosscache/docs">JBossCache doc</a>
*/
-public class TreeCache extends ServiceMBeanSupport implements TreeCacheMBean, Cloneable, MembershipListener
+public class TreeCache extends ServiceMBeanSupport implements Cloneable, MembershipListener, TreeCacheMBean
{
private static final String CREATE_MUX_CHANNEL = "createMultiplexerChannel";
private static final String[] MUX_TYPES = {"java.lang.String", "java.lang.String"};
@@ -106,7 +106,7 @@
*
* @see #addTreeCacheListener
*/
- private final Set listeners = new CopyOnWriteArraySet();
+ private final Set<CacheListener> listeners = new CopyOnWriteArraySet();
// calling iterator on a ConcurrentHashMap is expensive due to synchronization - same problem
// with calling isEmpty so hasListeners is an optimization to indicate whether or not listeners
@@ -121,7 +121,7 @@
// iterating through ConcurrentHashMap - eviction listener is always there (or almost always)
// and there are less frequently other listeners so optimization is justified
//
- TreeCacheListener evictionPolicyListener = null;
+ CacheListener evictionPolicyListener = null;
final static Object NULL = new Object();
@@ -1240,7 +1240,7 @@
/**
* Sets the eviction listener.
*/
- public void setEvictionListener(TreeCacheListener listener)
+ public void setEvictionListener(CacheListener listener)
{
evictionPolicyListener = listener;
}
@@ -1248,7 +1248,7 @@
/**
* Adds a tree cache listener.
*/
- public void addTreeCacheListener(TreeCacheListener listener)
+ public void addTreeCacheListener(CacheListener listener)
{
// synchronize on listenrs just to
// ensure hasListeners is set correctly
@@ -1264,7 +1264,7 @@
/**
* Removes a tree cache listener.
*/
- public void removeTreeCacheListener(TreeCacheListener listener)
+ public void removeTreeCacheListener(CacheListener listener)
{
// synchronize on listenrs just to
// ensure hasListeners is set correctly
@@ -1280,9 +1280,9 @@
/**
* Returns a collection containing the listeners of this tree cache.
*/
- public Collection getTreeCacheListeners()
+ public Set getTreeCacheListeners()
{
- return Collections.unmodifiableCollection(listeners);
+ return Collections.unmodifiableSet(listeners);
}
/* --------------------------- MBeanSupport ------------------------- */
@@ -5664,12 +5664,14 @@
{
if (evictionPolicyListener != null)
{
- evictionPolicyListener.nodeCreated(fqn);
+ evictionPolicyListener.nodeCreated(fqn, true, true);
}
if (hasListeners)
{
- for (Iterator it = listeners.iterator(); it.hasNext();)
- ((TreeCacheListener) it.next()).nodeCreated(fqn);
+ for (CacheListener listener : listeners)
+ {
+ listener.nodeCreated(fqn, true, true);
+ }
}
}
@@ -5680,12 +5682,14 @@
{
if (evictionPolicyListener != null)
{
- evictionPolicyListener.nodeLoaded(fqn);
+ evictionPolicyListener.nodeLoaded(fqn, true, Collections.EMPTY_MAP);
}
if (hasListeners)
{
- for (Iterator it = listeners.iterator(); it.hasNext();)
- ((TreeCacheListener) it.next()).nodeLoaded(fqn);
+ for (CacheListener listener : listeners)
+ {
+ listener.nodeLoaded(fqn, true, Collections.EMPTY_MAP);
+ }
}
}
@@ -5696,20 +5700,13 @@
{
if (evictionPolicyListener != null)
{
- if (evictionPolicyListener instanceof ExtendedTreeCacheListener)
- {
- ((ExtendedTreeCacheListener) evictionPolicyListener).nodeActivate(fqn, pre);
- }
+ evictionPolicyListener.nodeActivated(fqn, pre);
}
if (hasListeners)
{
- for (Iterator it = listeners.iterator(); it.hasNext();)
- {
- Object listener = it.next();
- if (listener instanceof ExtendedTreeCacheListener)
+ for (CacheListener listener : listeners)
{
- ((ExtendedTreeCacheListener) listener).nodeActivate(fqn, pre);
- }
+ listener.nodeActivated(fqn, pre);
}
}
}
@@ -5721,20 +5718,13 @@
{
if (evictionPolicyListener != null)
{
- if (evictionPolicyListener instanceof ExtendedTreeCacheListener)
- {
- ((ExtendedTreeCacheListener) evictionPolicyListener).nodePassivate(fqn, pre);
- }
+ evictionPolicyListener.nodePassivated(fqn, pre);
}
if (hasListeners)
{
- for (Iterator it = listeners.iterator(); it.hasNext();)
+ for (CacheListener listener : listeners)
{
- Object listener = it.next();
- if (listener instanceof ExtendedTreeCacheListener)
- {
- ((ExtendedTreeCacheListener) listener).nodePassivate(fqn, pre);
- }
+ listener.nodePassivated(fqn, pre);
}
}
}
@@ -5743,20 +5733,13 @@
{
if (evictionPolicyListener != null)
{
- if (evictionPolicyListener instanceof ExtendedTreeCacheListener)
- {
- ((ExtendedTreeCacheListener) evictionPolicyListener).nodeRemove(fqn, pre, getInvocationContext().isOriginLocal());
- }
+ evictionPolicyListener.nodeRemoved(fqn, pre, getInvocationContext().isOriginLocal(), Collections.EMPTY_MAP);
}
if (hasListeners)
{
- for (Iterator it = listeners.iterator(); it.hasNext();)
+ for (CacheListener listener : listeners)
{
- Object listener = it.next();
- if (listener instanceof ExtendedTreeCacheListener)
- {
- ((ExtendedTreeCacheListener) listener).nodeRemove(fqn, pre, getInvocationContext().isOriginLocal());
- }
+ listener.nodeRemoved(fqn, pre, getInvocationContext().isOriginLocal(), Collections.EMPTY_MAP);
}
}
}
@@ -5765,12 +5748,14 @@
{
if (evictionPolicyListener != null)
{
- evictionPolicyListener.nodeRemoved(fqn);
+ evictionPolicyListener.nodeRemoved(fqn, false, getInvocationContext().isOriginLocal(), Collections.EMPTY_MAP);
}
if (hasListeners)
{
- for (Iterator it = listeners.iterator(); it.hasNext();)
- ((TreeCacheListener) it.next()).nodeRemoved(fqn);
+ for (CacheListener listener : listeners)
+ {
+ listener.nodeRemoved(fqn, false, getInvocationContext().isOriginLocal(), Collections.EMPTY_MAP);
+ }
}
}
@@ -5800,12 +5785,14 @@
{
if (evictionPolicyListener != null)
{
- evictionPolicyListener.nodeEvicted(fqn);
+ evictionPolicyListener.nodeEvicted(fqn, true, true);
}
if (hasListeners)
{
- for (Iterator it = listeners.iterator(); it.hasNext();)
- ((TreeCacheListener) it.next()).nodeEvicted(fqn);
+ for (CacheListener listener : listeners)
+ {
+ listener.nodeEvicted(fqn, true, true);
+ }
}
}
@@ -5814,48 +5801,33 @@
{
if (evictionPolicyListener != null)
{
- if (evictionPolicyListener instanceof ExtendedTreeCacheListener)
- {
- ((ExtendedTreeCacheListener) evictionPolicyListener).nodeModify(fqn, pre, getInvocationContext().isOriginLocal());
- }
+ evictionPolicyListener.nodeModified(fqn, pre, getInvocationContext().isOriginLocal(), null);
}
if (hasListeners)
{
- for (Iterator it = listeners.iterator(); it.hasNext();)
- {
- Object listener = it.next();
- if (listener instanceof ExtendedTreeCacheListener)
+ for (CacheListener listener : listeners)
{
- ((ExtendedTreeCacheListener) listener).nodeModify(fqn, pre, getInvocationContext().isOriginLocal());
- }
+ listener.nodeModified(fqn, pre, getInvocationContext().isOriginLocal(), null);
}
}
}
protected void notifyNodeModified(Fqn fqn)
{
- if (evictionPolicyListener != null)
- {
- evictionPolicyListener.nodeModified(fqn);
- }
- if (hasListeners)
- {
- for (Iterator it = listeners.iterator(); it.hasNext();)
- ((TreeCacheListener) it.next()).nodeModified(fqn);
- }
-
}
protected void notifyNodeVisited(Fqn fqn)
{
if (evictionPolicyListener != null)
{
- evictionPolicyListener.nodeVisited(fqn);
+ evictionPolicyListener.nodeVisited(fqn, true);
}
if (hasListeners)
{
- for (Iterator it = listeners.iterator(); it.hasNext();)
- ((TreeCacheListener) it.next()).nodeVisited(fqn);
+ for (CacheListener listener : listeners)
+ {
+ listener.nodeVisited(fqn, true);
+ }
}
}
@@ -5863,25 +5835,34 @@
{
if (evictionPolicyListener != null)
{
- evictionPolicyListener.cacheStarted(this);
+ evictionPolicyListener.cacheStarted(getCacheSPI());
}
if (hasListeners)
{
- for (Iterator it = listeners.iterator(); it.hasNext();)
- ((TreeCacheListener) it.next()).cacheStarted(this);
+ for (CacheListener listener : listeners)
+ {
+ listener.cacheStarted(getCacheSPI());
+ }
+ }
}
+
+ protected CacheSPI getCacheSPI()
+ {
+ throw new UnsupportedOperationException("IMPLEMENT ME!!");
}
protected void notifyCacheStopped()
{
if (evictionPolicyListener != null)
{
- evictionPolicyListener.cacheStopped(this);
+ evictionPolicyListener.cacheStopped(getCacheSPI());
}
if (hasListeners)
{
- for (Iterator it = listeners.iterator(); it.hasNext();)
- ((TreeCacheListener) it.next()).cacheStopped(this);
+ for (CacheListener listener : listeners)
+ {
+ listener.cacheStopped(getCacheSPI());
+ }
}
}
@@ -5893,8 +5874,10 @@
}
if (hasListeners)
{
- for (Iterator it = listeners.iterator(); it.hasNext();)
- ((TreeCacheListener) it.next()).viewChange(v);
+ for (CacheListener listener : listeners)
+ {
+ listener.viewChange(v);
+ }
}
}
1.37 +3 -3 JBossCache/src/org/jboss/cache/TreeCacheMBean.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TreeCacheMBean.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/TreeCacheMBean.java,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -b -r1.36 -r1.37
--- TreeCacheMBean.java 21 Jun 2006 11:10:58 -0000 1.36
+++ TreeCacheMBean.java 18 Jul 2006 10:50:46 -0000 1.37
@@ -26,7 +26,7 @@
*
* @author Bela Ban
* @author Ben Wang
- * @version $Id: TreeCacheMBean.java,v 1.36 2006/06/21 11:10:58 msurtani Exp $
+ * @version $Id: TreeCacheMBean.java,v 1.37 2006/07/18 10:50:46 msurtani Exp $
*/
public interface TreeCacheMBean extends ServiceMBean
{
@@ -399,9 +399,9 @@
*/
void fetchState(long timeout) throws org.jgroups.ChannelClosedException, org.jgroups.ChannelNotConnectedException;
- void addTreeCacheListener(TreeCacheListener listener);
+ void addTreeCacheListener(CacheListener listener);
- void removeTreeCacheListener(TreeCacheListener listener);
+ void removeTreeCacheListener(CacheListener listener);
void createService() throws Exception;
1.11 +52 -52 JBossCache/src/org/jboss/cache/TreeCacheView.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TreeCacheView.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/TreeCacheView.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- TreeCacheView.java 13 Apr 2006 00:19:31 -0000 1.10
+++ TreeCacheView.java 18 Jul 2006 10:50:46 -0000 1.11
@@ -65,9 +65,8 @@
* The view itself caches only the nodes, but doesn't cache any of the data (HashMap) associated with it. When
* data needs to be displayed, the underlying tree will be accessed directly.
*
- * @version $Revision: 1.10 $
+ * @version $Revision: 1.11 $
* @author<a href="mailto:bela at jboss.org">Bela Ban</a> March 27 2003
- * @jmx.mbean extends="org.jboss.system.ServiceMBean"
*/
public class TreeCacheView extends ServiceMBeanSupport implements TreeCacheViewMBean {
/**
@@ -88,18 +87,10 @@
}
- /**
- * @throws Exception
- * @jmx.managed-operation
- */
public void create() throws Exception {
super.create();
}
- /**
- * @throws Exception
- * @jmx.managed-operation
- */
public void start() throws Exception {
super.start();
if(gui == null) {
@@ -108,9 +99,6 @@
}
}
- /**
- * @jmx.managed-operation
- */
public void stop() {
super.stop();
if(gui != null) {
@@ -121,16 +109,11 @@
}
/**
- * @jmx.managed-operation
*/
public void destroy() {
super.destroy();
}
- /**
- * @return
- * @jmx.managed-attribute
- */
public String getCacheService() {
return cache_service != null ? cache_service.toString() : null;
}
@@ -138,7 +121,6 @@
/**
* @param cache_service
* @throws Exception
- * @jmx.managed-attribute
*/
public void setCacheService(String cache_service) throws Exception {
init(cache_service);
@@ -323,13 +305,13 @@
}
- public static class MyListener extends AbstractTreeCacheListener {}
+ public static class MyListener extends AbstractCacheListener {}
}
-class TreeCacheGui extends JFrame implements WindowListener, TreeCacheListener,
+class TreeCacheGui extends JFrame implements WindowListener, CacheListener,
TreeSelectionListener, TableModelListener {
private static final long serialVersionUID = 8576324868563647538L;
TreeCacheMBean cache;
@@ -507,7 +489,9 @@
/* ------------------ ReplicatedTree.ReplicatedTreeListener interface ------------ */
- public void nodeCreated(Fqn fqn) {
+ public void nodeCreated(Fqn fqn, boolean pre, boolean isLocal) {
+ if (!pre)
+ {
MyNode n, p;
n=root.add(fqn.toString());
@@ -517,8 +501,12 @@
jtree.scrollPathToVisible(new TreePath(n.getPath()));
}
}
+ }
- public void nodeRemoved(Fqn fqn) {
+ public void nodeRemoved(Fqn fqn, boolean pre, boolean isLocal, Map data)
+ {
+ if (!pre)
+ {
MyNode n;
TreeNode par;
@@ -530,16 +518,31 @@
tree_model.reload(par);
}
}
+ }
- public void nodeLoaded(Fqn fqn) {
- nodeCreated(fqn);
+ public void nodeVisited(Fqn fqn, boolean pre)
+ {
}
- public void nodeEvicted(Fqn fqn) {
- nodeRemoved(fqn);
+ public void nodeLoaded(Fqn fqn, boolean pre, Map data)
+ {
+ nodeCreated(fqn, pre, false);
+ }
+
+ public void nodeActivated(Fqn fqn, boolean pre)
+ {
+ }
+
+ public void nodePassivated(Fqn fqn, boolean pre)
+ {
+ }
+
+ public void nodeEvicted(Fqn fqn, boolean pre, boolean isLocal)
+ {
+ nodeRemoved(fqn, pre, isLocal, null);
}
- public void nodeModified(Fqn fqn) {
+ public void nodeModified(Fqn fqn, boolean pre, boolean isLocal, Map data) {
// Map data;
//data=getData(fqn);
//populateTable(data); REVISIT
@@ -548,19 +551,16 @@
*/
}
- public void nodeVisited(Fqn fqn)
+ public void nodeVisited(Fqn fqn, boolean pre, boolean isLocal)
{
- //To change body of implemented methods use File | Settings | File Templates.
}
- public void cacheStarted(TreeCache cache)
+ public void cacheStarted(CacheSPI cache)
{
- //To change body of implemented methods use File | Settings | File Templates.
}
- public void cacheStopped(TreeCache cache)
+ public void cacheStopped(CacheSPI cache)
{
- //To change body of implemented methods use File | Settings | File Templates.
}
public void viewChange(final View new_view) {
1.11 +95 -93 JBossCache/src/org/jboss/cache/TreeCacheView2.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TreeCacheView2.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/TreeCacheView2.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- TreeCacheView2.java 18 May 2006 15:46:18 -0000 1.10
+++ TreeCacheView2.java 18 Jul 2006 10:50:46 -0000 1.11
@@ -8,33 +8,13 @@
package org.jboss.cache;
-import java.awt.BorderLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-import java.io.File;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.Vector;
+import bsh.Interpreter;
+import bsh.util.JConsole;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jgroups.View;
-import javax.swing.AbstractAction;
-import javax.swing.JFrame;
-import javax.swing.JMenu;
-import javax.swing.JMenuBar;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JPopupMenu;
-import javax.swing.JScrollPane;
-import javax.swing.JSplitPane;
-import javax.swing.JTable;
-import javax.swing.JTextField;
-import javax.swing.JTree;
+import javax.swing.*;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.event.TreeSelectionEvent;
@@ -48,13 +28,20 @@
import javax.swing.tree.TreeSelectionModel;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jgroups.View;
-
-import bsh.Interpreter;
-import bsh.util.JConsole;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowListener;
+import java.io.File;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.Vector;
/**
@@ -65,7 +52,7 @@
* The view itself caches only the nodes, but doesn't cache any of the data (HashMap) associated with it. When
* data needs to be displayed, the underlying tree will be accessed directly.
*
- * @version $Revision: 1.10 $
+ * @version $Revision: 1.11 $
*/
public class TreeCacheView2 {
static TreeCacheGui2 gui_=null;
@@ -183,7 +170,7 @@
}
}
-class TreeCacheGui2 extends JFrame implements WindowListener, TreeCacheListener,
+class TreeCacheGui2 extends JFrame implements WindowListener, CacheListener,
TreeSelectionListener, TableModelListener {
private static final long serialVersionUID = -1242167331988194987L;
@@ -412,7 +399,9 @@
/* ------------------ ReplicatedTree.ReplicatedTreeListener interface ------------ */
- public void nodeCreated(Fqn fqn) {
+ public void nodeCreated(Fqn fqn, boolean pre, boolean isLocal)
+ {
+ if (!pre) {
MyNode n, p;
n=root.add(fqn.toString());
@@ -420,10 +409,24 @@
p=(MyNode)n.getParent();
tree_model.reload(p);
jtree.scrollPathToVisible(new TreePath(n.getPath()));
+ } }
+
}
+
+ public void nodeModified(Fqn fqn, boolean pre, boolean isLocal, Map data)
+ {
+ // Map data;
+ //data=getData(fqn);
+ //populateTable(data); REVISIT
+ /*
+ poulateTable is the current table being shown is the info of the node. that is modified.
+ */
}
- public void nodeRemoved(Fqn fqn) {
+ public void nodeRemoved(Fqn fqn, boolean pre, boolean isLocal, Map data)
+ {
+ if (!pre)
+ {
MyNode n;
TreeNode par;
@@ -436,37 +439,36 @@
}
}
+ }
- public void nodeLoaded(Fqn fqn) {
- nodeCreated(fqn);
+ public void nodeVisited(Fqn fqn, boolean pre)
+ {
}
- public void nodeEvicted(Fqn fqn) {
- nodeRemoved(fqn);
+ public void nodeEvicted(Fqn fqn, boolean pre, boolean isLocal)
+ {
+ nodeRemoved(fqn, pre, isLocal, null);
}
- public void nodeModified(Fqn fqn) {
- // Map data;
- //data=getData(fqn);
- //populateTable(data); REVISIT
- /*
- poulateTable is the current table being shown is the info of the node. that is modified.
- */
+ public void nodeLoaded(Fqn fqn, boolean pre, Map data)
+ {
+ nodeCreated(fqn, pre, true);
+ }
+
+ public void nodeActivated(Fqn fqn, boolean pre)
+ {
}
- public void nodeVisited(Fqn fqn)
+ public void nodePassivated(Fqn fqn, boolean pre)
{
- //To change body of implemented methods use File | Settings | File Templates.
}
- public void cacheStarted(TreeCache cache)
+ public void cacheStarted(CacheSPI cache)
{
- //To change body of implemented methods use File | Settings | File Templates.
}
- public void cacheStopped(TreeCache cache)
+ public void cacheStopped(CacheSPI cache)
{
- //To change body of implemented methods use File | Settings | File Templates.
}
public void viewChange(final View new_view) {
1.1 date: 2006/07/18 10:50:46; author: msurtani; state: Exp;JBossCache/src/org/jboss/cache/AbstractCacheListener.java
Index: AbstractCacheListener.java
===================================================================
/*
* JBoss, Home of Professional Open Source
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.cache;
import org.jgroups.View;
import java.util.Map;
/**
* An abstract implementation of {@link CacheListener} with no-op methods. Subclass this as a convenience to
* implementing all the methods in {@link CacheListener}.
*
* @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
* @since 2.0.0
*/
public abstract class AbstractCacheListener implements CacheListener
{
public void nodeCreated(Fqn fqn, boolean pre, boolean isLocal)
{
}
public void nodeModified(Fqn fqn, boolean pre, boolean isLocal, Map data)
{
}
public void nodeRemoved(Fqn fqn, boolean pre, boolean isLocal, Map data)
{
}
public void nodeVisited(Fqn fqn, boolean pre)
{
}
public void nodeEvicted(Fqn fqn, boolean pre, boolean isLocal)
{
}
public void nodeLoaded(Fqn fqn, boolean pre, Map data)
{
}
public void nodeActivated(Fqn fqn, boolean pre)
{
}
public void nodePassivated(Fqn fqn, boolean pre)
{
}
public void cacheStarted(CacheSPI cache)
{
}
public void cacheStopped(CacheSPI cache)
{
}
public void viewChange(View new_view) // might be MergeView after merging
{
}
}
1.1 date: 2006/07/18 10:50:46; author: msurtani; state: Exp;JBossCache/src/org/jboss/cache/RegionImpl.java
Index: RegionImpl.java
===================================================================
/*
* JBoss, Home of Professional Open Source
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.cache;
import org.jboss.cache.eviction.EvictionPolicyConfig;
import org.jboss.cache.marshall.RegionNameConflictException;
import org.jboss.cache.marshall.RegionNotFoundException;
import java.util.Map;
import java.util.HashMap;
/**
* Default implementation of a {@link Region}
*
* @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
*/
public class RegionImpl implements Region
{
/**
* A registry of regions that have been defined.
*/
static Map<Fqn,Region> REGIONS_REGISTRY = new HashMap<Fqn, Region>();
TreeCache treeCache;
Fqn fqn;
/**
* Creates a Region from an fqn and registers the region in the region registry.
* @param c
* @param fqn
*/
public RegionImpl(TreeCache c, Fqn fqn)
{
this.treeCache = c;
this.fqn = fqn;
REGIONS_REGISTRY.put(fqn, this);
}
public void registerContextClassLoader(ClassLoader classLoader) throws RegionNameConflictException
{
treeCache.registerClassLoader(fqn.toString(), classLoader);
}
public void unregisterContextClassLoader() throws RegionNotFoundException
{
treeCache.unregisterClassLoader(fqn.toString());
}
public void activate() throws RegionNameConflictException
{
treeCache.activateRegion(fqn.toString());
}
public void deactivate() throws RegionNameConflictException
{
treeCache.inactivateRegion(fqn.toString());
}
public boolean isActive()
{
return getRegion().isActive();
}
private org.jboss.cache.marshall.Region getRegion()
{
return treeCache.getRegionManager().getRegion(fqn);
}
public ClassLoader getClassLoader()
{
return getRegion().getClassLoader();
}
public void setEvictionPolicy(EvictionPolicyConfig evictionPolicyConfig)
{
// TODO: MANIK: HABANERO: Eviction policy config
}
public EvictionPolicyConfig getEvictionPolicyConfig()
{
// TODO: MANIK: HABANERO: Eviction policy config
return null;
}
public Fqn getFqn()
{
return fqn;
}
public String toString()
{
return "RegionImpl{" +
"fqn=" + fqn +
'}';
}
}
1.1 date: 2006/07/18 10:50:46; author: msurtani; state: Exp;JBossCache/src/org/jboss/cache/TreeCacheProxyImpl.java
Index: TreeCacheProxyImpl.java
===================================================================
package org.jboss.cache;/*
* JBoss, Home of Professional Open Source
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.interceptors.Interceptor;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.lock.IdentityLock;
import org.jgroups.Address;
import javax.management.ObjectName;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.HashSet;
import java.util.Collections;
/**
* Implementation of a proxy class that adheres to new 2.0.0 interfaces while maintaining the old 1.x.x
* TreeCache implementation
*
* @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
*/
public class TreeCacheProxyImpl implements CacheSPI, NodeSPI
{
Configuration config;
TreeCache treeCache;
NodeImpl currentNode;
public TreeCacheProxyImpl(TreeCache treeCache, NodeImpl currentNode)
{
this.treeCache = treeCache;
this.currentNode = currentNode;
}
public Configuration getConfiguration()
{
return config;
}
public List<Interceptor> getInterceptorChain()
{
return treeCache.getInterceptors();
}
public CacheLoader getCacheLoader()
{
return treeCache.getCacheLoader();
}
public BuddyManager getBuddyManager()
{
return treeCache.getBuddyManager();
}
public TransactionTable getTransactionTable()
{
return treeCache.getTransactionTable();
}
public Object getLocalAddress()
{
return treeCache.getLocalAddress();
}
public List<Address> getMembers()
{
return treeCache.getMembers();
}
public boolean isCoordinator()
{
return treeCache.isCoordinator();
}
public String getClusterName()
{
return treeCache.getClusterName();
}
public String getVersion()
{
return treeCache.getVersion();
}
public ObjectName getServiceName()
{
return treeCache.getServiceName();
}
public Node getRoot()
{
NodeImpl root = treeCache.get(Fqn.ROOT);
return new TreeCacheProxyImpl(treeCache, root);
}
public void addCacheListener(CacheListener l)
{
treeCache.addTreeCacheListener(l);
}
public void removeCacheListener(CacheListener l)
{
treeCache.removeTreeCacheListener(l);
}
public Set<CacheListener> getCacheListeners()
{
return treeCache.getTreeCacheListeners();
}
public void put(Fqn fqn, Object key, Object value)
{
treeCache.put(fqn, key, value);
}
public void remove(Fqn fqn, Object key)
{
treeCache.remove(fqn, key);
}
public Object get(Fqn fqn, Object key)
{
return treeCache.get(fqn, key);
}
public void evict(Fqn fqn, boolean recursive)
{
if (recursive)
{
NodeImpl n = treeCache.get(fqn);
evictChildren(n);
}
else
{
treeCache.evict(fqn);
}
}
private void evictChildren(NodeImpl n)
{
Map children = n.getChildren();
Iterator childNames = children.keySet().iterator();
while (childNames.hasNext())
{
NodeImpl child = (NodeImpl) children.get(childNames.next());
evictChildren(child);
}
treeCache.evict(n.getFqn());
}
public Region getRegion(Fqn fqn)
{
if (RegionImpl.REGIONS_REGISTRY.containsKey(fqn))
{
return RegionImpl.REGIONS_REGISTRY.get(fqn);
}
else
{
return new RegionImpl(treeCache, fqn);
}
}
public void create() throws Exception
{
treeCache.create();
}
public void start() throws Exception
{
treeCache.start();
}
public void stop()
{
treeCache.stop();
}
public void destroy()
{
treeCache.destroy();
}
public Node getParent()
{
return new TreeCacheProxyImpl(treeCache, (NodeImpl) currentNode.getParent());
}
public Collection<Node> getChildren()
{
Map m = currentNode.getChildren();
Set<Node> children = new HashSet<Node>(m.size());
Iterator i = m.values().iterator();
while (i.hasNext())
children.add(new TreeCacheProxyImpl(treeCache, (NodeImpl) i.next()));
return children;
}
public Map getData()
{
return currentNode.getData();
}
public Set getKeys()
{
return currentNode.getDataKeys();
}
public Fqn getFqn()
{
return currentNode.getFqn();
}
public Node addChild(Fqn f)
{
treeCache.put(new Fqn(currentNode.getFqn(), f), Collections.EMPTY_MAP);
return getChild(f);
}
public void removeChild(Fqn f)
{
treeCache.remove(new Fqn(currentNode.getFqn(), f));
}
public Node getChild(Fqn f)
{
return new TreeCacheProxyImpl(treeCache, (NodeImpl) treeCache.get(currentNode.getFqn(), f));
}
public void put(Object k, Object v)
{
treeCache.put(currentNode.getFqn(), k, v);
}
public void putIfNull(Object k, Object v)
{
if (treeCache.get(currentNode.getFqn(), k) == null) put(k, v);
}
public void put(Map m)
{
treeCache.put(currentNode.getFqn(), m);
}
public void putIfNull(Map m)
{
if (getData() == null || getData().isEmpty()) put(m);
}
public Object get(Object k)
{
return treeCache.get(currentNode.getFqn(), k);
}
public Object remove(Object k)
{
return treeCache.remove(currentNode.getFqn(), k);
}
public void clearData()
{
treeCache.removeData(currentNode.getFqn());
}
public void move(Node newParent)
{
move(currentNode, currentNode.getParent().getFqn(), newParent.getFqn());
}
private void move(NodeImpl node, Fqn oldRoot, Fqn newRoot)
{
// recursive
Iterator i = node.getChildren().values().iterator();
Fqn oldBase = new Fqn(oldRoot, node.getName());
Fqn newBase = new Fqn(newRoot, node.getName());
while (i.hasNext())
{
NodeImpl child = (NodeImpl) i.next();
move(child, node.getFqn(), new Fqn(oldBase, newBase));
}
treeCache.put(newRoot, node.getData());
treeCache.remove(oldRoot);
}
public IdentityLock getLock()
{
return currentNode.getLock();
}
public boolean isLocked()
{
return currentNode.isLocked();
}
public boolean isReadLocked()
{
return currentNode.isReadLocked();
}
public boolean isWriteLocked()
{
return currentNode.isWriteLocked();
}
}
More information about the jboss-cvs-commits
mailing list