[jboss-cvs] jboss-cvs-commits Digest, Vol 40, Issue 522
Ales Justin
ales.justin at gmail.com
Wed Oct 21 15:10:55 EDT 2009
This is wrong.
The deployer you added is never invoked,
as there is no deployer that would create JBossWebMetaData.
You should *remove* the newly added jboss-metadata dependency,
and create a better/simpler mock, that would work off the .war
deployment unit.
e.g.
if (unit.getName().endswith(".war"))
{
// create this new ClassLoadingMetaData
}
No wonder the test worked w/o any changes,
as the classloader was still the same,
where in true web example it should be a new one,
hanging off the top one.
> ------------------------------
>
> Message: 8
> Date: Wed, 21 Oct 2009 10:26:49 -0400
> From: jboss-cvs-commits at lists.jboss.org
> Subject: [jboss-cvs] JBossAS SVN: r95304 - in
> projects/jboss-deployers/trunk/deployers-vfs/src/test:
> java/org/jboss/test/deployers/vfs/classpool/test and 1 other
> directories.
> To: jboss-cvs-commits at lists.jboss.org
> Message-ID:
> <200910211426.n9LEQnL4001497 at svn01.web.mwc.hst.phx2.redhat.com>
> Content-Type: text/plain; charset=UTF-8
>
> Author: flavia.rainone at jboss.com
> Date: 2009-10-21 10:26:49 -0400 (Wed, 21 Oct 2009)
> New Revision: 95304
>
> Added:
> projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classpool/support/MockWarClassLoaderDeployer.java
> Modified:
> projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classpool/test/ClassPoolTestCase.java
> projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/org/jboss/test/deployers/vfs/classpool/test/ClassPoolTestCase.xml
> Log:
> [JBDEPLOY-216] Added MockWarClassLoaderDeployer to ClassPoolTestCase.
>
> Added: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classpool/support/MockWarClassLoaderDeployer.java
> ===================================================================
> --- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classpool/support/MockWarClassLoaderDeployer.java (rev 0)
> +++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classpool/support/MockWarClassLoaderDeployer.java 2009-10-21 14:26:49 UTC (rev 95304)
> @@ -0,0 +1,175 @@
> +/*
> + * 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.test.deployers.vfs.classpool.support;
> +
> +import java.io.ByteArrayInputStream;
> +import java.util.Properties;
> +import java.util.Set;
> +
> +import org.jboss.classloader.spi.filter.ClassFilter;
> +import org.jboss.classloader.spi.filter.RecursivePackageClassFilter;
> +import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
> +import org.jboss.classloading.spi.metadata.ExportAll;
> +import org.jboss.classloading.spi.version.Version;
> +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.metadata.common.jboss.LoaderRepositoryConfigMetaData;
> +import org.jboss.metadata.common.jboss.LoaderRepositoryMetaData;
> +import org.jboss.metadata.web.jboss.JBossWebMetaData;
> +
> +/**
> + * MockWarClassLoaderDeployer.Based on WarClassLoaderDeployer.
> + *
> + * @author Scott.Stark at jboss.org
> + * @author adrian at jboss.org
> + * @author ales.justin at jboss.org
> + * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
> + */
> +public class MockWarClassLoaderDeployer extends AbstractSimpleVFSRealDeployer<JBossWebMetaData>
> +{
> + /** The parent class loader first model flag */
> + private boolean java2ClassLoadingCompliance = false;
> +
> + /** Package names that should be ignored for class loading */
> + private String filteredPackages;
> +
> + /**
> + * Create a new WarClassLoaderDeployer.
> + */
> + public MockWarClassLoaderDeployer()
> + {
> + super(JBossWebMetaData.class);
> + setStage(DeploymentStages.POST_PARSE);
> + addInput(ClassLoadingMetaData.class);
> + setOutput(ClassLoadingMetaData.class);
> + }
> +
> + public boolean isJava2ClassLoadingCompliance()
> + {
> + return java2ClassLoadingCompliance;
> + }
> +
> + public void setJava2ClassLoadingCompliance(boolean flag)
> + {
> + this.java2ClassLoadingCompliance = flag;
> + }
> +
> + public String getFilteredPackages()
> + {
> + return filteredPackages;
> + }
> + public void setFilteredPackages(String pkgs)
> + {
> + this.filteredPackages = pkgs;
> + }
> +
> + @Override
> + public void deploy(VFSDeploymentUnit unit, JBossWebMetaData metaData) throws DeploymentException
> + {
> + // Ignore if it already has classloading
> + if (unit.isAttachmentPresent(ClassLoadingMetaData.class))
> + return;
> +
> + // The default domain name is the unit name
> + String domainName = unit.getName();
> +
> + // The default classloading compliance is on the deployer
> + boolean j2seClassLoadingCompliance = java2ClassLoadingCompliance;
> +
> + // Do we have a legacy classloading element?
> + org.jboss.metadata.web.jboss.ClassLoadingMetaData webCLMD = metaData.getClassLoading();
> + if (webCLMD != null)
> + {
> + // Was the complince set?
> + if (webCLMD.wasJava2ClassLoadingComplianceSet())
> + j2seClassLoadingCompliance = webCLMD.isJava2ClassLoadingCompliance();
> +
> + // Does it have a loader repository
> + LoaderRepositoryMetaData lrmd = webCLMD.getLoaderRepository();
> + if (lrmd != null)
> + {
> + // Use the trimmed repository name as the domain
> + String repositoryName = lrmd.getName();
> + if (repositoryName != null)
> + {
> + repositoryName = repositoryName.trim();
> + if (repositoryName != null)
> + {
> + domainName = repositoryName;
> +
> + // If there was no compliance set see if the loader repository has one
> + if (webCLMD.wasJava2ClassLoadingComplianceSet() == false)
> + {
> + Set<LoaderRepositoryConfigMetaData> configs = lrmd.getLoaderRepositoryConfig();
> + if (configs != null && configs.isEmpty() == false)
> + {
> + LoaderRepositoryConfigMetaData lrcmd = configs.iterator().next();
> +
> + Properties props = new Properties();
> + String config = lrcmd.getConfig();
> + try
> + {
> + if (config != null)
> + {
> + ByteArrayInputStream bais = new ByteArrayInputStream(config.getBytes());
> + props.load(bais);
> + }
> + }
> + catch (Exception e)
> + {
> + throw DeploymentException.rethrowAsDeploymentException("Error parsing repository config " + config, e);
> + }
> + String java2ParentDelegation = props.getProperty("java2ParentDelegation");
> + if( java2ParentDelegation == null )
> + {
> + // Check for previous mis-spelled property name
> + java2ParentDelegation = props.getProperty("java2ParentDelegaton", "false");
> + }
> + j2seClassLoadingCompliance = Boolean.valueOf(java2ParentDelegation);
> + }
> + }
> + }
> + }
> + }
> + }
> +
> + // Create a classloading metadata
> + // NOTE: Don't explicitly set the parentDomain otherwise it will create a top level classloader
> + // for subdeployments rather than a classloader hanging off the main deployment's classloader
> + ClassLoadingMetaData classLoadingMetaData = new ClassLoadingMetaData();
> + classLoadingMetaData.setName(unit.getName());
> + classLoadingMetaData.setDomain(domainName);
> + classLoadingMetaData.setExportAll(ExportAll.NON_EMPTY);
> + classLoadingMetaData.setImportAll(true);
> + classLoadingMetaData.setVersion(Version.DEFAULT_VERSION);
> + classLoadingMetaData.setJ2seClassLoadingCompliance(j2seClassLoadingCompliance);
> + ClassFilter filter = null;
> + if (filteredPackages != null)
> + {
> + filter = RecursivePackageClassFilter.createRecursivePackageClassFilterFromString(filteredPackages);
> + classLoadingMetaData.setExcluded(filter);
> + }
> + unit.addAttachment(ClassLoadingMetaData.class, classLoadingMetaData);
> + }
> +}
>
>
> Property changes on: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classpool/support/MockWarClassLoaderDeployer.java
> ___________________________________________________________________
> Name: svn:keywords
> + Author Date Id Revision
> Name: svn:eol-style
> + native
>
> Modified: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classpool/test/ClassPoolTestCase.java
> ===================================================================
> --- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classpool/test/ClassPoolTestCase.java 2009-10-21 14:26:00 UTC (rev 95303)
> +++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classpool/test/ClassPoolTestCase.java 2009-10-21 14:26:49 UTC (rev 95304)
> @@ -21,6 +21,8 @@
> */
> package org.jboss.test.deployers.vfs.classpool.test;
>
> +import junit.framework.Test;
> +
> import org.jboss.test.deployers.vfs.classpool.support.crm.CrmFacade;
> import org.jboss.test.deployers.vfs.classpool.support.ejb.MySLSBean;
> import org.jboss.test.deployers.vfs.classpool.support.ext.External;
> @@ -32,8 +34,6 @@
> import org.jboss.test.deployers.vfs.classpool.support.web.AnyServlet;
> import org.jboss.virtual.AssembledDirectory;
>
> -import junit.framework.Test;
> -
> /**
> * Test case for ClassPool.
> *
> @@ -94,7 +94,6 @@
> public void testWarInEar() throws Exception
> {
> AssembledDirectory directory = createWarInEar();
> - // TODO - make proper .war CL check --> MockWarCLDeployer
> assertClassPool(directory, AnyServlet.class);
> }
>
>
> Modified: projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/org/jboss/test/deployers/vfs/classpool/test/ClassPoolTestCase.xml
> ===================================================================
> --- projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/org/jboss/test/deployers/vfs/classpool/test/ClassPoolTestCase.xml 2009-10-21 14:26:00 UTC (rev 95303)
> +++ projects/jboss-deployers/trunk/deployers-vfs/src/test/resources/org/jboss/test/deployers/vfs/classpool/test/ClassPoolTestCase.xml 2009-10-21 14:26:49 UTC (rev 95304)
> @@ -2,6 +2,7 @@
>
> <bean name="EarStructure" class="org.jboss.test.deployers.vfs.structure.ear.support.MockEarStructureDeployer"/>
> <bean name="WarStructure" class="org.jboss.test.deployers.vfs.structure.war.support.MockWarStructureDeployer"/>
> + <bean name="WarClassLoader" class="org.jboss.test.deployers.vfs.classpool.support.MockWarClassLoaderDeployer"/>
>
> <bean name="ClassLoaderScopingPolicy" class="org.jboss.classpool.plugins.as5.VFSClassLoaderDomainRegistry"/>
>
>
>
>
> ------------------------------
>
> _______________________________________________
> jboss-cvs-commits mailing list
> jboss-cvs-commits at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/jboss-cvs-commits
>
>
> End of jboss-cvs-commits Digest, Vol 40, Issue 522
> **************************************************
>
More information about the jboss-cvs-commits
mailing list