[jboss-cvs] JBossAS SVN: r101888 - in trunk: server/src/etc/conf/all/bootstrap and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Mar 4 14:57:10 EST 2010


Author: kabir.khan at jboss.com
Date: 2010-03-04 14:57:09 -0500 (Thu, 04 Mar 2010)
New Revision: 101888

Added:
   trunk/system/src/main/java/org/jboss/system/deployers/TempInMemoryClassesDeployer.java
Modified:
   trunk/component-matrix/pom.xml
   trunk/server/src/etc/conf/all/bootstrap/deployers.xml
Log:
[JBAS-7774][JBAS-7773] Upgrade to mdr 2.2.0.Alpha2 and kernel 2.2.0.Alpha8. Add temporary InMemoryClassesDeployer

Modified: trunk/component-matrix/pom.xml
===================================================================
--- trunk/component-matrix/pom.xml	2010-03-04 19:48:14 UTC (rev 101887)
+++ trunk/component-matrix/pom.xml	2010-03-04 19:57:09 UTC (rev 101888)
@@ -96,14 +96,14 @@
     <version.org.jboss.jpa.deployers>1.0.2-alpha-1</version.org.jboss.jpa.deployers>
     <version.org.jboss.jpa.impl>2.0.0</version.org.jboss.jpa.impl>
     <version.org.jboss.jpa.spi>1.0.0</version.org.jboss.jpa.spi>
-    <version.org.jboss.kernel>2.2.0.Alpha6</version.org.jboss.kernel>
+    <version.org.jboss.kernel>2.2.0.Alpha8</version.org.jboss.kernel>
     <version.org.jboss.logging>2.2.0.CR1</version.org.jboss.logging>
     <version.org.jboss.logging-service-metadata>1.0.0.CR7</version.org.jboss.logging-service-metadata>
     <version.org.jboss.logmanager>1.1.1.GA</version.org.jboss.logmanager>
     <version.org.jboss.man>2.1.1.SP1</version.org.jboss.man>
     <version.org.jboss.mcann>1.0.0.Alpha2</version.org.jboss.mcann>
     <version.org.jboss.mc-int>2.2.0.Alpha2</version.org.jboss.mc-int>
-    <version.org.jboss.mdr>2.2.0.Alpha1</version.org.jboss.mdr>
+    <version.org.jboss.mdr>2.2.0.Alpha2</version.org.jboss.mdr>
     <version.org.jboss.metadata.client>2.0.0.Alpha</version.org.jboss.metadata.client>
     <version.org.jboss.metadata.common>2.0.0.Alpha12</version.org.jboss.metadata.common>
     <version.org.jboss.metadata.ear>2.0.0.Alpha2</version.org.jboss.metadata.ear>

Modified: trunk/server/src/etc/conf/all/bootstrap/deployers.xml
===================================================================
--- trunk/server/src/etc/conf/all/bootstrap/deployers.xml	2010-03-04 19:48:14 UTC (rev 101887)
+++ trunk/server/src/etc/conf/all/bootstrap/deployers.xml	2010-03-04 19:57:09 UTC (rev 101888)
@@ -260,4 +260,5 @@
       <property name="system"><inject bean="ClassLoaderSystem"/></property>
    </bean>
    
+   <bean name="InMemoryClassesDeployer" class="org.jboss.system.deployers.TempInMemoryClassesDeployer"/>
 </deployment>

