[jboss-cvs] JBossAS SVN: r60241 - in trunk: naming/src/main/org/jboss and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Feb 3 13:49:26 EST 2007


Author: scott.stark at jboss.org
Date: 2007-02-03 13:49:26 -0500 (Sat, 03 Feb 2007)
New Revision: 60241

Added:
   trunk/naming/src/main/org/jboss/
   trunk/naming/src/main/org/jboss/naming/
   trunk/naming/src/main/org/jboss/naming/BridgeNamingContextFactory.java
   trunk/naming/src/main/org/jboss/naming/ENCFactory.java
   trunk/naming/src/main/org/jboss/naming/JavaCompInitializer.java
   trunk/naming/src/main/org/jboss/naming/ThreadLocalStack.java
   trunk/naming/src/main/org/jboss/naming/Util.java
   trunk/naming/src/main/org/jnp/server/NamingBean.java
   trunk/naming/src/main/org/jnp/server/NamingBeanImpl.java
   trunk/naming/src/main/org/jnp/server/NamingServerWrapper.java
   trunk/server/src/etc/conf/default/xmdesc/NamingBean-xmbean.xml
Removed:
   trunk/server/src/main/org/jboss/naming/BridgeNamingContextFactory.java
   trunk/server/src/main/org/jboss/naming/ENCFactory.java
   trunk/server/src/main/org/jboss/naming/JavaCompInitializer.java
   trunk/server/src/main/org/jboss/naming/ThreadLocalStack.java
   trunk/server/src/main/org/jboss/naming/Util.java
Modified:
   trunk/naming/src/main/org/jnp/server/Main.java
   trunk/naming/src/main/org/jnp/server/MainMBean.java
   trunk/server/src/etc/conf/default/jboss-service.xml
   trunk/server/src/etc/conf/default/xmdesc/NamingService-xmbean.xml
   trunk/server/src/main/org/jboss/naming/NamingService.java
Log:
JBAS-2865, core jndi classes have been moved to the naming project

Copied: trunk/naming/src/main/org/jboss/naming/BridgeNamingContextFactory.java (from rev 59865, trunk/server/src/main/org/jboss/naming/BridgeNamingContextFactory.java)
===================================================================
--- trunk/naming/src/main/org/jboss/naming/BridgeNamingContextFactory.java	                        (rev 0)
+++ trunk/naming/src/main/org/jboss/naming/BridgeNamingContextFactory.java	2007-02-03 18:49:26 UTC (rev 60241)
@@ -0,0 +1,119 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.naming;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Hashtable;
+import javax.naming.Context;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+
+import org.jnp.interfaces.NamingContextFactory;
+
+/** A naming provider InitialContextFactory implementation that combines
+ two Naming services to allow for delegation of lookups from one to the
+ other. The default naming service is specified via the standard
+ Context.PROVIDER_URL property while the secondary service is specified
+ using an org.jboss.naming.provider.url2 property. An example of where
+ this would be used is to bridge between the local JNDI service and the
+ HAJNDI service. Lookups into the local JNDI service that fail would then
+ try the HAJNDI service.
+
+ @see javax.naming.spi.InitialContextFactory
+ 
+ @author Scott.Stark at jboss.org
+ @version $Revision$
+ */
+public class BridgeNamingContextFactory extends NamingContextFactory
+{
+   // InitialContextFactory implementation --------------------------
+   public Context getInitialContext(Hashtable env)
+      throws NamingException
+   {
+      Context primaryCtx = super.getInitialContext(env);
+      Context bridgeCtx = primaryCtx;
+      Object providerURL2 = env.get("org.jboss.naming.provider.url2");
+      if( providerURL2 != null )
+      {
+         // A second provider url was given, create a secondary naming context
+         Hashtable env2 = (Hashtable) env.clone();
+         env2.put(Context.PROVIDER_URL, providerURL2);
+         Context secondaryCtx = super.getInitialContext(env2);
+         InvocationHandler h = new BridgeContext(primaryCtx, secondaryCtx);
+         Class[] interfaces = {Context.class};
+         ClassLoader loader = Thread.currentThread().getContextClassLoader();
+         bridgeCtx = (Context) Proxy.newProxyInstance(loader, interfaces, h);
+      }
+      return bridgeCtx;
+   }
+
+   /** This class is the Context interface handler and performs the
+       failed lookup delegation from the primary to secondary naming
+       Context.
+   */
+   static class BridgeContext implements InvocationHandler
+   {
+      private Context primaryCtx;
+      private Context secondaryCtx;
+
+      BridgeContext(Context primaryCtx, Context secondaryCtx)
+      {
+         this.primaryCtx = primaryCtx;
+         this.secondaryCtx = secondaryCtx;
+      }
+
+      public Object invoke(Object proxy, Method method, Object[] args)
+            throws Throwable
+      {
+         Object value = null;
+         // First try the primary context
+         try
+         {
+            value = method.invoke(primaryCtx, args);
+         }
+         catch(InvocationTargetException e)
+         {
+            Throwable t = e.getTargetException();
+            // Try the secondary if this is a failed lookup
+            if( t instanceof NameNotFoundException && method.getName().equals("lookup") )
+            {
+               try
+               {
+                  value = method.invoke(secondaryCtx, args);
+               }
+               catch (InvocationTargetException e1)
+               {
+                  throw e1.getTargetException();
+               }
+            }
+            else
+            {
+               throw t;
+            }
+         }
+         return value;
+      }
+   }
+}

Copied: trunk/naming/src/main/org/jboss/naming/ENCFactory.java (from rev 59865, trunk/server/src/main/org/jboss/naming/ENCFactory.java)
===================================================================
--- trunk/naming/src/main/org/jboss/naming/ENCFactory.java	                        (rev 0)
+++ trunk/naming/src/main/org/jboss/naming/ENCFactory.java	2007-02-03 18:49:26 UTC (rev 60241)
@@ -0,0 +1,194 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.naming;
+
+import java.util.Hashtable;
+import java.util.WeakHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import java.security.PrivilegedAction;
+import java.security.AccessController;
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NamingException;
+import javax.naming.spi.ObjectFactory;
+
+import org.jnp.server.NamingServer;
+import org.jnp.interfaces.NamingContext;
+
+/**
+ *   Implementation of "java:comp" namespace factory. The context is associated
+ *   with the thread class loader.
+ *     
+ *   @author <a href="mailto:rickard.oberg at telkel.com">Rickard Oberg</a>
+ *   @author <a href="mailto:scott.stark at jboss.org">Scott Stark</a>
+ *   @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ *   @version $Revision$
+ */
+public class ENCFactory
+   implements ObjectFactory
+{
+   // Constants -----------------------------------------------------
+    
+   // Attributes ----------------------------------------------------
+   private static WeakHashMap classloaderKeyedEncs = new WeakHashMap();
+   private static ClassLoader topLoader;
+   private static ThreadLocalStack<Object> encIdStack = new ThreadLocalStack<Object>();
+   private static ConcurrentHashMap<Object, Context> encById = new ConcurrentHashMap<Object, Context>();
+
+   public static List<Object> getIdStack()
+   {
+      return encIdStack.getList();
+   }
+
+   public static ConcurrentHashMap<Object, Context> getEncById()
+   {
+      return encById;
+   }
+
+   public static void pushContextId(Object id)
+   {
+      encIdStack.push(id);
+   }
+
+   public static Object popContextId()
+   {
+      return encIdStack.pop();
+   }
+
+   public static Object getCurrentId()
+   {
+      return encIdStack.get();
+   }
+
+   // Static --------------------------------------------------------
+   public static void setTopClassLoader(ClassLoader topLoader)
+   {
+      ENCFactory.topLoader = topLoader;
+   }
+   public static ClassLoader getTopClassLoader()
+   {
+      return ENCFactory.topLoader;
+   }
+
+
+
+
+   // Constructors --------------------------------------------------
+
+
+   // Public --------------------------------------------------------
+
+   // ObjectFactory implementation ----------------------------------
+   public Object getObjectInstance(Object obj, Name name, Context nameCtx,
+      Hashtable environment)
+      throws Exception
+   {
+      Object currentId = encIdStack.get();
+      if (currentId != null)
+      {
+         Context compCtx = encById.get(currentId);
+         if (compCtx == null)
+         {
+            compCtx = createContext(environment);
+            encById.put(currentId, compCtx);
+         }
+         return compCtx;
+      }
+      // Get naming for this component
+      ClassLoader ctxClassLoader = GetTCLAction.getContextClassLoader();
+      synchronized (classloaderKeyedEncs)
+      {
+         Context compCtx = (Context) classloaderKeyedEncs.get(ctxClassLoader);
+
+         /* If this is the first time we see ctxClassLoader first check to see
+          if a parent ClassLoader has created an ENC namespace.
+         */
+         if (compCtx == null)
+         {
+            ClassLoader loader = ctxClassLoader;
+            GetParentAction action = new GetParentAction(ctxClassLoader);
+            while( loader != null && loader != topLoader && compCtx == null )
+            {
+               compCtx = (Context) classloaderKeyedEncs.get(loader);
+               loader = action.getParent();
+            }
+            // If we did not find an ENC create it
+            if( compCtx == null )
+            {
+               compCtx = createContext(environment);
+               classloaderKeyedEncs.put(ctxClassLoader, compCtx);
+            }
+         }
+         return compCtx;
+      }
+   }
+
+   protected Context createContext(Hashtable environment)
+           throws NamingException
+   {
+      Context compCtx;
+      NamingServer srv = new NamingServer();
+      compCtx = new NamingContext(environment, null, srv);
+      return compCtx;
+   }
+
+   private static class GetTCLAction implements PrivilegedAction
+   {
+      static PrivilegedAction ACTION = new GetTCLAction();
+      public Object run()
+      {
+         ClassLoader loader = Thread.currentThread().getContextClassLoader();
+         return loader;
+      }
+      static ClassLoader getContextClassLoader()
+      {
+         ClassLoader loader = (ClassLoader) AccessController.doPrivileged(ACTION);
+         return loader;
+      }
+   }
+
+   private static class GetParentAction implements PrivilegedAction
+   {
+      ClassLoader loader;
+      GetParentAction(ClassLoader loader)
+      {
+         this.loader = loader;
+      }
+      public Object run()
+      {
+         ClassLoader parent = null;
+         if( loader != null )
+         {
+            parent = loader.getParent();
+            loader = parent;
+         }
+         return parent;
+      }
+      ClassLoader getParent()
+      {
+         ClassLoader parent = (ClassLoader) AccessController.doPrivileged(this);
+         return parent;
+      }
+   }
+}

