[jboss-cvs] JBossAS SVN: r69386 - in projects/microcontainer/trunk/deployers-impl/src: tests/org/jboss/test/deployers/main/support and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jan 28 09:00:28 EST 2008


Author: alesj
Date: 2008-01-28 09:00:28 -0500 (Mon, 28 Jan 2008)
New Revision: 69386

Added:
   projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/AbstractTestAttachmentDeployer.java
   projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/TestAttachmentDeployer.java
   projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/TestAttachments.java
   projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/TestAttachmentsDeployer.java
Modified:
   projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/deployers/DeployersImpl.java
   projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/DependencyDeployer.java
   projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/test/DeployerCheckCompleteTestCase.java
Log:
Add context component check in deployers.

Modified: projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/deployers/DeployersImpl.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/deployers/DeployersImpl.java	2008-01-28 08:31:23 UTC (rev 69385)
+++ projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/deployers/DeployersImpl.java	2008-01-28 14:00:28 UTC (rev 69386)
@@ -742,6 +742,13 @@
          for(DeploymentContext child : children)
             checkComplete(child, contextsInError, contextsMissingDependencies, notInstalled, states);
       }
+
+      List<DeploymentContext> components = context.getComponents();
+      if (components != null && components.isEmpty() == false)
+      {
+         for(DeploymentContext component : components)
+            checkComplete(component, contextsInError, contextsMissingDependencies, notInstalled, states);
+      }
    }
 
    /**

Added: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/AbstractTestAttachmentDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/AbstractTestAttachmentDeployer.java	                        (rev 0)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/AbstractTestAttachmentDeployer.java	2008-01-28 14:00:28 UTC (rev 69386)
@@ -0,0 +1,98 @@
+/*
+* 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.test.deployers.main.support;
+
+import org.jboss.dependency.plugins.AbstractControllerContext;
+import org.jboss.dependency.plugins.AbstractDependencyItem;
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerContextActions;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.DependencyInfo;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * Test attachments deployer.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class AbstractTestAttachmentDeployer extends AbstractRealDeployer
+{
+   private Controller controller;
+   private ControllerContextActions actions = new TestControllerContextActions();
+
+   protected AbstractTestAttachmentDeployer(Controller controller)
+   {
+      this.controller = controller;
+      setInput(TestAttachment.class);
+      setUseUnitName(true);
+   }
+
+   protected void internalDeploy(DeploymentUnit unit) throws DeploymentException
+   {
+      TestAttachment attachment = unit.getAttachment(TestAttachment.class);
+      if (attachment != null)
+      {
+         Object name = attachment.getName();
+         AbstractControllerContext context = new AbstractControllerContext(name, actions);
+         DependencyInfo dependencyInfo = context.getDependencyInfo();
+         Object dependency = attachment.getDependency();
+         if (dependency != null)
+         {
+            AbstractDependencyItem item = new AbstractDependencyItem(name, dependency, ControllerState.INSTALLED, null);
+            dependencyInfo.addIDependOn(item);
+         }
+         try
+         {
+            controller.install(context);
+         }
+         catch (Throwable t)
+         {
+            throw DeploymentException.rethrowAsDeploymentException("Unexpected.", t);
+         }
+      }
+   }
+
+   protected void internalUndeploy(DeploymentUnit unit)
+   {
+      TestAttachment attachment = unit.getAttachment(TestAttachment.class);
+      if (attachment != null)
+      {
+         controller.uninstall(attachment.getName());
+      }
+   }
+
+   private class TestControllerContextActions implements ControllerContextActions
+   {
+      public void install(ControllerContext context, ControllerState fromState, ControllerState toState) throws Throwable
+      {
+         context.setState(toState);
+      }
+
+      public void uninstall(ControllerContext context, ControllerState fromState, ControllerState toState)
+      {
+         context.setState(toState);
+      }
+   }
+}

Modified: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/DependencyDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/DependencyDeployer.java	2008-01-28 08:31:23 UTC (rev 69385)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/DependencyDeployer.java	2008-01-28 14:00:28 UTC (rev 69386)
@@ -21,28 +21,19 @@
 */
 package org.jboss.test.deployers.main.support;
 
-import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer;
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.dependency.spi.Controller;
-import org.jboss.dependency.spi.ControllerContextActions;
-import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.dependency.spi.DependencyInfo;
-import org.jboss.dependency.plugins.AbstractControllerContext;
-import org.jboss.dependency.plugins.AbstractDependencyItem;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
 
 /**
+ * Dependency test deployer.
+ *
  * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
  */
