[jboss-cvs] JBossAS SVN: r57477 - trunk/system-jmx/src/main/org/jboss/deployment

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Oct 6 15:26:31 EDT 2006


Author: scott.stark at jboss.org
Date: 2006-10-06 15:26:29 -0400 (Fri, 06 Oct 2006)
New Revision: 57477

Modified:
   trunk/system-jmx/src/main/org/jboss/deployment/MainDeployer.java
   trunk/system-jmx/src/main/org/jboss/deployment/MainDeployerMBean.java
Log:
Delegate deploy/undeploy to the kernel MainDeployer

Modified: trunk/system-jmx/src/main/org/jboss/deployment/MainDeployer.java
===================================================================
--- trunk/system-jmx/src/main/org/jboss/deployment/MainDeployer.java	2006-10-06 19:26:26 UTC (rev 57476)
+++ trunk/system-jmx/src/main/org/jboss/deployment/MainDeployer.java	2006-10-06 19:26:29 UTC (rev 57477)
@@ -53,6 +53,8 @@
 import javax.management.Notification;
 import javax.management.ObjectName;
 
+import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
+import org.jboss.deployers.spi.structure.DeploymentContext;
 import org.jboss.mx.util.JMXExceptionDecoder;
 import org.jboss.system.ServiceContext;
 import org.jboss.system.ServiceMBeanSupport;
@@ -61,13 +63,14 @@
 import org.jboss.util.file.Files;
 import org.jboss.util.file.JarUtils;
 import org.jboss.util.stream.Streams;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
 
 /**
- * The main/primary component for deployment.
+ * The legacy component for deployer management. This now simply delegates to the
+ * Main
  *
- * <p>MainDeployerMBean is generated by xdoclet.
- *
- * @deprecated see org.jboss.deployers.spi.MainDeployer
+ * @deprecated see org.jboss.deployers.spi.deployment.MainDeployer
  * 
  * @author <a href="mailto:marc.fleury at jboss.org">Marc Fleury</a>
  * @author <a href="mailto:scott.stark at jboss.org">Scott Stark</a>
@@ -78,6 +81,9 @@
 public class MainDeployer extends ServiceMBeanSupport
    implements Deployer, MainDeployerMBean
 {
+   private org.jboss.deployers.spi.deployment.MainDeployer delegate;
+   private Map<URL, String> contextMap = Collections.synchronizedMap(new HashMap<URL, String>());
+
    /**
     * The variable <code>serviceController</code> is used by the
     * checkIncompleteDeployments method to ask for lists of mbeans
@@ -132,6 +138,14 @@
       }
    }
 
+   public org.jboss.deployers.spi.deployment.MainDeployer getKernelMainDeployer()
+   {
+      return delegate;
+   }
+   public void setKernelMainDeployer(org.jboss.deployers.spi.deployment.MainDeployer delegate)
+   {
+      this.delegate = delegate;
+   }
    
    /** Get the flag indicating whether directory content will be deployed
     *
@@ -552,15 +566,8 @@
     */
    public void redeploy(URL url) throws DeploymentException
    {
-      DeploymentInfo sdi = getDeployment(url);
-      if (sdi!= null)
-      {
-         redeploy(sdi);
-      }
-      else
-      {
-         deploy(url);
-      } // end of else
+      undeploy(url);
+      deploy(url);
    }
 
    /**
@@ -605,10 +612,19 @@
     */
    public void undeploy(URL url) throws DeploymentException
    {
-      DeploymentInfo sdi = getDeployment(url);
-      if (sdi != null)
+      String deploymentName = contextMap.remove(url);
+      if (deploymentName != null)
       {
-         undeploy(sdi);
+         try
+         {
+            delegate.removeDeploymentContext(deploymentName);
+            delegate.process();
+         }
+         catch(Exception e)
+         {
+            DeploymentException ex = new DeploymentException("Error during undeploy of: "+url, e);
+            throw ex;
+         }
       }
       else
       {
@@ -765,15 +781,27 @@
     */
    public void deploy(URL url) throws DeploymentException
    {
-      DeploymentInfo sdi = getDeployment(url);
+      log.info("deploy, url="+url);
+      String deploymentName = contextMap.get(url);
       // if it does not exist create a new deployment
-      if (sdi == null)
+      if (deploymentName == null)
       {
-         sdi = new DeploymentInfo(url, null, getServer());
-         deploy(sdi);
+         try
+         {
+            VirtualFile file = VFS.getRoot(url);
+            DeploymentContext deployment = new AbstractDeploymentContext(file);
+            delegate.addDeploymentContext(deployment);
+            deploymentName = deployment.getName();
+            delegate.process();
+            contextMap.put(url, deploymentName);
+         }
+         catch(Exception e)
+         {
+            log.warn("Failed to deploy: "+url, e);
+            DeploymentException ex = new DeploymentException("Failed to deploy: "+url, e);
+            throw ex;
+         }
       }
-      if( sdi.state != DeploymentState.STARTED )
-         checkIncompleteDeployments();
    }
 
    /**

Modified: trunk/system-jmx/src/main/org/jboss/deployment/MainDeployerMBean.java
===================================================================
--- trunk/system-jmx/src/main/org/jboss/deployment/MainDeployerMBean.java	2006-10-06 19:26:26 UTC (rev 57476)
+++ trunk/system-jmx/src/main/org/jboss/deployment/MainDeployerMBean.java	2006-10-06 19:26:29 UTC (rev 57477)
@@ -43,7 +43,10 @@
    ObjectName OBJECT_NAME = ObjectNameFactory.create("jboss.system:service=MainDeployer");
 
    // Attributes ----------------------------------------------------
-   
+   public org.jboss.deployers.spi.deployment.MainDeployer getKernelMainDeployer();
+   /** set the kernel MainDeployer which will handle deployments */
+   public void setKernelMainDeployer(org.jboss.deployers.spi.deployment.MainDeployer delegate);
+
    /** Flag indicating whether directory content will be deployed.
     * The default value is taken from the jboss.deploy.localcopy system property. */
    boolean getCopyFiles();




More information about the jboss-cvs-commits mailing list