Copied: trunk/naming/src/main/org/jboss/naming/JavaCompInitializer.java (from rev 59865, trunk/server/src/main/org/jboss/naming/JavaCompInitializer.java)
===================================================================
--- trunk/naming/src/main/org/jboss/naming/JavaCompInitializer.java	                        (rev 0)
+++ trunk/naming/src/main/org/jboss/naming/JavaCompInitializer.java	2007-02-03 18:49:26 UTC (rev 60241)
@@ -0,0 +1,86 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.naming;
+
+import javax.naming.RefAddr;
+import javax.naming.StringRefAddr;
+import javax.naming.Reference;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Map;
+import java.util.Hashtable;
+
+/**
+ * Bean that initializes the "java:comp" context
+ *
+ * @author <a href="bill at jboss.com">Bill Burke</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavaCompInitializer
+{
+   private InitialContext iniCtx;
+   private Hashtable initialContextProperties;
+
+   public Hashtable getInitialContextProperties()
+   {
+      return initialContextProperties;
+   }
+
+   public void setInitialContextProperties(Hashtable initialContextProperties)
+   {
+      this.initialContextProperties = initialContextProperties;
+   }
+
+   public InitialContext getIniCtx()
+   {
+      return iniCtx;
+   }
+
+   public void setIniCtx(InitialContext iniCtx)
+   {
+      this.iniCtx = iniCtx;
+   }
+
+   protected void initialContext() throws Exception
+   {
+      if (iniCtx != null) return;
+      if (initialContextProperties == null)
+      {
+         iniCtx = new InitialContext();
+      }
+      else
+      {
+         iniCtx = new InitialContext(initialContextProperties);
+      }
+   }
+
+   public void start() throws Exception
+   {
+      initialContext();
+      ClassLoader topLoader = Thread.currentThread().getContextClassLoader();
+      ENCFactory.setTopClassLoader(topLoader);
+      RefAddr refAddr = new StringRefAddr("nns", "ENC");
+      Reference envRef = new Reference("javax.naming.Context", refAddr, ENCFactory.class.getName(), null);
+      Context ctx = (Context)iniCtx.lookup("java:");
+      ctx.rebind("comp", envRef);
+   }
+}

Copied: trunk/naming/src/main/org/jboss/naming/ThreadLocalStack.java (from rev 59865, trunk/server/src/main/org/jboss/naming/ThreadLocalStack.java)
===================================================================
--- trunk/naming/src/main/org/jboss/naming/ThreadLocalStack.java	                        (rev 0)
+++ trunk/naming/src/main/org/jboss/naming/ThreadLocalStack.java	2007-02-03 18:49:26 UTC (rev 60241)
@@ -0,0 +1,78 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.naming;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision: 42263 $
+ */
+public class ThreadLocalStack<T>
+{
+   private ThreadLocal<ArrayList<T>> stack = new ThreadLocal<ArrayList<T>>();
+
+   public void push(T obj)
+   {
+      ArrayList<T> list = stack.get();
+      if (list == null)
+      {
+         list = new ArrayList<T>(1);
+         stack.set(list);
+      }
+      list.add(obj);
+   }
+
+   public T pop()
+   {
+      ArrayList<T> list = stack.get();
+      if (list == null)
+      {
+         return null;
+      }
+      T rtn = list.remove(list.size() - 1);
+      if (list.size() == 0)
+      {
+         stack.set(null);
+         list.clear();
+      }
+      return rtn;
+   }
+
+   public T get()
+   {
+      ArrayList<T> list = (ArrayList<T>)stack.get();
+      if (list == null)
+      {
+         return null;
+      }
+      return list.get(list.size() - 1);
+   }
+
+   public List<T> getList()
+   {
+      return stack.get();
+   }
+}

Copied: trunk/naming/src/main/org/jboss/naming/Util.java (from rev 59865, trunk/server/src/main/org/jboss/naming/Util.java)
===================================================================
--- trunk/naming/src/main/org/jboss/naming/Util.java	                        (rev 0)
+++ trunk/naming/src/main/org/jboss/naming/Util.java	2007-02-03 18:49:26 UTC (rev 60241)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.naming;
+
+/** A static utility class for common JNDI operations.
+ *
+ * @author Scott.Stark at jboss.org
+ * @author adrian at jboss.com
+ * @version $Revision$
+ */
+public class Util extends org.jboss.util.naming.Util
+{
+}
\ No newline at end of file

Modified: trunk/naming/src/main/org/jnp/server/Main.java
===================================================================
--- trunk/naming/src/main/org/jnp/server/Main.java	2007-02-03 18:29:53 UTC (rev 60240)
+++ trunk/naming/src/main/org/jnp/server/Main.java	2007-02-03 18:49:26 UTC (rev 60241)
@@ -1,8 +1,8 @@
 /*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
@@ -43,7 +43,6 @@
 import org.jboss.util.threadpool.BasicThreadPool;
 import org.jboss.util.threadpool.ThreadPool;
 import org.jnp.interfaces.Naming;
-import org.jnp.interfaces.NamingContext;
 
 /** 
  * A main() entry point for running the jnp naming service implementation as
@@ -59,7 +58,7 @@
    
    // Attributes ----------------------------------------------------
    /** The Naming interface server implementation */
-   protected NamingServer theServer;
+   protected NamingBean theServer;
    protected MarshalledObject serverStub;
    protected boolean isStubExported;
    /** The jnp server socket through which the NamingServer stub is vended */
@@ -92,6 +91,8 @@
    protected int rmiPort = 0;
    /** A flag indicating if theServer will be set as the NamingContext.setLocal value */
    protected boolean InstallGlobalService = true;
+   /** A flag indicating if theServer will try to use the NamingContext.setLocal value */
+   protected boolean UseGlobalService = true;
    protected Logger log;
    /** The thread pool used to handle jnp stub lookup requests */
    protected ThreadPool lookupPool;
@@ -129,10 +130,14 @@
    }
 
    // Public --------------------------------------------------------
-   public Naming getServer()
+   public NamingBean getNamingInfo()
    {
       return theServer;
    }
