[jboss-cvs] JBossAS SVN: r90338 - in projects/jboss-deployers/trunk: deployers-impl/src/test/java/org/jboss/test/deployers/deployer/helpers/support and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jun 17 12:06:39 EDT 2009


Author: alesj
Date: 2009-06-17 12:06:39 -0400 (Wed, 17 Jun 2009)
New Revision: 90338

Added:
   projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/helpers/test/ExactAttachmentDeployerWithVisitorTestCase.java
   projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/ExactAttachmentDeployerWithVisitor.java
Removed:
   projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/helpers/test/RealDeployerWithInputTestCase.java
   projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/ExtendedDeploymentVisitor.java
   projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/RealDeployerWithInput.java
Modified:
   projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/DeployersDeployerTestSuite.java
   projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/helpers/support/MockExtendedDeploymentVisitor.java
Log:
[JBDEPLOY-193]; fix current impl.

Modified: projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/DeployersDeployerTestSuite.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/DeployersDeployerTestSuite.java	2009-06-17 15:37:31 UTC (rev 90337)
+++ projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/DeployersDeployerTestSuite.java	2009-06-17 16:06:39 UTC (rev 90338)
@@ -37,6 +37,7 @@
 import org.jboss.test.deployers.deployer.test.HeuristicAllOrNothingUnitTestCase;
 import org.jboss.test.deployers.deployer.test.HeuristicRussionDollUnitTestCase;
 import org.jboss.test.deployers.deployer.test.MultipleComponentTypeUnitTestCase;
+import org.jboss.test.deployers.deployer.helpers.test.ExactAttachmentDeployerWithVisitorTestCase;
 
 /**
  * Deployers Deployer Test Suite.
@@ -68,6 +69,9 @@
       suite.addTest(DeployerContextClassLoaderUnitTestCase.suite());
       suite.addTest(DeployerRequiredStageUnitTestCase.suite());
 
+      // helper deployers
+      suite.addTest(ExactAttachmentDeployerWithVisitorTestCase.suite());
+
       return suite;
    }
 }

Modified: projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/helpers/support/MockExtendedDeploymentVisitor.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/helpers/support/MockExtendedDeploymentVisitor.java	2009-06-17 15:37:31 UTC (rev 90337)
+++ projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/helpers/support/MockExtendedDeploymentVisitor.java	2009-06-17 16:06:39 UTC (rev 90338)
@@ -23,8 +23,7 @@
 package org.jboss.test.deployers.deployer.helpers.support;
 
 import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.helpers.ExtendedDeploymentVisitor;
-import org.jboss.deployers.spi.deployer.helpers.RealDeployerWithInput;
+import org.jboss.deployers.spi.deployer.helpers.DeploymentVisitor;
 import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.logging.Logger;
 
@@ -32,15 +31,14 @@
  * MockExtendedDeploymentVisitor
  * 
  * A mock implementation of {@link ExtendedDeploymentVisitor}, to be used in testing
- * the {@link RealDeployerWithInput}
+ * the {@link org.jboss.deployers.spi.deployer.helpers.ExactAttachmentDeployerWithVisitor}
  * 
  *
  * @author Jaikiran Pai
  * @version $Revision: $
  */
-public class MockExtendedDeploymentVisitor<T> implements ExtendedDeploymentVisitor<T>
+public class MockExtendedDeploymentVisitor<T> implements DeploymentVisitor<T>
 {
-
    private String typeName;
    
    private Class<T> type;
@@ -55,9 +53,6 @@
       this.typeName = typeName;
    }
    