Added: trunk/system/src/main/java/org/jboss/system/deployers/TempInMemoryClassesDeployer.java
===================================================================
--- trunk/system/src/main/java/org/jboss/system/deployers/TempInMemoryClassesDeployer.java	                        (rev 0)
+++ trunk/system/src/main/java/org/jboss/system/deployers/TempInMemoryClassesDeployer.java	2010-03-04 19:57:09 UTC (rev 101888)
@@ -0,0 +1,142 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, 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.Closeable;
+import java.io.IOException;
+import java.net.URL;
+import java.util.concurrent.Executors;
+
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.vfs.spi.deployer.AbstractVFSRealDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.util.id.GUID;
+import org.jboss.vfs.TempFileProvider;
+import org.jboss.vfs.VFS;
+import org.jboss.vfs.VirtualFile;
+
+/**
+ * Temporary until deployers 2.2.0.Alpha4 is out..
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ * @version $Revision: 1.1 $
+ */
+public class TempInMemoryClassesDeployer extends AbstractVFSRealDeployer
+{
+   /** The name of the dynamic class root */
+   public static final String DYNAMIC_CLASS_URL_KEY = "DYNAMIC_CLASS_URL_KEY";
+
+   /** The name of the dynamic class root */
+   public static final String DYNAMIC_CLASS_KEY = "DYNAMIC_CLASS_KEY";
+
+   /** The name of the mount closeable handle */
+   private static final String MOUNT_HANDLE_KEY = "MOUNT_HANDLE_KEY";
+
+   /** The temp file provider */
+   private TempFileProvider tempFileProvider = TempFileProvider.create("vfsinmemory", Executors.newScheduledThreadPool(2));
+
+   public TempInMemoryClassesDeployer() throws IOException
+   {
+      // Make it run before the classloader describe deployer
+      setStage(DeploymentStages.DESCRIBE);
+      setOutput(ClassLoadingMetaData.class);
+      setTopLevelOnly(true);
+      
+      log.warn(this.getClass().getName() + " should be replaced in deployers.xml by org.jboss.deployers.vfs.plugins.classloader.InMemoryClassesDeployer once jboss-deployers 2.2.0.Alpha4 is released");
+   }
+
+   /**
+    * Create host name.
+    *
+    * @param unit the deployment unit
+    * @return the host name
+    */
+   protected String createHost(VFSDeploymentUnit unit)
+   {
+      return GUID.asString();
+   }
+
+   public void deploy(VFSDeploymentUnit unit) throws DeploymentException
+   {
+      try
+      {
+         VirtualFile classes = VFS.getChild(createHost(unit));
+         URL dynamicClassRoot = classes.toURL();
+         Closeable closeable = VFS.mountTemp(classes, tempFileProvider);
+         unit.addAttachment(MOUNT_HANDLE_KEY, closeable);
+         unit.addAttachment(DYNAMIC_CLASS_KEY, classes);
+         unit.addAttachment(DYNAMIC_CLASS_URL_KEY, dynamicClassRoot);
+         unit.prependClassPath(classes);
+         log.debug("Dynamic class root for " + unit.getName() + " is " + dynamicClassRoot);
+      }
+      catch (Exception e)
+      {
+         throw new DeploymentException("Error creating dynamic class root", e);
+      }
+   }
+
+   @Override
+   public void undeploy(VFSDeploymentUnit unit)
+   {
+      log.debug("Removing dynamic class root for " + unit.getName());
+      try
+      {
+         unit.removeAttachment(DYNAMIC_CLASS_URL_KEY, URL.class);
+
+         VirtualFile classes = unit.removeAttachment(DYNAMIC_CLASS_KEY, VirtualFile.class);
+         if (classes != null)
+         {
+            unit.removeClassPath(classes);
+         }
+      }
+      finally
+      {
+         try
+         {
+            Closeable closeable = unit.removeAttachment(MOUNT_HANDLE_KEY, Closeable.class);
+            if (closeable != null)
+            {
+               closeable.close();
+            }
+         }
+         catch (Exception e)
+         {
+            log.warn("Error deleting dynamic class root for " + unit.getName(), e);
+         }
+      }
+   }
+
+   /**
+    * The temp file provider.
+    *
+    * @param tempFileProvider temp file provider
+    */
+   public void setTempFileProvider(TempFileProvider tempFileProvider)
+   {
+      if (tempFileProvider == null)
+         throw new IllegalArgumentException("Null temp file provider.");
+      this.tempFileProvider = tempFileProvider;
+   }
+}




More information about the jboss-cvs-commits mailing list