[jboss-cvs] JBossAS SVN: r79221 - in trunk: server/src/etc/conf/default and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Oct 7 10:04:38 EDT 2008


Author: adrian at jboss.org
Date: 2008-10-07 10:04:38 -0400 (Tue, 07 Oct 2008)
New Revision: 79221

Added:
   trunk/server/src/main/org/jboss/deployment/EarClassLoaderDeployer.java
   trunk/server/src/main/org/jboss/deployment/EarClassLoaderDeployerMBean.java
   trunk/server/src/main/org/jboss/deployment/EjbClassLoaderDeployer.java
   trunk/server/src/main/org/jboss/deployment/LoaderRepositoryMetaDataHelper.java
   trunk/system-jmx/src/main/org/jboss/system/deployers/LoaderRepositoryConfigHelper.java
Removed:
   trunk/system-jmx/src/main/org/jboss/system/deployers/HackClassloaderMetaDataDeployer.java
   trunk/testsuite/src/main/org/jboss/test/deployers/ear/test/JBossAppParsingDeployerUnitTestCase.java
Modified:
   trunk/connector/src/main/org/jboss/resource/deployers/ManagedConnectionFactoryClassLoaderDeployer.java
   trunk/server/src/etc/conf/default/deployers.xml
   trunk/server/src/etc/deployers/ear-deployer-jboss-beans.xml
   trunk/server/src/etc/deployers/ejb-deployer-jboss-beans.xml
   trunk/server/src/main/org/jboss/deployment/JBossAppParsingDeployer.java
   trunk/server/src/main/org/jboss/deployment/JBossAppParsingDeployerMBean.java
   trunk/server/src/main/org/jboss/deployment/JBossEjbParsingDeployer.java
   trunk/system-jmx/src/main/org/jboss/system/deployers/ServiceClassLoaderDeployer.java
   trunk/testsuite/src/main/org/jboss/test/isolation/test/IsolationUnitTestCase.java
Log:
[JBAS-6042] - Remove the use of LoaderRepositoryConfig in the deployment chains. Create ClassLoadingMetaData directly and add some helpers for legacy LoaderRepository conversion

Modified: trunk/connector/src/main/org/jboss/resource/deployers/ManagedConnectionFactoryClassLoaderDeployer.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/deployers/ManagedConnectionFactoryClassLoaderDeployer.java	2008-10-07 13:31:30 UTC (rev 79220)
+++ trunk/connector/src/main/org/jboss/resource/deployers/ManagedConnectionFactoryClassLoaderDeployer.java	2008-10-07 14:04:38 UTC (rev 79221)
@@ -35,6 +35,7 @@
 import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.mx.loading.LoaderRepositoryFactory.LoaderRepositoryConfig;
 import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentGroup;
