[jboss-cvs] JBossAS SVN: r59630 - in projects/microcontainer/trunk/deployers/src: main/org/jboss/deployers/plugins/deployers/helpers and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Jan 14 20:27:06 EST 2007


Author: scott.stark at jboss.org
Date: 2007-01-14 20:26:53 -0500 (Sun, 14 Jan 2007)
New Revision: 59630

Added:
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/StandardDeployerTypes.java
Modified:
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeployer.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeploymentUnit.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/DeployerWrapper.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/AbstractParsingDeployer.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/AbstractSimpleRealDeployer.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/AbstractDeploymentContext.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/ComponentDeploymentContext.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/Deployer.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/DeploymentUnit.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/DeploymentContext.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/support/TestSimpleDeployer.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/test/DeployerProtocolUnitTestCase.java
Log:
Add a deployment unit/context deployment types set to track deployment type as seen by the deployers.

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeployer.java	2007-01-15 01:16:21 UTC (rev 59629)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeployer.java	2007-01-15 01:26:53 UTC (rev 59630)
@@ -23,19 +23,24 @@
 
 import org.jboss.deployers.spi.deployer.Deployer;
 import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.deployers.spi.deployer.StandardDeployerTypes;
 import org.jboss.logging.Logger;
 
 /**
  * AbstractDeployer.
  * 
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author Scott.Stark at jboss.org
  * @version $Revision: 1.1 $
  */
 public abstract class AbstractDeployer implements Deployer
 {
    /** The log */
    protected Logger log = Logger.getLogger(this.getClass());
+
    private int relativeOrder = Integer.MAX_VALUE;
+   /** The type of the deployer */
+   private String type = StandardDeployerTypes.UNSPECIFIED_TYPE;
 
    public boolean isRelevant(DeploymentUnit unit)
    {
@@ -50,4 +55,14 @@
    {
       this.relativeOrder = order;
    }
+
+   public String getType()
+   {
+      return type;
+   }
+   public void setType(String type)
+   {
+      this.type = type;
+   }
+   
 }

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeploymentUnit.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeploymentUnit.java	2007-01-15 01:16:21 UTC (rev 59629)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeploymentUnit.java	2007-01-15 01:26:53 UTC (rev 59630)
@@ -92,6 +92,16 @@
    }
 
    /**
+    * Get the deployment types associated with this deployment.
+    * @return set of deployment type names deployers have identified
+    * in this deployment.
+    */
+   public Set<String> getTypes()
+   {
+      return deploymentContext.getTypes();
+   }
+
+   /**
     * Find a child of the deployment root.
     * @param name - relative path of the file to find
     * @return the file if found, null otherwise.

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/DeployerWrapper.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/DeployerWrapper.java	2007-01-15 01:16:21 UTC (rev 59629)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/DeployerWrapper.java	2007-01-15 01:26:53 UTC (rev 59630)
@@ -76,6 +76,11 @@
       this.managedObjectBuilder = managedObjectBuilder;
    }
 
+   public String getType()
+   {
+      return deployer.getType();
+   }
+
    public boolean isRelevant(DeploymentUnit unit)
    {
       if (unit == null)

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/AbstractParsingDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/AbstractParsingDeployer.java	2007-01-15 01:16:21 UTC (rev 59629)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/AbstractParsingDeployer.java	2007-01-15 01:26:53 UTC (rev 59630)
@@ -112,6 +112,9 @@
             result = parse(unit, name, result);
          else
             result = parse(unit, name, suffix, result);
+         // Add the associated deployer type if there is a result
+         if( result != null )
+            unit.getTypes().add(getType());
       }
       catch (Exception e)
       {

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/AbstractSimpleRealDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/AbstractSimpleRealDeployer.java	2007-01-15 01:16:21 UTC (rev 59629)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/AbstractSimpleRealDeployer.java	2007-01-15 01:26:53 UTC (rev 59630)
@@ -50,7 +50,11 @@
    {
       T deployment = unit.getAttachment(getDeploymentType());
       if (deployment != null)
+      {
+         // Set the deployer type
+         unit.getTypes().add(getType());
          deploy(unit, deployment);
+      }
    }
 
    public void undeploy(DeploymentUnit unit)

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/AbstractDeploymentContext.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/AbstractDeploymentContext.java	2007-01-15 01:16:21 UTC (rev 59629)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/AbstractDeploymentContext.java	2007-01-15 01:26:53 UTC (rev 59630)
@@ -93,6 +93,9 @@
    /** The parent context */
    private DeploymentContext parent;
 
+   /** The types of deployments this has been identified as */
+   private Set<String> deploymentTypes = new CopyOnWriteArraySet<String>();
+
    /** The child contexts */
    private Set<DeploymentContext> children = new CopyOnWriteArraySet<DeploymentContext>();
 
@@ -269,6 +272,10 @@
       return relativePath;
    }
 
+   public Set<String> getTypes()
+   {
+      return deploymentTypes;
+   }
    public StructureDetermined getStructureDetermined()
    {
       return structureDetermined;

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/ComponentDeploymentContext.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/ComponentDeploymentContext.java	2007-01-15 01:16:21 UTC (rev 59629)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/ComponentDeploymentContext.java	2007-01-15 01:26:53 UTC (rev 59630)
@@ -103,6 +103,16 @@
       return parent.getRelativePath();
    }
 