-public class DependencyDeployer extends AbstractRealDeployer
+public class DependencyDeployer extends AbstractTestAttachmentDeployer
 {
-   private Controller controller;
-   private ControllerContextActions actions = new TestControllerContextActions();
-
    public DependencyDeployer(Controller controller)
    {
-      this.controller = controller;
+      super(controller);
       setUseUnitName(true);
    }
 
@@ -60,51 +51,4 @@
    {
       unit.removeControllerContextName("x" + unit.getName());
    }
-
-   protected void internalDeploy(DeploymentUnit unit) throws DeploymentException
-   {
-      TestAttachment attachment = unit.getAttachment(TestAttachment.class);
-      if (attachment != null)
-      {
-         Object name = attachment.getName();
-         AbstractControllerContext context = new AbstractControllerContext(name, actions);
-         DependencyInfo dependencyInfo = context.getDependencyInfo();
-         Object dependency = attachment.getDependency();
-         if (dependency != null)
-         {
-            AbstractDependencyItem item = new AbstractDependencyItem(name, dependency, ControllerState.INSTALLED, null);
-            dependencyInfo.addIDependOn(item);
-         }
-         try
-         {
-            controller.install(context);
-         }
-         catch (Throwable t)
-         {
-            throw DeploymentException.rethrowAsDeploymentException("Unexpected.", t);
-         }
-      }
-   }
-
-   protected void internalUndeploy(DeploymentUnit unit)
-   {
-      TestAttachment attachment = unit.getAttachment(TestAttachment.class);
-      if (attachment != null)
-      {
-         controller.uninstall(attachment.getName());
-      }
-   }
-
-   private class TestControllerContextActions implements ControllerContextActions
-   {
-      public void install(ControllerContext context, ControllerState fromState, ControllerState toState) throws Throwable
-      {
-         context.setState(toState);
-      }
-
-      public void uninstall(ControllerContext context, ControllerState fromState, ControllerState toState)
-      {
-         context.setState(toState);
-      }
-   }
 }

Added: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/TestAttachmentDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/TestAttachmentDeployer.java	                        (rev 0)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/TestAttachmentDeployer.java	2008-01-28 14:00:28 UTC (rev 69386)
@@ -0,0 +1,38 @@
+/*
+* 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.test.deployers.main.support;
+
+import org.jboss.dependency.spi.Controller;
+
+/**
+ * Test attachments deployer.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class TestAttachmentDeployer extends AbstractTestAttachmentDeployer
+{
+   public TestAttachmentDeployer(Controller controller)
+   {
+      super(controller);
+      setComponentsOnly(true);
+   }
+}

Added: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/TestAttachments.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/TestAttachments.java	                        (rev 0)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/TestAttachments.java	2008-01-28 14:00:28 UTC (rev 69386)
@@ -0,0 +1,48 @@
+/*
+* 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.test.deployers.main.support;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Test attachments.
+ * 
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class TestAttachments implements Serializable
+{
+   private static final long serialVersionUID = -1034970512310610762L;
+
+   private List<TestAttachment> attachments = new ArrayList<TestAttachment>();
+
+   public void addAttachment(TestAttachment attachment)
+   {
+      attachments.add(attachment);
+   }
+
+   public List<TestAttachment> getAttachments()
+   {
+      return attachments;
+   }
+}

Added: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/TestAttachmentsDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/TestAttachmentsDeployer.java	                        (rev 0)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/support/TestAttachmentsDeployer.java	2008-01-28 14:00:28 UTC (rev 69386)
@@ -0,0 +1,106 @@
+/*
+* 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.test.deployers.main.support;
+
+import java.util.List;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractComponentDeployer;
+import org.jboss.deployers.spi.deployer.helpers.DeploymentVisitor;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * Test attachments deployer.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class TestAttachmentsDeployer extends AbstractComponentDeployer<TestAttachments, TestAttachment>
+{
+   public TestAttachmentsDeployer()
+   {
+      setDeploymentVisitor(new TestAttachmentsVisitor());
+      setComponentVisitor(new TesAttachmentVisitor());
+   }
+
+   protected static void addTestComponent(DeploymentUnit unit, TestAttachment bean)
+   {
+      DeploymentUnit component = unit.addComponent(bean.getName().toString());
+      component.addAttachment(TestAttachment.class.getName(), bean);
+   }
+
+   protected static void removeTestComponent(DeploymentUnit unit, TestAttachment bean)
+   {
+      unit.removeComponent(bean.getName().toString());
+   }
+
+   /**
+    * TestAttachmentsVisitor.
+    */
+   public static class TestAttachmentsVisitor implements DeploymentVisitor<TestAttachments>
+   {
+      public Class<TestAttachments> getVisitorType()
+      {
+         return TestAttachments.class;
+      }
+
+      public void deploy(DeploymentUnit unit, TestAttachments deployment) throws DeploymentException
+      {
+         List<TestAttachment> beans = deployment.getAttachments();
+         if (beans != null && beans.isEmpty() == false)
+         {
+            for (TestAttachment bean : beans)
+               addTestComponent(unit, bean);
+         }
+      }
+
+      public void undeploy(DeploymentUnit unit, TestAttachments deployment)
+      {
+         List<TestAttachment> beans = deployment.getAttachments();
+         if (beans != null && beans.isEmpty() == false)
+         {
+            for (TestAttachment bean : beans)
+               removeTestComponent(unit, bean);
+         }
+      }
+   }
+
+   /**
+    * TestAttachmentVisitor.
+    */
+   public static class TesAttachmentVisitor implements DeploymentVisitor<TestAttachment>
+   {
+      public Class<TestAttachment> getVisitorType()
+      {
+         return TestAttachment.class;
+      }
+
+      public void deploy(DeploymentUnit unit, TestAttachment deployment) throws DeploymentException
+      {
+         addTestComponent(unit, deployment);
+      }
+
+      public void undeploy(DeploymentUnit unit, TestAttachment deployment)
+      {
+         removeTestComponent(unit, deployment);
+      }
+   }
+}