+import org.jboss.system.deployers.LoaderRepositoryConfigHelper;
 
 /**
  * ManagedConnectionFactoryClassLoaderDeployer.
@@ -48,6 +49,7 @@
    {
       super(ManagedConnectionFactoryDeploymentGroup.class);
       setStage(DeploymentStages.POST_PARSE);
+      setTopLevelOnly(true);
       setOutput(ClassLoadingMetaData.class);
    }
 
@@ -55,53 +57,12 @@
    {
       ClassLoadingMetaData classLoadingMetaData = unit.getAttachment(ClassLoadingMetaData.class);
       if (classLoadingMetaData != null)
-      {
-         log.warn("Not converting LoaderRepositoryConfig to ClassLoadingMetaData for " + unit.getName() + " since it already exists: " + classLoadingMetaData);
          return;
-      }
       
       LoaderRepositoryConfig loaderConfig = deployment.getLoaderRepositoryConfig();
       if (loaderConfig == null)
          return;
-      
-      ObjectName name = loaderConfig.repositoryName;
-      if (name != null)
-      {
-         String domain = name.getCanonicalName().trim();
-         if (domain.length() != 0)
-         {
-            ClassLoadingMetaData metaData = new ClassLoadingMetaData();
-            metaData.setName(unit.getName());
-            metaData.setDomain(domain);
-            metaData.setExportAll(ExportAll.NON_EMPTY);
-            metaData.setImportAll(true);
-            metaData.setVersion(Version.DEFAULT_VERSION);
 
-            Properties props = new Properties();
-            String config = loaderConfig.repositoryConfig;
-            try
-            {
-               if (config != null)
-               {
-                  ByteArrayInputStream bais = new ByteArrayInputStream(config.getBytes());
-                  props.load(bais);
-               }
-            }
-            catch (Exception e)
-            {
-               throw DeploymentException.rethrowAsDeploymentException("Error parsing repository config " + config, e);
-            }
-            String java2ParentDelegation = props.getProperty("java2ParentDelegation");
-            if( java2ParentDelegation == null )
-            {
-               // Check for previous mis-spelled property name
-               java2ParentDelegation = props.getProperty("java2ParentDelegaton", "false");
-            }
-            boolean useParentFirst = Boolean.valueOf(java2ParentDelegation).booleanValue();
-            metaData.setJ2seClassLoadingCompliance(useParentFirst);
-            
-            unit.addAttachment(ClassLoadingMetaData.class, metaData);
-         }
-      }
+      LoaderRepositoryConfigHelper.create(unit, loaderConfig);
    }
 }

Modified: trunk/server/src/etc/conf/default/deployers.xml
===================================================================
--- trunk/server/src/etc/conf/default/deployers.xml	2008-10-07 13:31:30 UTC (rev 79220)
+++ trunk/server/src/etc/conf/default/deployers.xml	2008-10-07 14:04:38 UTC (rev 79221)
@@ -178,14 +178,13 @@
    <bean name="SARDeployer" class="org.jboss.system.deployers.SARDeployer">
       <property name="icf"><inject bean="ServiceMetaDataICF"/></property>
    </bean>
+   <bean name="ServiceClassLoaderDeployer" class="org.jboss.system.deployers.ServiceClassLoaderDeployer"/>
    <bean name="ServiceDeploymentDeployer" class="org.jboss.system.deployers.ServiceDeploymentDeployer">
    </bean>
    <bean name="ServiceDeployer" class="org.jboss.system.deployers.ServiceDeployer">
        <constructor><parameter><inject bean="JMXKernel" property="serviceController"/></parameter></constructor>
    </bean>
 
-   <!-- FIXME Remove this -->
-   <bean name="HackClassLoaderMetaDataDeployer" class="org.jboss.system.deployers.HackClassloaderMetaDataDeployer"/>
    <bean name="ClassLoadingMetaDataParser" class="org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer">
       <constructor>
          <parameter>org.jboss.classloading.spi.metadata.ClassLoadingMetaData</parameter>

Modified: trunk/server/src/etc/deployers/ear-deployer-jboss-beans.xml
===================================================================
--- trunk/server/src/etc/deployers/ear-deployer-jboss-beans.xml	2008-10-07 13:31:30 UTC (rev 79220)
+++ trunk/server/src/etc/deployers/ear-deployer-jboss-beans.xml	2008-10-07 14:04:38 UTC (rev 79221)
@@ -42,10 +42,6 @@
             <value>org.jboss.metadata.ear.jboss.JBossAppMetaData</value>
          </parameter>
       </uninstall>
-      <!-- A flag indicating if ear deployments should have their own scoped
-         class loader to isolate their classes from other deployments.
-      -->      
-      <property name="isolated">false</property>
       <!-- A flag indicating if the ear components should have in VM call
          optimization disabled.
       -->
@@ -54,4 +50,10 @@
       <!-- Specify an unauthenticated identity -->
       <property name="unauthenticatedIdentity">anonymous</property>    
    </bean>
+   <bean name="EARClassLoaderDeployer" class="org.jboss.deployment.EarClassLoaderDeployer">
+      <!-- A flag indicating if ear deployments should have their own scoped
+         class loader to isolate their classes from other deployments.
+      -->      
+      <property name="isolated">false</property>
+   </bean>
 </deployment>

Modified: trunk/server/src/etc/deployers/ejb-deployer-jboss-beans.xml
===================================================================
--- trunk/server/src/etc/deployers/ejb-deployer-jboss-beans.xml	2008-10-07 13:31:30 UTC (rev 79220)
+++ trunk/server/src/etc/deployers/ejb-deployer-jboss-beans.xml	2008-10-07 14:04:38 UTC (rev 79221)
@@ -19,6 +19,8 @@
       <property name="standardJBossXmlPath">${jboss.server.config.url}/standardjboss.xml</property>
    </bean>
 
+   <bean name="EjbClassLoaderDeployer" class="org.jboss.deployment.EjbClassLoaderDeployer"/>
+
     <bean name="EJB2xDeployer" class="org.jboss.ejb.deployers.EjbDeployer">
        <install bean="ManagedDeploymentCreator" method="addVersionedAttachmentType">
           <parameter>

Added: trunk/server/src/main/org/jboss/deployment/EarClassLoaderDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/EarClassLoaderDeployer.java	                        (rev 0)
+++ trunk/server/src/main/org/jboss/deployment/EarClassLoaderDeployer.java	2008-10-07 14:04:38 UTC (rev 79221)
@@ -0,0 +1,99 @@
+/*
+* 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.deployment;
+
+import org.jboss.aop.microcontainer.aspects.jmx.JMX;
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
+import org.jboss.classloading.spi.metadata.ExportAll;
+import org.jboss.classloading.spi.version.Version;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.metadata.common.jboss.LoaderRepositoryMetaData;
+import org.jboss.metadata.ear.jboss.JBossAppMetaData;
+
+/**
+ * EarClassLoaderDeployer.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+ at JMX(name="jboss.j2ee:service=EARClassLoaderDeployer", exposedInterface=EarClassLoaderDeployerMBean.class)
+public class EarClassLoaderDeployer extends AbstractSimpleRealDeployer<JBossAppMetaData> implements EarClassLoaderDeployerMBean
+{
+   /** Whether to isolated ear deployments */
+   private boolean isolated = false;
+
+   /**
+    * @return whether ear deployments should be isolated
+    */
+   public boolean isIsolated()
+   {
+      return isolated;
+   }
+   
+   /**
+    * @param isolated whether ear deployments should be isolated
+    */
+   public void setIsolated(boolean isolated)
+   {
+      this.isolated = isolated;
+   }
+   
+   /**
+    * Create a new EarClassLoaderDeployer.
+    */
+   public EarClassLoaderDeployer()
+   {
+      super(JBossAppMetaData.class);
+      setOutput(ClassLoadingMetaData.class);
+      setStage(DeploymentStages.POST_PARSE);
+      setTopLevelOnly(true);
+   }
+
+   @Override
+   public void deploy(DeploymentUnit unit, JBossAppMetaData metaData) throws DeploymentException
+   {
+      ClassLoadingMetaData classLoadingMetaData = unit.getAttachment(ClassLoadingMetaData.class);
+      if (classLoadingMetaData != null)
+         return;
+
+      LoaderRepositoryMetaData lrmd = metaData.getLoaderRepository();
+      if (lrmd != null)
+      {
+         ClassLoadingMetaData clmd = LoaderRepositoryMetaDataHelper.create(unit, lrmd);
+         // For isolated automatically create the classloader in a new domain
+         if (clmd == null && isolated)
+         {
+            String domain = EARDeployment.getJMXName(metaData, unit) + ",extension=LoaderRepository";
+            classLoadingMetaData = new ClassLoadingMetaData();
+            classLoadingMetaData.setName(unit.getName());
+            classLoadingMetaData.setDomain(domain);
+            classLoadingMetaData.setExportAll(ExportAll.NON_EMPTY);
+            classLoadingMetaData.setImportAll(true);
+            classLoadingMetaData.setVersion(Version.DEFAULT_VERSION);
+            classLoadingMetaData.setJ2seClassLoadingCompliance(false);
+         }
+      }
+   }
+}

