[jboss-cvs] JBossAS SVN: r94976 - in projects/jboss-deployers/branches/vfs3/deployers-vfs/src: test/java/org/jboss/test/deployers/vfs/classloader and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Oct 15 14:02:48 EDT 2009
Author: david.lloyd at jboss.com
Date: 2009-10-15 14:02:48 -0400 (Thu, 15 Oct 2009)
New Revision: 94976
Removed:
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/InMemoryClassesDeployer.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/test/InMemoryClasesUnitTestCase.java
Modified:
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/VFSDeploymentClassLoaderPolicyModule.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/ClassLoaderTestSuite.java
Log:
Start removing special handling of in-memory stuff
Deleted: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/InMemoryClassesDeployer.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/InMemoryClassesDeployer.java 2009-10-15 17:59:45 UTC (rev 94975)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/InMemoryClassesDeployer.java 2009-10-15 18:02:48 UTC (rev 94976)
@@ -1,128 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, 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 org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.DeploymentStages;
-import org.jboss.deployers.vfs.spi.deployer.AbstractVFSRealDeployer;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.util.id.GUID;
-import org.jboss.vfs.VirtualFile;
-
-/**
- * TempURLDeployer.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @author <a href="ales.justin at jboss.com">Ales Justin</a>
- * @version $Revision: 1.1 $
- */
-public class InMemoryClassesDeployer extends AbstractVFSRealDeployer
-{
- /** The name of the dynamic class root */
- public static final String DYNAMIC_CLASS_URL_KEY = "DYNAMIC_CLASS_URL_KEY";
-
- /** The name of the dynamic class root */
- public static final String DYNAMIC_CLASS_KEY = "DYNAMIC_CLASS_KEY";
-
- /** The host name creator */
- private HostNameCreator hostNameCreator;
-
- /**
- * Create a new TempURLDeployer.
- */
- public InMemoryClassesDeployer()
- {
- // Make it run before the classloader describe deployer
- setStage(DeploymentStages.DESCRIBE);
- setOutput(ClassLoadingMetaData.class);
- setTopLevelOnly(true);
- }
-
- /**
- * Create host name.
- *
- * @param unit the deployment unit
- * @return the host name
- */
- protected String createHost(VFSDeploymentUnit unit)
- {
- return (hostNameCreator != null) ? hostNameCreator.createHostName(unit) : GUID.asString();
- }
-
- @Override
- public void deploy(VFSDeploymentUnit unit) throws DeploymentException
- {
- try
- {
- URL dynamicClassRoot = new URL("vfsmemory", createHost(unit), "");
- VirtualFile classes = MemoryFileFactory.createRoot(dynamicClassRoot).getRoot();
- unit.addAttachment(DYNAMIC_CLASS_URL_KEY, dynamicClassRoot);
- unit.addAttachment(DYNAMIC_CLASS_KEY, classes);
- unit.prependClassPath(classes);
- log.debug("Dynamic class root for " + unit.getName() + " is " + dynamicClassRoot);
- }
- catch (Exception e)
- {
- throw new DeploymentException("Error creating dynamic class root", e);
- }
- }
-
- @Override
- public void undeploy(VFSDeploymentUnit unit)
- {
- log.debug("Removing dynamic class root for " + unit.getName());
- try
- {
- VirtualFile classes = unit.removeAttachment(DYNAMIC_CLASS_KEY, VirtualFile.class);
- if (classes != null)
- {
- unit.removeClassPath(classes);
- }
- }
- finally
- {
- try
- {
- URL root = unit.removeAttachment(DYNAMIC_CLASS_URL_KEY, URL.class);
- if (root != null)
- MemoryFileFactory.deleteRoot(root);
- }
- catch (Exception e)
- {
- log.warn("Error deleting dynamic class root for " + unit.getName(), e);
- }
- }
- }
-
- /**
- * Set host name creator.
- *
- * @param hostNameCreator the host name creator
- */
- public void setHostNameCreator(HostNameCreator hostNameCreator)
- {
- this.hostNameCreator = hostNameCreator;
- }
-}
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/VFSDeploymentClassLoaderPolicyModule.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/VFSDeploymentClassLoaderPolicyModule.java 2009-10-15 17:59:45 UTC (rev 94975)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/VFSDeploymentClassLoaderPolicyModule.java 2009-10-15 18:02:48 UTC (rev 94976)
@@ -142,7 +142,7 @@
@Override
public URL getDynamicClassRoot()
{
- return getDeploymentUnit().getAttachment(InMemoryClassesDeployer.DYNAMIC_CLASS_URL_KEY, URL.class);
+ return getDeploymentUnit().getAttachment("DYNAMIC_CLASS_URL_KEY", URL.class);
}
@Override
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/ClassLoaderTestSuite.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/ClassLoaderTestSuite.java 2009-10-15 17:59:45 UTC (rev 94975)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/ClassLoaderTestSuite.java 2009-10-15 18:02:48 UTC (rev 94976)
@@ -24,7 +24,6 @@
import org.jboss.test.deployers.vfs.classloader.test.BootstrapDeployersSmokeTestUnitTestCase;
import org.jboss.test.deployers.vfs.classloader.test.DeploymentDependsOnDeploymentClassLoaderUnitTestCase;
import org.jboss.test.deployers.vfs.classloader.test.DeploymentDependsOnManualClassLoaderUnitTestCase;
-import org.jboss.test.deployers.vfs.classloader.test.InMemoryClasesUnitTestCase;
import org.jboss.test.deployers.vfs.classloader.test.ManagedObjectClassLoadingParserUnitTestCase;
import org.jboss.test.deployers.vfs.classloader.test.ManifestClassLoaderUnitTestCase;
import org.jboss.test.deployers.vfs.classloader.test.ManualDependsOnDeploymentClassLoaderUnitTestCase;
@@ -60,7 +59,6 @@
suite.addTest(BootstrapDeployersSmokeTestUnitTestCase.suite());
suite.addTest(VFSClassLoaderDependenciesUnitTestCase.suite());
suite.addTest(VFSUndeployOrderClassLoaderUnitTestCase.suite());
- suite.addTest(InMemoryClasesUnitTestCase.suite());
suite.addTest(DeploymentDependsOnManualClassLoaderUnitTestCase.suite());
suite.addTest(ManualDependsOnDeploymentClassLoaderUnitTestCase.suite());
suite.addTest(DeploymentDependsOnDeploymentClassLoaderUnitTestCase.suite());
Deleted: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/test/InMemoryClasesUnitTestCase.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/test/InMemoryClasesUnitTestCase.java 2009-10-15 17:59:45 UTC (rev 94975)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/test/InMemoryClasesUnitTestCase.java 2009-10-15 18:02:48 UTC (rev 94976)
@@ -1,153 +0,0 @@
-/*
-* 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.test.deployers.vfs.classloader.test;
-
-import java.net.URL;
-
-import junit.framework.Test;
-import org.jboss.classloader.plugins.jdk.AbstractJDKChecker;
-import org.jboss.classloader.plugins.system.DefaultClassLoaderSystem;
-import org.jboss.classloader.spi.ClassLoaderSystem;
-import org.jboss.classloader.spi.ParentPolicy;
-import org.jboss.classloading.spi.dependency.ClassLoading;
-import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
-import org.jboss.classloading.spi.version.Version;
-import org.jboss.deployers.client.spi.DeployerClient;
-import org.jboss.deployers.client.spi.Deployment;
-import org.jboss.deployers.spi.deployer.Deployer;
-import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
-import org.jboss.deployers.vfs.plugins.classloader.InMemoryClassesDeployer;
-import org.jboss.deployers.vfs.plugins.classloader.VFSClassLoaderClassPathDeployer;
-import org.jboss.deployers.vfs.plugins.classloader.VFSClassLoaderDescribeDeployer;
-import org.jboss.deployers.vfs.plugins.classloader.DeploymentHostNameCreator;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.test.deployers.vfs.classloader.support.TestLevelClassLoaderSystemDeployer;
-import org.jboss.test.deployers.vfs.classloader.support.a.A;
-import org.jboss.vfs.MemoryFileFactory;
-import org.jboss.vfs.VirtualFile;
-
-/**
- * InMemoryClasesUnitTestCase.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @author <a href="ales.justin at jboss.com">Ales Justin</a>
- * @version $Revision: 1.1 $
- */
-public class InMemoryClasesUnitTestCase extends VFSClassLoaderDependenciesTest
-{
- private InMemoryClassesDeployer inMemoryClassesDeployer = new InMemoryClassesDeployer();
-
- public InMemoryClasesUnitTestCase(String name)
- {
- super(name);
- }
-
- public static Test suite()
- {
- return suite(InMemoryClasesUnitTestCase.class);
- }
-
- public void testInMemory() throws Exception
- {
- DeployerClient mainDeployer = getMainDeployer();
- MainDeployerStructure main = (MainDeployerStructure) mainDeployer;
-
- Version v1 = Version.parseVersion("1");
-
- Deployment ad = createDeployment("A");
- ClassLoadingMetaData clmd = addClassLoadingMetaData(ad, v1, true, A.class);
- clmd.setBlackListable(false);
- assertDeploy(mainDeployer, ad);
-
- VFSDeploymentUnit unit = (VFSDeploymentUnit) main.getDeploymentUnit("A");
- VirtualFile file = unit.getAttachment(InMemoryClassesDeployer.DYNAMIC_CLASS_KEY, VirtualFile.class);
- assertNotNull(file);
- assertTrue("dynamic classes should be in the classpath", unit.getClassPath().contains(file));
-
- URL root = unit.getAttachment(InMemoryClassesDeployer.DYNAMIC_CLASS_URL_KEY, URL.class);
- assertNotNull(root);
-
- String aPackage = A.class.getPackage().getName();
- aPackage = aPackage.replace(".", "/");
- String resourceName = aPackage + "/TestInMemory";
- URL testResource = new URL(root, resourceName);
- ClassLoader cl = unit.getClassLoader();
- assertNull(cl.getResource(resourceName));
-
- byte[] bytes = new byte[0];
- MemoryFileFactory.putFile(testResource, bytes);
- URL resource = cl.getResource(resourceName);
- assertNotNull(resource);
- // dunno why direct URL equals fails?
- assertEquals(testResource.toExternalForm(), resource.toExternalForm());
-
- mainDeployer.undeploy(ad);
- mainDeployer.checkComplete();
- assertFalse("dynamic classes should NOT be in the classpath", unit.getClassPath().contains(file));
- }
-
- public void testHostNameCreator() throws Exception
- {
- DeployerClient mainDeployer = getMainDeployer();
- MainDeployerStructure main = (MainDeployerStructure) mainDeployer;
-
- Deployment ad = createDeployment("A");
- Version v1 = Version.parseVersion("1");
- ClassLoadingMetaData clmd = addClassLoadingMetaData(ad, v1, true, A.class);
- clmd.setBlackListable(false);
-
- inMemoryClassesDeployer.setHostNameCreator(new DeploymentHostNameCreator());
- try
- {
- assertDeploy(mainDeployer, ad);
-
- VFSDeploymentUnit unit = (VFSDeploymentUnit) main.getDeploymentUnit("A");
- URL root = unit.getAttachment(InMemoryClassesDeployer.DYNAMIC_CLASS_URL_KEY, URL.class);
- assertNotNull(root);
- assertEquals("vfsmemory://in-memory-test-classes", root.toExternalForm());
- }
- finally
- {
- inMemoryClassesDeployer.setHostNameCreator(null);
- }
- }
-
- protected DeployerClient getMainDeployer()
- {
- AbstractJDKChecker.getExcluded().add(VFSClassLoaderDependenciesTest.class);
-
- ClassLoading classLoading = new ClassLoading();
- ClassLoaderSystem system = new DefaultClassLoaderSystem();
- system.getDefaultDomain().setParentPolicy(ParentPolicy.BEFORE_BUT_JAVA_ONLY);
-
- deployer1 = new VFSClassLoaderDescribeDeployer();
- deployer1.setClassLoading(classLoading);
-
- deployer2 = new TestLevelClassLoaderSystemDeployer();
- deployer2.setClassLoading(classLoading);
- deployer2.setSystem(system);
-
- Deployer deployer4 = new VFSClassLoaderClassPathDeployer();
-
- return createMainDeployer(deployer1, deployer2, inMemoryClassesDeployer, deployer4);
- }
-}
More information about the jboss-cvs-commits
mailing list