[jboss-cvs] JBossAS SVN: r76093 - projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/classloader.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jul 22 06:58:31 EDT 2008
Author: alesj
Date: 2008-07-22 06:58:31 -0400 (Tue, 22 Jul 2008)
New Revision: 76093
Added:
projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/classloader/RequirementIntegrationDeployer.java
projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/classloader/UrlIntegrationDeployer.java
Log:
Add integration deployers - TODO on tests.
Added: projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/classloader/RequirementIntegrationDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/classloader/RequirementIntegrationDeployer.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/classloader/RequirementIntegrationDeployer.java 2008-07-22 10:58:31 UTC (rev 76093)
@@ -0,0 +1,101 @@
+/*
+* 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.vfs.plugins.classloader;
+
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory;
+import org.jboss.classloading.spi.metadata.Requirement;
+import org.jboss.classloading.spi.metadata.RequirementsMetaData;
+import org.jboss.classloading.spi.metadata.helpers.AbstractRequirement;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.vfs.spi.deployer.AbstractSimpleVFSRealDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+
+/**
+ * Integration deployer.
+ * Adds integration requirement to deployment classpath.
+ *
+ * @param <T> exact output type
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class RequirementIntegrationDeployer<T> extends AbstractSimpleVFSRealDeployer<T>
+{
+ /** The jboss integration module name */
+ private String integrationModuleName;
+
+ public RequirementIntegrationDeployer(Class<T> input)
+ {
+ super(input);
+
+ // We have to run before the classloading is setup
+ setStage(DeploymentStages.DESCRIBE);
+
+ // We modify the classloading "imports"/requirements
+ addInput(ClassLoadingMetaData.class);
+ setOutput(ClassLoadingMetaData.class);
+ }
+
+ /**
+ * Get the integration module name.
+ *
+ * @return the integration modeule name
+ */
+ public String getIntegrationModuleName()
+ {
+ return integrationModuleName;
+ }
+
+ /**
+ * Set the intagration module name.
+ *
+ * @param integrationModuleName the integration module name
+ */
+ public void setIntegrationModuleName(String integrationModuleName)
+ {
+ this.integrationModuleName = integrationModuleName;
+ }
+
+ @Override
+ public void deploy(VFSDeploymentUnit unit, T metaData) throws DeploymentException
+ {
+ ClassLoadingMetaData clmd = unit.getAttachment(ClassLoadingMetaData.class);
+ RequirementsMetaData requirements = clmd.getRequirements();
+ AbstractRequirement integrationModule = hasIntegrationModuleRequirement(requirements);
+ // If we are importing integration core then import the jboss integration at the same version
+ if (integrationModule != null)
+ {
+ ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance();
+ Requirement integrationRequirement = factory.createRequireModule(integrationModuleName, integrationModule.getVersionRange());
+ requirements.addRequirement(integrationRequirement);
+ }
+ }
+
+ /**
+ * Do we have integration module requirements.
+ *
+ * @param requirements the current requirements
+ * @return integration core requirement
+ */
+ protected abstract AbstractRequirement hasIntegrationModuleRequirement(RequirementsMetaData requirements);
+}
\ No newline at end of file
Added: projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/classloader/UrlIntegrationDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/classloader/UrlIntegrationDeployer.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/classloader/UrlIntegrationDeployer.java 2008-07-22 10:58:31 UTC (rev 76093)
@@ -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.deployers.vfs.plugins.classloader;
+
+import java.net.URL;
+import java.io.IOException;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.vfs.spi.deployer.AbstractSimpleVFSRealDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Integration deployer.
+ * Adds integration path to deployment classpath.
+ *
+ * @param <T> exact output type
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class UrlIntegrationDeployer<T> extends AbstractSimpleVFSRealDeployer<T>
+{
+ /** Location of integration jar */
+ private URL integrationURL;
+
+ public UrlIntegrationDeployer(Class<T> input)
+ {
+ super(input);
+ // We have to run before the classloading is setup
+ setStage(DeploymentStages.POST_PARSE);
+ }
+
+ /**
+ * Get the integration url.
+ *
+ * @return the integration url
+ */
+ public URL getIntegarionURL()
+ {
+ return integrationURL;
+ }
+
+ /**
+ * Set integration url.
+ *
+ * @param url the integration url
+ */
+ public void setIntegrationURL(URL url)
+ {
+ this.integrationURL = url;
+ }
+
+ @Override
+ public void deploy(VFSDeploymentUnit unit, T metaData) throws DeploymentException
+ {
+ if (isIntegrationDeployment(unit))
+ {
+ try
+ {
+ VirtualFile integration = VFS.getRoot(integrationURL);
+ unit.addClassPath(integration);
+ }
+ catch (IOException e)
+ {
+ throw DeploymentException.rethrowAsDeploymentException("Error adding integration path.", e);
+ }
+ }
+ }
+
+ /**
+ * Is unit integration deployment unit?
+ *
+ * @param unit the deployment unit
+ * @return true if the unit is integration deployment
+ */
+ protected abstract boolean isIntegrationDeployment(VFSDeploymentUnit unit);
+}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list