User: starksm 
  Date: 01/09/06 19:56:56

  Modified:    src/main/org/jnp/server Tag: Branch_2_4 NamingServer.java
  Log:
  The createSubcontext method was not correctly identifying duplicate attempts
  to create the same subcontext.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.6.4.1   +48 -22    jnp/src/main/org/jnp/server/NamingServer.java
  
  Index: NamingServer.java
  ===================================================================
  RCS file: /cvsroot/jboss/jnp/src/main/org/jnp/server/NamingServer.java,v
  retrieving revision 1.6
  retrieving revision 1.6.4.1
  diff -u -r1.6 -r1.6.4.1
  --- NamingServer.java 2001/04/26 07:50:52     1.6
  +++ NamingServer.java 2001/09/07 02:56:55     1.6.4.1
  @@ -40,7 +40,7 @@
    *      
    *   @see <related>
    *   @author $Author: starksm $
  - *   @version $Revision: 1.6 $
  + *   @version $Revision: 1.6.4.1 $
    */
   public class NamingServer
      implements Naming, java.io.Serializable
  @@ -395,52 +395,78 @@
      public Context createSubcontext(Name name)
         throws NamingException
      {
  +       if( name.size() == 0 )
  +          throw new InvalidNameException("Cannot pass an empty name to 
createSubcontext");
  +
  +      NamingException ex = null;
  +      Context subCtx = null;
         if (name.size() > 1)
  -      {
  -         // System.out.println("create#"+name.get(0)+"#");
  -         
  -         Object ctx = getObject(name);
  +      {         
  +         // Get the target ctx for the creation
  +         int targetSize = name.size() - 1;
  +         Name targetName = name.getPrefix(targetSize);
  +         Name atom = name.getSuffix(targetSize);
  +         Object ctx = getObject(targetName);
            if (ctx != null)
            {
               if (ctx instanceof NamingServer)
               {
  -               return ((NamingServer)ctx).createSubcontext(name.getSuffix(1));
  -            } else if (ctx instanceof Reference)
  +               subCtx = ((NamingServer)ctx).createSubcontext(atom);
  +            }
  +            else if (ctx instanceof Reference)
               {
                  // Federation
                  if (((Reference)ctx).get("nns") != null)
                  {
                     CannotProceedException cpe = new CannotProceedException();
                     cpe.setResolvedObj(ctx);
  -                  cpe.setRemainingName(name.getSuffix(1));
  +                  cpe.setRemainingName(atom);
                     throw cpe;
  -               } else
  +               }
  +               else
                  {
  -                  throw new NotContextException();
  +                  ex = new NotContextException();
  +                  ex.setResolvedName(targetName);
  +                  ex.setRemainingName(atom);
  +                  throw ex;
                  }
  -            } else
  +            }
  +            else
               {
  -               throw new NotContextException();
  +               ex = new NotContextException();
  +               ex.setResolvedName(targetName);
  +               ex.setRemainingName(atom);
  +               throw ex;
               }
  -         } else
  -         {
  -            throw new NameNotFoundException();
            }
  -      } else
  +         else
  +         {
  +            ex = new NameNotFoundException();
  +            ex.setResolvedName(targetName);
  +            ex.setRemainingName(atom);
  +            throw ex;
  +         }
  +      }
  +      else
         {
  -         if (name.get(0).equals(""))
  +         Object binding = table.get(name.get(0));
  +         if( binding != null )
            {
  -            throw new NameAlreadyBoundException();
  -         } else
  +            ex = new NameAlreadyBoundException();
  +            ex.setResolvedName(prefix);
  +            ex.setRemainingName(name);
  +            throw ex;
  +         }
  +         else
            {
  -//            System.out.println("create subcontext "+name);
  -            Name fullName = (Name)(prefix.clone());
  +            Name fullName = (Name) prefix.clone();
               fullName.addAll(name);
               NamingServer subContext = new NamingServer(fullName, this);
               setBinding(name, subContext, NamingContext.class.getName());
  -            return new NamingContext(null, fullName, getRoot());
  +            subCtx = new NamingContext(null, fullName, getRoot());
            }
         }
  +      return subCtx;
      }
         
      public Naming getRoot()
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to