-   /**
-    * @see ExtendedDeploymentVisitor#getVisitorTypeName()
-    */
    public String getVisitorTypeName()
    {
       return this.typeName;
@@ -69,7 +64,6 @@
     */
    public void deploy(DeploymentUnit unit, T deployment) throws DeploymentException
    {
-      
       logger.info("Processing unit " + unit + " for deployment " + deployment);
       // if the unit has already been processed by this visitor then increment the count in the
       // attachment
@@ -83,7 +77,7 @@
    }
 
    /**
-    * @see ExtendedDeploymentVisitor#getVisitorType()
+    * @see DeploymentVisitor#getVisitorType()
     */
    public Class<T> getVisitorType()
    {
@@ -92,8 +86,5 @@
 
    public void undeploy(DeploymentUnit unit, T deployment)
    {
-      // TODO Auto-generated method stub
-
    }
-
 }

Copied: projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/helpers/test/ExactAttachmentDeployerWithVisitorTestCase.java (from rev 90335, projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/helpers/test/RealDeployerWithInputTestCase.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/helpers/test/ExactAttachmentDeployerWithVisitorTestCase.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/helpers/test/ExactAttachmentDeployerWithVisitorTestCase.java	2009-06-17 16:06:39 UTC (rev 90338)
@@ -0,0 +1,147 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.deployer.helpers.test;
+
+import junit.framework.Test;
+import org.jboss.deployers.client.spi.DeployerClient;
+import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.deployers.spi.attachments.MutableAttachments;
+import org.jboss.deployers.spi.deployer.helpers.DeploymentVisitor;
+import org.jboss.deployers.spi.deployer.helpers.ExactAttachmentDeployerWithVisitor;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.test.deployers.AbstractDeployerTest;
+import org.jboss.test.deployers.deployer.helpers.support.MockExtendedDeploymentVisitor;
+
+/**
+ * ExactAttachmentDeployerWithVisitorTestCase
+ * 
+ * Test that the {@link org.jboss.deployers.spi.deployer.helpers.ExactAttachmentDeployerWithVisitor} works as expected
+ * with an {@link DeploymentVisitor}
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class ExactAttachmentDeployerWithVisitorTestCase extends AbstractDeployerTest
+{
+   /**
+    * Constructor
+    * 
+    * @param name the name
+    */
+   public ExactAttachmentDeployerWithVisitorTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(ExactAttachmentDeployerWithVisitorTestCase.class);
+   }
+
+   /**
+    * Tests that the {@link org.jboss.deployers.spi.deployer.helpers.ExactAttachmentDeployerWithVisitor} works correctly with an {@link ExtendedDeploymentVisitor}
+    * when the unit being processed contains the expected attachment
+    * 
+    * @throws Exception for any error
+    */
+   public void testExtendedDeploymentVisitorForUnitContainingExpectedAttachment() throws Exception
+   {
+      // the attachment name which the visitor is interested in
+      String attachmentName = "someAttachment";
+      // create an mock visitor 
+      MockExtendedDeploymentVisitor<String> visitor = new MockExtendedDeploymentVisitor<String>(attachmentName, String.class);
+      // create the real deployer which will then use the visitor to filter out 
+      // deployment units
+      ExactAttachmentDeployerWithVisitor<String> deployer = new ExactAttachmentDeployerWithVisitor<String>(visitor.getVisitorTypeName(), visitor);
+      // Create the main deployer which will be responsible for processing the deployment
+      // unit through various stages
+      DeployerClient mainDeployer = createMainDeployer(deployer);
+
+      // some name to the deployment and create a deployment out of it
+      String deploymentName = "test-deployment";
+      Deployment deployment = createSimpleDeployment(deploymentName);
+      MutableAttachments attachments = (MutableAttachments) deployment.getPredeterminedManagedObjects();
+      
+      // Jaikiran's deleted comment ;-)
+      attachments.addAttachment(String.class.getName(), "IHaveNoClueWhyTheSetInputAPIWorksTheWayItDoes");
+      
+      // add the attachment so that this unit will be picked up by the visitor
+      attachments.addAttachment(attachmentName, "Test123");
+
+      log.debug("Deploying " + deployment);
+      // deploy the deployment
+      mainDeployer.deploy(deployment);
+
+      // get the processed deployment unit
+      DeploymentUnit unit = getDeploymentUnit(mainDeployer, deploymentName);
+
+      // the processed unit is expected to contain the "processed" attachment which
+      // is added by the mock visitor. This attachment indicates that the unit was
+      // rightly picked up by the visitor
+      assertNotNull(DeploymentVisitor.class.getName() + " did not process the unit " + unit, unit.getAttachment(MockExtendedDeploymentVisitor.PROCESSED_ATTACHMENT_NAME));
+      // ensure that the unit was picked up only once by the visitor
+      assertEquals("The extended deployment visitor was expected to process the unit " + unit + " exactly once", unit.getAttachment(MockExtendedDeploymentVisitor.PROCESSED_ATTACHMENT_NAME), 1);
+   }
+
+   /**
+    * Tests that the {@link org.jboss.deployers.spi.deployer.helpers.ExactAttachmentDeployerWithVisitor} works correctly with an {@link DeploymentVisitor}
+    * when the unit being processed does *not* contain the expected attachment
+    * 
+    * @throws Exception for any error
+    */
+   public void testExtendedDeploymentVisitorForWithoutExpectedAttachment() throws Exception
+   {
+      // the attachment name which the visitor is interested in
+      String attachmentName = "someAttachment";
+      // create an mock visitor 
+      MockExtendedDeploymentVisitor<String> visitor = new MockExtendedDeploymentVisitor<String>(attachmentName, String.class);
+      // create the real deployer which will then use the visitor to filter out 
+      // deployment units
+      ExactAttachmentDeployerWithVisitor<String> deployer = new ExactAttachmentDeployerWithVisitor<String>(visitor.getVisitorTypeName(), visitor);
+      // Create the main deployer which will be responsible for processing the deployment
+      // unit through various stages
+      DeployerClient mainDeployer = createMainDeployer(deployer);
+
+      // some name to the deployment and create a deployment out of it
+      String deploymentName = "test-deployment";
+      Deployment deployment = createSimpleDeployment(deploymentName);
+      MutableAttachments attachments = (MutableAttachments) deployment.getPredeterminedManagedObjects();
+
+      // Jaikiran's deleted comment ;-)
+      attachments.addAttachment(String.class.getName(), "IHaveNoClueWhyTheSetInputAPIWorksTheWayItDoes");
+      
+      // add the attachment which the visitor is NOT interested in
+      attachments.addAttachment("ADifferentAttachment", "Test123");
+
+      log.debug("Deploying " + deployment);
+      // deploy the deployment
+      mainDeployer.deploy(deployment);
+
+      // get the processed deployment unit
+      DeploymentUnit unit = getDeploymentUnit(mainDeployer, deploymentName);
+
+      // its expected that the visitor will NOT process this unit, since the
+      // unit does not contain the expected attachment
+      assertNull(DeploymentVisitor.class.getName() + " did not process the unit " + unit, unit.getAttachment(MockExtendedDeploymentVisitor.PROCESSED_ATTACHMENT_NAME));
+   }
+}

