[jboss-cvs] JBossAS SVN: r107360 - projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/jndi/ispn.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Aug 3 12:46:44 EDT 2010
Author: pferraro
Date: 2010-08-03 12:46:43 -0400 (Tue, 03 Aug 2010)
New Revision: 107360
Modified:
projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/jndi/ispn/DistributedTreeManager.java
Log:
Inject InfinispanHAPartitionCacheHandler in constructor - instead of setter. Make cacheHandler final.
Don't inject haStub in constructor. This is set via setHAStub() in DetachedNamingService.
TreeCacheFactory should be final.
Modified: projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/jndi/ispn/DistributedTreeManager.java
===================================================================
--- projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/jndi/ispn/DistributedTreeManager.java 2010-08-03 16:44:28 UTC (rev 107359)
+++ projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/jndi/ispn/DistributedTreeManager.java 2010-08-03 16:46:43 UTC (rev 107360)
@@ -69,38 +69,27 @@
private static final String DEFAULT_ROOT = "__HA_JNDI__";
private static final Fqn FQN_ROOT = Fqn.fromString(DEFAULT_ROOT);
- protected volatile TreeCache<String, Binding> m_cache;
- private volatile InfinispanHAPartitionCacheHandler<String, Binding> cacheHandler;
- private final Naming haStub;
- private volatile TreeCacheFactory treeCacheFactory;
+ private final InfinispanHAPartitionCacheHandler<String, Binding> cacheHandler;
+ private final TreeCacheFactory treeCacheFactory;
+
+ private volatile Naming haStub;
+ private volatile TreeCache<String, Binding> cache;
-
- public DistributedTreeManager(Naming haStub)
+ public DistributedTreeManager(InfinispanHAPartitionCacheHandler<String, Binding> cacheHandler)
{
- this.haStub = haStub;
- treeCacheFactory = new DefaultTreeCacheFactory();
+ this(cacheHandler, new DefaultTreeCacheFactory());
}
- public DistributedTreeManager(Naming haStub, TreeCacheFactory factory)
+ public DistributedTreeManager(InfinispanHAPartitionCacheHandler<String, Binding> cacheHandler, TreeCacheFactory factory)
{
- this.haStub = haStub;
+ this.cacheHandler = cacheHandler;
this.treeCacheFactory = factory;
}
- public InfinispanHAPartitionCacheHandler<String, Binding> getCacheHandler()
- {
- return cacheHandler;
- }
-
- public void setCacheHandler(InfinispanHAPartitionCacheHandler<String, Binding> cacheHandler)
- {
- this.cacheHandler = cacheHandler;
- }
-
@Override
public void init()
{
- m_cache = treeCacheFactory.createTreeCache(cacheHandler.getCache());
+ cache = treeCacheFactory.createTreeCache(cacheHandler.getCache());
LOG.debug("initializing HAJNDITreeCache root");
}
@@ -108,7 +97,7 @@
@Override
public void shutdown()
{
- m_cache = null;
+ cache = null;
}
@@ -119,9 +108,9 @@
}
@Override
- public void setHAStub(Naming stub)
+ public void setHAStub(Naming haStub)
{
- // TODO: delete this method from the interface as its ignored (ctor accepts the stub)
+ this.haStub = haStub;
}
// Naming implementation -----------------------------------------
@@ -166,9 +155,9 @@
{
Fqn temp = Fqn.fromRelativeFqn(FQN_ROOT, Fqn.fromString(name.toString()));
// TODO why not jst call remove -- why hasChild first?
- if (this.m_cache.getRoot().hasChild(temp))
+ if (this.cache.getRoot().hasChild(temp))
{
- this.m_cache.removeNode(temp);
+ this.cache.removeNode(temp);
return;
}
}
@@ -198,10 +187,10 @@
try
{
- Object removed = this.m_cache.remove(ctx, key);
+ Object removed = this.cache.remove(ctx, key);
if (removed == null)
{
- if (!this.m_cache.getRoot().hasChild(ctx))
+ if (!this.cache.getRoot().hasChild(ctx))
{
throw new NotContextException(name.getPrefix(size - 1).toString() + " not a context");
}
@@ -236,7 +225,7 @@
// is the name a context?
try
{
- Node<String, Binding> n = this.m_cache.getRoot().getChild(Fqn.fromRelativeFqn(FQN_ROOT, Fqn.fromString(name.toString())));
+ Node<String, Binding> n = this.cache.getRoot().getChild(Fqn.fromRelativeFqn(FQN_ROOT, Fqn.fromString(name.toString())));
if (n != null)
{
Name fullName = (Name) name.clone();
@@ -269,7 +258,7 @@
try
{
- Binding b = this.m_cache.get(ctx, key);
+ Binding b = this.cache.get(ctx, key);
// if key not in cache, return null
return (b != null) ? b.getObject() : null;
@@ -306,7 +295,7 @@
ctx = FQN_ROOT;
}
- boolean exists = this.m_cache.getRoot().hasChild(ctx);
+ boolean exists = this.cache.getRoot().hasChild(ctx);
if (!exists)
{
try
@@ -323,7 +312,7 @@
{
List<NameClassPair> list = new LinkedList<NameClassPair>();
- Node<String, Binding> base = this.m_cache.getRoot().getChild(ctx);
+ Node<String, Binding> base = this.cache.getRoot().getChild(ctx);
if (base != null)
{
for (Binding b: base.getData().values())
@@ -379,7 +368,7 @@
ctx = FQN_ROOT;
}
- boolean exists = this.m_cache.getRoot().hasChild(ctx);
+ boolean exists = this.cache.getRoot().hasChild(ctx);
if (!exists)
{
// not found in global jndi, look in local.
@@ -397,7 +386,7 @@
{
List<Binding> list = new LinkedList<Binding>();
- Node<String, Binding> node = this.m_cache.getRoot().getChild(ctx);
+ Node<String, Binding> node = this.cache.getRoot().getChild(ctx);
if (node != null)
{
Map<String, Binding> data = node.getData();
@@ -451,7 +440,7 @@
String str = name.toString();
Fqn fqn = Fqn.fromString(str);
Fqn ctx = Fqn.fromRelativeFqn(FQN_ROOT, fqn);
- if (this.m_cache.getRoot().hasChild(ctx))
+ if (this.cache.getRoot().hasChild(ctx))
{
throw new NameAlreadyBoundException(str);
}
@@ -470,7 +459,7 @@
pctx = FQN_ROOT;
}
- boolean exists = this.m_cache.getRoot().hasChild(pctx);
+ boolean exists = this.cache.getRoot().hasChild(pctx);
if (!exists)
{
throw new NotContextException(name.getPrefix(size - 1).toString());
@@ -479,7 +468,7 @@
Fqn newf = Fqn.fromRelativeFqn(pctx, Fqn.fromString(newctx));
try
{
- this.m_cache.put(newf, new HashMap<String, Binding>());
+ this.cache.put(newf, new HashMap<String, Binding>());
}
catch (CacheException ce)
{
@@ -518,7 +507,7 @@
ctx = FQN_ROOT;
}
- boolean exists = this.m_cache.getRoot().hasChild(ctx);
+ boolean exists = this.cache.getRoot().hasChild(ctx);
if (!exists)
{
throw new NotContextException(name.getPrefix(size - 1).toString() + " not a context");
@@ -528,13 +517,13 @@
}
if (!rebind)
{
- Node<String, Binding> node = this.m_cache.getRoot().getChild(ctx);
+ Node<String, Binding> node = this.cache.getRoot().getChild(ctx);
if ((node != null) && (node.get(key) != null))
{
throw new NameAlreadyBoundException(key);
}
}
- this.m_cache.put(ctx, key, new Binding(key, className, obj, true));
+ this.cache.put(ctx, key, new Binding(key, className, obj, true));
}
}
More information about the jboss-cvs-commits
mailing list