Added: trunk/server/src/main/org/jboss/deployment/EarClassLoaderDeployerMBean.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/EarClassLoaderDeployerMBean.java	                        (rev 0)
+++ trunk/server/src/main/org/jboss/deployment/EarClassLoaderDeployerMBean.java	2008-10-07 14:04:38 UTC (rev 79221)
@@ -0,0 +1,52 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, 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.jboss.deployment;
+
+import javax.management.ObjectName;
+
+import org.jboss.mx.util.ObjectNameFactory;
+
+/**
+ * EarClassLoaderDeployerMBean.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface EarClassLoaderDeployerMBean
+{
+   /** The default ObjectName */
+   ObjectName OBJECT_NAME = ObjectNameFactory.create("jboss.j2ee:service=EARClassLoaderDeployer");
+   
+   /**
+    * Return true if ears should be isolated by default
+    * 
+    * @return whether ears should be isolated
+    */
+   boolean isIsolated();
+   
+   /**
+    * Set whether ears should isolated
+    * 
+    * @param isolated true for isolated ears
+    */
+   void setIsolated(boolean isolated);
+}

Added: trunk/server/src/main/org/jboss/deployment/EjbClassLoaderDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/EjbClassLoaderDeployer.java	                        (rev 0)
+++ trunk/server/src/main/org/jboss/deployment/EjbClassLoaderDeployer.java	2008-10-07 14:04:38 UTC (rev 79221)
@@ -0,0 +1,62 @@
+/*
+* 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.deployment;
+
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.metadata.common.jboss.LoaderRepositoryMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+
+/**
+ * EjbClassLoaderDeployer.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class EjbClassLoaderDeployer extends AbstractSimpleRealDeployer<JBossMetaData>
+{
+   /**
+    * Create a new EjbClassLoaderDeployer.
+    */
+   public EjbClassLoaderDeployer()
+   {
+      super(JBossMetaData.class);
+      setOutput(ClassLoadingMetaData.class);
+      setStage(DeploymentStages.POST_PARSE);
+      setTopLevelOnly(true);
+   }
+
+   @Override
+   public void deploy(DeploymentUnit unit, JBossMetaData metaData) throws DeploymentException
+   {
+      ClassLoadingMetaData classLoadingMetaData = unit.getAttachment(ClassLoadingMetaData.class);
+      if (classLoadingMetaData != null)
+         return;
+
+      LoaderRepositoryMetaData lrmd = metaData.getLoaderRepository();
+      if (lrmd != null)
+         LoaderRepositoryMetaDataHelper.create(unit, lrmd);
+   }
+}

Modified: trunk/server/src/main/org/jboss/deployment/JBossAppParsingDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/JBossAppParsingDeployer.java	2008-10-07 13:31:30 UTC (rev 79220)
+++ trunk/server/src/main/org/jboss/deployment/JBossAppParsingDeployer.java	2008-10-07 14:04:38 UTC (rev 79221)
@@ -21,21 +21,12 @@
  */
 package org.jboss.deployment;
 
-import java.util.Set;
-
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
 import org.jboss.aop.microcontainer.aspects.jmx.JMX;
 import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer;
-import org.jboss.metadata.common.jboss.LoaderRepositoryConfigMetaData;
-import org.jboss.metadata.common.jboss.LoaderRepositoryMetaData;
 import org.jboss.metadata.ear.jboss.JBossAppMetaData;
 import org.jboss.metadata.ear.spec.EarMetaData;
-import org.jboss.mx.loading.LoaderRepositoryFactory;
-import org.jboss.mx.loading.LoaderRepositoryFactory.LoaderRepositoryConfig;
 
 /**
  * An ObjectModelFactoryDeployer for translating jboss-app.xml descriptors into
@@ -49,8 +40,6 @@
 @JMX(name="jboss.j2ee:service=EARDeployer", exposedInterface=JBossAppParsingDeployerMBean.class)
 public class JBossAppParsingDeployer extends SchemaResolverDeployer<JBossAppMetaData> implements JBossAppParsingDeployerMBean
 {
-   private boolean isolated = false;
-
    private boolean callByValue = false;
    
    private String unauthenticatedIdentity = null;
@@ -86,24 +75,8 @@
    {
       setName(appXmlPath);
    }
-
-   /**
-    * @return whether ear deployments should be isolated
-    */
-   public boolean isIsolated()
-   {
-      return isolated;
-   }
    
    /**
-    * @param isolated whether ear deployments should be isolated
-    */
-   public void setIsolated(boolean isolated)
-   {
-      this.isolated = isolated;
-   }
-   
-   /**
     * @return whether ear deployments should be call by value
     */
    public boolean isCallByValue()
@@ -149,51 +122,10 @@
       if(specMetaData == null && metaData == null)
          return;
 
-      LoaderRepositoryConfig loaderCfg = null;
-
       // If there no JBossMetaData was created from a jboss-app.xml, create one
       if (metaData == null)
-      {
          metaData = new JBossAppMetaData();
-      }
-      else
-      {
-         LoaderRepositoryMetaData lrmd = metaData.getLoaderRepository();
-         if (lrmd != null)
-         {
-            loaderCfg = new LoaderRepositoryConfig();
-            loaderCfg.repositoryClassName = lrmd.getLoaderRepositoryClass();
-            if(lrmd.getName() != null)
-            {
-               try
-               {
-                  loaderCfg.repositoryName = new ObjectName(lrmd.getName());
-               }
-               catch (MalformedObjectNameException e)
-               {
-                  throw new DeploymentException("Invalid object name: " + lrmd.getName(), e);
-               }
-            }
-            Set<LoaderRepositoryConfigMetaData> configs = lrmd.getLoaderRepositoryConfig();
-            if (configs != null && configs.isEmpty() == false)
-            {
-               LoaderRepositoryConfigMetaData config = configs.iterator().next();
-               loaderCfg.configParserClassName = config.getConfigParserClass();
-               loaderCfg.repositoryConfig = config.getConfig();
-            }
-         }
-      }
 
-      if (loaderCfg == null && isolated)
-      {
-         // If no config was given and isolation is on, create an isolated config
-         loaderCfg = initLoaderRepository(metaData, unit);
-      }
-
-      // Add the loader repository config
-      if (loaderCfg != null)
-         unit.addAttachment(LoaderRepositoryConfig.class, loaderCfg);
-
       // Create a merged view
       JBossAppMetaData mergedMetaData = new JBossAppMetaData();
       mergedMetaData.merge(metaData, specMetaData);
@@ -208,28 +140,4 @@
       if (this.unauthenticatedIdentity != null)
          unit.addAttachment("EAR.unauthenticatedIdentity", this.unauthenticatedIdentity, String.class);
    }