+   public void setNamingInfo(NamingBean info)
+   {
+      this.theServer = info;
+   }
 
    public ThreadPool getLookupPool()
    {
@@ -216,7 +221,15 @@
    {
       this.InstallGlobalService = flag;
    }
-
+   public boolean getUseGlobalService()
+   {
+      return UseGlobalService;
+   }
+   public void setUseGlobalService(boolean flag)
+   {
+      this.UseGlobalService = flag;
+   }
+   
    public String getClientSocketFactory()
    {
       return clientSocketFactoryName;
@@ -230,6 +243,15 @@
       clientSocketFactory = (RMIClientSocketFactory) clazz.newInstance();
    }
    
+   public RMIClientSocketFactory getClientSocketFactoryBean()
+   {
+      return clientSocketFactory;
+   }
+   public void setClientSocketFactoryBean(RMIClientSocketFactory factory)
+   {
+      this.clientSocketFactory = factory;
+   }
+
    public String getServerSocketFactory()
    {
       return serverSocketFactoryName;
@@ -243,6 +265,19 @@
       serverSocketFactory = (RMIServerSocketFactory) clazz.newInstance();
    }
 
+   public RMIServerSocketFactory getServerSocketFactoryBean()
+   {
+      return serverSocketFactory;
+   }
+   public void setServerSocketFactoryBean(RMIServerSocketFactory factory)
+   {
+      this.serverSocketFactory = factory;
+   }
+
+   public String getJNPServerSocketFactory()
+   {
+      return jnpServerSocketFactoryName;
+   }
    public void setJNPServerSocketFactory(String factoryClassName)
       throws ClassNotFoundException, InstantiationException, IllegalAccessException
    {
@@ -252,19 +287,23 @@
       jnpServerSocketFactory = (ServerSocketFactory) clazz.newInstance();
    }
 
+   public ServerSocketFactory getJNPServerSocketFactoryBean()
+   {
+      return jnpServerSocketFactory;
+   }
+   public void setJNPServerSocketFactoryBean(ServerSocketFactory factory)
+   {
+      this.jnpServerSocketFactory = factory;
+   }
+
+   public Naming getNamingInstance()
+   {
+      return theServer.getNamingInstance();
+   }
+
    public void start()
       throws Exception
    {
-      // Create the local naming service instance if it does not exist
-      if( theServer == null )
-      {
-         theServer = new NamingServer();
-         if( InstallGlobalService == true )
-         {
-            // Set local server reference
-            NamingContext.setLocal(theServer);
-         }
-      }
 
       // Initialize the custom socket factories with any bind address
       initCustomSocketFactories();
@@ -272,7 +311,7 @@
         the port is >= 0 and an external proxy has not been installed.
         A value < 0 indicates no socket based access
       */
-      if( this.serverStub == null && this.port >= 0 )
+      if( this.serverStub == null && port >= 0 )
       {
          initJnpInvoker();
       }
@@ -295,7 +334,7 @@
             s.close();
          }
          if( isStubExported == true )
-            UnicastRemoteObject.unexportObject(theServer, false);
+            UnicastRemoteObject.unexportObject(theServer.getNamingInstance(), false);
       }
       catch (Exception e)
       {
@@ -309,10 +348,11 @@
    protected void initJnpInvoker() throws IOException
    {
       log.debug("Creating NamingServer stub, theServer="+theServer
-         +",rmiPort="+rmiPort+",clientSocketFactory="+clientSocketFactory
+         +",rmiPort="+rmiPort
+         +",clientSocketFactory="+clientSocketFactory
          +",serverSocketFactory="+serverSocketFactory);
-      Remote stub = UnicastRemoteObject.exportObject(theServer, rmiPort,
-         clientSocketFactory, serverSocketFactory);
+      Remote stub = UnicastRemoteObject.exportObject(getNamingInstance(),
+            rmiPort, clientSocketFactory, serverSocketFactory);
       log.debug("NamingServer stub: "+stub);
       serverStub = new MarshalledObject(stub);      
    }
@@ -339,19 +379,19 @@
           if (clientSocketFactory == null)
             msg+= ", no client SocketFactory";
           else
-            msg+= ", Client SocketFactory="+clientSocketFactory.getClass().toString();
+            msg+= ", Client SocketFactory="+clientSocketFactory.toString();
 
           if (serverSocketFactory == null)
             msg+= ", no server SocketFactory";
           else
-            msg+= ", Server SocketFactory="+serverSocketFactory.getClass().toString();
+            msg+= ", Server SocketFactory="+serverSocketFactory.toString();
 
-         log.info(msg);
+         log.debug(msg);
       }
       catch (IOException e)
       {
          log.error("Could not start on port " + port, e);
-	   }
+      }
 
       if( lookupPool == null  )
          lookupPool = new BasicThreadPool("NamingBootstrap Pool");
@@ -367,7 +407,7 @@
       // Use either the rmiBindAddress or bindAddress for the RMI service
       InetAddress addr = rmiBindAddress != null ? rmiBindAddress : bindAddress;
 
-      if (clientSocketFactory != null)
+      if( clientSocketFactory != null && addr != null )
       {
          // See if the client socket supports setBindAddress(String)
          try

Modified: trunk/naming/src/main/org/jnp/server/MainMBean.java
===================================================================
--- trunk/naming/src/main/org/jnp/server/MainMBean.java	2007-02-03 18:29:53 UTC (rev 60240)
+++ trunk/naming/src/main/org/jnp/server/MainMBean.java	2007-02-03 18:49:26 UTC (rev 60241)
@@ -1,8 +1,8 @@
 /*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
@@ -22,7 +22,11 @@
 package org.jnp.server;
 
 import java.net.UnknownHostException;
+import java.rmi.server.RMIClientSocketFactory;
+import java.rmi.server.RMIServerSocketFactory;
 
+import javax.net.ServerSocketFactory;
+
 /** 
  * The Mbean interface for the jnp provider server.
  * 
@@ -30,7 +34,7 @@
  * @author Scott.Stark at jboss.org
  * @version $Revision$
  */
-public interface MainMBean
+public interface MainMBean extends NamingBean
 {
    // Attributes  ---------------------------------------------------
    
@@ -53,17 +57,42 @@
    void setInstallGlobalService(boolean flag);
    boolean getInstallGlobalService();
 
-   /** The RMIServerSocketFactory implementation class */
+   /** Get the UseGlobalService which defines whether the MainMBean's
+    * Naming server will initialized from the existing NamingContext.setLocal
+    * global value.
+    * 
+    * @return true if this should try to use VM global naming service, false otherwise 
+    */ 
+   public boolean getUseGlobalService();
+   /** Set the UseGlobalService which defines whether the MainMBean's
+    * Naming server will initialized from the existing NamingContext.setLocal global
+    * value. This allows one to export multiple servers via different transports
+    * and still share the same underlying naming service.
+    * 
+    * @return true if this should try to use VM global naming service, false otherwise 
+    */ 
+   public void setUseGlobalService(boolean flag);
+
+   /** The RMIClientSocketFactory implementation class */
    void setClientSocketFactory(String factoryClassName)
       throws ClassNotFoundException, InstantiationException, IllegalAccessException;
    String getClientSocketFactory();
-   
+   /** The RMIClientSocketFactory bean */
+   public RMIClientSocketFactory getClientSocketFactoryBean();
+   public void setClientSocketFactoryBean(RMIClientSocketFactory factory);
+
    /** The RMIServerSocketFactory implementation class */
    void setServerSocketFactory(String factoryClassName)
       throws ClassNotFoundException, InstantiationException, IllegalAccessException;
    String getServerSocketFactory();
+   /** The RMIServerSocketFactory bean */
+   public RMIServerSocketFactory getServerSocketFactoryBean();
+   public void setServerSocketFactoryBean(RMIServerSocketFactory factory);
 
    /** The JNPServerSocketFactory implementation class */
+   ServerSocketFactory getJNPServerSocketFactoryBean();
+   void setJNPServerSocketFactoryBean(ServerSocketFactory factory);
+   public String getJNPServerSocketFactory();
    void setJNPServerSocketFactory(String factoryClassName) 
       throws ClassNotFoundException, InstantiationException, IllegalAccessException;
 
@@ -73,4 +102,4 @@
    
    public void stop();
    
-}
\ No newline at end of file
+}