Deleted: projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/helpers/test/RealDeployerWithInputTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/helpers/test/RealDeployerWithInputTestCase.java	2009-06-17 15:37:31 UTC (rev 90337)
+++ projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/deployer/helpers/test/RealDeployerWithInputTestCase.java	2009-06-17 16:06:39 UTC (rev 90338)
@@ -1,162 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.deployer.helpers.test;
-
-import org.jboss.deployers.client.spi.DeployerClient;
-import org.jboss.deployers.client.spi.Deployment;
-import org.jboss.deployers.spi.attachments.MutableAttachments;
-import org.jboss.deployers.spi.deployer.helpers.ExtendedDeploymentVisitor;
-import org.jboss.deployers.spi.deployer.helpers.RealDeployerWithInput;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.logging.Logger;
-import org.jboss.test.deployers.AbstractDeployerTest;
-import org.jboss.test.deployers.deployer.helpers.support.MockExtendedDeploymentVisitor;
-
-/**
- * RealDeployerWithInputTestCase
- * 
- * Test that the {@link RealDeployerWithInput} works as expected
- * with an {@link ExtendedDeploymentVisitor}
- *
- * @author Jaikiran Pai
- * @version $Revision: $
- */
-public class RealDeployerWithInputTestCase extends AbstractDeployerTest
-{
-
-   /**
-    * Logger
-    */
-   private static Logger logger = Logger.getLogger(RealDeployerWithInputTestCase.class);
-
-   /**
-    * Constructor
-    * 
-    * @param name
-    */
-   public RealDeployerWithInputTestCase(String name)
-   {
-      super(name);
-
-   }
-
-   /**
-    * Tests that the {@link RealDeployerWithInput} works correctly with an {@link ExtendedDeploymentVisitor}
-    * when the unit being processed contains the expected attachment
-    * 
-    * @throws Exception
-    */
-   public void testExtendedDeploymentVisitorForUnitContainingExpectedAttachment() throws Exception
-   {
-      // the attachment name which the visitor is interested in
-      String attachmentName = "someAttachment";
-      // create an mock visitor 
-      ExtendedDeploymentVisitor<String> visitor = new MockExtendedDeploymentVisitor<String>(attachmentName,
-            String.class);
-      // create the real deployer which will then use the visitor to filter out 
-      // deployment units
-      RealDeployerWithInput<String> deployer = new RealDeployerWithInput<String>(visitor);
-      // Create the main deployer which will be responsible for processing the deployment
-      // unit through various stages
-      DeployerClient mainDeployer = createMainDeployer(deployer);
-
-      // some name to the deployment and create a deployment out of it
-      String deploymentName = "test-deployment";
-      Deployment deployment = createSimpleDeployment(deploymentName);
-      MutableAttachments attachments = (MutableAttachments) deployment.getPredeterminedManagedObjects();
-      
-      // I seriously have no idea about how the setInput()/setInputs()/addInput() API expect/work
-      // The more i look into it, the more confused i am.
-      // For some weird reason, this is expected to be done.
-      attachments.addAttachment(String.class.getName(), "IHaveNoClueWhyTheSetInputAPIWorksTheWayItDoes");
-      
-      // add the attachment so that this unit will be picked up by the visitor
-      attachments.addAttachment(attachmentName, new String("Test123"));
-
-      log.debug("Deploying " + deployment);
-      // deploy the deployment
-      mainDeployer.deploy(deployment);
-
-      // get the processed deployment unit
-      DeploymentUnit unit = getDeploymentUnit(mainDeployer, deploymentName);
-
-      // the processed unit is expected to contain the "processed" attachment which
-      // is added by the mock visitor. This attachment indicates that the unit was
-      // rightly picked up by the visitor
-      assertNotNull(ExtendedDeploymentVisitor.class.getName() + " did not process the unit " + unit, unit
-            .getAttachment(MockExtendedDeploymentVisitor.PROCESSED_ATTACHMENT_NAME));
-      // ensure that the unit was picked up only once by the visitor
-      assertEquals("The extended deployment visitor was expected to process the unit " + unit + " exactly once", unit
-            .getAttachment(MockExtendedDeploymentVisitor.PROCESSED_ATTACHMENT_NAME), 1);
-
-   }
-
-   /**
-    * Tests that the {@link RealDeployerWithInput} works correctly with an {@link ExtendedDeploymentVisitor}
-    * when the unit being processed does *not* contain the expected attachment
-    * 
-    * @throws Exception
-    */
-   public void testExtendedDeploymentVisitorForWithoutExpectedAttachment() throws Exception
-   {
-      // the attachment name which the visitor is interested in
-      String attachmentName = "someAttachment";
-      // create an mock visitor 
-      ExtendedDeploymentVisitor<String> visitor = new MockExtendedDeploymentVisitor<String>(attachmentName,
-            String.class);
-      // create the real deployer which will then use the visitor to filter out 
-      // deployment units
-      RealDeployerWithInput<String> deployer = new RealDeployerWithInput<String>(visitor);
-      // Create the main deployer which will be responsible for processing the deployment
-      // unit through various stages
-      DeployerClient mainDeployer = createMainDeployer(deployer);
-
-      // some name to the deployment and create a deployment out of it
-      String deploymentName = "test-deployment";
-      Deployment deployment = createSimpleDeployment(deploymentName);
-      MutableAttachments attachments = (MutableAttachments) deployment.getPredeterminedManagedObjects();
-
-      // I seriously have no idea about how the setInput()/setInputs()/addInput() API expect/work
-      // The more i look into it, the more confused i am.
-      // For some weird reason, this is expected to be done.
-      attachments.addAttachment(String.class.getName(), "IHaveNoClueWhyTheSetInputAPIWorksTheWayItDoes");
-
-      
-      // add the attachment which the visitor is NOT interested in
-      attachments.addAttachment("ADifferentAttachment", new String("Test123"));
-
-      log.debug("Deploying " + deployment);
-      // deploy the deployment
-      mainDeployer.deploy(deployment);
-
-      // get the processed deployment unit
-      DeploymentUnit unit = getDeploymentUnit(mainDeployer, deploymentName);
-
-      // its expected that the visitor will NOT process this unit, since the
-      // unit does not contain the expected attachment
-      assertNull(ExtendedDeploymentVisitor.class.getName() + " did not process the unit " + unit, unit
-            .getAttachment(MockExtendedDeploymentVisitor.PROCESSED_ATTACHMENT_NAME));
-
-   }
-
-}