-
-   /** Build the ear scoped repository
-   *
-   * @param metaData the deployment info passed to deploy
-   * @param unit the deployment unit
-   * @return LoaderRepositoryConfig to use
-   * @throws DeploymentException for any error
-   */
-  protected LoaderRepositoryConfig initLoaderRepository(JBossAppMetaData metaData, DeploymentUnit unit)
-     throws DeploymentException
-  {
-     try
-     {
-        String name = EARDeployment.getJMXName(metaData, unit) + ",extension=LoaderRepository";
-        ObjectName objectName = new ObjectName(name);
-        LoaderRepositoryConfig config = new LoaderRepositoryFactory.LoaderRepositoryConfig();
-        config.repositoryName = objectName;
-        return config;
-     }
-     catch(Exception e)
-     {
-        throw new DeploymentException("Failed to create LoaderRepositoryConfig", e);
-     }
-  }
 }

Modified: trunk/server/src/main/org/jboss/deployment/JBossAppParsingDeployerMBean.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/JBossAppParsingDeployerMBean.java	2008-10-07 13:31:30 UTC (rev 79220)
+++ trunk/server/src/main/org/jboss/deployment/JBossAppParsingDeployerMBean.java	2008-10-07 14:04:38 UTC (rev 79221)
@@ -29,9 +29,6 @@
  */
 public interface JBossAppParsingDeployerMBean
 {
-   boolean isIsolated();
-   void setIsolated(boolean isolated);
-
    boolean isCallByValue();
    void setCallByValue(boolean callByValue);
 }

Modified: trunk/server/src/main/org/jboss/deployment/JBossEjbParsingDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/JBossEjbParsingDeployer.java	2008-10-07 13:31:30 UTC (rev 79220)
+++ trunk/server/src/main/org/jboss/deployment/JBossEjbParsingDeployer.java	2008-10-07 14:04:38 UTC (rev 79221)
@@ -22,21 +22,13 @@
 package org.jboss.deployment;
 
 import java.net.URL;
-import java.util.Set;
 
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
 import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer;
 import org.jboss.metadata.ApplicationMetaData;
-import org.jboss.metadata.common.jboss.LoaderRepositoryConfigMetaData;
-import org.jboss.metadata.common.jboss.LoaderRepositoryMetaData;
 import org.jboss.metadata.ejb.jboss.JBossMetaData;
 import org.jboss.metadata.ejb.spec.EjbJarMetaData;
-import org.jboss.mx.loading.LoaderRepositoryFactory.LoaderRepositoryConfig;
-import org.jboss.mx.server.ServerConstants;
 import org.jboss.system.server.ServerConfig;
 import org.jboss.virtual.VFS;
 import org.jboss.virtual.VirtualFile;
@@ -73,8 +65,6 @@
       addOutput(ApplicationMetaData.class.getName());
       // Output the standardjboss.xml metadata
       addOutput("standardjboss.xml");
-      // Output the LoaderRepositoryConfig
-      addOutput(LoaderRepositoryConfig.class);
    }
 
    public URL getStandardJBossXmlPath()
@@ -118,71 +108,10 @@
             // For legacy - but its totally redundant????
             ApplicationMetaData amd = new ApplicationMetaData(jbossMetaData);
             unit.addAttachment(ApplicationMetaData.class, amd);
-
-            // Add the loader repository config
-            LoaderRepositoryConfig loaderRepositoryConfig = createLoaderRepositoryConfig(jbossMetaData);
-            if (loaderRepositoryConfig != null)
-               unit.addAttachment(LoaderRepositoryConfig.class.getName(), loaderRepositoryConfig);
          }
       }
    }
 