Copied: trunk/naming/src/main/org/jnp/server/NamingBean.java (from rev 60239, branches/Branch_4_2/naming/src/main/org/jnp/server/NamingBean.java)
===================================================================
--- trunk/naming/src/main/org/jnp/server/NamingBean.java	                        (rev 0)
+++ trunk/naming/src/main/org/jnp/server/NamingBean.java	2007-02-03 18:49:26 UTC (rev 60241)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jnp.server;
+
+import org.jnp.interfaces.Naming;
+
+/**
+ * Interface for the Main naming pojo.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public interface NamingBean
+{
+   public Naming getNamingInstance();
+}


Property changes on: trunk/naming/src/main/org/jnp/server/NamingBean.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Copied: trunk/naming/src/main/org/jnp/server/NamingBeanImpl.java (from rev 60239, branches/Branch_4_2/naming/src/main/org/jnp/server/NamingBeanImpl.java)
===================================================================
--- trunk/naming/src/main/org/jnp/server/NamingBeanImpl.java	                        (rev 0)
+++ trunk/naming/src/main/org/jnp/server/NamingBeanImpl.java	2007-02-03 18:49:26 UTC (rev 60241)
@@ -0,0 +1,159 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jnp.server;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.RefAddr;
+import javax.naming.Reference;
+import javax.naming.StringRefAddr;
+
+import org.jboss.logging.Logger;
+import org.jboss.naming.ENCFactory;
+import org.jnp.interfaces.Naming;
+import org.jnp.interfaces.NamingContext;
+
+/**
+ * A naming pojo that wraps the Naming server implementation. This is
+ * a refactoring of the legacy org.jnp.server.Main into a 
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class NamingBeanImpl
+   implements NamingBean
+{
+   private static Logger log = Logger.getLogger(NamingBeanImpl.class);
+   // Attributes ----------------------------------------------------
+   /** The Naming interface server implementation */
+   protected Naming theServer;
+   /** A flag indicating if theServer will be set as the NamingContext.setLocal value */
+   protected boolean InstallGlobalService = true;
+   /** A flag indicating if theServer will try to use the NamingContext.setLocal value */
+   protected boolean UseGlobalService = true;
+
+   // Static --------------------------------------------------------
+   public static void main(String[] args)
+      throws Exception
+   {
+      new Main().start();
+   }
+ 
+   // Constructors --------------------------------------------------
+   public NamingBeanImpl()
+   {
+   }
+
+   // Public --------------------------------------------------------
+   public Naming getNamingInstance()
+   {
+      return theServer;
+   }
+
+   public boolean getInstallGlobalService()
+   {
+      return InstallGlobalService;
+   }
+   public void setInstallGlobalService(boolean flag)
+   {
+      this.InstallGlobalService = flag;
+   }
+   public boolean getUseGlobalService()
+   {
+      return UseGlobalService;
+   }
+   public void setUseGlobalService(boolean flag)
+   {
+      this.UseGlobalService = flag;
+   }
+
+   public void start()
+      throws Exception
+   {
+      // Create the local naming service instance if it does not exist
+      if( theServer == null )
+      {
+         // See if we should try to reuse the current local server
+         if( UseGlobalService == true )
+            theServer = NamingContext.localServer;
+         // If not, or there is no server create one
+         if( theServer == null )
+            theServer = new NamingServer();
+         else
+         {
+            // We need to wrap the server to allow exporting it
+            NamingServerWrapper wrapper = new NamingServerWrapper(theServer);
+            theServer = wrapper;
+         }
+         log.debug("Using NamingServer: "+theServer);
+         if( InstallGlobalService == true )
+         {
+            // Set local server reference
+            NamingContext.setLocal(theServer);
+            log.debug("Installed global NamingServer: "+theServer);
+         }
+      }
+
+      /* Create a default InitialContext and dump out its env to show what properties
+      were used in its creation. If we find a Context.PROVIDER_URL property
+      issue a warning as this means JNDI lookups are going through RMI.
+      */
+      InitialContext iniCtx = new InitialContext();
+      Hashtable env = iniCtx.getEnvironment();
+      log.debug("InitialContext Environment: ");
+      Object providerURL = null;
+      for (Enumeration keys = env.keys(); keys.hasMoreElements(); )
+      {
+         Object key = keys.nextElement();
+         Object value = env.get(key);
+         String type = value == null ? "" : value.getClass().getName();
+         log.debug("key="+key+", value("+type+")="+value);
+         if( key.equals(Context.PROVIDER_URL) )
+            providerURL = value;
+      }
+      // Warn if there was a Context.PROVIDER_URL
+      if( providerURL != null )
+         log.warn("Context.PROVIDER_URL in server jndi.properties, url="+providerURL);
+   
+      /* Bind an ObjectFactory to "java:comp" so that "java:comp/env" lookups
+         produce a unique context for each thread contexxt ClassLoader that
+         performs the lookup.
+      */
+      ClassLoader topLoader = Thread.currentThread().getContextClassLoader();
+      ENCFactory.setTopClassLoader(topLoader);
+      RefAddr refAddr = new StringRefAddr("nns", "ENC");
+      Reference envRef = new Reference("javax.namingMain.Context", refAddr, ENCFactory.class.getName(), null);
+      Context ctx = (Context)iniCtx.lookup("java:");
+      ctx.rebind("comp", envRef);
+      ctx.close();
+      iniCtx.close();
+
+   }
+
+   public void stop()
+   {
+   }
+
+}


Property changes on: trunk/naming/src/main/org/jnp/server/NamingBeanImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id,Revision
Name: svn:eol-style
   + native