+   /**
+    * A component deployment context has no deployment types as
+    * the deployment type is more of a top-level notion, so
+    * return the parent deployment types. 
+    */
+   public Set<String> getTypes()
+   {
+      return parent.getTypes();
+   }
+
    public StructureDetermined getStructureDetermined()
    {
       return parent.getStructureDetermined();

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/Deployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/Deployer.java	2007-01-15 01:16:21 UTC (rev 59629)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/Deployer.java	2007-01-15 01:26:53 UTC (rev 59630)
@@ -54,8 +54,17 @@
 
    /** The real order */
    public static final int REAL_DEPLOYER = 10000;
-   
+
    /**
+    * Get the type of the deployer. This should be reflected in
+    * the DeploymentUnit deploymentType set of deployments the
+    * Deployer processes.
+    * 
+    * @return the deployer type.
+    */
+   public String getType();
+
+   /**
     * Whether the deployer is relevant for this unit
     * 
     * @param unit the unit

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/DeploymentUnit.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/DeploymentUnit.java	2007-01-15 01:16:21 UTC (rev 59629)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/DeploymentUnit.java	2007-01-15 01:26:53 UTC (rev 59630)
@@ -79,6 +79,13 @@
    public String getRelativePath();
 
    /**
+    * Get the deployment types associated with this deployment.
+    * @return set of deployment type names deployers have identified
+    * in this deployment.
+    */
+   public Set<String> getTypes();
+
+   /**
     * Gets a metadata file. This is a file located under the deployment metadata
     * context(s).
     * 

Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/StandardDeployerTypes.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/StandardDeployerTypes.java	2007-01-15 01:16:21 UTC (rev 59629)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/StandardDeployerTypes.java	2007-01-15 01:26:53 UTC (rev 59630)
@@ -0,0 +1,58 @@
+/*
+ * 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.jboss.deployers.spi.deployer;
+
+/**
+ * Standard (known) deployment types found in the DeploymentUnit types set.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface StandardDeployerTypes
+{
+   /** JavaEE enterprise application archive */
+   public static final String EAR = "ear";
+   /** JavaEE client application archive */
+   public static final String CAR = "car";
+   /** JavaEE ejb generic archive */
+   public static final String EJB = "ejb";
+   /** JavaEE ejb 2.1 and earlier archive */
+   public static final String EJB2x = "ejb2x";
+   /** JavaEE ejb 3x archive */
+   public static final String EJB3x = "ejb3x";
+   /** JavaEE JPA archive */
+   public static final String JPA = "jpa";
+   /** JavaEE resource adaptor archive */
+   public static final String RAR = "rar";
+   /** JBoss MC beans archive */
+   public static final String MCBEANS = "beans";
+   /** JBoss service archive */
+   public static final String SAR = "sar";
+   /** JBoss hibernate archive */
+   public static final String HAR = "har";
+   /** Spring archive */
+   public static final String SPRING = "spring";
+   /** An OSGi bundle */
+   public static final String OSGI_BUNDLE = "osgi";
+   /** The deployment type used if a deployer does not specify anything */
+   public static final String UNSPECIFIED_TYPE = "unspecified";
+}


Property changes on: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/StandardDeployerTypes.java
___________________________________________________________________
Name: svn:keywords
   + Id,Revision
Name: svn:eol-style
   + native

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/DeploymentContext.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/DeploymentContext.java	2007-01-15 01:16:21 UTC (rev 59629)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/DeploymentContext.java	2007-01-15 01:26:53 UTC (rev 59630)
@@ -74,6 +74,13 @@
    public String getRelativePath();
 
    /**
+    * Get the deployment types associated with this deployment.
+    * @return set of deployment type names deployers have identified
+    * in this deployment.
+    */
+   public Set<String> getTypes();
+
+   /**
     * Whether the structure is determined
     * 
     * @return true when the structure is determined

Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/support/TestSimpleDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/support/TestSimpleDeployer.java	2007-01-15 01:16:21 UTC (rev 59629)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/support/TestSimpleDeployer.java	2007-01-15 01:26:53 UTC (rev 59630)
@@ -52,12 +52,13 @@
    
    public TestSimpleDeployer()
    {
-      this.relativeOrder = Integer.MAX_VALUE;
+      this(Integer.MAX_VALUE);
    }
    
    public TestSimpleDeployer(int relativeOrder)
    {
       this.relativeOrder = relativeOrder;
+      this.setType("test");
    }
 
    public void clear()
@@ -107,6 +108,7 @@
 
    public void deploy(DeploymentUnit unit) throws DeploymentException
    {
+      unit.getTypes().add(getType());
       deployed.put(unit, ++order);
    }
 

Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/test/DeployerProtocolUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/test/DeployerProtocolUnitTestCase.java	2007-01-15 01:16:21 UTC (rev 59629)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/deployer/test/DeployerProtocolUnitTestCase.java	2007-01-15 01:26:53 UTC (rev 59630)
@@ -67,6 +67,9 @@
       Set<DeploymentUnit> expected = new HashSet<DeploymentUnit>();
       expected.add(context.getDeploymentUnit());
       assertEquals(expected, deployer.getDeployedUnits());
+      HashSet<String> types = new HashSet<String>();
+      types.add("test");
+      assertEquals(types, context.getTypes());
    }
 
    public void testUndeploy() throws Exception




More information about the jboss-cvs-commits mailing list