[jboss-cvs] JBossAS SVN: r69931 - in projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi: helpers and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Feb 19 10:45:26 EST 2008
Author: adrian at jboss.org
Date: 2008-02-19 10:45:26 -0500 (Tue, 19 Feb 2008)
New Revision: 69931
Added:
projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/DeploymentUnitVisitor.java
projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/helpers/UnitVisitorToContextVisitor.java
Modified:
projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/DeploymentUnit.java
projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/helpers/AbstractDeploymentUnit.java
Log:
Introduce a notion of DeploymentUnitVisitor and add isTopLevel() to the deployment unit
Modified: projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/DeploymentUnit.java
===================================================================
--- projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/DeploymentUnit.java 2008-02-19 15:41:59 UTC (rev 69930)
+++ projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/DeploymentUnit.java 2008-02-19 15:45:26 UTC (rev 69931)
@@ -191,6 +191,13 @@
MutableAttachments getTransientManagedObjects();
/**
+ * Whether this unit is a top level deployment
+ *
+ * @return true if a top level deployment
+ */
+ boolean isTopLevel();
+
+ /**
* Get the top leve deployment unit
*
* @return the top level deployment unit
@@ -256,8 +263,17 @@
* @return the resource classloader loader
*/
ClassLoader getResourceClassLoader();
-
+
/**
+ * Visit the unit and the children
+ *
+ * @param visitor the visitor
+ * @throws DeploymentException for any error in the visitor
+ * @throws IllegalArgumentException for a null visitor
+ */
+ void visit(DeploymentUnitVisitor visitor) throws DeploymentException;
+
+ /**
* Get the dependency info
*
* @return the dependency
Added: projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/DeploymentUnitVisitor.java
===================================================================
--- projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/DeploymentUnitVisitor.java (rev 0)
+++ projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/DeploymentUnitVisitor.java 2008-02-19 15:45:26 UTC (rev 69931)
@@ -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.deployers.structure.spi;
+
+import org.jboss.deployers.spi.DeploymentException;
+
+/**
+ * DeploymentUnitVisitor.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface DeploymentUnitVisitor
+{
+ /**
+ * Visit a unit
+ *
+ * @param unit the unit
+ * @throws DeploymentException for any error
+ */
+ void visit(DeploymentUnit unit) throws DeploymentException;
+
+ /**
+ * Invoked when there is a subsequent error in the visit
+ *
+ * @param unit the unit
+ */
+ void error(DeploymentUnit unit);
+}
Modified: projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/helpers/AbstractDeploymentUnit.java
===================================================================
--- projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/helpers/AbstractDeploymentUnit.java 2008-02-19 15:41:59 UTC (rev 69930)
+++ projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/helpers/AbstractDeploymentUnit.java 2008-02-19 15:45:26 UTC (rev 69931)
@@ -41,6 +41,7 @@
import org.jboss.deployers.structure.spi.DeploymentContext;
import org.jboss.deployers.structure.spi.DeploymentResourceLoader;
import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.structure.spi.DeploymentUnitVisitor;
import org.jboss.metadata.spi.MetaData;
import org.jboss.metadata.spi.MutableMetaData;
import org.jboss.metadata.spi.scope.ScopeKey;
@@ -167,12 +168,15 @@
deploymentContext.removeClassLoader(factory);
}
+ public boolean isTopLevel()
+ {
+ return deploymentContext.isTopLevel();
+ }
+
public DeploymentUnit getTopLevel()
{
- DeploymentUnit top = getParent();
- if (top == null)
- top = this;
- return top;
+ DeploymentContext context = deploymentContext.getTopLevel();
+ return context.getDeploymentUnit();
}
public DeploymentUnit getParent()
@@ -423,6 +427,12 @@
getDependencyInfo().addIDependOn(dependency);
}
+ public void visit(DeploymentUnitVisitor visitor) throws DeploymentException
+ {
+ UnitVisitorToContextVisitor contextVisitor = new UnitVisitorToContextVisitor(visitor);
+ deploymentContext.visit(contextVisitor);
+ }
+
public DependencyInfo getDependencyInfo()
{
return deploymentContext.getDependencyInfo();
Added: projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/helpers/UnitVisitorToContextVisitor.java
===================================================================
--- projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/helpers/UnitVisitorToContextVisitor.java (rev 0)
+++ projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/helpers/UnitVisitorToContextVisitor.java 2008-02-19 15:45:26 UTC (rev 69931)
@@ -0,0 +1,62 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, 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.structure.spi.helpers;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.structure.spi.DeploymentContext;
+import org.jboss.deployers.structure.spi.DeploymentContextVisitor;
+import org.jboss.deployers.structure.spi.DeploymentUnitVisitor;
+
+/**
+ * UnitVisitorToContextVisitor.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class UnitVisitorToContextVisitor implements DeploymentContextVisitor
+{
+ /** The deployment unit visitor */
+ private DeploymentUnitVisitor visitor;
+
+ /**
+ * Create a new UnitVisitorToContextVisitor.
+ *
+ * @param visitor the deployment unit visitor
+ * @throws IllegalArgumentException for a null visitor
+ */
+ public UnitVisitorToContextVisitor(DeploymentUnitVisitor visitor)
+ {
+ if (visitor == null)
+ throw new IllegalArgumentException("Null visitor");
+ this.visitor = visitor;
+ }
+
+ public void visit(DeploymentContext context) throws DeploymentException
+ {
+ visitor.visit(context.getDeploymentUnit());
+ }
+
+ public void error(DeploymentContext context)
+ {
+ visitor.error(context.getDeploymentUnit());
+ }
+}
More information about the jboss-cvs-commits
mailing list