Copied: trunk/naming/src/main/org/jnp/server/NamingServerWrapper.java (from rev 60239, branches/Branch_4_2/naming/src/main/org/jnp/server/NamingServerWrapper.java)
===================================================================
--- trunk/naming/src/main/org/jnp/server/NamingServerWrapper.java	                        (rev 0)
+++ trunk/naming/src/main/org/jnp/server/NamingServerWrapper.java	2007-02-03 18:49:26 UTC (rev 60241)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jnp.server;
+
+import java.rmi.RemoteException;
+import java.util.Collection;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NamingException;
+
+import org.jnp.interfaces.Naming;
+
+/**
+ * A delegating wrapper that can be used to create a unique rmi server endpoint
+ * that shares the an underlying Naming server implementation.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class NamingServerWrapper
+   implements Naming
+{
+   Naming delegate;
+   NamingServerWrapper(Naming delegate)
+   {
+      this.delegate = delegate;
+   }
+
+   public void bind(Name name, Object obj, String className)
+      throws NamingException, RemoteException
+   {
+      delegate.bind(name, obj, className);
+   }
+   public Context createSubcontext(Name name)
+      throws NamingException, RemoteException
+   {
+      return delegate.createSubcontext(name);
+   }
+   public Collection list(Name name)
+      throws NamingException, RemoteException
+   {
+      return delegate.list(name);
+   }
+   public Collection listBindings(Name name)
+      throws NamingException, RemoteException
+   {
+      return delegate.listBindings(name);
+   }
+   public Object lookup(Name name)
+      throws NamingException, RemoteException
+   {
+      return delegate.lookup(name);
+   }
+   public void rebind(Name name, Object obj, String className)
+      throws NamingException, RemoteException
+   {
+      delegate.rebind(name, obj, className);
+   }
+   public void unbind(Name name)
+      throws NamingException, RemoteException
+   {
+      delegate.unbind(name);
+   }
+}

Modified: trunk/server/src/etc/conf/default/jboss-service.xml
===================================================================
--- trunk/server/src/etc/conf/default/jboss-service.xml	2007-02-03 18:29:53 UTC (rev 60240)
+++ trunk/server/src/etc/conf/default/jboss-service.xml	2007-02-03 18:49:26 UTC (rev 60241)
@@ -219,31 +219,46 @@
    <!-- JNDI                                                                 -->
    <!-- ==================================================================== -->
 
+   <!-- A simple mbean wrapper around the jndi Naming object. This
+      only handles an in memory instance. The NamingService uses this
+      as the JNDI store and exposes it remotely.
+   -->
+   <mbean code="org.jnp.server.NamingBeanImpl"
+      name="jboss:service=NamingBeanImpl"
+      xmbean-dd="resource:xmdesc/NamingBean-xmbean.xml">
+   </mbean>
+   
    <mbean code="org.jboss.naming.NamingService"
       name="jboss:service=Naming"
       xmbean-dd="resource:xmdesc/NamingService-xmbean.xml">
       <!-- The call by value mode. true if all lookups are unmarshalled using
-      the caller's TCL, false if in VM lookups return the value by reference.
+         the caller's TCL, false if in VM lookups return the value by reference.
       -->
       <attribute name="CallByValue">false</attribute>
       <!-- The listening port for the bootstrap JNP service. Set this to -1
-        to run the NamingService without the JNP invoker listening port.
+         to run the NamingService without the JNP invoker listening port.
       -->
       <attribute name="Port">1099</attribute>
       <!-- The bootstrap JNP server bind address. This also sets the default
-      RMI service bind address. Empty == all addresses
-       -->
+         RMI service bind address. Empty == all addresses
+      -->
       <attribute name="BindAddress">${jboss.bind.address}</attribute>
       <!-- The port of the RMI naming service, 0 == anonymous -->
       <attribute name="RmiPort">1098</attribute>
       <!-- The RMI service bind address. Empty == all addresses
-       -->
+      -->
       <attribute name="RmiBindAddress">${jboss.bind.address}</attribute>
       <!-- The thread pool service used to control the bootstrap lookups -->
       <depends optional-attribute-name="LookupPool"
          proxy-type="attribute">jboss.system:service=ThreadPool</depends>
+      <!-- An example of using the unifed invoker as the transport.
+         <depends optional-attribute-name="InvokerProxyFactory"
+         proxy-type="attribute">jboss:service=proxyFactory,type=unified,target=Naming</depends>
+      -->
+      <depends optional-attribute-name="Naming"
+         proxy-type="attribute">jboss:service=NamingBeanImpl</depends>
    </mbean>
-
+   
    <mbean code="org.jboss.naming.JNDIView"
    	name="jboss:service=JNDIView"
    	xmbean-dd="resource:xmdesc/JNDIView-xmbean.xml">

Copied: trunk/server/src/etc/conf/default/xmdesc/NamingBean-xmbean.xml (from rev 60240, branches/Branch_4_2/server/src/etc/conf/default/xmdesc/NamingBean-xmbean.xml)
===================================================================
--- trunk/server/src/etc/conf/default/xmdesc/NamingBean-xmbean.xml	                        (rev 0)
+++ trunk/server/src/etc/conf/default/xmdesc/NamingBean-xmbean.xml	2007-02-03 18:49:26 UTC (rev 60241)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mbean PUBLIC
+   "-//JBoss//DTD JBOSS XMBEAN 1.1//EN"
+   "http://www.jboss.org/j2ee/dtd/jboss_xmbean_1_1.dtd">
+
+<!-- The JNDI Naming XMBean
+   $Id$
+-->
+<mbean>
+   <description>The JNDI pojo bean</description>
+
+   <class>org.jnp.server.NamingBeanImpl</class>
+   
+   <constructor>
+       <description>The default constructor</description>
+       <name>NamingBeanImpl</name>
+   </constructor>
+   
+   <attribute access="read-only" getMethod="getNamingInstance">
+       <description>The NamingInstance</description>
+       <name>NamingInstance</name>
+       <type>org.jnp.interfaces.Naming</type>
+   </attribute>
+   
+   <!-- Operations -->
+   <operation>
+       <description>The start lifecycle op</description>
+       <name>start</name>
+       <return-type>void</return-type>
+   </operation>
+   <operation>
+       <description>The stop lifecycle op</description>
+       <name>stop</name>
+       <return-type>void</return-type>
+   </operation>
+   
+</mbean>


Property changes on: trunk/server/src/etc/conf/default/xmdesc/NamingBean-xmbean.xml
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Modified: trunk/server/src/etc/conf/default/xmdesc/NamingService-xmbean.xml
===================================================================
--- trunk/server/src/etc/conf/default/xmdesc/NamingService-xmbean.xml	2007-02-03 18:29:53 UTC (rev 60240)
+++ trunk/server/src/etc/conf/default/xmdesc/NamingService-xmbean.xml	2007-02-03 18:49:26 UTC (rev 60241)
@@ -3,23 +3,23 @@
    "-//JBoss//DTD JBOSS XMBEAN 1.1//EN"
    "http://www.jboss.org/j2ee/dtd/jboss_xmbean_1_1.dtd"
 [
-   <!ATTLIST interceptor proxyName CDATA #IMPLIED>
+<!ATTLIST interceptor proxyName CDATA #IMPLIED>
 ]>
 
 <!-- The JNDI Naming service XMBean
-$Id$
+   $Id$
 -->
 <mbean>
    <description>The standard JBoss JNDI naming server with a custom
       ProxyFactoryInterceptor interceptor that does replacement of NamingContext
       objects with the detached invoker proxy.
    </description>
-
+   
    <descriptors>
       <interceptors>
          <!-- Uncomment to enable NamingContext replacement by the detached
-         invoker proxy. You need to set the proxyName attribute correctly.
-         <interceptor code="org.jboss.naming.interceptors.ProxyFactoryInterceptor"
+            invoker proxy. You need to set the proxyName attribute correctly.
+            <interceptor code="org.jboss.naming.interceptors.ProxyFactoryInterceptor"
             proxyName="jboss:service=proxyFactory,type=pooled,target=Naming"/>
          -->
          <interceptor code="org.jboss.mx.interceptor.PersistenceInterceptor2" />
@@ -27,23 +27,33 @@
          <interceptor code="org.jboss.mx.interceptor.ObjectReferenceInterceptor" />
       </interceptors>
    </descriptors>
-
+   
    <class>org.jboss.naming.NamingService</class>
-
+   
    <constructor>
       <description>The default constructor</description>
       <name>NamingService</name>
    </constructor>
    
    &defaultAttributes;
-
+   
    <attribute access="read-only" getMethod="getMethodMap">
       <name>MethodMap</name>
       <type>java.util.Map</type>
    </attribute>
+   <attribute access="read-write" getMethod="getNaming" setMethod="setNaming">
+      <description>Underlying Naming bean instance</description>
+      <name>Naming</name>
+      <type>org.jnp.server.NamingBean</type>
+   </attribute>
+   <attribute access="read-only" getMethod="getNamingInstance">
+      <description>Underlying Naming bean instance</description>
+      <name>NamingInstance</name>
+      <type>org.jnp.interfaces.Naming</type>
+   </attribute>   
    <attribute access="read-write" getMethod="getCallByValue" setMethod="setCallByValue">
       <description>The call by value mode. true if all lookups are unmarshalled using
-      the caller's TCL, false if in VM lookups return the value by reference.</description>
+         the caller's TCL, false if in VM lookups return the value by reference.</description>
       <name>CallByValue</name>
       <type>boolean</type>
    </attribute>
@@ -54,7 +64,7 @@
    </attribute>
    <attribute access="read-write" getMethod="getPort" setMethod="setPort">
       <description>The listening port for the bootstrap JNP service. Set this to -1
-        to run the NamingService without the JNP invoker listening port.</description>
+         to run the NamingService without the JNP invoker listening port.</description>
       <name>Port</name>
       <type>int</type>
    </attribute>
@@ -65,14 +75,20 @@
    </attribute>
    <attribute access="read-write" getMethod="getJNPServerSocketFactory"
       setMethod="setJNPServerSocketFactory">
-      <description>The bootstrap socket javax.net.ServerSocketFactory</description>
+      <description>The bootstrap socket javax.net.ServerSocketFactory class name</description>
       <name>JNPServerSocketFactory</name>
       <type>java.lang.String</type>
    </attribute>
-
+   <attribute access="read-write" getMethod="getJNPServerSocketFactoryBean"
+      setMethod="setJNPServerSocketFactoryBean">
+      <description>The bootstrap socket javax.net.ServerSocketFactory</description>
+      <name>JNPServerSocketFactoryBean</name>
+      <type>javax.net.ServerSocketFactory</type>
+   </attribute>
+   
    <attribute access="read-write" getMethod="getRmiPort" setMethod="setRmiPort">
       <description>The port of the RMI naming service, 0 == anonymous. This
-      is only used if an explicit InvokerProxyFactory has not been set.</description>
+         is only used if an explicit InvokerProxyFactory has not been set.</description>
       <name>RmiPort</name>
       <type>int</type>
    </attribute>
@@ -82,21 +98,42 @@
       <type>java.lang.String</type>
    </attribute>
    <attribute access="read-write" getMethod="getClientSocketFactory" setMethod="setClientSocketFactory">
-      <description>The RMI service java.rmi.server.RMIClientSocketFactory</description>
+      <description>The RMI service java.rmi.server.RMIClientSocketFactory class name</description>
       <name>ClientSocketFactory</name>
       <type>java.lang.String</type>
    </attribute>
+   <attribute access="read-write" getMethod="getClientSocketFactoryBean" setMethod="setClientSocketFactoryBean">
+      <description>The RMI service java.rmi.server.RMIServerSocketFactory instance</description>
+      <name>ClientSocketFactoryBean</name>
+      <type>java.rmi.server.RMIClientSocketFactory</type>
+   </attribute>
    <attribute access="read-write" getMethod="getServerSocketFactory" setMethod="setServerSocketFactory">
-      <description>The RMI service java.rmi.server.RMIServerSocketFactory</description>
+      <description>The RMI service java.rmi.server.RMIServerSocketFactory class name</description>
       <name>ServerSocketFactory</name>
       <type>java.lang.String</type>
    </attribute>
-
+   <attribute access="read-write" getMethod="getServerSocketFactoryBean" setMethod="setServerSocketFactoryBean">
+      <description>The RMI service java.rmi.server.RMIServerSocketFactory instance</description>
+      <name>ServerSocketFactory</name>
+      <type>java.rmi.server.RMIServerSocketFactory</type>
+   </attribute>
+   
    <attribute access="read-write" getMethod="getInstallGlobalService"
       setMethod="setInstallGlobalService">
+      <description>Ghe InstallGlobalService which defines whether the MainMBean's
+         Naming server will be installed as the NamingContext.setLocal global
+         value.</description>
       <name>InstallGlobalService</name>
       <type>boolean</type>
    </attribute>
+   <attribute access="read-write" getMethod="getUseGlobalService"
+      setMethod="setUseGlobalService">
+      <description>The UseGlobalService which defines whether the MainMBean's
+         Naming server will initialized from the existing NamingContext.setLocal global
+         value.</description>
+      <name>UseGlobalService</name>
+      <type>boolean</type>
+   </attribute>
    <attribute access="write-only" setMethod="setLookupPool">
       <description>The thread pool service used to control the bootstrap lookups</description>
       <name>LookupPool</name>
@@ -104,11 +141,11 @@
    </attribute>
    <attribute access="write-only" setMethod="setInvokerProxyFactory">
       <description>The detached invoker proxy factory to use for the naming
-      service transport.</description>
+         service transport.</description>
       <name>InvokerProxyFactory</name>
       <type>org.jboss.invocation.jrmp.server.JRMPProxyFactoryMBean</type>
    </attribute>
-
+   
    <!-- Operations -->
    <operation>
       <description>The generic invocation operation used by detached invokers
@@ -153,7 +190,8 @@
       </parameter>
       <return-type>void</return-type>
    </operation>
-
+   
    &defaultOperations;   			
-
+   
 </mbean>
+   
\ No newline at end of file

Deleted: trunk/server/src/main/org/jboss/naming/BridgeNamingContextFactory.java
===================================================================
--- trunk/server/src/main/org/jboss/naming/BridgeNamingContextFactory.java	2007-02-03 18:29:53 UTC (rev 60240)
+++ trunk/server/src/main/org/jboss/naming/BridgeNamingContextFactory.java	2007-02-03 18:49:26 UTC (rev 60241)
@@ -1,119 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.naming;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Hashtable;
-import javax.naming.Context;
-import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
-
-import org.jnp.interfaces.NamingContextFactory;
-
-/** A naming provider InitialContextFactory implementation that combines
- two Naming services to allow for delegation of lookups from one to the
- other. The default naming service is specified via the standard
- Context.PROVIDER_URL property while the secondary service is specified
- using an org.jboss.naming.provider.url2 property. An example of where
- this would be used is to bridge between the local JNDI service and the
- HAJNDI service. Lookups into the local JNDI service that fail would then
- try the HAJNDI service.
-
- @see javax.naming.spi.InitialContextFactory
- 
- @author Scott.Stark at jboss.org
- @version $Revision$
- */
-public class BridgeNamingContextFactory extends NamingContextFactory
-{
-   // InitialContextFactory implementation --------------------------
-   public Context getInitialContext(Hashtable env)
-      throws NamingException
-   {
-      Context primaryCtx = super.getInitialContext(env);
-      Context bridgeCtx = primaryCtx;
-      Object providerURL2 = env.get("org.jboss.naming.provider.url2");
-      if( providerURL2 != null )
-      {
-         // A second provider url was given, create a secondary naming context
-         Hashtable env2 = (Hashtable) env.clone();
-         env2.put(Context.PROVIDER_URL, providerURL2);
-         Context secondaryCtx = super.getInitialContext(env2);
-         InvocationHandler h = new BridgeContext(primaryCtx, secondaryCtx);
-         Class[] interfaces = {Context.class};
-         ClassLoader loader = Thread.currentThread().getContextClassLoader();
-         bridgeCtx = (Context) Proxy.newProxyInstance(loader, interfaces, h);
-      }
-      return bridgeCtx;
-   }
-
-   /** This class is the Context interface handler and performs the
-       failed lookup delegation from the primary to secondary naming
-       Context.
-   */
-   static class BridgeContext implements InvocationHandler
-   {
-      private Context primaryCtx;
-      private Context secondaryCtx;
-
-      BridgeContext(Context primaryCtx, Context secondaryCtx)
-      {
-         this.primaryCtx = primaryCtx;
-         this.secondaryCtx = secondaryCtx;
-      }
-
-      public Object invoke(Object proxy, Method method, Object[] args)
-            throws Throwable
-      {
-         Object value = null;
-         // First try the primary context
-         try
-         {
-            value = method.invoke(primaryCtx, args);
-         }
-         catch(InvocationTargetException e)
-         {
-            Throwable t = e.getTargetException();
-            // Try the secondary if this is a failed lookup
-            if( t instanceof NameNotFoundException && method.getName().equals("lookup") )
-            {
-               try
-               {
-                  value = method.invoke(secondaryCtx, args);
-               }
-               catch (InvocationTargetException e1)
-               {
-                  throw e1.getTargetException();
-               }
-            }
-            else
-            {
-               throw t;
-            }
-         }
-         return value;
-      }
-   }
-}