Copied: projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/ExactAttachmentDeployerWithVisitor.java (from rev 90335, projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/RealDeployerWithInput.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/ExactAttachmentDeployerWithVisitor.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/ExactAttachmentDeployerWithVisitor.java	2009-06-17 16:06:39 UTC (rev 90338)
@@ -0,0 +1,142 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.helpers;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * A deployer which by default is set to process
+ * deployments during the {@link DeploymentStages#REAL} phase. This deployer
+ * is similar to {@link AbstractRealDeployerWithInput} except that, this one 
+ * is more efficient when used with a {@link DeploymentVisitor}.
+ * <br>
+ * This deployer uses the {@link DeploymentVisitor} to filter out deployers
+ * for processing the units. It internally relies on {@link DeploymentVisitor#getVisitorType()}
+ * and exact attachment name to decide whether the deployer
+ * is eligible for processing the unit. See {@link #deploy(DeploymentUnit)}
+ * and {@link #undeploy(DeploymentUnit)} for more details about this deployer.
+ * 
+ * Note that the deployment stage for this deployer can be changed by invoking 
+ * {@link #setStage(org.jboss.deployers.spi.deployer.DeploymentStage)} during the construction of the 
+ * deployer
+ * 
+ * @author Jaikiran Pai
+ * @author Ales Justin
+ * @version $Revision: $
+ */
+public class ExactAttachmentDeployerWithVisitor<T> extends AbstractRealDeployer
+{
+   /** The attachment name */
+   private String attachmentName;
+
+   /**
+    * Visitor which will be used for processing the deployment unit
+    */
+   private DeploymentVisitor<T> visitor;
+
+   /**
+    * Constructor.
+    *
+    * @param attachmentName the attachment name
+    * @param visitor the visitor
+    */
+   public ExactAttachmentDeployerWithVisitor(String attachmentName, DeploymentVisitor<T> visitor)
+   {
+      if (attachmentName == null)
+         throw new IllegalArgumentException("Null attachment name");
+      if (visitor == null)
+         throw new IllegalArgumentException("Null visitor");
+
+      this.attachmentName = attachmentName;
+      this.visitor = visitor;
+      // set the input for this deployer
+      setInput(visitor.getVisitorType());
+   }
+
+   /**
+    * First checks whether the <code>visitor</code> is eligible for
+    * processing the <code>unit</code>. The attachmentName
+    * and {@link DeploymentVisitor#getVisitorType()} APIs are used to decide whether
+    * the unit is eligible to be processed by the visitor. If the unit contains an attachment with
+    * the attachmentName and of type visitorType, then the visitor is considered
+    * valid for this deployment unit. Eligible visitor are then allowed to process
+    * the unit by calling the {@link DeploymentVisitor#deploy(DeploymentUnit, Object)} API
+    *
+    *
+    * @param unit The deployment unit being processed
+    * @throws DeploymentException If any exception occurs during deployment
+    */
+   @Override
+   protected void internalDeploy(DeploymentUnit unit) throws DeploymentException
+   {
+      Class<T> attachmentType = visitor.getVisitorType();
+      T attachment = unit.getAttachment(attachmentName, attachmentType);
+
+      // no such attachment, so let's skip this visitor for this unit
+      if (attachment == null)
+      {
+         if (log.isTraceEnabled())
+         {
+            log.trace("Skipping " + visitor + " during deploy, since no attachment named " + attachmentName
+                  + " of type " + attachmentType + " found in unit " + unit);
+         }
+         return;
+      }
+
+      // attachment found, let the visitor process this unit
+      visitor.deploy(unit, attachment);
+   }
+
+   /**
+    * 
+    * First checks whether the <code>visitor</code> is eligible for
+    * processing the <code>unit</code>. The attchmentName
+    * and {@link DeploymentVisitor#getVisitorType()} APIs are used to decide whether
+    * the unit is eligible to be processed by the visitor. If the unit contains an attachment with 
+    * the attachmentName and of type visitorType, then the visitor is considered
+    * valid for this deployment unit. Eligible visitor are then allowed to process
+    * the unit by calling the {@link DeploymentVisitor#deploy(DeploymentUnit, Object)} API
+
+    * @param unit The deployment unit to be processed
+    */
+   protected void internalUndeploy(DeploymentUnit unit)
+   {
+      Class<T> attachmentType = visitor.getVisitorType();
+      T attachment = unit.getAttachment(attachmentName, attachmentType);
+
+      // no such attachment, so let's skip this visitor for this unit
+      if (attachment == null)
+      {
+         if (log.isTraceEnabled())
+         {
+            log.trace("Skipping " + visitor + " during undeploy, since no attachment named " + attachmentName
+                  + " of type " + attachmentType + " found in unit " + unit);
+         }
+         return;
+      }
+
+      // attachment found, let the visitor process this unit
+      visitor.undeploy(unit, attachment);
+   }
+}

Deleted: projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/ExtendedDeploymentVisitor.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/ExtendedDeploymentVisitor.java	2009-06-17 15:37:31 UTC (rev 90337)
+++ projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/ExtendedDeploymentVisitor.java	2009-06-17 16:06:39 UTC (rev 90338)
@@ -1,55 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.helpers;
-
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-
-/**
- * ExtendedDeploymentVisitor
- *
- * Extended version of the {@link DeploymentVisitor} which allows to filter
- * out eligible unit based on the name of the attachments. The {@link #getVisitorTypeName()}
- * and {@link #getVisitorType()} decide which units are eligible for being 
- * processed by this visitor.
- * 
- * @author Jaikiran Pai
- * @version $Revision: $
- * @param <T>
- */
-public interface ExtendedDeploymentVisitor<T> extends DeploymentVisitor<T>
-{
-
-   /**
-    * Returns the name of attachment in the deployment unit, which this
-    * visitor is interested in processing.<br>
-    *  
-    * This along with the {@link #getVisitorType()} will be used to check
-    * whether an {@link DeploymentUnit} is eligible to be processed by this {@link DeploymentVisitor}.
-    * If the unit contains a attachment with {@link #getVisitorTypeName()} of type {@link #getVisitorType()}
-    * then that unit is considered eligible to be passed to this {@link DeploymentVisitor}. 
-    * 
-    * @return 
-    */
-   String getVisitorTypeName();
-
-}

Deleted: projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/RealDeployerWithInput.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/RealDeployerWithInput.java	2009-06-17 15:37:31 UTC (rev 90337)
+++ projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/RealDeployerWithInput.java	2009-06-17 16:06:39 UTC (rev 90338)
@@ -1,175 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.helpers;
-
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.DeploymentStages;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.logging.Logger;
-
-/**
- * 
- * RealDeployerWithInput - A deployer which by default is set to process
- * deployments during the {@link DeploymentStages#REAL} phase. This deployer
- * is similar to {@link AbstractRealDeployerWithInput} except that, this one 
- * is more efficient when used with a {@link ExtendedDeploymentVisitor}.
- * <br>
- * This deployer uses the {@link ExtendedDeploymentVisitor} to filter out deployers
- * for processing the units. It internally relies on {@link ExtendedDeploymentVisitor#getVisitorType()}
- * and {@link ExtendedDeploymentVisitor#getVisitorTypeName()} to decide whether the deployer
- * is eligible for processing the unit. See {@link #deploy(DeploymentUnit, ExtendedDeploymentVisitor)}
- * and {@link #undeploy(DeploymentUnit, ExtendedDeploymentVisitor)} for more details 
- * about this deployer.
- * 
- * Note that the deployment stage for this deployer can be changed by invoking 
- * {@link #setStage(org.jboss.deployers.spi.deployer.DeploymentStage)} during the construction of the 
- * deployer
- * 
- *
- * @author Jaikiran Pai
- * @version $Revision: $
- */
-public class RealDeployerWithInput<T> extends AbstractRealDeployer
-{
-
-   /**
-    * Logger
-    */
-   private static Logger logger = Logger.getLogger(RealDeployerWithInput.class);
-
-   /**
-    * Visitor which will be used for processing the deployment unit
-    */
-   private ExtendedDeploymentVisitor<T> visitor;
-
-   /**
-    * Constructor
-    * @param visitor
-    */
-   public RealDeployerWithInput(ExtendedDeploymentVisitor<T> visitor)
-   {
-      this.visitor = visitor;
-      // set the input for this deployer
-      setInput(visitor.getVisitorType());
-   }
-   
-   /**
-    * Returns the {@link ExtendedDeploymentVisitor} associated with this deployer
-    * @return
-    */
-   public ExtendedDeploymentVisitor<T> getDeploymentVisitor()
-   {
-      return this.visitor;
-   }
-
-   @Override
-   protected void internalDeploy(DeploymentUnit unit) throws DeploymentException
-   {
-      deploy(unit, this.visitor);
-
-   }
-
-   /**
-    * First checks whether the <code>visitor</code> is eligible for
-    * processing the <code>unit</code>. The {@link ExtendedDeploymentVisitor#getVisitorTypeName()}
-    * and {@link ExtendedDeploymentVisitor#getVisitorType()} APIs are used to decide whether
-    * the unit is eligible to be processed by the visitor. If the unit contains an attachment with 
-    * the visitorTypeName and of type visitorType, then the visitor is considered
-    * valid for this deployment unit. Eligible visitor are then allowed to process
-    * the unit by calling the {@link ExtendedDeploymentVisitor#deploy(DeploymentUnit, Object)} API
-    * 
-    * 
-    * @param unit The deployment unit being processed
-    * @param visitor The visitor which will be checked for eligibility for processing the unit
-    *                  based on the {@link ExtendedDeploymentVisitor#getVisitorTypeName()} and
-    *                  {@link ExtendedDeploymentVisitor#getVisitorType()} values
-    *                  
-    * @throws DeploymentException If any exception occurs during deployment
-    * @throws NullPointerException If either of <code>unit</code> or <code>visitor</code> is null
-    */
-   protected void deploy(DeploymentUnit unit, ExtendedDeploymentVisitor<T> visitor) throws DeploymentException
-   {
-      // get hold of the attachment based on the visitorTypeName and visitorType
-      String attachmentName = visitor.getVisitorTypeName();
-      Class<T> attachmentType = visitor.getVisitorType();
-
-      T attachment = unit.getAttachment(attachmentName, attachmentType);
-
-      // no such attachment, so let's skip this visitor for this unit
-      if (attachment == null)
-      {
-         if (logger.isTraceEnabled())
-         {
-            logger.trace("Skipping " + visitor + " during deploy, since no attachment named " + attachmentName
-                  + " of type " + attachmentType + " found in unit " + unit);
-         }
-         return;
-      }
-
-      // attachment found, let the visitor process this unit
-      visitor.deploy(unit, attachment);
-
-   }
-
-   /**
-    * 
-    * First checks whether the <code>visitor</code> is eligible for
-    * processing the <code>unit</code>. The {@link ExtendedDeploymentVisitor#getVisitorTypeName()}
-    * and {@link ExtendedDeploymentVisitor#getVisitorType()} APIs are used to decide whether
-    * the unit is eligible to be processed by the visitor. If the unit contains an attachment with 
-    * the visitorTypeName and of type visitorType, then the visitor is considered
-    * valid for this deployment unit. Eligible visitor are then allowed to process
-    * the unit by calling the {@link ExtendedDeploymentVisitor#deploy(DeploymentUnit, Object)} API
-
-    * @param unit The deployment unit to be processed
-    * @param visitor The visitor which will be checked for eligibility for processing the unit
-    *                  based on the {@link ExtendedDeploymentVisitor#getVisitorTypeName()} and
-    *                  {@link ExtendedDeploymentVisitor#getVisitorType()} values
-    *                  
-    * @throws DeploymentException If any exception occurs during deployment
-    * @throws NullPointerException If either of <code>unit</code> or <code>visitor</code> is null
-    */
-   protected void undeploy(DeploymentUnit unit, ExtendedDeploymentVisitor<T> visitor) throws DeploymentException
-   {
-      // get hold of the attachment based on the visitorTypeName and visitorType
-      String attachmentName = visitor.getVisitorTypeName();
-      Class<T> attachmentType = visitor.getVisitorType();
-
-      T attachment = unit.getAttachment(attachmentName, attachmentType);
-
-      // no such attachment, so let's skip this visitor for this unit
-      if (attachment == null)
-      {
-         if (logger.isTraceEnabled())
-         {
-            logger.trace("Skipping " + visitor + " during undeploy, since no attachment named " + attachmentName
-                  + " of type " + attachmentType + " found in unit " + unit);
-         }
-         return;
-      }
-
-      // attachment found, let the visitor process this unit
-      visitor.undeploy(unit, attachment);
-
-   }
-
-}




More information about the jboss-cvs-commits mailing list