[jboss-cvs] JBossAS SVN: r63683 - in projects/microcontainer/trunk: deployers-spi and 10 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jun 27 11:57:58 EDT 2007
Author: adrian at jboss.org
Date: 2007-06-27 11:57:58 -0400 (Wed, 27 Jun 2007)
New Revision: 63683
Added:
projects/microcontainer/trunk/deployers-spi/
projects/microcontainer/trunk/deployers-spi/.classpath
projects/microcontainer/trunk/deployers-spi/.project
projects/microcontainer/trunk/deployers-spi/pom.xml
projects/microcontainer/trunk/deployers-spi/src/
projects/microcontainer/trunk/deployers-spi/src/main/
projects/microcontainer/trunk/deployers-spi/src/main/org/
projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/
projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/
projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/
projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/
projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/Deployer.java
projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/Deployers.java
projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/DeploymentStage.java
projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/DeploymentStages.java
projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/StandardDeployerTypes.java
projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/
projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractClassLoaderDeployer.java
projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractComponentDeployer.java
projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractDeployer.java
projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractParsingDeployer.java
projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractParsingDeployerWithOutput.java
projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractRealDeployer.java
projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractRealDeployerWithInput.java
projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractSimpleRealDeployer.java
projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractTopLevelClassLoaderDeployer.java
projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AttachmentLocator.java
projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/DeploymentVisitor.java
projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/managed/
projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/managed/ManagedObjectCreator.java
projects/microcontainer/trunk/deployers-spi/src/resources/
projects/microcontainer/trunk/deployers-spi/src/resources/tests/
projects/microcontainer/trunk/deployers-spi/src/tests/
Log:
Import refactored deployers code
Added: projects/microcontainer/trunk/deployers-spi/.classpath
===================================================================
--- projects/microcontainer/trunk/deployers-spi/.classpath (rev 0)
+++ projects/microcontainer/trunk/deployers-spi/.classpath 2007-06-27 15:57:58 UTC (rev 63683)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main"/>
+ <classpathentry kind="lib" path="src/resources"/>
+ <classpathentry kind="output" path="target/eclipse-classes"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/jboss-deployers-core-spi"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/jboss-deployers-structure-spi"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/jboss-managed"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-common-logging-spi/2.0.4.GA/jboss-common-logging-spi-2.0.4.GA.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+</classpath>
Added: projects/microcontainer/trunk/deployers-spi/.project
===================================================================
--- projects/microcontainer/trunk/deployers-spi/.project (rev 0)
+++ projects/microcontainer/trunk/deployers-spi/.project 2007-06-27 15:57:58 UTC (rev 63683)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>jboss-deployers-spi</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: projects/microcontainer/trunk/deployers-spi/pom.xml
===================================================================
--- projects/microcontainer/trunk/deployers-spi/pom.xml (rev 0)
+++ projects/microcontainer/trunk/deployers-spi/pom.xml 2007-06-27 15:57:58 UTC (rev 63683)
@@ -0,0 +1,21 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-microcontainer</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>jboss-deployers-spi</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Deployers SPI</name>
+ <url>http://www.jboss.com/products/jbossmc</url>
+ <description>JBoss Deployers SPI</description>
+ <dependencies>
+ <!-- Global dependencies -->
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-deployers-structure-spi</artifactId>
+ </dependency>
+ </dependencies>
+</project>
Added: projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/Deployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/Deployer.java (rev 0)
+++ projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/Deployer.java 2007-06-27 15:57:58 UTC (rev 63683)
@@ -0,0 +1,124 @@
+/*
+* 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;
+
+import java.util.Set;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.Ordered;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * Deployer.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface Deployer extends Ordered
+{
+ /**
+ * Get the type of the deployer. This should be reflected in
+ * the DeploymentUnit deploymentType set of deployments the
+ * Deployer processes.
+ *
+ * @return the deployer type.
+ */
+ String getType();
+
+ /**
+ * Get the deployment stage for this deployer
+ *
+ * @return the stage
+ */
+ DeploymentStage getStage();
+
+ /**
+ * Whether we only want the top level
+ *
+ * @return true for top level only
+ */
+ boolean isTopLevelOnly();
+
+ /**
+ * Whether we only want components
+ *
+ * @return true for components only
+ */
+ boolean isComponentsOnly();
+
+ /**
+ * Whether we dont want components
+ *
+ * @return true for no components
+ */
+ boolean isWantComponents();
+
+ /**
+ * Whether we want all inputs
+ *
+ * @return true for all inputs
+ */
+ boolean isAllInputs();
+
+ /**
+ * Get the input for this deployer
+ *
+ * @return the input type
+ */
+ Class<?> getInput();
+
+ /**
+ * Get the otput for this deployer
+ *
+ * @return the output type
+ */
+ Class<?> getOutput();
+
+ /**
+ * Get the input for this deployer
+ *
+ * @return the inputs
+ */
+ Set<String> getInputs();
+
+ /**
+ * Get the outputs for this deployer
+ *
+ * @return the outputs
+ */
+ Set<String> getOutputs();
+
+ /**
+ * Deploy a deployment
+ *
+ * @param unit the unit
+ * @throws DeploymentException for any error
+ */
+ void deploy(DeploymentUnit unit) throws DeploymentException;
+
+ /**
+ * Undeploy an deployment
+ *
+ * @param unit the unit
+ */
+ void undeploy(DeploymentUnit unit);
+}
Added: projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/Deployers.java
===================================================================
--- projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/Deployers.java (rev 0)
+++ projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/Deployers.java 2007-06-27 15:57:58 UTC (rev 63683)
@@ -0,0 +1,73 @@
+/*
+* 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;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.structure.spi.DeploymentContext;
+import org.jboss.managed.api.ManagedObject;
+
+/**
+ * Deployers.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface Deployers
+{
+ /**
+ * Get the managed objects for a deployer
+ *
+ * @param context the context
+ * @return the managed objects
+ * @throws DeploymentException for any error
+ */
+ Map<String, ManagedObject> getManagedObjects(DeploymentContext context) throws DeploymentException;
+
+ /**
+ * Process deployment
+ *
+ * @param deploy the deployments to deploy
+ * @param undeploy the deployments to remove
+ */
+ void process(List<DeploymentContext> deploy, List<DeploymentContext> undeploy);
+
+ /**
+ * Check all the deployments are complete
+ *
+ * @param errors the contexts in error
+ * @param missingDeployer the deployments missing a deployer
+ * @throws DeploymentException when some deployment is not complete
+ */
+ void checkComplete(Collection<DeploymentContext> errors, Collection<DeploymentContext> missingDeployer) throws DeploymentException;
+
+ /**
+ * Check a single deployment is complete
+ *
+ * @param context the deployment
+ * @throws DeploymentException when the deployment is not complete
+ */
+ void checkComplete(DeploymentContext context) throws DeploymentException;
+}
Added: projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/DeploymentStage.java
===================================================================
--- projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/DeploymentStage.java (rev 0)
+++ projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/DeploymentStage.java 2007-06-27 15:57:58 UTC (rev 63683)
@@ -0,0 +1,150 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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;
+
+
+/**
+ * DeploymentStage.
+ *
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class DeploymentStage
+{
+ /** Our stage */
+ private String name;
+
+ /** The previous state */
+ private String after;
+
+ /** The next state */
+ private String before;
+
+ /**
+ * Safely get the name of stage
+ *
+ * @param stage the stage
+ * @param context the context for an error
+ * @return the stage name
+ */
+ private static String getStageName(DeploymentStage stage, String context)
+ {
+ if (stage == null)
+ throw new IllegalArgumentException("Null " + context);
+ return stage.getName();
+ }
+
+ /**
+ * Create a new DeploymentStage.
+ *
+ * @param name the name of the stage
+ * @throws IllegalArgumentException for a null name
+ */
+ public DeploymentStage(String name)
+ {
+ this(name, (String) null);
+ }
+
+ /**
+ * Create a new DeploymentStage.
+ *
+ * @param name the name of the stage
+ * @param after the name of the stage before our stage
+ * @throws IllegalArgumentException for a null name
+ */
+ public DeploymentStage(String name, String after)
+ {
+ this(name, after, null);
+ }
+
+ /**
+ * Create a new DeploymentStage.
+ *
+ * @param name the name of the stage
+ * @param after the stage before our stage
+ * @throws IllegalArgumentException for a null parameter
+ */
+ public DeploymentStage(String name, DeploymentStage after)
+ {
+ this(name, getStageName(after, "after"), null);
+ }
+
+ /**
+ * Create a new DeploymentStage.
+ *
+ * @param name the name of the stage
+ * @param after he stage before our stage
+ * @param before the stage after our stage
+ * @throws IllegalArgumentException for a null parameter
+ */
+ public DeploymentStage(String name, DeploymentStage after, DeploymentStage before)
+ {
+ this(name, getStageName(after, "after"), getStageName(before, "before"));
+ }
+
+ /**
+ * Create a new DeploymentStage.
+ *
+ * @param name the name of the stage
+ * @param after the name of the stage before our stage
+ * @param before the name of the stage after our stage
+ * @throws IllegalArgumentException for a null name
+ */
+ public DeploymentStage(String name, String after, String before)
+ {
+ if (name == null)
+ throw new IllegalArgumentException("Null name");
+ this.name = name;
+ this.after = after;
+ this.before = before;
+ }
+
+ /**
+ * Get the name.
+ *
+ * @return the name.
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Get the after.
+ *
+ * @return the after.
+ */
+ public String getAfter()
+ {
+ return after;
+ }
+
+ /**
+ * Get the before.
+ *
+ * @return the before.
+ */
+ public String getBefore()
+ {
+ return before;
+ }
+}
Added: projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/DeploymentStages.java
===================================================================
--- projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/DeploymentStages.java (rev 0)
+++ projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/DeploymentStages.java 2007-06-27 15:57:58 UTC (rev 63683)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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;
+
+/**
+ * The Standard DeploymentStages.
+ *
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface DeploymentStages
+{
+ /** The not installed stage - nothing is done here */
+ DeploymentStage NOT_INSTALLED = new DeploymentStage("Not Installed");
+
+ /** The parse stage - where metadata is read */
+ DeploymentStage PARSE = new DeploymentStage("Parse", NOT_INSTALLED);
+
+ /** The describe stage - where dependencies are established */
+ DeploymentStage DESCRIBE = new DeploymentStage("Describe", PARSE);
+
+ /** The classloader stage - where classloaders are created */
+ DeploymentStage CLASSLOADER = new DeploymentStage("ClassLoader", DESCRIBE);
+
+ /** The post classloader stage - e.g. aop */
+ DeploymentStage POST_CLASSLOADER = new DeploymentStage("PostClassLoader", CLASSLOADER);
+
+ /** The real stage - where real deployment processing is done */
+ DeploymentStage REAL = new DeploymentStage("Real", POST_CLASSLOADER);
+
+ /** The installed stage - could be used to provide valve in future? */
+ DeploymentStage INSTALLED = new DeploymentStage("Installed", REAL);
+}
Added: projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/StandardDeployerTypes.java
===================================================================
--- projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/StandardDeployerTypes.java (rev 0)
+++ projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/StandardDeployerTypes.java 2007-06-27 15:57:58 UTC (rev 63683)
@@ -0,0 +1,73 @@
+/*
+ * 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 */
+ String EAR = "ear";
+
+ /** JavaEE client application archive */
+ String CAR = "car";
+
+ /** JavaEE ejb generic archive */
+ String EJB = "ejb";
+
+ /** JavaEE ejb 2.1 and earlier archive */
+ String EJB2x = "ejb2x";
+
+ /** JavaEE ejb 3x archive */
+ String EJB3x = "ejb3x";
+
+ /** JavaEE JPA archive */
+ String JPA = "jpa";
+
+ /** JavaEE resource adaptor archive */
+ String RAR = "rar";
+
+ /** JBoss MC beans archive */
+ String MCBEANS = "beans";
+
+ /** JBoss service archive */
+ String SAR = "sar";
+
+ /** JBoss hibernate archive */
+ String HAR = "har";
+
+ /** JBoss aop archive */
+ String AOP = "aop";
+
+ /** Spring archive */
+ String SPRING = "spring";
+
+ /** An OSGi bundle */
+ String OSGI_BUNDLE = "osgi";
+
+ /** The deployment type used if a deployer does not specify anything */
+ String UNSPECIFIED_TYPE = "unspecified";
+}
Added: projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractClassLoaderDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractClassLoaderDeployer.java (rev 0)
+++ projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractClassLoaderDeployer.java 2007-06-27 15:57:58 UTC (rev 63683)
@@ -0,0 +1,59 @@
+/*
+* 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.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.structure.spi.ClassLoaderFactory;
+import org.jboss.deployers.structure.spi.DeploymentContext;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * AbstractClassLoaderDeployer.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractClassLoaderDeployer extends AbstractDeployer implements ClassLoaderFactory
+{
+ /**
+ * Create a new AbstractClassLoaderDeployer.
+ */
+ public AbstractClassLoaderDeployer()
+ {
+ setStage(DeploymentStages.CLASSLOADER);
+ setInput(ClassLoaderFactory.class);
+ setAllInputs(true);
+ }
+
+ public void deploy(DeploymentUnit unit) throws DeploymentException
+ {
+ ClassLoaderFactory factory = unit.getAttachment(ClassLoaderFactory.class);
+ if (factory == null)
+ factory = this;
+ unit.createClassLoader(factory);
+ }
+
+ public void removeClassLoader(DeploymentContext context) throws Exception
+ {
+ }
+}
Added: projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractComponentDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractComponentDeployer.java (rev 0)
+++ projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractComponentDeployer.java 2007-06-27 15:57:58 UTC (rev 63683)
@@ -0,0 +1,117 @@
+/*
+* 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 java.util.Set;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * AbstractComponentDeployer.
+ *
+ * @param <D> the deployment type
+ * @param <C> the component type
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractComponentDeployer<D, C> extends AbstractRealDeployerWithInput<D>
+{
+ /** The component visitor */
+ private DeploymentVisitor<C> compVisitor;
+
+ /**
+ * Create a new AbstractComponentDeployer.
+ */
+ public AbstractComponentDeployer()
+ {
+ setAllInputs(true);
+ }
+
+ @SuppressWarnings("unchecked")
+ public Class<? extends C> getOutput()
+ {
+ Class<?> output = super.getOutput();
+ if (output == null)
+ throw new IllegalStateException("No output for " + this);
+ return (Class<? extends C>) output;
+ }
+
+ /**
+ * Set the component visitor
+ *
+ * @param visitor the visitor
+ * @throws IllegalArgumentException if the visitor is null
+ */
+ protected void setComponentVisitor(DeploymentVisitor<C> visitor)
+ {
+ if (visitor == null)
+ throw new IllegalArgumentException("Null visitor");
+ this.compVisitor = visitor;
+ Class<C> componentType = visitor.getVisitorType();
+ if (componentType == null)
+ throw new IllegalArgumentException("Null visitor type");
+ setOutput(componentType);
+ addInput(componentType);
+ }
+
+ public void deploy(DeploymentUnit unit) throws DeploymentException
+ {
+ super.deploy(unit);
+
+ try
+ {
+ deployComponents(unit);
+ }
+ catch (Throwable t)
+ {
+ undeployComponents(unit);
+ throw DeploymentException.rethrowAsDeploymentException("Error deploying: " + unit.getName(), t);
+ }
+ }
+
+ public void undeploy(DeploymentUnit unit)
+ {
+ super.undeploy(unit);
+ undeployComponents(unit);
+ }
+
+ protected void deployComponents(DeploymentUnit unit) throws DeploymentException
+ {
+ if (compVisitor == null)
+ return;
+
+ Set<? extends C> components = unit.getAllMetaData(getOutput());
+ for (C component : components)
+ compVisitor.deploy(unit, component);
+ }
+
+ protected void undeployComponents(DeploymentUnit unit)
+ {
+ if (compVisitor == null)
+ return;
+
+ Set<? extends C> components = unit.getAllMetaData(getOutput());
+ for (C component : components)
+ compVisitor.undeploy(unit, component);
+ }
+}
Added: projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractDeployer.java (rev 0)
+++ projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractDeployer.java 2007-06-27 15:57:58 UTC (rev 63683)
@@ -0,0 +1,399 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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 java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.deployers.spi.deployer.Deployer;
+import org.jboss.deployers.spi.deployer.DeploymentStage;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.logging.Logger;
+
+/**
+ * AbstractDeployer.
+ *
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractDeployer implements Deployer
+{
+ /** The log */
+ protected Logger log = Logger.getLogger(getClass());
+
+ /** The relative order */
+ private int relativeOrder = 0;
+
+ /** The deployment stage */
+ private DeploymentStage stage = DeploymentStages.REAL;
+
+ /** Top level only */
+ private boolean topLevelOnly;
+
+ /** Components only */
+ private boolean componentsOnly;
+
+ /** Want components */
+ private boolean wantComponents;
+
+ /** All inputs */
+ private boolean allInputs;
+
+ /** The input type */
+ private Class<?> input;
+
+ /** The output type */
+ private Class<?> output;
+
+ /** The input name */
+ private Set<String> inputs;
+
+ /** The output name */
+ private Set<String> outputs;
+
+ /** The type */
+ private String type;
+
+ public int getRelativeOrder()
+ {
+ return relativeOrder;
+ }
+
+ public void setRelativeOrder(int relativeOrder)
+ {
+ this.relativeOrder = relativeOrder;
+ }
+
+ public DeploymentStage getStage()
+ {
+ return stage;
+ }
+
+ /**
+ * Set the stage.
+ *
+ * @param stage the stage.
+ * @throws IllegalArgumentException for a null stage
+ */
+ public void setStage(DeploymentStage stage)
+ {
+ if (stage == null)
+ throw new IllegalArgumentException("Null stage");
+ this.stage = stage;
+ }
+
+ public boolean isAllInputs()
+ {
+ return allInputs;
+ }
+
+ /**
+ * Set the allInputs.
+ *
+ * @param allInputs the allInputs.
+ */
+ public void setAllInputs(boolean allInputs)
+ {
+ this.allInputs = allInputs;
+ }
+
+ public boolean isComponentsOnly()
+ {
+ return componentsOnly;
+ }
+
+ /**
+ * Set the components only.
+ *
+ * @param componentsOnly the componentsOnly.
+ */
+ public void setComponentsOnly(boolean componentsOnly)
+ {
+ this.componentsOnly = componentsOnly;
+ setWantComponents(true);
+ }
+
+ public boolean isWantComponents()
+ {
+ return wantComponents;
+ }
+
+ /**
+ * Set the want components.
+ *
+ * @param wantComponents the want components.
+ */
+ public void setWantComponents(boolean wantComponents)
+ {
+ this.wantComponents = wantComponents;
+ }
+
+ public boolean isTopLevelOnly()
+ {
+ return topLevelOnly;
+ }
+
+ /**
+ * Set the top level only.
+ *
+ * @param topLevelOnly the top level only.
+ */
+ public void setTopLevelOnly(boolean topLevelOnly)
+ {
+ this.topLevelOnly = topLevelOnly;
+ }
+
+ public Class<?> getInput()
+ {
+ return input;
+ }
+
+ /**
+ * Set the input
+ *
+ * @param input the input
+ */
+ @SuppressWarnings("unchecked")
+ public void setInput(Class<?> input)
+ {
+ addInput(input);
+ this.input = input;
+ }
+
+ public Class<?> getOutput()
+ {
+ return output;
+ }
+
+ /**
+ * Set the output
+ *
+ * @param output the outputs
+ */
+ @SuppressWarnings("unchecked")
+ public void setOutput(Class<?> output)
+ {
+ addOutput(output);
+ this.output = output;
+ }
+
+ public Set<String> getInputs()
+ {
+ return inputs;
+ }
+
+ /**
+ * Set the inputs.
+ *
+ * @param inputs the inputs.
+ */
+ public void setInputs(Set<String> inputs)
+ {
+ this.inputs = inputs;
+ }
+
+ /**
+ * Set the inputs.
+ *
+ * @param inputs the inputs.
+ */
+ @SuppressWarnings("unchecked")
+ public void setInputs(String... inputs)
+ {
+ if (inputs == null)
+ {
+ setInputs((Set) null);
+ return;
+ }
+ Set<String> temp = new HashSet<String>(inputs.length);
+ for (String input : inputs)
+ {
+ if (input == null)
+ throw new IllegalArgumentException("Null input");
+ temp.add(input);
+ }
+ setInputs(temp);
+ }
+
+ /**
+ * Set the inputs.
+ *
+ * @param inputs the inputs.
+ */
+ @SuppressWarnings("unchecked")
+ public void setInputs(Class<?>... inputs)
+ {
+ if (inputs == null)
+ {
+ setInputs((Set) null);
+ return;
+ }
+ Set<String> temp = new HashSet<String>(inputs.length);
+ for (Class<?> input : inputs)
+ {
+ if (input == null)
+ throw new IllegalArgumentException("Null input");
+ temp.add(input.getName());
+ }
+ setInputs(temp);
+ }
+
+ /**
+ * Add an input
+ *
+ * @param input the input
+ */
+ public void addInput(String input)
+ {
+ if (input == null)
+ throw new IllegalArgumentException("Null input");
+
+ if (inputs == null)
+ inputs = new HashSet<String>();
+
+ inputs.add(input);
+ }
+
+ /**
+ * Add an input
+ *
+ * @param input the input
+ */
+ public void addInput(Class<?> input)
+ {
+ if (input == null)
+ throw new IllegalArgumentException("Null input");
+
+ addInput(input.getName());
+ }
+
+ public Set<String> getOutputs()
+ {
+ return outputs;
+ }
+
+ /**
+ * Set the outputs.
+ *
+ * @param outputs the outputs.
+ */
+ public void setOutputs(Set<String> outputs)
+ {
+ this.outputs = outputs;
+ }
+
+ /**
+ * Set the outputs.
+ *
+ * @param outputs the outputs.
+ */
+ @SuppressWarnings("unchecked")
+ public void setOutputs(String... outputs)
+ {
+ if (outputs == null)
+ {
+ setOutputs((Set) null);
+ return;
+ }
+ Set<String> temp = new HashSet<String>(outputs.length);
+ for (String output : outputs)
+ {
+ if (output == null)
+ throw new IllegalArgumentException("Null output");
+ temp.add(output);
+ }
+ setOutputs(temp);
+ }
+
+ /**
+ * Set the outputs.
+ *
+ * @param outputs the outputs.
+ */
+ @SuppressWarnings("unchecked")
+ public void setOutputs(Class<?>... outputs)
+ {
+ if (outputs == null)
+ {
+ setOutputs((Set) null);
+ return;
+ }
+ Set<String> temp = new HashSet<String>(outputs.length);
+ for (Class<?> output : outputs)
+ {
+ if (output == null)
+ throw new IllegalArgumentException("Null output");
+ temp.add(output.getName());
+ }
+ setOutputs(temp);
+ }
+
+ /**
+ * Add an output
+ *
+ * @param output the output
+ */
+ public void addOutput(String output)
+ {
+ if (output == null)
+ throw new IllegalArgumentException("Null output");
+
+ if (outputs == null)
+ outputs = new HashSet<String>();
+
+ outputs.add(output);
+ }
+
+ /**
+ * Add an output
+ *
+ * @param output the output
+ */
+ public void addOutput(Class<?> output)
+ {
+ if (output == null)
+ throw new IllegalArgumentException("Null output");
+
+ addOutput(output.getName());
+ }
+
+ /**
+ * Get the type.
+ *
+ * @return the type.
+ */
+ public String getType()
+ {
+ return type;
+ }
+
+ public void setType(String type)
+ {
+ this.type = type;
+ }
+
+ public void undeploy(DeploymentUnit unit)
+ {
+ // Nothing
+ }
+}
Added: projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractParsingDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractParsingDeployer.java (rev 0)
+++ projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractParsingDeployer.java 2007-06-27 15:57:58 UTC (rev 63683)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.deployer.DeploymentStages;
+
+/**
+ * AbstractParsingDeployer.
+ *
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractParsingDeployer extends AbstractDeployer
+{
+ /**
+ * Create a new AbstractParsingDeployer.
+ */
+ public AbstractParsingDeployer()
+ {
+ setStage(DeploymentStages.PARSE);
+ }
+}
Added: projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractParsingDeployerWithOutput.java
===================================================================
--- projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractParsingDeployerWithOutput.java (rev 0)
+++ projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractParsingDeployerWithOutput.java 2007-06-27 15:57:58 UTC (rev 63683)
@@ -0,0 +1,243 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.structure.spi.DeploymentUnit;
+
+/**
+ * AbstractParsingDeployerWithOutput.
+ *
+ * @param <T> the type of output
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractParsingDeployerWithOutput<T> extends AbstractParsingDeployer
+{
+ /** The metadata file name */
+ private String name;
+
+ /** The suffix */
+ private String suffix;
+
+ /** Include the deployment file */
+ private boolean includeDeploymentFile = false;
+
+ /**
+ * Create a new AbstractParsingDeployerWithOutput.
+ *
+ * @param output the type of output
+ * @throws IllegalArgumentException for null output
+ */
+ public AbstractParsingDeployerWithOutput(Class<T> output)
+ {
+ if (output == null)
+ throw new IllegalArgumentException("Null output");
+ setOutput(output);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Class<T> getOutput()
+ {
+ return (Class<T>) super.getOutput();
+ }
+
+ /**
+ * Get the name.
+ *
+ * @return the name.
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Set the name.
+ *
+ * @param name the name.
+ */
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * Get the suffix.
+ *
+ * @return the suffix.
+ */
+ public String getSuffix()
+ {
+ return suffix;
+ }
+
+ /**
+ * Set the suffix.
+ *
+ * @param suffix the suffix.
+ */
+ public void setSuffix(String suffix)
+ {
+ this.suffix = suffix;
+ }
+
+ /**
+ * Get the includeDeploymentFile.
+ *
+ * @return the includeDeploymentFile.
+ */
+ public boolean isIncludeDeploymentFile()
+ {
+ return includeDeploymentFile;
+ }
+
+ /**
+ * Set the includeDeploymentFile.
+ *
+ * @param includeDeploymentFile the includeDeploymentFile.
+ */
+ public void setIncludeDeploymentFile(boolean includeDeploymentFile)
+ {
+ this.includeDeploymentFile = includeDeploymentFile;
+ }
+
+ /**
+ * A flag indicating whether createMetaData should execute a parse even if a non-null metadata value exists.
+ *
+ * @return false if a parse should be performed only if there is no existing metadata value. True indicates
+ * that parse should be done regardless of an existing metadata value.
+ */
+ protected boolean allowsReparse()
+ {
+ return false;
+ }
+
+ public void deploy(DeploymentUnit unit) throws DeploymentException
+ {
+ if (accepts(unit) == false)
+ return;
+ createMetaData(unit, name, suffix);
+ }
+
+ /**
+ * Callback to do prechecking on the deployment
+ *
+ * @param unit the unit
+ * @return true by default
+ * @throws DeploymentException for any error
+ */
+ protected boolean accepts(DeploymentUnit unit) throws DeploymentException
+ {
+ return true;
+ }
+
+ /**
+ * Get some meta data
+ *
+ * @param unit the deployment unit
+ * @param key the key into the managed objects
+ * @return the metadata or null if it doesn't exist
+ */
+ protected T getMetaData(DeploymentUnit unit, String key)
+ {
+ return unit.getAttachment(key, getOutput());
+ }
+
+ /**
+ * Create some meta data. Calls createMetaData(unit, name, suffix, getDeploymentType().getName()).
+ *
+ * @param unit the deployment unit
+ * @param name the name
+ * @param suffix the suffix
+ * @throws DeploymentException for any error
+ */
+ protected void createMetaData(DeploymentUnit unit, String name, String suffix) throws DeploymentException
+ {
+ createMetaData(unit, name, suffix, getOutput().getName());
+ }
+
+ /**
+ * Create some meta data. Invokes parse(unit, name, suffix) if there is not already a
+ * metadata
+ *
+ * @param unit the deployment unit
+ * @param name the name
+ * @param suffix the suffix
+ * @param key the key into the managed objects
+ * @throws DeploymentException for any error
+ */
+ protected void createMetaData(DeploymentUnit unit, String name, String suffix, String key) throws DeploymentException
+ {
+ // First see whether it already exists
+ T result = getMetaData(unit, key);
+ if (result != null && allowsReparse() == false)
+ return;
+
+ // Create it
+ try
+ {
+ if (suffix == null)
+ 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)
+ {
+ throw DeploymentException.rethrowAsDeploymentException("Error creating managed object for " + unit.getName(), e);
+ }
+
+ // Doesn't exist
+ if (result == null)
+ return;
+
+ // Register it
+ unit.getTransientManagedObjects().addAttachment(key, result, getOutput());
+ }
+
+ /**
+ * Parse an exact file name
+ *
+ * @param unit the unit
+ * @param name the exact name to match
+ * @param root - possibly null pre-existing root
+ * @return the metadata or null if it doesn't exist
+ * @throws Exception for any error
+ */
+ protected abstract T parse(DeploymentUnit unit, String name, T root) throws Exception;
+
+ /**
+ * Parse an exact file name or look for a suffix
+ *
+ * @param unit the unit
+ * @param name the exact name to match
+ * @param suffix the suffix to match
+ * @param root - possibly null pre-existing root
+ * @return the metadata or null if it doesn't exist
+ * @throws Exception for any error
+ */
+ protected abstract T parse(DeploymentUnit unit, String name, String suffix, T root) throws Exception;
+}
Added: projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractRealDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractRealDeployer.java (rev 0)
+++ projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractRealDeployer.java 2007-06-27 15:57:58 UTC (rev 63683)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.deployer.DeploymentStages;
+
+/**
+ * AbstractRealDeployer.
+ *
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractRealDeployer extends AbstractDeployer
+{
+ /**
+ * Create a new AbstractRealDeployer.
+ */
+ public AbstractRealDeployer()
+ {
+ setStage(DeploymentStages.REAL);
+ }
+}
Added: projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractRealDeployerWithInput.java
===================================================================
--- projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractRealDeployerWithInput.java (rev 0)
+++ projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractRealDeployerWithInput.java 2007-06-27 15:57:58 UTC (rev 63683)
@@ -0,0 +1,120 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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 java.util.Set;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * AbstractRealDeployerWithInput.
+ *
+ * @param <T> the type of the input
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractRealDeployerWithInput<T> extends AbstractRealDeployer
+{
+ /** The visitor */
+ private DeploymentVisitor<T> visitor;
+
+ /** Whether the warning has been displayed */
+ private boolean warned;
+
+ /**
+ * Create a new AbstractRealDeployerWithInput.
+ */
+ public AbstractRealDeployerWithInput()
+ {
+ }
+
+ /**
+ * Create a new AbstractRealDeployerWithInput.
+ *
+ * @param input the input
+ */
+ public AbstractRealDeployerWithInput(Class<T> input)
+ {
+ setInput(input);
+ }
+
+ @SuppressWarnings("unchecked")
+ public Class<? extends T> getInput()
+ {
+ Class<?> input = super.getInput();
+ if (input == null)
+ throw new IllegalStateException("No input for " + this);
+ return (Class<? extends T>) input;
+ }
+
+ /**
+ * Set the deployment visitor
+ *
+ * @param visitor the visitor
+ * @throws IllegalArgumentException if the visitor is null
+ */
+ protected void setDeploymentVisitor(DeploymentVisitor<T> visitor)
+ {
+ if (visitor == null)
+ throw new IllegalArgumentException("Null visitor");
+ this.visitor = visitor;
+ Class<T> input = visitor.getVisitorType();
+ if (input == null)
+ throw new IllegalArgumentException("Null visitor type");
+ setInput(input);
+ }
+
+ public void deploy(DeploymentUnit unit) throws DeploymentException
+ {
+ if (visitor == null)
+ {
+ if (warned == false)
+ {
+ log.error("INTERNAL ERROR: Visitor is null for " + getClass().getName());
+ warned = true;
+ }
+ return;
+ }
+
+ try
+ {
+ Set<? extends T> deployments = unit.getAllMetaData(getInput());
+ for (T deployment : deployments)
+ visitor.deploy(unit, deployment);
+ }
+ catch (Throwable t)
+ {
+ undeploy(unit);
+ throw DeploymentException.rethrowAsDeploymentException("Error deploying: " + unit.getName(), t);
+ }
+ }
+
+ public void undeploy(DeploymentUnit unit)
+ {
+ if (visitor == null)
+ return;
+ Set<? extends T> deployments = unit.getAllMetaData(getInput());
+ for (T deployment : deployments)
+ visitor.undeploy(unit, deployment);
+ }
+}
Added: projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractSimpleRealDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractSimpleRealDeployer.java (rev 0)
+++ projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractSimpleRealDeployer.java 2007-06-27 15:57:58 UTC (rev 63683)
@@ -0,0 +1,82 @@
+/*
+* 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.spi.DeploymentException;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * AbstractSimpleRealDeployer.
+ *
+ * @param <T> the input type
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractSimpleRealDeployer<T> extends AbstractRealDeployer
+{
+ /**
+ * Create a new AbstractSimpleRealDeployer
+ *
+ * @param input the input type
+ * @throws IllegalArgumentException for a null input
+ */
+ public AbstractSimpleRealDeployer(Class<T> input)
+ {
+ if (input == null)
+ throw new IllegalArgumentException("Null input");
+ setInput(input);
+ }
+
+ @SuppressWarnings("unchecked")
+ public Class<? extends T> getInput()
+ {
+ Class<?> input = super.getInput();
+ if (input == null)
+ throw new IllegalStateException("No input for " + this);
+ return (Class<? extends T>) input;
+ }
+
+ public void deploy(DeploymentUnit unit) throws DeploymentException
+ {
+ T deployment = unit.getAttachment(getInput());
+ if (deployment != null)
+ {
+ // Set the deployer type
+ unit.getTypes().add(getType());
+ deploy(unit, deployment);
+ }
+ }
+
+ public void undeploy(DeploymentUnit unit)
+ {
+ T deployment = unit.getAttachment(getInput());
+ if (deployment != null)
+ undeploy(unit, deployment);
+ }
+
+ public abstract void deploy(DeploymentUnit unit, T deployment) throws DeploymentException;
+
+ public void undeploy(DeploymentUnit unit, T deployment)
+ {
+ // Nothing
+ }
+}
Added: projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractTopLevelClassLoaderDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractTopLevelClassLoaderDeployer.java (rev 0)
+++ projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AbstractTopLevelClassLoaderDeployer.java 2007-06-27 15:57:58 UTC (rev 63683)
@@ -0,0 +1,67 @@
+/*
+* 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.DeploymentContext;
+
+/**
+ * AbstractTopLevelClassLoaderDeployer.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractTopLevelClassLoaderDeployer extends AbstractClassLoaderDeployer
+{
+ public ClassLoader createClassLoader(DeploymentContext context) throws Exception
+ {
+ if (context.isTopLevel())
+ return createTopLevelClassLoader(context);
+
+ return context.getTopLevel().getClassLoader();
+ }
+
+ @Override
+ public void removeClassLoader(DeploymentContext context) throws Exception
+ {
+ if (context.isTopLevel())
+ removeTopLevelClassLoader(context);
+ }
+
+ /**
+ * Create a top level classloader
+ *
+ * @param context the context
+ * @return the classloader
+ * @throws Exception for any error
+ */
+ protected abstract ClassLoader createTopLevelClassLoader(DeploymentContext context) throws Exception;
+
+ /**
+ * Remove a top level classloader
+ *
+ * @param context the context
+ * @throws Exception for any error
+ */
+ protected void removeTopLevelClassLoader(DeploymentContext context) throws Exception
+ {
+ }
+}
Added: projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AttachmentLocator.java
===================================================================
--- projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AttachmentLocator.java (rev 0)
+++ projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/AttachmentLocator.java 2007-06-27 15:57:58 UTC (rev 63683)
@@ -0,0 +1,86 @@
+/*
+ * 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.helpers;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * Search a DeploymentUnit structure from child to parent for a matching
+ * attachment.
+ *
+ * @author Scott.Stark at jboss.org
+ * @author adrian at jboss.org
+ * @version $Revision:$
+ */
+public class AttachmentLocator
+{
+ /**
+ * Get a named attachment
+ *
+ * @param unit the deployment unit
+ * @param name the name of the attachment
+ * @return the attachment or null if not present
+ * @throws IllegalArgumentException for a null name
+ */
+ static public Object search(DeploymentUnit unit, String name)
+ {
+ Object attachment = null;
+ while (attachment == null && unit != null)
+ {
+ attachment = unit.getAttachment(name);
+ unit = unit.getParent();
+ }
+ return attachment;
+ }
+
+ /**
+ * Get named attachment of a given type
+ *
+ * @param <T> the expected type
+ * @param unit the deployment unit
+ * @param name the name of the attachment
+ * @param expectedType the expected type
+ * @return the attachment or null if not present
+ * @throws IllegalArgumentException for a null name or expectedType
+ */
+ static public <T> T search(DeploymentUnit unit, String name, Class<T> expectedType)
+ {
+ Object result = search(unit, name);
+ if (result == null)
+ return null;
+ return expectedType.cast(result);
+ }
+
+ /**
+ * Get an attachment of the given type
+ *
+ * @param <T> the expected type
+ * @param type the type
+ * @param unit the deployment unit
+ * @return the attachment or null if not present
+ * @throws IllegalArgumentException for a null name or type
+ */
+ static public <T> T search(DeploymentUnit unit, Class<T> type)
+ {
+ return search(unit, type.getName(), type);
+ }
+}
Added: projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/DeploymentVisitor.java
===================================================================
--- projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/DeploymentVisitor.java (rev 0)
+++ projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/helpers/DeploymentVisitor.java 2007-06-27 15:57:58 UTC (rev 63683)
@@ -0,0 +1,59 @@
+/*
+* 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.spi.DeploymentException;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * DeploymentVisitor.
+ *
+ * @param <T> the deployment type
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface DeploymentVisitor<T>
+{
+ /**
+ * Get the visitor type
+ *
+ * @return the visitor type
+ */
+ Class<T> getVisitorType();
+
+ /**
+ * Deploy the deployment
+ *
+ * @param unit the deployment unit
+ * @param deployment the deployment
+ * @throws DeploymentException the deployment exception
+ */
+ void deploy(DeploymentUnit unit, T deployment) throws DeploymentException;
+
+ /**
+ * Undeploy the deployment
+ *
+ * @param unit the deployment unit
+ * @param deployment the deployment
+ */
+ void undeploy(DeploymentUnit unit, T deployment);
+}
Added: projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/managed/ManagedObjectCreator.java
===================================================================
--- projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/managed/ManagedObjectCreator.java (rev 0)
+++ projects/microcontainer/trunk/deployers-spi/src/main/org/jboss/deployers/spi/deployer/managed/ManagedObjectCreator.java 2007-06-27 15:57:58 UTC (rev 63683)
@@ -0,0 +1,58 @@
+/*
+* 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.managed;
+
+import java.util.Map;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.managed.api.ManagedObject;
+
+/**
+ * ManagedObjectCreator.
+ *
+ * TODO Critique
+ * Rather having the contexts create the managed objects directly
+ * they should provide the underlying metadata, e.g. the Fields + other information
+ * from which we can create the managed object.
+ * This is important because it is likely that multiple builders/deployers will
+ * play populate an object, e.g. (possibly?)
+ * - the parsing deployer will describe the properties/metadata
+ * - there maybe transformation, augmentation by some other deployers
+ * - the component deployers will want to link their component metadata back into
+ * the parent by reference, e.g. an mbean as part of sar/-service.xml
+ * - the real deployer will describe any runtime support, e.g. managed operations and statistics
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ManagedObjectCreator
+{
+ /**
+ * Build managed objects for this deployment context
+ *
+ * @param unit the deployment unit
+ * @param managedObjects the managed objects
+ * @throws DeploymentException
+ */
+ void build(DeploymentUnit unit, Map<String, ManagedObject> managedObjects) throws DeploymentException;
+}
More information about the jboss-cvs-commits
mailing list