Deleted: trunk/server/src/main/org/jboss/naming/ENCFactory.java
===================================================================
--- trunk/server/src/main/org/jboss/naming/ENCFactory.java	2007-02-03 18:29:53 UTC (rev 60240)
+++ trunk/server/src/main/org/jboss/naming/ENCFactory.java	2007-02-03 18:49:26 UTC (rev 60241)
@@ -1,194 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.naming;
-
-import java.util.Hashtable;
-import java.util.WeakHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.concurrent.ConcurrentHashMap;
-import java.security.PrivilegedAction;
-import java.security.AccessController;
-import javax.naming.Context;
-import javax.naming.Name;
-import javax.naming.NamingException;
-import javax.naming.spi.ObjectFactory;
-
-import org.jnp.server.NamingServer;
-import org.jnp.interfaces.NamingContext;
-
-/**
- *   Implementation of "java:comp" namespace factory. The context is associated
- *   with the thread class loader.
- *     
- *   @author <a href="mailto:rickard.oberg at telkel.com">Rickard Oberg</a>
- *   @author <a href="mailto:scott.stark at jboss.org">Scott Stark</a>
- *   @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- *   @version $Revision$
- */
-public class ENCFactory
-   implements ObjectFactory
-{
-   // Constants -----------------------------------------------------
-    
-   // Attributes ----------------------------------------------------
-   private static WeakHashMap classloaderKeyedEncs = new WeakHashMap();
-   private static ClassLoader topLoader;
-   private static ThreadLocalStack<Object> encIdStack = new ThreadLocalStack<Object>();
-   private static ConcurrentHashMap<Object, Context> encById = new ConcurrentHashMap<Object, Context>();
-
-   public static List<Object> getIdStack()
-   {
-      return encIdStack.getList();
-   }
-
-   public static ConcurrentHashMap<Object, Context> getEncById()
-   {
-      return encById;
-   }
-
-   public static void pushContextId(Object id)
-   {
-      encIdStack.push(id);
-   }
-
-   public static Object popContextId()
-   {
-      return encIdStack.pop();
-   }
-
-   public static Object getCurrentId()
-   {
-      return encIdStack.get();
-   }
-
-   // Static --------------------------------------------------------
-   public static void setTopClassLoader(ClassLoader topLoader)
-   {
-      ENCFactory.topLoader = topLoader;
-   }
-   public static ClassLoader getTopClassLoader()
-   {
-      return ENCFactory.topLoader;
-   }
-
-
-
-
-   // Constructors --------------------------------------------------
-
-
-   // Public --------------------------------------------------------
-
-   // ObjectFactory implementation ----------------------------------
-   public Object getObjectInstance(Object obj, Name name, Context nameCtx,
-      Hashtable environment)
-      throws Exception
-   {
-      Object currentId = encIdStack.get();
-      if (currentId != null)
-      {
-         Context compCtx = encById.get(currentId);
-         if (compCtx == null)
-         {
-            compCtx = createContext(environment);
-            encById.put(currentId, compCtx);
-         }
-         return compCtx;
-      }
-      // Get naming for this component
-      ClassLoader ctxClassLoader = GetTCLAction.getContextClassLoader();
-      synchronized (classloaderKeyedEncs)
-      {
-         Context compCtx = (Context) classloaderKeyedEncs.get(ctxClassLoader);
-
-         /* If this is the first time we see ctxClassLoader first check to see
-          if a parent ClassLoader has created an ENC namespace.
-         */
-         if (compCtx == null)
-         {
-            ClassLoader loader = ctxClassLoader;
-            GetParentAction action = new GetParentAction(ctxClassLoader);
-            while( loader != null && loader != topLoader && compCtx == null )
-            {
-               compCtx = (Context) classloaderKeyedEncs.get(loader);
-               loader = action.getParent();
-            }
-            // If we did not find an ENC create it
-            if( compCtx == null )
-            {
-               compCtx = createContext(environment);
-               classloaderKeyedEncs.put(ctxClassLoader, compCtx);
-            }
-         }
-         return compCtx;
-      }
-   }
-
-   protected Context createContext(Hashtable environment)
-           throws NamingException
-   {
-      Context compCtx;
-      NamingServer srv = new NamingServer();
-      compCtx = new NamingContext(environment, null, srv);
-      return compCtx;
-   }
-
-   private static class GetTCLAction implements PrivilegedAction
-   {
-      static PrivilegedAction ACTION = new GetTCLAction();
-      public Object run()
-      {
-         ClassLoader loader = Thread.currentThread().getContextClassLoader();
-         return loader;
-      }
-      static ClassLoader getContextClassLoader()
-      {
-         ClassLoader loader = (ClassLoader) AccessController.doPrivileged(ACTION);
-         return loader;
-      }
-   }
-
-   private static class GetParentAction implements PrivilegedAction
-   {
-      ClassLoader loader;
-      GetParentAction(ClassLoader loader)
-      {
-         this.loader = loader;
-      }
-      public Object run()
-      {
-         ClassLoader parent = null;
-         if( loader != null )
-         {
-            parent = loader.getParent();
-            loader = parent;
-         }
-         return parent;
-      }
-      ClassLoader getParent()
-      {
-         ClassLoader parent = (ClassLoader) AccessController.doPrivileged(this);
-         return parent;
-      }
-   }
-}