-   /**
-    * Create the loader repository config
-    * 
-    * @param jbossMetaData the jboss metadata
-    * @return the loader repository config or null if there isn't one
-    * @throws DeploymentException for any error
-    */
-   protected LoaderRepositoryConfig createLoaderRepositoryConfig(JBossMetaData jbossMetaData) throws DeploymentException
-   {
-      LoaderRepositoryMetaData config = jbossMetaData.getLoaderRepository();
-      if (config == null)
-         return null;
-      
-      LoaderRepositoryConfig repositoryConfig = new LoaderRepositoryConfig();
-      
-      repositoryConfig.repositoryClassName = config.getLoaderRepositoryClass();
-      if (repositoryConfig.repositoryClassName == null || repositoryConfig.repositoryClassName.length() == 0)
-         repositoryConfig.repositoryClassName = ServerConstants.DEFAULT_SCOPED_REPOSITORY_CLASS;
-
-      // Get the object name of the repository
-      String name = config.getName();
-      if (name != null)
-      {
-         try
-         {
-            repositoryConfig.repositoryName = new ObjectName(name.trim());
-         }
-         catch (MalformedObjectNameException e)
-         {
-            throw new DeploymentException("Loader repository name is malformed: " + name, e);
-         }
-      }
-      
-      StringBuilder configData = new StringBuilder();
-      Set<LoaderRepositoryConfigMetaData> children = config.getLoaderRepositoryConfig();
-      if (children != null)
-      {
-         for (LoaderRepositoryConfigMetaData child : children)
-         {
-            // This looks stupid? Why inside a loop?
-            String parserClassName = child.getConfigParserClass();
-            if (parserClassName == null || parserClassName.length() == 0)
-               repositoryConfig.configParserClassName = ServerConstants.DEFAULT_SCOPED_REPOSITORY_PARSER_CLASS;
-            else
-               repositoryConfig.configParserClassName = parserClassName;
-            
-            // Append all config
-            String childConfig = child.getConfig();
-            if (childConfig != null)
-               configData.append(childConfig);
-         }
-      }
-      repositoryConfig.repositoryConfig = configData.toString().trim();
-      return repositoryConfig;
-   }
-
    private JBossMetaData getStandardMetaData() throws DeploymentException
    {
       if (standardMetaData == null)

Added: trunk/server/src/main/org/jboss/deployment/LoaderRepositoryMetaDataHelper.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/LoaderRepositoryMetaDataHelper.java	                        (rev 0)
+++ trunk/server/src/main/org/jboss/deployment/LoaderRepositoryMetaDataHelper.java	2008-10-07 14:04:38 UTC (rev 79221)
@@ -0,0 +1,158 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, 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.jboss.deployment;
+
+import java.util.Set;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.metadata.common.jboss.LoaderRepositoryConfigMetaData;
+import org.jboss.metadata.common.jboss.LoaderRepositoryMetaData;
+import org.jboss.mx.loading.LoaderRepositoryFactory.LoaderRepositoryConfig;
+import org.jboss.mx.server.ServerConstants;
+import org.jboss.system.deployers.LoaderRepositoryConfigHelper;
+
+/**
+ * LoaderRepositoryMetaDataHelper.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class LoaderRepositoryMetaDataHelper
+{
+   /**
+    * Populate the deployment's classloading metadata from a loader repository metadata
+    * with parent delegation false.
+    * 
+    * @param unit the deployment unit
+    * @param loaderMetaData the loader meta data
+    * @return the classloading metadata
+    * @throws DeploymentException for any error
+    */
+   public static ClassLoadingMetaData create(DeploymentUnit unit, LoaderRepositoryMetaData loaderMetaData) throws DeploymentException
+   {
+      return create(unit, loaderMetaData, false);
+   }
+
+   /**
+    * Populate the deployment's classloading metadata from a loader repository metadata
+    * 
+    * @param unit the deployment unit
+    * @param loaderMetaData the loader repository metadata
+    * @param parentDelegation the default value for parent delegation
+    * @return the classloading metadata
+    * @throws DeploymentException for any error
+    */
+   public static ClassLoadingMetaData create(DeploymentUnit unit, LoaderRepositoryMetaData loaderMetaData, boolean parentDelegation) throws DeploymentException
+   {
+      if (unit == null)
+         throw new IllegalArgumentException("Null unit");
+      
+      ClassLoadingMetaData clmd = unit.getAttachment(ClassLoadingMetaData.class);
+      if (clmd != null)
+         return clmd;
+      
+      clmd = create(unit.getName(), loaderMetaData, parentDelegation);
+      if (clmd != null)
+         unit.addAttachment(ClassLoadingMetaData.class, clmd);
+      return clmd;
+   }
+
+   /**
+    * Create classloading metadata from a loader repository metadata
+    * with parent delegation false
+    * 
+    * @param deploymentName the deployment name
+    * @param loaderMetaData the loader repository metadata
+    * @return the classloading metadata
+    * @throws DeploymentException for any error
+    */
+   public static ClassLoadingMetaData create(String deploymentName, LoaderRepositoryMetaData loaderMetaData) throws DeploymentException
+   {
+      return create(deploymentName, loaderMetaData, false);
+   }
+
+   /**
+    * Create classloading metadata from a loader repository metadata
+    * 
+    * @param deploymentName the deployment name
+    * @param loaderMetaData the loader repository metadata
+    * @param parentDelegation the default value for parent delegation
+    * @return the classloading metadata
+    * @throws DeploymentException for any error
+    */
+   public static ClassLoadingMetaData create(String deploymentName, LoaderRepositoryMetaData loaderMetaData, boolean parentDelegation) throws DeploymentException
+   {
+      if (deploymentName == null)
+         throw new IllegalArgumentException("Null deployment name");
+      if (loaderMetaData == null)
+         throw new IllegalArgumentException("Null loader repository metadata");
+
+      
+      LoaderRepositoryConfig repositoryConfig = new LoaderRepositoryConfig();
+      
+      repositoryConfig.repositoryClassName = loaderMetaData.getLoaderRepositoryClass();
+      if (repositoryConfig.repositoryClassName == null || repositoryConfig.repositoryClassName.length() == 0)
+         repositoryConfig.repositoryClassName = ServerConstants.DEFAULT_SCOPED_REPOSITORY_CLASS;
+
+      // Get the object name of the repository
+      String name = loaderMetaData.getName();
+      if (name != null)
+      {
+         try
+         {
+            repositoryConfig.repositoryName = new ObjectName(name.trim());
+         }
+         catch (MalformedObjectNameException e)
+         {
+            throw new DeploymentException("Loader repository name is malformed: " + name, e);
+         }
+      }
+      
+      StringBuilder configData = new StringBuilder();
+      Set<LoaderRepositoryConfigMetaData> children = loaderMetaData.getLoaderRepositoryConfig();
+      if (children != null)
+      {
+         for (LoaderRepositoryConfigMetaData child : children)
+         {
+            // This looks stupid? Why inside a loop?
+            String parserClassName = child.getConfigParserClass();
+            if (parserClassName == null || parserClassName.length() == 0)
+               repositoryConfig.configParserClassName = ServerConstants.DEFAULT_SCOPED_REPOSITORY_PARSER_CLASS;
+            else
+               repositoryConfig.configParserClassName = parserClassName;
+            
+            // Append all config
+            String childConfig = child.getConfig();
+            if (childConfig != null)
+               configData.append(childConfig);
+         }
+      }
+      repositoryConfig.repositoryConfig = configData.toString().trim();
+
+      return LoaderRepositoryConfigHelper.create(name, repositoryConfig, parentDelegation);
+   }
+}

