[jboss-cvs] JBossAS SVN: r59390 - in trunk: server/src/main/org/jboss/naming system-jmx/src/main/org/jboss/system/deployers

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Jan 5 17:18:00 EST 2007


Author: bill.burke at jboss.com
Date: 2007-01-05 17:17:58 -0500 (Fri, 05 Jan 2007)
New Revision: 59390

Added:
   trunk/server/src/main/org/jboss/naming/JavaCompInitializer.java
Modified:
   trunk/system-jmx/src/main/org/jboss/system/deployers/ServiceDeployer.java
Log:
* Refactored out java:comp initialization into its own bean org.jboss.naming.JavaCompInitializer.  Currently only used by Embedded JBoss
* ServiceDeployer will use use a default classloader OBjectName if the current classloader is not a RepositoryClassLoader.  This was done so that EmbeddedJBoss could use the JavaSE classloader

Added: trunk/server/src/main/org/jboss/naming/JavaCompInitializer.java
===================================================================
--- trunk/server/src/main/org/jboss/naming/JavaCompInitializer.java	2007-01-05 22:14:20 UTC (rev 59389)
+++ trunk/server/src/main/org/jboss/naming/JavaCompInitializer.java	2007-01-05 22:17:58 UTC (rev 59390)
@@ -0,0 +1,88 @@
+/*
+* 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/system-jmx/src/main/org/jboss/system/deployers/ServiceDeployer.java
===================================================================
--- trunk/system-jmx/src/main/org/jboss/system/deployers/ServiceDeployer.java	2007-01-05 22:14:20 UTC (rev 59389)
+++ trunk/system-jmx/src/main/org/jboss/system/deployers/ServiceDeployer.java	2007-01-05 22:17:58 UTC (rev 59390)
@@ -27,6 +27,8 @@
 import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.deployers.spi.deployer.DeploymentUnit;
 import org.jboss.mx.loading.RepositoryClassLoader;
+import org.jboss.mx.util.ObjectNameFactory;
+import org.jboss.mx.server.ServerConstants;
 import org.jboss.system.ServiceContext;
 import org.jboss.system.ServiceController;
 import org.jboss.system.metadata.ServiceDeployment;
@@ -45,7 +47,10 @@
 {
    /** The service controller */
    private final ServiceController controller;
+   public static final ObjectName DEFAULT_CLASSLOADER_OBJECT_NAME = ObjectNameFactory.create("jboss:service=defaultClassLoader");
 
+   private ObjectName defaultClassLoader = DEFAULT_CLASSLOADER_OBJECT_NAME;
+
    /**
     * Create a new ServiceDeployer.
     * 
@@ -60,6 +65,17 @@
       this.controller = controller;
    }
 
+
+   public ObjectName getDefaultClassLoader()
+   {
+      return defaultClassLoader;
+   }
+
+   public void setDefaultClassLoader(ObjectName defaultClassLoader)
+   {
+      this.defaultClassLoader = defaultClassLoader;
+   }
+
    public void deploy(DeploymentUnit unit, ServiceMetaData deployment) throws DeploymentException
    {
       ObjectName name = deployment.getObjectName();
@@ -71,6 +87,8 @@
             ClassLoader cl = unit.getClassLoader();
             if (cl != null && cl instanceof RepositoryClassLoader)
                loaderName = ((RepositoryClassLoader) cl).getObjectName();
+            else
+               loaderName = defaultClassLoader;
          }
 
          controller.install(deployment, loaderName);




More information about the jboss-cvs-commits mailing list