Deleted: trunk/server/src/main/org/jboss/naming/JavaCompInitializer.java
===================================================================
--- trunk/server/src/main/org/jboss/naming/JavaCompInitializer.java	2007-02-03 18:29:53 UTC (rev 60240)
+++ trunk/server/src/main/org/jboss/naming/JavaCompInitializer.java	2007-02-03 18:49:26 UTC (rev 60241)
@@ -1,86 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.naming;
-
-import javax.naming.RefAddr;
-import javax.naming.StringRefAddr;
-import javax.naming.Reference;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import java.util.Map;
-import java.util.Hashtable;
-
-/**
- * Bean that initializes the "java:comp" context
- *
- * @author <a href="bill at jboss.com">Bill Burke</a>
- * @version $Revision: 1.1 $
- */
-public class JavaCompInitializer
-{
-   private InitialContext iniCtx;
-   private Hashtable initialContextProperties;
-
-   public Hashtable getInitialContextProperties()
-   {
-      return initialContextProperties;
-   }
-
-   public void setInitialContextProperties(Hashtable initialContextProperties)
-   {
-      this.initialContextProperties = initialContextProperties;
-   }
-
-   public InitialContext getIniCtx()
-   {
-      return iniCtx;
-   }
-
-   public void setIniCtx(InitialContext iniCtx)
-   {
-      this.iniCtx = iniCtx;
-   }
-
-   protected void initialContext() throws Exception
-   {
-      if (iniCtx != null) return;
-      if (initialContextProperties == null)
-      {
-         iniCtx = new InitialContext();
-      }
-      else
-      {
-         iniCtx = new InitialContext(initialContextProperties);
-      }
-   }
-
-   public void start() throws Exception
-   {
-      initialContext();
-      ClassLoader topLoader = Thread.currentThread().getContextClassLoader();
-      ENCFactory.setTopClassLoader(topLoader);
-      RefAddr refAddr = new StringRefAddr("nns", "ENC");
-      Reference envRef = new Reference("javax.naming.Context", refAddr, ENCFactory.class.getName(), null);
-      Context ctx = (Context)iniCtx.lookup("java:");
-      ctx.rebind("comp", envRef);
-   }
-}

Modified: trunk/server/src/main/org/jboss/naming/NamingService.java
===================================================================
--- trunk/server/src/main/org/jboss/naming/NamingService.java	2007-02-03 18:29:53 UTC (rev 60240)
+++ trunk/server/src/main/org/jboss/naming/NamingService.java	2007-02-03 18:49:26 UTC (rev 60241)
@@ -1,24 +1,24 @@
 /*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
 package org.jboss.naming;
 
 import java.io.InputStream;
@@ -26,17 +26,14 @@
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.UndeclaredThrowableException;
 import java.net.UnknownHostException;
+import java.rmi.server.RMIClientSocketFactory;
+import java.rmi.server.RMIServerSocketFactory;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
-import java.util.Hashtable;
 import java.util.Map;
 import java.util.Properties;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.RefAddr;
-import javax.naming.Reference;
-import javax.naming.StringRefAddr;
+import javax.net.ServerSocketFactory;
 
 import org.jboss.invocation.Invocation;
 import org.jboss.invocation.MarshalledInvocation;
@@ -47,11 +44,12 @@
 import org.jnp.interfaces.Naming;
 import org.jnp.interfaces.MarshalledValuePair;
 import org.jnp.server.Main;
+import org.jnp.server.NamingBean;
 
 /**
  * A JBoss service that starts the jnp JNDI server.
  *
- * @author <a href="mailto:rickard.oberg at telkel.com">Rickard �berg</a>
+ * @author <a href="mailto:rickard.oberg at telkel.com">Rickard Oberg</a>
  * @author <a href="mailto:Scott.Stark at jboss.org">Scott Stark</a>.
  * @author <a href="mailto:andreas at jboss.org">Andreas Schaefer</a>.
  * @version $Revision$
@@ -63,8 +61,10 @@
    extends ServiceMBeanSupport
    implements NamingServiceMBean
 {
-   /** The actual naming service impl from the legacy jndi service */
-   private Main naming;
+   /** The actual namingMain service impl bean */
+   private NamingBean namingBean;
+   /** */
+   private Main namingMain = new Main();
    /** The hash mappings of the Naming interface methods */
    private Map marshalledInvocationMapping = new HashMap();
    /** An optional proxy factory for externalizing the Naming proxy transport */
@@ -72,27 +72,41 @@
 
    public NamingService()
    {
-      naming = new Main(this.getClass().getName());
    }
 
