User: starksm 
  Date: 01/05/29 18:59:09

  Modified:    src/main/org/jnp/client Main.java
  Log:
  Add support for setting the RMI client and server socket factories on which
  the Naming interface implementation is exported.
  
  Revision  Changes    Path
  1.6       +33 -16    jnp/src/main/org/jnp/client/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /cvsroot/jboss/jnp/src/main/org/jnp/client/Main.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Main.java 2001/04/26 07:50:51     1.5
  +++ Main.java 2001/05/30 01:59:09     1.6
  @@ -23,6 +23,8 @@
   import javax.naming.NameParser;
   import javax.naming.NamingException;
   import javax.naming.NameNotFoundException;
  +import javax.naming.Reference;
  +import javax.naming.StringRefAddr;
   
   /**
    *   This is a test client of the NamingServer. It calls the server
  @@ -33,7 +35,7 @@
    *   @see NamingContext
    *   @author oberg
    *   @author [EMAIL PROTECTED]
  - *   @version $Revision: 1.5 $
  + *   @version $Revision: 1.6 $
    */
   public class Main
      implements Runnable
  @@ -79,11 +81,16 @@
      public void showTree(Context ctx)
         throws NamingException
      {
  +      showTree(ctx, Integer.MAX_VALUE);
  +   }
  +   public void showTree(Context ctx, int maxDepth)
  +      throws NamingException
  +   {
         System.out.println("----------------------------");
  -      showTree("/", ctx);
  +      showTree("/", ctx, 0, maxDepth);
         System.out.println("----------------------------");
      }
  -   
  +
      // Runnable implementation ---------------------------------------
   
      /**
  @@ -209,6 +216,14 @@
            
            showTree(ctx);
   
  +         // Test a URL Reference to a filesystem context
  +         StringRefAddr addr = new StringRefAddr("URL", "file:/tmp");
  +         Reference fsRef = new Reference("javax.naming.Context", addr);
  +         ctx.bind("external", fsRef);
  +         Context tmpfs = (Context) ctx.lookup("external");
  +         System.out.println("+++ tmp filesystem context:");
  +         showTree(tmpfs, 2);
  +
            // Create an initial context that is rooted at /test
            Properties env = new Properties();
            env.setProperty(Context.INITIAL_CONTEXT_FACTORY, 
"org.jnp.interfaces.NamingContextFactory");
  @@ -265,25 +280,27 @@
          remoteServer.start();
      }
   
  -   /**
  +    /**
       *   Print the contents of a JNDI context recursively
       *
       * @param   indent  indentation string
       * @param   ctx  the JNDI context
       * @exception   NamingException  thrown if any problems occur
       */
  -   private void showTree(String indent, Context ctx)
  -      throws NamingException
  -   {
  -      NamingEnumeration enum = ctx.list("");
  -      while (enum.hasMoreElements())
  -      {
  -         NameClassPair ncp = (NameClassPair)enum.next();
  -         System.out.println(indent+ncp);
  -         if (ncp.getClassName().indexOf("Context") != -1)
  -            showTree(indent+ncp.getName()+"/", (Context)ctx.lookup(ncp.getName()));
  -      }
  -   }
  +    private void showTree(String indent, Context ctx, int depth, int maxDepth)
  +        throws NamingException
  +    {
  +        if( depth == maxDepth )
  +            return;
  +        NamingEnumeration enum = ctx.list("");
  +        while (enum.hasMoreElements())
  +        {
  +            NameClassPair ncp = (NameClassPair)enum.next();
  +            System.out.println(indent+ncp);
  +            if (ncp.getClassName().indexOf("Context") != -1)
  +               showTree(indent+ncp.getName()+"/", 
(Context)ctx.lookup(ncp.getName()), depth+1, maxDepth);
  +        }
  +    }
   
      // Inner classes -------------------------------------------------
   }
  
  
  

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

Reply via email to