Deleted: trunk/system-jmx/src/main/org/jboss/system/deployers/HackClassloaderMetaDataDeployer.java
===================================================================
--- trunk/system-jmx/src/main/org/jboss/system/deployers/HackClassloaderMetaDataDeployer.java	2008-10-07 13:31:30 UTC (rev 79220)
+++ trunk/system-jmx/src/main/org/jboss/system/deployers/HackClassloaderMetaDataDeployer.java	2008-10-07 14:04:38 UTC (rev 79221)
@@ -1,107 +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.system.deployers;
-
-import java.io.ByteArrayInputStream;
-import java.util.Properties;
-
-import javax.management.ObjectName;
-
-import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
-import org.jboss.classloading.spi.metadata.ExportAll;
-import org.jboss.classloading.spi.version.Version;
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.DeploymentStages;
-import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.mx.loading.LoaderRepositoryFactory.LoaderRepositoryConfig;
-import org.jboss.system.metadata.ServiceDeployment;
-
-/**
- * Hacky deployer to create ClassLoaderMetaData and Module from real
- * 
- * This deployer is responsible for creating classloaders for services of
- * type {@link ServiceDeployment}.
- * 
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class HackClassloaderMetaDataDeployer extends AbstractSimpleRealDeployer<LoaderRepositoryConfig>
-{
-   public HackClassloaderMetaDataDeployer()
-   {
-      super(LoaderRepositoryConfig.class);
-      setStage(DeploymentStages.POST_PARSE);
-      setOutput(ClassLoadingMetaData.class);
-   }
-
-   public void deploy(DeploymentUnit unit, LoaderRepositoryConfig loaderConfig) throws DeploymentException
-   {
-      ClassLoadingMetaData classLoadingMetaData = unit.getAttachment(ClassLoadingMetaData.class);
-      if (classLoadingMetaData != null)
-      {
-         log.warn("Not converting LoaderRepositoryConfig to ClassLoadingMetaData for " + unit.getName() + " since it already exists: " + classLoadingMetaData);
-         return;
-      }
-         
-      log.warn("FIXME Using loader repository config: " + loaderConfig.repositoryName + " for  " + unit.getName() + " use classloading metadata not loader repository config");
-      ObjectName name = loaderConfig.repositoryName;
-      if (name != null)
-      {
-         String domain = name.getCanonicalName().trim();
-         if (domain.length() != 0)
-         {
-            ClassLoadingMetaData metaData = new ClassLoadingMetaData();
-            metaData.setName(unit.getName());
-            metaData.setDomain(domain);
-            metaData.setExportAll(ExportAll.NON_EMPTY);
-            metaData.setImportAll(true);
-            metaData.setVersion(Version.DEFAULT_VERSION);
-
-            Properties props = new Properties();
-            String config = loaderConfig.repositoryConfig;
-            try
-            {
-               if (config != null)
-               {
-                  ByteArrayInputStream bais = new ByteArrayInputStream(config.getBytes());
-                  props.load(bais);
-               }
-            }
-            catch (Exception e)
-            {
-               throw DeploymentException.rethrowAsDeploymentException("Error parsing repository config " + config, e);
-            }
-            String java2ParentDelegation = props.getProperty("java2ParentDelegation");
-            if( java2ParentDelegation == null )
-            {
-               // Check for previous mis-spelled property name
-               java2ParentDelegation = props.getProperty("java2ParentDelegaton", "false");
-            }
-            boolean useParentFirst = Boolean.valueOf(java2ParentDelegation).booleanValue();
-            metaData.setJ2seClassLoadingCompliance(useParentFirst);
-            
-            unit.addAttachment(ClassLoadingMetaData.class, metaData);
-         }
-      }
-   }
-}

Added: trunk/system-jmx/src/main/org/jboss/system/deployers/LoaderRepositoryConfigHelper.java
===================================================================
--- trunk/system-jmx/src/main/org/jboss/system/deployers/LoaderRepositoryConfigHelper.java	                        (rev 0)
+++ trunk/system-jmx/src/main/org/jboss/system/deployers/LoaderRepositoryConfigHelper.java	2008-10-07 14:04:38 UTC (rev 79221)
@@ -0,0 +1,149 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, 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.jboss.system.deployers;
+
+import java.io.ByteArrayInputStream;
+import java.util.Properties;
+
+import javax.management.ObjectName;
+
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
+import org.jboss.classloading.spi.metadata.ExportAll;
+import org.jboss.classloading.spi.version.Version;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.mx.loading.LoaderRepositoryFactory.LoaderRepositoryConfig;
+
+/**
+ * LoaderRepositoryConfigHelper.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class LoaderRepositoryConfigHelper
+{
+   /**
+    * Populate the deployment's classloading metadata from a loader repository config
+    * with parent delegation false.
+    * 
+    * @param unit the deployment unit
+    * @param loaderConfig the loader repository config
+    * @return the classloading metadata
+    * @throws DeploymentException for any error
+    */
+   public static ClassLoadingMetaData create(DeploymentUnit unit, LoaderRepositoryConfig loaderConfig) throws DeploymentException
+   {
+      return create(unit, loaderConfig, false);
+   }
+
+   /**
+    * Populate the deployment's classloading metadata from a loader repository config
+    * 
+    * @param unit the deployment unit
+    * @param loaderConfig the loader repository config
+    * @param parentDelegation the default value for parent delegation
+    * @return the classloading metadata
+    * @throws DeploymentException for any error
+    */
+   public static ClassLoadingMetaData create(DeploymentUnit unit, LoaderRepositoryConfig loaderConfig, boolean parentDelegation) throws DeploymentException
+   {
+      if (unit == null)
+         throw new IllegalArgumentException("Null unit");
+      
+      ClassLoadingMetaData clmd = unit.getAttachment(ClassLoadingMetaData.class);
+      if (clmd != null)
+         return clmd;
+      
+      clmd = create(unit.getName(), loaderConfig, parentDelegation);
+      if (clmd != null)
+         unit.addAttachment(ClassLoadingMetaData.class, clmd);
+      return clmd;
+   }
+
+   /**
+    * Create classloading metadata from a loader repository config
+    * with parent delegation false
+    * 
+    * @param deploymentName the deployment name
+    * @param loaderConfig the loader repository config
+    * @return the classloading metadata
+    * @throws DeploymentException for any error
+    */
+   public static ClassLoadingMetaData create(String deploymentName, LoaderRepositoryConfig loaderConfig) throws DeploymentException
+   {
+      return create(deploymentName, loaderConfig, false);
+   }
+
+   /**
+    * Create classloading metadata from a loader repository config
+    * 
+    * @param deploymentName the deployment name
+    * @param loaderConfig the loader repository config
+    * @param parentDelegation the default value for parent delegation
+    * @return the classloading metadata
+    * @throws DeploymentException for any error
+    */
+   public static ClassLoadingMetaData create(String deploymentName, LoaderRepositoryConfig loaderConfig, boolean parentDelegation) throws DeploymentException
+   {
+      if (deploymentName == null)
+         throw new IllegalArgumentException("Null deployment name");
+      if (loaderConfig == null)
+         throw new IllegalArgumentException("Null loader config");
+      
+      ObjectName name = loaderConfig.repositoryName;
+      if (name == null)
+         return null;
+      String domain = name.getCanonicalName().trim();
+      if (domain.length() == 0)
+         return null;
+      ClassLoadingMetaData metaData = new ClassLoadingMetaData();
+      metaData.setName(deploymentName);
+      metaData.setDomain(domain);
+      metaData.setExportAll(ExportAll.NON_EMPTY);
+      metaData.setImportAll(true);
+      metaData.setVersion(Version.DEFAULT_VERSION);
+
+      Properties props = new Properties();
+      String config = loaderConfig.repositoryConfig;
+      try
+      {
+         if (config != null)
+         {
+            ByteArrayInputStream bais = new ByteArrayInputStream(config.getBytes());
+            props.load(bais);
+         }
+      }
+      catch (Exception e)
+      {
+         throw DeploymentException.rethrowAsDeploymentException("Error parsing repository config " + config, e);
+      }
+      String java2ParentDelegation = props.getProperty("java2ParentDelegation");
+      // Check for previous mis-spelled property name
+      if( java2ParentDelegation == null )
+         java2ParentDelegation = props.getProperty("java2ParentDelegaton");
+      boolean useParentFirst = parentDelegation;
+      if (java2ParentDelegation != null)
+         useParentFirst = Boolean.valueOf(java2ParentDelegation);
+      metaData.setJ2seClassLoadingCompliance(useParentFirst);
+      return metaData;
+   }
+}

