[jboss-cvs] JBossAS SVN: r108094 - 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
Thu Sep 9 16:24:01 EDT 2010


Author: smarlow at redhat.com
Date: 2010-09-09 16:24:01 -0400 (Thu, 09 Sep 2010)
New Revision: 108094

Modified:
   projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/jndi/ispn/DistributedTreeManager.java
Log:
use infinispan root as hajndi root

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-09-09 20:12:50 UTC (rev 108093)
+++ projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/jndi/ispn/DistributedTreeManager.java	2010-09-09 20:24:01 UTC (rev 108094)
@@ -70,8 +70,7 @@
 {
    private static final Logger LOG = Logger.getLogger(DistributedTreeManager.class);
    private static final NamingParser PARSER = new NamingParser();
-   private static final String DEFAULT_ROOT = "__HA_JNDI__";
-   private static final Fqn FQN_ROOT = Fqn.fromString(DEFAULT_ROOT);
+   private static final Fqn FQN_ROOT = Fqn.root();
 
    private final CacheContainerRegistry registry;
    private final TreeCacheFactory treeCacheFactory;
@@ -200,6 +199,7 @@
       // get the context and key
       Fqn ctx;
       String key = name.get(size - 1);
+      boolean ctxIsRoot = false;
       if (size > 1) // find subcontext to which the key is bound
       {
          String prefix = name.getPrefix(size - 1).toString();
@@ -209,6 +209,7 @@
       else
       {
          ctx = FQN_ROOT;
+         ctxIsRoot = true;
       }
       
       try
@@ -216,7 +217,7 @@
          Object removed = this.cache.remove(ctx, key);
          if (removed == null)
          {
-            if (!this.cache.getRoot().hasChild(ctx))
+            if (! ctxIsRoot && !this.cache.getRoot().hasChild(ctx))
             {
                 throw new NotContextException(name.getPrefix(size - 1).toString() + " not a context");
             }
@@ -479,17 +480,16 @@
          String prefix = name.getPrefix(size - 1).toString();
          Fqn fqn2 = Fqn.fromString(prefix);
          pctx = Fqn.fromRelativeFqn(FQN_ROOT, fqn2);
+         boolean exists = this.cache.getRoot().hasChild(pctx);
+         if (!exists)
+         {
+            throw new NotContextException(name.getPrefix(size - 1).toString());
+         }
       }
       else
       {
          pctx = FQN_ROOT;
       }
-      
-      boolean exists = this.cache.getRoot().hasChild(pctx);
-      if (!exists)
-      {
-         throw new NotContextException(name.getPrefix(size - 1).toString());
-      }
 
       Fqn newf = Fqn.fromRelativeFqn(pctx, Fqn.fromString(newctx));
       try
@@ -510,6 +510,7 @@
       return new NamingContext(null, fullName, this.getHAStub());
    }
 
+
    private void internalBind(Name name, Object obj, String className, boolean rebind) throws NamingException
    {
       if (name.isEmpty())
@@ -522,28 +523,42 @@
       // get the context and key
       Fqn ctx;
       String key = name.get(size - 1);
+      boolean isRootCtx = false;
+
       if (size > 1) // find subcontext to which the key will be added
       {
          String prefix = name.getPrefix(size - 1).toString();
          Fqn fqn = Fqn.fromString(prefix);
          ctx = Fqn.fromRelativeFqn(FQN_ROOT, fqn);
+         boolean exists = this.cache.getRoot().hasChild(ctx);
+         if (!exists)
+         {
+            throw new NotContextException(name.getPrefix(size - 1).toString() + " not a context");
+            // note - NamingServer throws a CannotProceedException if the client attempts to bind
+            //        to a Reference object having an "nns" address.  This implementation simply
+            //        throws the NotContextException that's used when "nns" isn't present.
+         }
+
       }
       else
       {
          ctx = FQN_ROOT;
+         isRootCtx = true;
       }
-   
-      boolean exists = this.cache.getRoot().hasChild(ctx);
-      if (!exists)
+
+
+      if (LOG.isTraceEnabled())
       {
-         throw new NotContextException(name.getPrefix(size - 1).toString() + " not a context");
-         // note - NamingServer throws a CannotProceedException if the client attempts to bind
-         //        to a Reference object having an "nns" address.  This implementation simply
-         //        throws the NotContextException that's used when "nns" isn't present.
+         LOG.trace("internalBind, name=" + name + ", class=" + className + ", ctx=" + ctx);
       }
+
       if (!rebind)
       {
-         Node<String, Binding> node = this.cache.getRoot().getChild(ctx);
+         Node<String, Binding> node = this.cache.getRoot();
+         if(!isRootCtx)  // search from context node otherwise search from root
+         {
+            node = node.getChild(ctx);
+         }
          if ((node != null) && (node.get(key) != null))
          {
             throw new NameAlreadyBoundException(key);



More information about the jboss-cvs-commits mailing list