[jboss-cvs] JBossAS SVN: r88214 - projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue May 5 09:34:49 EDT 2009
Author: alesj
Date: 2009-05-05 09:34:49 -0400 (Tue, 05 May 2009)
New Revision: 88214
Added:
projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/CachingRequirementIntegrationDeployer.java
Modified:
projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/ModuleRequirementIntegrationDeployer.java
projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/PackageRequirementIntegrationDeployer.java
projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/RequirementIntegrationDeployer.java
projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/UrlIntegrationDeployer.java
Log:
Port JBDEPLOY-185.
Copied: projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/CachingRequirementIntegrationDeployer.java (from rev 88213, projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/CachingRequirementIntegrationDeployer.java)
===================================================================
--- projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/CachingRequirementIntegrationDeployer.java (rev 0)
+++ projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/CachingRequirementIntegrationDeployer.java 2009-05-05 13:34:49 UTC (rev 88214)
@@ -0,0 +1,76 @@
+/*
+* 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.helpers.AbstractRequirement;
+import org.jboss.classloading.spi.metadata.RequirementsMetaData;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+
+/**
+ * Integration deployer.
+ * Caches integration requirement.
+ *
+ * @param <T> exact output type
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class CachingRequirementIntegrationDeployer<T> extends RequirementIntegrationDeployer<T>
+{
+ /** The cached requirement key */
+ public static final String REQUIREMENT_KEY = CachingRequirementIntegrationDeployer.class.getSimpleName() + "::Requirement";
+
+ /** Should we cache the requirement */
+ private boolean cacheRequirement;
+
+ protected CachingRequirementIntegrationDeployer(Class<T> input)
+ {
+ super(input);
+ }
+
+ public void setCacheRequirement(boolean cacheRequirement)
+ {
+ this.cacheRequirement = cacheRequirement;
+ }
+
+ @Override
+ public void undeploy(VFSDeploymentUnit unit, T deployment)
+ {
+ super.undeploy(unit, deployment);
+ // remove the cached requirement
+ if (unit.isAttachmentPresent(REQUIREMENT_KEY))
+ {
+ unit.removeAttachment(REQUIREMENT_KEY);
+ }
+ }
+
+ @Override
+ protected AbstractRequirement hasIntegrationModuleRequirement(VFSDeploymentUnit unit, RequirementsMetaData requirements)
+ {
+ AbstractRequirement abstractRequirement = unit.getAttachment(REQUIREMENT_KEY, AbstractRequirement.class);
+ if (abstractRequirement == null)
+ {
+ abstractRequirement = super.hasIntegrationModuleRequirement(unit, requirements);
+ if (cacheRequirement)
+ unit.addAttachment(REQUIREMENT_KEY, abstractRequirement, AbstractRequirement.class);
+ }
+ return abstractRequirement;
+ }
+}
\ No newline at end of file
Modified: projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/ModuleRequirementIntegrationDeployer.java
===================================================================
--- projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/ModuleRequirementIntegrationDeployer.java 2009-05-05 13:29:30 UTC (rev 88213)
+++ projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/ModuleRequirementIntegrationDeployer.java 2009-05-05 13:34:49 UTC (rev 88214)
@@ -34,7 +34,7 @@
* @param <T> exact output type
* @author <a href="ales.justin at jboss.com">Ales Justin</a>
*/
-public class ModuleRequirementIntegrationDeployer<T> extends RequirementIntegrationDeployer<T>
+public class ModuleRequirementIntegrationDeployer<T> extends CachingRequirementIntegrationDeployer<T>
{
private String module;
Modified: projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/PackageRequirementIntegrationDeployer.java
===================================================================
--- projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/PackageRequirementIntegrationDeployer.java 2009-05-05 13:29:30 UTC (rev 88213)
+++ projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/PackageRequirementIntegrationDeployer.java 2009-05-05 13:34:49 UTC (rev 88214)
@@ -35,7 +35,7 @@
* @param <T> exact output type
* @author <a href="ales.justin at jboss.com">Ales Justin</a>
*/
-public class PackageRequirementIntegrationDeployer<T> extends RequirementIntegrationDeployer<T>
+public class PackageRequirementIntegrationDeployer<T> extends CachingRequirementIntegrationDeployer<T>
{
private Set<String> packages;
Modified: projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/RequirementIntegrationDeployer.java
===================================================================
--- projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/RequirementIntegrationDeployer.java 2009-05-05 13:29:30 UTC (rev 88213)
+++ projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/RequirementIntegrationDeployer.java 2009-05-05 13:34:49 UTC (rev 88214)
@@ -124,7 +124,7 @@
}
RequirementsMetaData requirements = clmd.getRequirements();
- AbstractRequirement integrationModule = hasIntegrationModuleRequirement(requirements);
+ AbstractRequirement integrationModule = hasIntegrationModuleRequirement(unit, requirements);
// If we are importing integration core then import the integration at the same version
if (integrationModule != null)
{
@@ -157,7 +157,7 @@
if (clmd != null)
{
RequirementsMetaData requirements = clmd.getRequirements();
- AbstractRequirement integrationModule = hasIntegrationModuleRequirement(requirements);
+ AbstractRequirement integrationModule = hasIntegrationModuleRequirement(unit, requirements);
if (integrationModule != null)
{
ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance();
@@ -180,8 +180,20 @@
/**
* Do we have integration module requirements.
*
+ * @param unit the deployment unit
* @param requirements the current requirements
* @return integration core requirement
*/
+ protected AbstractRequirement hasIntegrationModuleRequirement(VFSDeploymentUnit unit, RequirementsMetaData requirements)
+ {
+ return hasIntegrationModuleRequirement(requirements);
+ }
+
+ /**
+ * 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
Modified: projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/UrlIntegrationDeployer.java
===================================================================
--- projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/UrlIntegrationDeployer.java 2009-05-05 13:29:30 UTC (rev 88213)
+++ projects/jboss-deployers/branches/Branch_2_0/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/UrlIntegrationDeployer.java 2009-05-05 13:34:49 UTC (rev 88214)
@@ -47,6 +47,9 @@
*/
public abstract class UrlIntegrationDeployer<T> extends AbstractOptionalVFSRealDeployer<T>
{
+ /** The is integration cached flag key */
+ public static final String IS_INTEGRATION_FLAG_KEY = UrlIntegrationDeployer.class.getSimpleName() + "::isIntegrationDeployment";
+
/** Location of integration jar */
private Set<URL> integrationURLs;
@@ -118,6 +121,9 @@
{
if (isIntegrationDeployment(unit, metaData))
{
+ // mark as integration deployment
+ unit.addAttachment(IS_INTEGRATION_FLAG_KEY, true, Boolean.class);
+
List<VirtualFile> added = new ArrayList<VirtualFile>();
try
{
@@ -140,7 +146,8 @@
@Override
public void undeploy(VFSDeploymentUnit unit, T metaData)
{
- if (isIntegrationDeployment(unit, metaData))
+ Boolean isIntegrationDeployment = unit.getAttachment(IS_INTEGRATION_FLAG_KEY, Boolean.class);
+ if (isIntegrationDeployment != null && isIntegrationDeployment)
{
for (URL integrationURL : integrationURLs)
{
@@ -154,6 +161,8 @@
log.warn("Error removing integration from classpath: " + integrationURL, t);
}
}
+ // remove integration flag
+ unit.removeAttachment(IS_INTEGRATION_FLAG_KEY);
}
}
More information about the jboss-cvs-commits
mailing list