Modified: trunk/system-jmx/src/main/org/jboss/system/deployers/ServiceClassLoaderDeployer.java
===================================================================
--- trunk/system-jmx/src/main/org/jboss/system/deployers/ServiceClassLoaderDeployer.java	2008-10-07 13:31:30 UTC (rev 79220)
+++ trunk/system-jmx/src/main/org/jboss/system/deployers/ServiceClassLoaderDeployer.java	2008-10-07 14:04:38 UTC (rev 79221)
@@ -21,189 +21,42 @@
 */
 package org.jboss.system.deployers;
 
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Set;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
 import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.helpers.AbstractTopLevelClassLoaderDeployer;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
 import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.deployers.vfs.spi.structure.helpers.ClassPathVisitor;
-import org.jboss.mx.loading.LoaderRepositoryFactory;
-import org.jboss.mx.loading.RepositoryClassLoader;
 import org.jboss.mx.loading.LoaderRepositoryFactory.LoaderRepositoryConfig;
-import org.jboss.system.ServiceController;
 import org.jboss.system.metadata.ServiceDeployment;
-import org.jboss.virtual.VirtualFile;
 
 /**
- * ServiceClassLoaderDeployer.<p>
+ * ServiceClassLoaderDeployer
  * 
- * This deployer is responsible for creating classloaders for services of
- * type {@link ServiceDeployment}.
- * 
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @version $Revision: 1.1 $
  */
-public class ServiceClassLoaderDeployer extends AbstractTopLevelClassLoaderDeployer
+public class ServiceClassLoaderDeployer extends AbstractSimpleRealDeployer<ServiceDeployment>
 {
-   /** The service controller */
-   private final ServiceController controller;
-   
    /**
-    * Create a new ServiceDeployer.
-    * 
-    * @param controller the service controller
-    * @throws IllegalArgumentException for a null controller
+    * Create a new ServiceClassLoaderDeployer.
     */
-   public ServiceClassLoaderDeployer(ServiceController controller)
+   public ServiceClassLoaderDeployer()
    {
-      if (controller == null)
-         throw new IllegalArgumentException("Null controller");
-      this.controller = controller;
+      super(ServiceDeployment.class);
+      setOutput(ClassLoadingMetaData.class);
+      setStage(DeploymentStages.POST_PARSE);
+      setTopLevelOnly(true);
    }
 
-   public ClassLoader createTopLevelClassLoader(DeploymentUnit unit) throws Exception
+   @Override
+   public void deploy(DeploymentUnit unit, ServiceDeployment metaData) throws DeploymentException
    {
-      MBeanServer server = controller.getMBeanServer();
-
-      VirtualFile root = null;
-      URL url = null;
-      if (unit instanceof VFSDeploymentUnit)
-      {
-         VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit) unit;
-         
-         // Try to determine a root url
-         root = vfsUnit.getRoot();
-         try
-         {
-            if (root != null)
-               url = trimJARURL(root.toURL());
-         }
-         catch (Exception ignored)
-         {
-            log.debug("Unable to get URL for " + unit.getName() + " reason=" + ignored);
-         }
-      }
-
-      // Check the loader repository config
-      LoaderRepositoryConfig loaderConfig = unit.getAttachment(LoaderRepositoryConfig.class);
-      if (loaderConfig != null)
-         log.debug("Using loader repository config: " + loaderConfig.repositoryName);
-      
-      // Create default loader repository config
-      if (loaderConfig == null)
-      {
-         loaderConfig = new LoaderRepositoryConfig();
-         unit.addAttachment(LoaderRepositoryConfig.class, loaderConfig);
-         log.trace("Using default loader repository config: " + loaderConfig.repositoryName);
-      }
-
-      LoaderRepositoryFactory.createLoaderRepository(server, loaderConfig);
-
-      // Create the classloader
-      Object[] args = { url, url, Boolean.TRUE };
-      String[] sig =  { "java.net.URL", "java.net.URL", "boolean" };
-      RepositoryClassLoader ucl = (RepositoryClassLoader) server.invoke(loaderConfig.repositoryName, "newClassLoader", args, sig);
-
-      // Add in the classpath
-      try
-      {
-         ClassPathVisitor visitor = new ClassPathVisitor(unit);
-         unit.visit(visitor);
-         Set<VirtualFile> classpath = visitor.getClassPath();
-         for (VirtualFile path : classpath)
-         {
-            // TODO Weed duplicates from other deployments
-            if (path != root)
-               ucl.addURL(trimJARURL(path.toURL()));
-         }
-         
-         // Register the classloader with the MBeanServer
-         ObjectName uclName = ucl.getObjectName();
-         if (server.isRegistered(uclName) == false)
-            server.registerMBean(ucl, uclName);
-      }
-      catch (Throwable t)
-      {
-         internalRemoveClassLoader(unit, ucl);
-         throw DeploymentException.rethrowAsDeploymentException("Error creating classloader: " + unit.getName(), t);
-      }
-
-      return ucl;
-   }
-
-   public void removeTopLevelClassLoader(DeploymentUnit unit)
-   {
-      RepositoryClassLoader ucl = (RepositoryClassLoader) unit.getClassLoader();
-      if (ucl == null)
+      ClassLoadingMetaData classLoadingMetaData = unit.getAttachment(ClassLoadingMetaData.class);
+      if (classLoadingMetaData != null)
          return;
-      internalRemoveClassLoader(unit, ucl);
-   }
-   
-   /**
-    * Remove the classloader
-    * 
-    * @param context the deployment context
-    * @param ucl the unified classloader
-    */
-   private void internalRemoveClassLoader(DeploymentUnit unit, RepositoryClassLoader ucl)
-   {
-      MBeanServer server = controller.getMBeanServer();
 
-      // Remove the classloader from the MBeanServer
-      try
-      {
-         ObjectName uclName = ucl.getObjectName();
-         if (server.isRegistered(uclName) == true )
-            server.unregisterMBean(uclName);
-      }
-      catch (Throwable t)
-      {
-         log.warn("Error unregistering classloader mbean: " + ucl + " for " + unit.getName(), t);
-      }
-
-      // Remove the classloader from the loader repository
-      try
-      {
-         ucl.unregister();
-      }
-      catch (Throwable t)
-      {
-         log.warn("Error unregistering ucl: " + ucl + " for " + unit.getName(), t);
-      }
-
-      // Remove the loader repository
-      try
-      {
-
-         ServiceDeployment deployment = unit.getAttachment(ServiceDeployment.class);
-         if (deployment != null)
-         {
-            LoaderRepositoryConfig config = unit.getAttachment(LoaderRepositoryConfig.class);
-            if (config != null)
-               LoaderRepositoryFactory.destroyLoaderRepository(server, config.repositoryName);
-         }
-      }
-      catch (Throwable t)
-      {
-         log.warn("Error removing classloader from repository: " + ucl + " for " + unit.getName(), t);
-      }
+      LoaderRepositoryConfig config = metaData.getLoaderRepositoryConfig();
+      if (config != null)
+         LoaderRepositoryConfigHelper.create(unit, config);
    }
