User: oberg   
  Date: 00/10/25 01:34:08

  Modified:    src/main/org/jboss/naming NamingService.java
  Added:       src/main/org/jboss/naming ENCFactory.java
  Log:
  Changed to new java: handling, i.e. create a "java:comp" reference which is 
component local
  Added JNDI factory for the "java:comp" ENC namespace
  
  Revision  Changes    Path
  1.2       +8 -1      jboss/src/main/org/jboss/naming/NamingService.java
  
  Index: NamingService.java
  ===================================================================
  RCS file: /products/cvs/ejboss/jboss/src/main/org/jboss/naming/NamingService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- NamingService.java        2000/06/16 13:10:31     1.1
  +++ NamingService.java        2000/10/25 08:34:08     1.2
  @@ -7,6 +7,7 @@
   package org.jboss.naming;
   
   import javax.management.*;
  +import javax.naming.*;
   
   import org.jnp.server.Main;
   
  @@ -18,7 +19,7 @@
    *      
    *   @see <related>
    *   @author Rickard �berg ([EMAIL PROTECTED])
  - *   @version $Revision: 1.1 $
  + *   @version $Revision: 1.2 $
    */
   public class NamingService
      extends ServiceMBeanSupport
  @@ -54,6 +55,12 @@
      {
         naming.start();
         log.log("Naming started on port "+naming.getPort());
  +      
  +      // Create "java:comp/env"
  +      RefAddr refAddr = new StringRefAddr("nns", "ENC");
  +      Reference envRef = new Reference("javax.naming.Context", refAddr, 
ENCFactory.class.getName(), null);
  +      Context ctx = (Context)new InitialContext().lookup("java:");
  +      ctx.rebind("comp", envRef);
      }
      
      public void destroyService()
  
  
  
  1.1                  jboss/src/main/org/jboss/naming/ENCFactory.java
  
  Index: ENCFactory.java
  ===================================================================
  /*
   * jBoss, the OpenSource EJB server
   *
   * Distributable under GPL license.
   * See terms of license at gnu.org.
   */
  package org.jboss.naming;
  
  import java.util.Hashtable;
  import javax.naming.*;
  import javax.naming.spi.*;
  
  import org.jnp.server.NamingServer;
  import org.jnp.interfaces.NamingContext;
  
  import org.jboss.ejb.BeanClassLoader;
  
  /**
   *   Implementation of "java:" namespace factory. The context is associated
   *   with the thread, so the root context must be set before this is used in a thread
   *   
   *   SA FIXME: the java: namespace should be global.  the java:comp/env subcontext 
should 
   *   be threadlocal
   *     
   *   @see <related>
   *   @author Rickard Oberg ([EMAIL PROTECTED])
   *   @version $Revision: 1.1 $
   */
  public class ENCFactory
     implements ObjectFactory
  {
     // Constants -----------------------------------------------------
      
     // Attributes ----------------------------------------------------
     static Hashtable encs = new Hashtable();
      
     // Static --------------------------------------------------------
     
     // Constructors --------------------------------------------------
     
     // Public --------------------------------------------------------
  
     // ObjectFactory implementation ----------------------------------
     public Object getObjectInstance(Object obj,
                                  Name name,
                                  Context nameCtx,
                                  Hashtable environment)
                           throws Exception
     {
        synchronized (encs)
        {
           // Get naming for this component
           NamingServer srv = 
(NamingServer)encs.get(Thread.currentThread().getContextClassLoader());
        
           // If this is the first time we see this name
           if (srv == null)
           {
              srv = new NamingServer();
              encs.put(Thread.currentThread().getContextClassLoader(), srv);
           }
           return new NamingContext(environment, null, srv);
        }
     }
      
     // Y overrides ---------------------------------------------------
  
     // Package protected ---------------------------------------------
      
     // Protected -----------------------------------------------------
      
     // Private -------------------------------------------------------
  
     // Inner classes -------------------------------------------------
  }
  
  
  

Reply via email to