Modified: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/test/DeployerCheckCompleteTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/test/DeployerCheckCompleteTestCase.java	2008-01-28 08:31:23 UTC (rev 69385)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/main/test/DeployerCheckCompleteTestCase.java	2008-01-28 14:00:28 UTC (rev 69386)
@@ -34,6 +34,9 @@
 import org.jboss.deployers.structure.spi.StructuralDeployers;
 import org.jboss.test.deployers.main.support.DependencyDeployer;
 import org.jboss.test.deployers.main.support.TestAttachment;
+import org.jboss.test.deployers.main.support.TestAttachmentDeployer;
+import org.jboss.test.deployers.main.support.TestAttachments;
+import org.jboss.test.deployers.main.support.TestAttachmentsDeployer;
 
 /**
  * Check complete deployment test case.
@@ -176,6 +179,35 @@
       }
    }
 
+   public void testComponentAllThenHalf() throws Exception
+   {
+      DeployerClient main = getComponentMainDeployer();
+
+      Deployment dA = createSimpleDeployment("A");
+      addComponentAttachment(dA, "xB");
+
+      main.addDeployment(dA);
+      main.process();
+
+      Deployment dB = createSimpleDeployment("B");
+      addComponentAttachment(dB, null);
+      main.deploy(dB);
+
+      main.checkComplete(dA);
+
+      main.undeploy(dB);
+
+      try
+      {
+         main.checkComplete(dA);
+         fail("Should not be here.");
+      }
+      catch (DeploymentException e)
+      {
+         assertInstanceOf(e, IncompleteDeploymentException.class);
+      }
+   }
+
    protected DeployerClient getDependencyMainDeployer()
    {
       MainDeployerImpl main = new MainDeployerImpl();
@@ -187,9 +219,30 @@
       return main;
    }
 
+   protected DeployerClient getComponentMainDeployer()
+   {
+      MainDeployerImpl main = new MainDeployerImpl();
+      main.setStructuralDeployers(createStructuralDeployers());
+      AbstractController controller = new AbstractController();
+      DeployersImpl deployers = new DeployersImpl(controller);
+      deployers.addDeployer(new TestAttachmentsDeployer());
+      deployers.addDeployer(new TestAttachmentDeployer(controller));
+      main.setDeployers(deployers);
+      return main;
+   }
+
    protected void addAttachment(Deployment deployment, Object dependency)
    {
       MutableAttachments mutableAttachments = (MutableAttachments)deployment.getPredeterminedManagedObjects();
       mutableAttachments.addAttachment(TestAttachment.class, new TestAttachment("x" + deployment.getName(), dependency));
    }
+
+   protected void addComponentAttachment(Deployment deployment, Object dependency)
+   {
+      MutableAttachments mutableAttachments = (MutableAttachments)deployment.getPredeterminedManagedObjects();
+      TestAttachment testAttachment = new TestAttachment("x" + deployment.getName(), dependency);
+      TestAttachments testAttachments = new TestAttachments();
+      testAttachments.addAttachment(testAttachment);
+      mutableAttachments.addAttachment(TestAttachments.class, testAttachments);
+   }
 }




More information about the jboss-cvs-commits mailing list