-
-   // TODO figure out why this is necessary
-   private URL trimJARURL(URL url) throws MalformedURLException
-   {
-      String temp = url.toString();
-      if (temp.startsWith("jar:") && temp.endsWith("!/"))
-      {
-         temp = temp.substring(4, temp.length()-2);
-         return new URL(temp);
-      }
-      return url;
-   }
 }

Deleted: trunk/testsuite/src/main/org/jboss/test/deployers/ear/test/JBossAppParsingDeployerUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/deployers/ear/test/JBossAppParsingDeployerUnitTestCase.java	2008-10-07 13:31:30 UTC (rev 79220)
+++ trunk/testsuite/src/main/org/jboss/test/deployers/ear/test/JBossAppParsingDeployerUnitTestCase.java	2008-10-07 14:04:38 UTC (rev 79221)
@@ -1,60 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, 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.test.deployers.ear.test;
-
-import org.jboss.deployers.vfs.plugins.structure.AbstractVFSDeploymentContext;
-import org.jboss.deployers.vfs.plugins.structure.AbstractVFSDeploymentUnit;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentContext;
-import org.jboss.deployment.JBossAppParsingDeployer;
-import org.jboss.metadata.ear.spec.EarMetaData;
-import org.jboss.mx.loading.LoaderRepositoryFactory.LoaderRepositoryConfig;
-
-import junit.framework.TestCase;
-
-/**
-* @author <a href="mailto:alex at jboss.com">Alexey Loubyansky</a>
-* @version $Revision: 72883 $
- */
-public class JBossAppParsingDeployerUnitTestCase extends TestCase
-{
-   public void testDefaultIsolationConfig() throws Exception
-   {
-      VFSDeploymentContext dc = new AbstractVFSDeploymentContext();
-      AbstractVFSDeploymentUnit unit = new AbstractVFSDeploymentUnit(dc);
-      unit.addAttachment(EarMetaData.class, new EarMetaData());
-      JBossAppParsingDeployer deployer = new JBossAppParsingDeployer();
-      
-      // isolated is false
-      deployer.deploy(unit);      
-      LoaderRepositoryConfig attachment = unit.getAttachment(LoaderRepositoryConfig.class);
-      assertNull(attachment);
-      
-      // isolated is true
-      deployer.setIsolated(true);
-      dc = new AbstractVFSDeploymentContext();
-      unit = new AbstractVFSDeploymentUnit(dc);
-      unit.addAttachment(EarMetaData.class, new EarMetaData());
-      deployer.deploy(unit);
-      attachment = unit.getAttachment(LoaderRepositoryConfig.class);
-      assertNotNull(attachment);  
-   }
-}

Modified: trunk/testsuite/src/main/org/jboss/test/isolation/test/IsolationUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/isolation/test/IsolationUnitTestCase.java	2008-10-07 13:31:30 UTC (rev 79220)
+++ trunk/testsuite/src/main/org/jboss/test/isolation/test/IsolationUnitTestCase.java	2008-10-07 14:04:38 UTC (rev 79221)
@@ -22,10 +22,9 @@
 package org.jboss.test.isolation.test;
 
 import javax.management.Attribute;
-import javax.management.AttributeList;
-import javax.management.ObjectName;
 
 import org.jboss.deployment.EARDeployerMBean;
+import org.jboss.deployment.EarClassLoaderDeployerMBean;
 import org.jboss.test.JBossTestCase;
 import org.jboss.test.isolation.interfaces.a.SessionA;
 import org.jboss.test.isolation.interfaces.a.SessionAHome;
@@ -93,8 +92,7 @@
    
    private void isolateDeployments(Boolean value) throws Exception
    {
-      ObjectName name = new ObjectName("jboss.j2ee:service=EARDeployer");
-      getServer().setAttribute(name, new Attribute("Isolated", value));
-      getServer().setAttribute(name, new Attribute("CallByValue", value));
+      getServer().setAttribute(EarClassLoaderDeployerMBean.OBJECT_NAME, new Attribute("Isolated", value));
+      getServer().setAttribute(EARDeployerMBean.OBJECT_NAME, new Attribute("CallByValue", value));
    }
 }




More information about the jboss-cvs-commits mailing list