+   public NamingBean getNaming()
+   {
+      return namingBean;
+   }
+   public void setNaming(NamingBean bean)
+   {
+      this.namingBean = bean;
+      this.namingMain.setNamingInfo(bean);
+   }
+
+   public Naming getNamingInstance()
+   {
+      return namingBean.getNamingInstance();
+   }
+
    /** Set the thread pool used for the bootstrap lookups
     *
     * @jmx:managed-attribute
     *
-    * @param poolMBean
+    * @param poolMBean 
     */
    public void setLookupPool(BasicThreadPoolMBean poolMBean)
    {
       ThreadPool lookupPool = poolMBean.getInstance();
-      naming.setLookupPool(lookupPool);
+      namingMain.setLookupPool(lookupPool);
    }
 
    /** Get the call by value flag for jndi lookups.
-    *
+    * 
     * @jmx:managed-attribute
     * @return true if all lookups are unmarshalled using the caller's TCL,
     *    false if in VM lookups return the value by reference.
-    */
+    */ 
    public boolean getCallByValue()
    {
       return MarshalledValuePair.getEnableCallByReference() == false;
@@ -111,111 +125,135 @@
 
    public void setPort(int port)
    {
-      naming.setPort(port);
+      namingMain.setPort(port);
    }
 
    public int getPort()
    {
-      return naming.getPort();
+      return namingMain.getPort();
    }
 
    public void setRmiPort(int port)
    {
-      naming.setRmiPort(port);
+      namingMain.setRmiPort(port);
    }
 
    public int getRmiPort()
    {
-      return naming.getRmiPort();
+      return namingMain.getRmiPort();
    }
 
    public String getBindAddress()
    {
-      return naming.getBindAddress();
+      return namingMain.getBindAddress();
    }
 
    public void setBindAddress(String host) throws UnknownHostException
    {
-      naming.setBindAddress(host);
+      namingMain.setBindAddress(host);
    }
 
    public String getRmiBindAddress()
    {
-      return naming.getRmiBindAddress();
+      return namingMain.getRmiBindAddress();
    }
 
    public void setRmiBindAddress(String host) throws UnknownHostException
    {
-      naming.setRmiBindAddress(host);
+      namingMain.setRmiBindAddress(host);
    }
 
    public int getBacklog()
    {
-      return naming.getBacklog();
+      return namingMain.getBacklog();
    }
 
    public void setBacklog(int backlog)
    {
-      naming.setBacklog(backlog);
+      namingMain.setBacklog(backlog);
    }
 
    public boolean getInstallGlobalService()
    {
-      return naming.getInstallGlobalService();
+      return namingMain.getInstallGlobalService();
    }
    public void setInstallGlobalService(boolean flag)
    {
-      naming.setInstallGlobalService(flag);
+      namingMain.setInstallGlobalService(flag);
    }
-
+   public boolean getUseGlobalService()
+   {
+      return namingMain.getUseGlobalService();
+   }
+   public void setUseGlobalService(boolean flag)
+   {
+      namingMain.setUseGlobalService(flag);
+   }
    public String getClientSocketFactory()
    {
-      return naming.getClientSocketFactory();
+      return namingMain.getClientSocketFactory();
    }
-
    public void setClientSocketFactory(String factoryClassName)
       throws ClassNotFoundException, InstantiationException, IllegalAccessException
    {
-      naming.setClientSocketFactory(factoryClassName);
+      namingMain.setClientSocketFactory(factoryClassName);
    }
 
+   public RMIClientSocketFactory getClientSocketFactoryBean()
+   {
+      return namingMain.getClientSocketFactoryBean();
+   }
+   public void setClientSocketFactoryBean(RMIClientSocketFactory factory)
+   {
+      namingMain.setClientSocketFactoryBean(factory);
+   }
+
    public String getServerSocketFactory()
    {
-      return naming.getServerSocketFactory();
+      return namingMain.getServerSocketFactory();
    }
-
    public void setServerSocketFactory(String factoryClassName)
       throws ClassNotFoundException, InstantiationException, IllegalAccessException
    {
-      naming.setServerSocketFactory(factoryClassName);
+      namingMain.setServerSocketFactory(factoryClassName);
    }
+   public RMIServerSocketFactory getServerSocketFactoryBean()
+   {
+      return namingMain.getServerSocketFactoryBean();
+   }
+   public void setServerSocketFactoryBean(RMIServerSocketFactory factory)
+   {
+      namingMain.setServerSocketFactoryBean(factory);      
+   }
 
+   public String getJNPServerSocketFactory()
+   {
+      return namingMain.getJNPServerSocketFactory();
+   }
    public void setJNPServerSocketFactory(String factoryClassName)
       throws ClassNotFoundException, InstantiationException, IllegalAccessException
    {
-      naming.setJNPServerSocketFactory(factoryClassName);
+      namingMain.setJNPServerSocketFactory(factoryClassName);
    }
-
-   public void setInvokerProxyFactory(JRMPProxyFactoryMBean proxyFactory)
+   public ServerSocketFactory getJNPServerSocketFactoryBean()
    {
-      this.proxyFactory = proxyFactory;
+      return namingMain.getJNPServerSocketFactoryBean();
    }
-   
-   public void createAlias(String fromName, String toName) throws Exception
+   public void setJNPServerSocketFactoryBean(ServerSocketFactory factory)
    {
-      Util.createLinkRef(fromName, toName);
-      log.info("Created alias " + fromName + "->" + toName);
+      namingMain.setJNPServerSocketFactoryBean(factory);
    }
-   
-   public void removeAlias(String name) throws Exception
+
+   public void setInvokerProxyFactory(JRMPProxyFactoryMBean proxyFactory)
    {
-      log.info("Removing alias " + name);
-      Util.removeLinkRef(name);
+      this.proxyFactory = proxyFactory;
    }
 
    protected void startService()
       throws Exception
    {
+      boolean debug = log.isDebugEnabled();
+
       // Read jndi.properties into system properties
       ClassLoader loader = Thread.currentThread().getContextClassLoader();
       InputStream is = loader.getResourceAsStream("jndi.properties");
@@ -235,48 +273,16 @@
       {
          String key = (String) keys.nextElement();
          String value = props.getProperty(key);
-         log.debug("System.setProperty, key="+key+", value="+value);
+         if (debug)
+         {
+            log.debug("System.setProperty, key="+key+", value="+value);
+         }
          System.setProperty(key, value);
       }
       if( proxyFactory != null )
-         naming.setNamingProxy(proxyFactory.getProxy());
-      naming.start();
+         namingMain.setNamingProxy(proxyFactory.getProxy());
+      namingMain.start();
 
-      /* Create a default InitialContext and dump out its env to show what properties
-         were used in its creation. If we find a Context.PROVIDER_URL property
-         issue a warning as this means JNDI lookups are going through RMI.
-      */
-      InitialContext iniCtx = new InitialContext();
-      Hashtable env = iniCtx.getEnvironment();
-      log.debug("InitialContext Environment: ");
-      Object providerURL = null;
-      for (Enumeration keys = env.keys(); keys.hasMoreElements(); )
-      {
-         Object key = keys.nextElement();
-         Object value = env.get(key);
-         String type = value == null ? "" : value.getClass().getName();
-         log.debug("key="+key+", value("+type+")="+value);
-         if( key.equals(Context.PROVIDER_URL) )
-            providerURL = value;
-      }
-      // Warn if there was a Context.PROVIDER_URL
-      if( providerURL != null )
-         log.warn("Context.PROVIDER_URL in server jndi.properties, url="+providerURL);
-
-      /* Bind an ObjectFactory to "java:comp" so that "java:comp/env" lookups
-         produce a unique context for each thread contexxt ClassLoader that
-         performs the lookup.
-      */
-      ClassLoader topLoader = Thread.currentThread().getContextClassLoader();
-      ENCFactory.setTopClassLoader(topLoader);
-      RefAddr refAddr = new StringRefAddr("nns", "ENC");
-      Reference envRef = new Reference("javax.naming.Context", refAddr, ENCFactory.class.getName(), null);
-      Context ctx = (Context)iniCtx.lookup("java:");
-      ctx.rebind("comp", envRef);
-      log.debug("Listening on port "+naming.getPort());
-      ctx.close();
-      iniCtx.close();
-
       // Build the Naming interface method map
       HashMap tmpMap = new HashMap(13);
       Method[] methods = Naming.class.getMethods();
@@ -292,7 +298,7 @@
    protected void stopService()
       throws Exception
    {
-      naming.stop();
+      namingMain.stop();
       log.debug("JNP server stopped");
    }
 
@@ -307,7 +313,7 @@
     */
    protected Main getNamingServer()
    {
-      return naming;
+      return namingMain;
    } // end of main()
 
 
@@ -321,6 +327,18 @@
    {
       return marshalledInvocationMapping;
    }
+   
+   public void createAlias(String fromName, String toName) throws Exception
+   {
+      Util.createLinkRef(fromName, toName);
+      log.info("Created alias " + fromName + "->" + toName);
+   }
+   
+   public void removeAlias(String name) throws Exception
+   {
+      log.info("Removing alias " + name);
+      Util.removeLinkRef(name);
+   }
 
    /** Expose the Naming service via JMX to invokers.
     *
@@ -333,7 +351,7 @@
     */
    public Object invoke(Invocation invocation) throws Exception
    {
-      Naming theServer = naming.getServer();
+      Naming theServer = namingMain.getNamingInstance();
       // Set the method hash to Method mapping
       if (invocation instanceof MarshalledInvocation)
       {

Deleted: trunk/server/src/main/org/jboss/naming/ThreadLocalStack.java
===================================================================
--- trunk/server/src/main/org/jboss/naming/ThreadLocalStack.java	2007-02-03 18:29:53 UTC (rev 60240)
+++ trunk/server/src/main/org/jboss/naming/ThreadLocalStack.java	2007-02-03 18:49:26 UTC (rev 60241)
@@ -1,78 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.naming;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision: 42263 $
- */
-public class ThreadLocalStack<T>
-{
-   private ThreadLocal<ArrayList<T>> stack = new ThreadLocal<ArrayList<T>>();
-
-   public void push(T obj)
-   {
-      ArrayList<T> list = stack.get();
-      if (list == null)
-      {
-         list = new ArrayList<T>(1);
-         stack.set(list);
-      }
-      list.add(obj);
-   }
-
-   public T pop()
-   {
-      ArrayList<T> list = stack.get();
-      if (list == null)
-      {
-         return null;
-      }
-      T rtn = list.remove(list.size() - 1);
-      if (list.size() == 0)
-      {
-         stack.set(null);
-         list.clear();
-      }
-      return rtn;
-   }
-
-   public T get()
-   {
-      ArrayList<T> list = (ArrayList<T>)stack.get();
-      if (list == null)
-      {
-         return null;
-      }
-      return list.get(list.size() - 1);
-   }
-
-   public List<T> getList()
-   {
-      return stack.get();
-   }
-}

Deleted: trunk/server/src/main/org/jboss/naming/Util.java
===================================================================
--- trunk/server/src/main/org/jboss/naming/Util.java	2007-02-03 18:29:53 UTC (rev 60240)
+++ trunk/server/src/main/org/jboss/naming/Util.java	2007-02-03 18:49:26 UTC (rev 60241)
@@ -1,32 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.naming;
-
-/** A static utility class for common JNDI operations.
- *
- * @author Scott.Stark at jboss.org
- * @author adrian at jboss.com
- * @version $Revision$
- */
-public class Util extends org.jboss.util.naming.Util
-{
-}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list