[jboss-cvs] JBossAS SVN: r79170 - projects/jboss-deployers/branches/Branch_2_0/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Oct 6 17:22:22 EDT 2008


Author: alesj
Date: 2008-10-06 17:22:22 -0400 (Mon, 06 Oct 2008)
New Revision: 79170

Added:
   projects/jboss-deployers/branches/Branch_2_0/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/AbstractComponentVisitor.java
Log:
Port of ACV to branch 2_0.

Copied: projects/jboss-deployers/branches/Branch_2_0/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/AbstractComponentVisitor.java (from rev 79169, projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/AbstractComponentVisitor.java)
===================================================================
--- projects/jboss-deployers/branches/Branch_2_0/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/AbstractComponentVisitor.java	                        (rev 0)
+++ projects/jboss-deployers/branches/Branch_2_0/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/AbstractComponentVisitor.java	2008-10-06 21:22:22 UTC (rev 79170)
@@ -0,0 +1,65 @@
+/*
+* 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.deployers.spi.deployer.helpers;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.spi.DeploymentException;
+
+/**
+ * Simple component visitor.
+ *
+ * @param <T> exact attachment type
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class AbstractComponentVisitor<T> implements DeploymentVisitor<T>
+{
+   /**
+    * Get component name.
+    *
+    * @param attachment the attachment
+    * @return the component name
+    */
+   protected abstract String getComponentName(T attachment);
+
+   /**
+    * Get attachment name.
+    * By default we return visitor type's name.
+    *
+    * @param attachment the attachment
+    * @return the attachment name
+    */
+   protected String getAttachmentName(T attachment)
+   {
+      return getVisitorType().getName();
+   }
+
+   public void deploy(DeploymentUnit unit, T attachment) throws DeploymentException
+   {
+      DeploymentUnit component = unit.addComponent(getComponentName(attachment));
+      component.addAttachment(getAttachmentName(attachment), attachment);
+   }
+
+   public void undeploy(DeploymentUnit unit, T attachment)
+   {
+      unit.removeComponent(getComponentName(attachment));
+   }
+}




More information about the jboss-cvs-commits mailing list