[jboss-cvs] JBossAS SVN: r97735 - in projects/jboss-classpool/trunk/jbosscl: src and 58 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Dec 11 08:48:29 EST 2009
Author: flavia.rainone at jboss.com
Date: 2009-12-11 08:48:25 -0500 (Fri, 11 Dec 2009)
New Revision: 97735
Added:
projects/jboss-classpool/trunk/jbosscl/src/
projects/jboss-classpool/trunk/jbosscl/src/main/
projects/jboss-classpool/trunk/jbosscl/src/main/java/
projects/jboss-classpool/trunk/jbosscl/src/main/java/org/
projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/
projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/
projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/
projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/
projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/DomainRegistry.java
projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBoss5ClassPool.java
projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBoss5ClassPoolFactory.java
projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClClassPoolDomain.java
projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClClassPoolToClassPoolDomainAdapter.java
projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClClassPoolToClassPoolDomainAdaptorFactory.java
projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClDelegatingClassPool.java
projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClDelegatingClassPoolFactory.java
projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClDelegatingClassPoolRepository.java
projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClParentDelegationStrategy.java
projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/RegisterModuleCallback.java
projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/ScopedJBoss5ClassPool.java
projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/SecurityActions.java
projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/ToClassInvoker.java
projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/ToClassInvokerPoolReference.java
projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/VFSClassLoaderDomainRegistry.java
projects/jboss-classpool/trunk/jbosscl/src/main/resources/
projects/jboss-classpool/trunk/jbosscl/src/main/resources/jbossorg-eula.txt
projects/jboss-classpool/trunk/jbosscl/src/test/
projects/jboss-classpool/trunk/jbosscl/src/test/java/
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/JBossClClassPoolFullTestSuite.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/JBossClClassPoolTestSuite.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/JBossClClassSanityTestSuite.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/CLDeploymentBuilder.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/DomainRegistry.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/FilteredClassPool.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/JBossCLFactory.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/LoaderRegistry.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/NoMatchClassFilter.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/NoSuchClassLoaderException.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/SupportArchives.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/SupportClasses.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/TestVFSClassLoaderFactory.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/TestVFSClassLoaderPolicyModule.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/a/
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/a/A.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/b/
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/b/B.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/c/
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/c/C.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/crm/
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/crm/CrmFacade.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/d/
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/d/D.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/ejb/
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/ejb/BusinessInterface.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/ejb/MySLSBean.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/ext/
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/ext/External.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/jar/
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/jar/PlainJavaBean.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/jsf/
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/jsf/JsfBean.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/replacereferences/
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/replacereferences/Invoked.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/replacereferences/child/
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/replacereferences/child/Child.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/replacereferences/child/ChildCaller.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/replacereferences/parent/
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/replacereferences/parent/Parent.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/replacereferences/parent/ParentCaller.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/service/
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/service/SomeMBean.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/tif/
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/tif/TIFTester.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/ui/
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/ui/UIBean.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/util/
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/util/SomeUtil.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/web/
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/web/AnyServlet.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ArchiveClassPoolTestCase.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ArchiveSanityTestCase.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ArchiveTest.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/CtClassCreationTestCase.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/DependencyTest.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/HierarchicalDomainClassPoolTestCase.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/HierarchicalDomainSanityTestCase.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/HierarchicalDomainTest.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/HierarchicalParentLoaderClassPoolTestCase.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/HierarchicalParentLoaderSanityTestCase.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/HierarchicalParentLoaderTest.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/JBossClClassPoolTest.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/JBossClClassPoolTestDelegate.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ModuleDependencyClassPoolTestCase.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ModuleDependencySanityTestCase.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ModuleDependencyTest.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/PackageDependencyClassPoolTestCase.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/PackageDependencySanityTestCase.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/PackageDependencyTest.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportModuleClassPoolTestCase.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportModuleSanityTestCase.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportModuleTest.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportPackageClassPoolTestCase.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportPackageSanityTestCase.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportPackageTest.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportTest.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReplaceReferencesClassPoolTestCase.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/RepositoryClassPoolTestCase.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/RepositorySanityTestCase.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/RepositoryTest.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/UsesPackageClassPoolTestCase.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/UsesPackageSanityTestCase.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/UsesPackageTest.java
projects/jboss-classpool/trunk/jbosscl/src/test/resources/
projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/
projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/ear/
projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/ear/META-INF/
projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/ear/META-INF/application.properties
projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/ear2war/
projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/ear2war/META-INF/
projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/ear2war/META-INF/application.properties
projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/earutil/
projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/earutil/META-INF/
projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/earutil/META-INF/application.properties
projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/ejb-jar/
projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/ejb-jar/META-INF/
projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/ejb-jar/META-INF/ejb-jar.xml
projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/jarinear/
projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/jarinear/META-INF/
projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/jarinear/META-INF/application.properties
projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/sar/
projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/sar/META-INF/
projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/sar/META-INF/jboss-service.xml
projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/war/
projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/war/WEB-INF/
projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/war/WEB-INF/web.xml
projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/warinear/
projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/warinear/META-INF/
projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/warinear/META-INF/application.properties
projects/jboss-classpool/trunk/jbosscl/src/test/resources/log4j.xml
projects/jboss-classpool/trunk/jbosscl/src/test/resources/org/
projects/jboss-classpool/trunk/jbosscl/src/test/resources/org/jboss/
projects/jboss-classpool/trunk/jbosscl/src/test/resources/org/jboss/test/
projects/jboss-classpool/trunk/jbosscl/src/test/resources/org/jboss/test/classpool/
projects/jboss-classpool/trunk/jbosscl/src/test/resources/org/jboss/test/classpool/jbosscl/
projects/jboss-classpool/trunk/jbosscl/src/test/resources/org/jboss/test/classpool/jbosscl/Common.xml
Log:
[JBREFLECT-75] Src dir of classpool-jbosscl module
Added: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/DomainRegistry.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/DomainRegistry.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/DomainRegistry.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,51 @@
+package org.jboss.classpool.plugins.jbosscl;
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.
+*/
+
+
+import org.jboss.classloader.spi.ClassLoaderDomain;
+import org.jboss.classloader.spi.ClassLoaderSystem;
+import org.jboss.classloading.spi.dependency.Module;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public interface DomainRegistry
+{
+ ClassLoaderSystem getSystem();
+
+ ClassLoaderDomain getDefaultDomain();
+
+ boolean initMapsForModule(Module module);
+
+ void cleanupModule(Module module);
+
+ ClassLoaderDomain getClassLoaderDomainForLoader(ClassLoader cl);
+
+ ClassLoader getParentUnitLoader(ClassLoader loader);
+
+ Module getModule(ClassLoader loader);
+
+ ClassLoader getClassLoader(Module module);
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/DomainRegistry.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBoss5ClassPool.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBoss5ClassPool.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBoss5ClassPool.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,76 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.classpool.plugins.jbosscl;
+
+import java.net.URL;
+import java.security.ProtectionDomain;
+
+import javassist.CannotCompileException;
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.scopedpool.ScopedClassPoolRepository;
+
+import org.jboss.classpool.spi.AbstractClassPool;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+class JBoss5ClassPool extends AbstractClassPool implements ToClassInvokerPoolReference
+{
+ protected ToClassInvoker toClassInvoker = null;
+
+ boolean closed;
+
+ protected JBoss5ClassPool(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository, URL tmpURL)
+ {
+ super(cl, src, repository);
+ toClassInvoker = new ToClassInvoker(tmpURL);
+ }
+
+ protected JBoss5ClassPool(ClassPool src, ScopedClassPoolRepository repository)
+ {
+ super(src, repository);
+ }
+
+ public boolean isUnloadedClassLoader()
+ {
+ return closed;
+ }
+
+ public void close()
+ {
+ closed = true;
+ super.close();
+ }
+
+ public Class<?> toClass(CtClass cc, ClassLoader loader, ProtectionDomain domain) throws CannotCompileException
+ {
+ return toClassInvoker.toClass(this, cc, getResourceName(cc.getName()), loader, domain);
+ }
+
+ public Class<?> superPoolToClass(CtClass cc, ClassLoader loader, ProtectionDomain domain) throws CannotCompileException
+ {
+ return super.toClass(cc, loader, domain);
+ }
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBoss5ClassPool.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBoss5ClassPoolFactory.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBoss5ClassPoolFactory.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBoss5ClassPoolFactory.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,102 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.classpool.plugins.jbosscl;
+
+import java.net.URL;
+
+import javassist.ClassPool;
+import javassist.scopedpool.ScopedClassPoolFactory;
+import javassist.scopedpool.ScopedClassPoolRepository;
+
+import org.jboss.classloader.spi.ClassLoaderDomain;
+import org.jboss.classloader.spi.ClassLoaderSystem;
+import org.jboss.classloading.spi.RealClassLoader;
+import org.jboss.classloading.spi.dependency.Module;
+import org.jboss.classpool.plugins.AbstractJBossClassPoolFactory;
+import org.jboss.classpool.spi.AbstractClassPool;
+import org.jboss.classpool.spi.ClassPoolRepository;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author adrian at jboss.org
+ * @version $Revision$
+ **/
+ at Deprecated
+public class JBoss5ClassPoolFactory extends AbstractJBossClassPoolFactory implements ScopedClassPoolFactory
+{
+ private DomainRegistry registry;
+
+ public JBoss5ClassPoolFactory(DomainRegistry registry)
+ {
+ this.registry = registry;
+ }
+
+ public AbstractClassPool create(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository)
+ {
+ ClassPool parent = getCreateParentClassPools(cl, src, repository);
+
+ AbstractClassPool pool = null;
+
+ if (cl instanceof RealClassLoader)
+ {
+ Module module = registry.getModule(cl);
+ if (module != null && module.getDeterminedParentDomainName() != null)
+ {
+ //It is scoped
+ ClassLoaderSystem sys = registry.getSystem();
+ ClassLoaderDomain domain = sys.getDomain(module.getDeterminedDomainName());
+ boolean parentFirst = module.isJ2seClassLoadingCompliance();
+ ClassPool parentDomainPool = getParentUnitClassPool(cl);
+ pool = new ScopedJBoss5ClassPool(cl, parent, parentDomainPool, repository, getTempURL(module), parentFirst, domain);
+ }
+ else
+ {
+ pool = new JBoss5ClassPool(cl, parent, repository, getTempURL(module));
+ }
+ }
+
+ if (pool == null)
+ {
+ pool = new AbstractClassPool(cl, parent, repository);
+ }
+ log.debug("Created pool " + pool + " for loader " + cl);
+
+ return pool;
+ }
+
+ private ClassPool getParentUnitClassPool(ClassLoader cl)
+ {
+ ClassLoader parent = registry.getParentUnitLoader(cl);
+ return ClassPoolRepository.getInstance().registerClassLoader(parent);
+ }
+
+
+ private URL getTempURL(Module module)
+ {
+ if (module == null)
+ return null;
+
+ return module.getDynamicClassRoot();
+ }
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBoss5ClassPoolFactory.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClClassPoolDomain.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClClassPoolDomain.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClClassPoolDomain.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,266 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.classpool.plugins.jbosscl;
+
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.NotFoundException;
+
+import org.jboss.classloader.spi.ParentPolicy;
+import org.jboss.classloading.spi.dependency.Module;
+import org.jboss.classpool.base.BaseClassPool;
+import org.jboss.classpool.base.BaseClassPoolDomain;
+import org.jboss.classpool.domain.ClassPoolDomain;
+import org.jboss.classpool.helpers.ClassLoaderUtils;
+import org.jboss.classpool.plugins.DelegatingClassPool;
+import org.jboss.classpool.spi.ClassPoolRepository;
+
+/**
+ * JBoss Cl class pool domain.
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+class JBossClClassPoolDomain extends BaseClassPoolDomain
+{
+ private Map<String, Set<DelegatingClassPool>> poolsByPackage = new HashMap<String, Set<DelegatingClassPool>>();
+ private DomainRegistry registry;
+
+ public JBossClClassPoolDomain(String domainName, ParentPolicy parentPolicy, DomainRegistry registry)
+ {
+ super(domainName,
+ new JBossClParentDelegationStrategy(parentPolicy,
+ JBossClClassPoolToClassPoolDomainAdaptorFactory.getInstance())
+ );
+ this.registry = registry;
+ }
+
+ public JBossClClassPoolDomain(String domainName, ClassPoolDomain parent, ParentPolicy parentPolicy, DomainRegistry registry)
+ {
+ super(domainName,
+ new JBossClParentDelegationStrategy(
+ parent,
+ parentPolicy,
+ JBossClClassPoolToClassPoolDomainAdaptorFactory.getInstance())
+ );
+ this.registry = registry;
+ }
+
+ public JBossClClassPoolDomain(String domainName, ClassPool parent, ParentPolicy parentPolicy, DomainRegistry registry)
+ {
+ super(domainName,
+ new JBossClParentDelegationStrategy(
+ parent,
+ parentPolicy,
+ JBossClClassPoolToClassPoolDomainAdaptorFactory.getInstance())
+ );
+ this.registry = registry;
+ }
+
+ synchronized void setupPoolsByPackage(DelegatingClassPool pool)
+ {
+ if (pool instanceof JBossClDelegatingClassPool == false)
+ {
+ throw new IllegalStateException("Not an instance of JBossClDelegatingClassPool: " + pool.getClass().getName());
+ }
+
+ Module module = getModuleForPool(pool);
+ boolean trace = logger.isTraceEnabled();
+
+ for (String pkg : module.getPackageNames())
+ {
+ Set<DelegatingClassPool> pools = poolsByPackage.get(pkg);
+ if (pools == null)
+ {
+ pools = new LinkedHashSet<DelegatingClassPool>();
+ poolsByPackage.put(pkg, pools);
+ }
+ pools.add(pool);
+ if (trace) logger.trace(this + " adding package " + pkg + " for pool " + pool);
+ }
+ }
+
+ @Override
+ public synchronized void removeClassPool(DelegatingClassPool pool)
+ {
+ super.removeClassPool(pool);
+
+ Module module = getModuleForPool(pool);
+ boolean trace = logger.isTraceEnabled();
+
+ for (String pkg : module.getPackageNames())
+ {
+ Set<DelegatingClassPool> pools = poolsByPackage.get(pkg);
+ if (pools != null)
+ {
+ pools.remove(pool);
+ if (pools.size() == 0)
+ {
+ poolsByPackage.remove(pkg);
+ if (trace) logger.trace(this + " removing package " + pkg + " for pool " + pool);
+ }
+ }
+ }
+ }
+
+ @Override
+ public CtClass getCachedOrCreate(DelegatingClassPool initiatingPool, String classname, String resourceName, boolean create, boolean trace)
+ {
+ if (trace) logger.trace(this + " looking for " + classname);
+
+ CtClass clazz = getCheckPrimitive(classname);
+ if (clazz != null)
+ {
+ if (trace) logger.trace(this + " isPrimitive " + classname);
+ }
+ else
+ {
+ Module module = getModuleForPool(initiatingPool);
+ if (module != null && module.isImportAll())
+ {
+ //Use the old "big ball of mud" model
+ if (trace) logger.trace(this + " isImportAll");
+ return super.getCachedOrCreate(initiatingPool, classname, resourceName, create, trace);
+ }
+
+ //Attempt OSGi style loading
+ if (isParentBefore(classname))
+ {
+ if (trace) logger.trace(this + " checking parent first for " + classname);
+ clazz = getCachedOrCreateFromParent(null, classname, resourceName, create, trace);
+ }
+
+ //Check imports first
+ if (clazz == null && module != null)
+ {
+ if (trace) logger.trace(this + " checking imports for " + classname);
+ clazz = getCtClassFromModule(module, classname, trace);
+ }
+
+ //Try to check the initiating pool itself
+ if (clazz == null && initiatingPool != null)
+ {
+ if (trace) logger.trace(this + " checking pool " + initiatingPool + " locally for " + classname);
+ clazz = initiatingPool.loadLocally(classname, resourceName, create);
+ }
+
+ if (clazz == null && isParentAfter(classname))
+ {
+ if (trace) logger.trace(this + " checking parent last for " + classname);
+ clazz = getCachedOrCreateFromParent(null, classname, resourceName, create, trace);
+ }
+ }
+ if (trace) logger.trace(this + " found " + classname + " in " + (clazz == null ? "null" : clazz.getClassPool()));
+ return clazz;
+ }
+
+ private CtClass getCheckPrimitive(String classname)
+ {
+ if (ClassLoaderUtils.isPrimitiveType(classname))
+ {
+ try
+ {
+ return ClassPool.getDefault().get(classname);
+ }
+ catch(NotFoundException e)
+ {
+ throw new RuntimeException(classname + " should have been a primitive", e);
+ }
+ }
+ return null;
+ }
+
+ private Module getModuleForPool(DelegatingClassPool pool)
+ {
+ if (pool == null)
+ {
+ return null;
+ }
+ Module module = ((JBossClDelegatingClassPool)pool).getModule();
+ if (logger.isTraceEnabled()) logger.trace(this + " got module " + module + " for " + pool);
+ return module;
+ }
+
+ @Override
+ protected List<DelegatingClassPool> getPoolsForClassName(String classname)
+ {
+ String packageName = ClassLoaderUtils.getPackageName(classname);
+ Set<DelegatingClassPool> poolSet = poolsByPackage.get(packageName);
+ return (poolSet == null) ? Collections.<DelegatingClassPool>emptyList() : new ArrayList<DelegatingClassPool>(poolSet);
+ }
+
+ private CtClass getCtClassFromModule(final Module module, final String classname, boolean trace)
+ {
+ Module found = null;
+ try
+ {
+ found = AccessController.doPrivileged(new PrivilegedExceptionAction<Module>()
+ {
+
+ public Module run() throws Exception
+ {
+ return module.getModuleForClass(ClassLoaderUtils.stripArrayFromClassName(classname));
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ if (e.getCause() instanceof ClassNotFoundException == false)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ if (trace) logger.trace(this + " module for " + classname + " " + found);
+
+ if (found == null || found == module)
+ {
+ return null;
+ }
+ ClassLoader foundLoader = registry.getClassLoader(found);
+ ClassPool pool = ClassPoolRepository.getInstance().registerClassLoader(foundLoader);
+ try
+ {
+ if (pool instanceof BaseClassPool)
+ {
+ return getCachedOrCreateFromPool((BaseClassPool)pool, classname, true, trace);
+ }
+ return pool.get(classname);
+ }
+ catch(NotFoundException ignore)
+ {
+ }
+ return null;
+ }
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClClassPoolDomain.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClClassPoolToClassPoolDomainAdapter.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClClassPoolToClassPoolDomainAdapter.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClClassPoolToClassPoolDomainAdapter.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,54 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.classpool.plugins.jbosscl;
+
+import javassist.ClassPool;
+
+import org.jboss.classloader.spi.base.BaseClassLoaderDomain;
+import org.jboss.classpool.domain.ClassPoolToClassPoolDomainAdapter;
+import org.jboss.classpool.spi.ClassPoolRepository;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+class JBossClClassPoolToClassPoolDomainAdapter extends ClassPoolToClassPoolDomainAdapter
+{
+ public JBossClClassPoolToClassPoolDomainAdapter()
+ {
+ super();
+ }
+
+ public JBossClClassPoolToClassPoolDomainAdapter(ClassPool classPool)
+ {
+ super(classPool);
+ }
+
+ // TODO JBREFLECT-65 FIXME this methd shouldn't be returning always the app classloader
+ @Override
+ public ClassPool initialiseParentClassLoader()
+ {
+ return ClassPoolRepository.getInstance().registerClassLoader(BaseClassLoaderDomain.class.getClassLoader());
+ }
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClClassPoolToClassPoolDomainAdapter.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClClassPoolToClassPoolDomainAdaptorFactory.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClClassPoolToClassPoolDomainAdaptorFactory.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClClassPoolToClassPoolDomainAdaptorFactory.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,59 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.classpool.plugins.jbosscl;
+
+import javassist.ClassPool;
+
+import org.jboss.classpool.domain.ClassPoolToClassPoolDomainAdapter;
+import org.jboss.classpool.domain.ClassPoolToClassPoolDomainAdaptorFactory;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+class JBossClClassPoolToClassPoolDomainAdaptorFactory implements ClassPoolToClassPoolDomainAdaptorFactory
+{
+ private static final JBossClClassPoolToClassPoolDomainAdaptorFactory INSTANCE = new JBossClClassPoolToClassPoolDomainAdaptorFactory();
+
+ private JBossClClassPoolToClassPoolDomainAdaptorFactory()
+ {
+
+ }
+
+ public static ClassPoolToClassPoolDomainAdaptorFactory getInstance()
+ {
+ return INSTANCE;
+ }
+
+ public ClassPoolToClassPoolDomainAdapter createAdaptor()
+ {
+ return new JBossClClassPoolToClassPoolDomainAdapter();
+ }
+
+ public ClassPoolToClassPoolDomainAdapter createAdaptor(ClassPool classPool)
+ {
+ return new JBossClClassPoolToClassPoolDomainAdapter(classPool);
+ }
+
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClClassPoolToClassPoolDomainAdaptorFactory.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClDelegatingClassPool.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClDelegatingClassPool.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClDelegatingClassPool.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,95 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.classpool.plugins.jbosscl;
+
+import java.lang.ref.WeakReference;
+import java.security.ProtectionDomain;
+
+import javassist.CannotCompileException;
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.scopedpool.ScopedClassPoolRepository;
+
+import org.jboss.classloading.spi.dependency.Module;
+import org.jboss.classpool.domain.ClassPoolDomain;
+import org.jboss.classpool.plugins.DelegatingClassPool;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+class JBossClDelegatingClassPool extends DelegatingClassPool implements ToClassInvokerPoolReference
+{
+ private WeakReference<Module> module;
+ private RegisterModuleCallback callback;
+
+ ToClassInvoker toClassInvoker;
+
+ protected JBossClDelegatingClassPool(ClassPoolDomain domain, ClassLoader cl, ClassPool parent,
+ ScopedClassPoolRepository repository, Module module, RegisterModuleCallback callback)
+ {
+ super(domain, cl, parent, repository);
+ if (logger.isTraceEnabled())
+ {
+ logger.trace("ClassPool being created: " + cl + " - " + this);
+ }
+ if (module == null)
+ {
+ throw new IllegalStateException("Null Module for loader " + cl);
+ }
+ if (domain instanceof JBossClClassPoolDomain == false)
+ {
+ throw new IllegalArgumentException("Domain was not instance of JBossClClassPoolDomain: " + domain.getClass().getName());
+ }
+ this.module = new WeakReference<Module>(module);
+ this.callback = callback;
+ toClassInvoker = new ToClassInvoker(module == null ? null : module.getDynamicClassRoot());
+ if (logger.isTraceEnabled()) logger.trace(this + " module");
+ ((JBossClClassPoolDomain)domain).setupPoolsByPackage(this);
+ }
+
+ Module getModule()
+ {
+ if (module != null)
+ {
+ return module.get();
+ }
+ return null;
+ }
+
+ public Class<?> toClass(CtClass cc, ClassLoader loader, ProtectionDomain domain) throws CannotCompileException
+ {
+ return toClassInvoker.toClass(this, cc, getResourceName(cc.getName()), loader, domain);
+ }
+
+ public Class<?> superPoolToClass(CtClass cc, ClassLoader loader, ProtectionDomain domain) throws CannotCompileException
+ {
+ return super.toClass(cc, loader, domain);
+ }
+
+ @Override
+ public void close()
+ {
+ super.close();
+ }
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClDelegatingClassPool.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClDelegatingClassPoolFactory.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClDelegatingClassPoolFactory.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClDelegatingClassPoolFactory.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,220 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.classpool.plugins.jbosscl;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Collection;
+import java.util.HashSet;
+
+import javassist.ClassPool;
+import javassist.scopedpool.ScopedClassPoolFactory;
+import javassist.scopedpool.ScopedClassPoolRepository;
+
+import org.jboss.classloader.spi.ClassLoaderDomain;
+import org.jboss.classloader.spi.ClassLoaderSystem;
+import org.jboss.classloading.spi.RealClassLoader;
+import org.jboss.classloading.spi.dependency.ClassLoading;
+import org.jboss.classloading.spi.dependency.Module;
+import org.jboss.classpool.domain.ClassPoolDomain;
+import org.jboss.classpool.domain.ClassPoolDomainRegistry;
+import org.jboss.classpool.plugins.NonDelegatingClassPool;
+import org.jboss.classpool.plugins.temp.TempClassPoolFactory;
+import org.jboss.classpool.spi.AbstractClassPool;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class JBossClDelegatingClassPoolFactory extends TempClassPoolFactory implements ScopedClassPoolFactory
+{
+ private final DomainRegistry registry;
+
+ private final RegisterModuleCallback registerModuleCallback;
+
+ private Collection<ClassLoader> currentClassLoaders = new HashSet<ClassLoader>();
+
+ public JBossClDelegatingClassPoolFactory(DomainRegistry registry, RegisterModuleCallback registerModuleCallback)
+ {
+ this.registry = registry;
+ this.registerModuleCallback = registerModuleCallback;
+ }
+
+ public synchronized AbstractClassPool create(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository)
+ {
+ if (this.currentClassLoaders.contains(cl))
+ {
+ return null;
+ }
+ currentClassLoaders.add(cl);
+ try
+ {
+ ClassPool parent = getCreateParentClassPools(cl, src, repository);
+
+ if (cl instanceof RealClassLoader)
+ {
+ Module module = registry.getModule(cl);
+ if (module == null)
+ {
+ module = getModuleForClassLoader(cl);
+ }
+ registerModuleCallback.registerModule(module);
+ registerBootstrapLoaders(module, repository);
+ ClassPoolDomain domain = getDomain(module, cl, repository);
+ // this indicates that the domain corresponds to a cp that is being created
+ // to avoid duplicate class pools
+ if (domain == null)
+ {
+ return null;
+ }
+ return new JBossClDelegatingClassPool(domain, cl, parent, repository, module, registerModuleCallback);
+ }
+ if (parent == null)
+ {
+ parent = ClassPool.getDefault();
+ }
+ return new NonDelegatingClassPool(cl, parent, repository, true);
+ }
+ finally
+ {
+ this.currentClassLoaders.remove(cl);
+ }
+ }
+
+ private synchronized ClassPoolDomain getDomain(Module module, ClassLoader cl, ScopedClassPoolRepository repository)
+ {
+ ClassLoaderDomain domain = null;
+ ClassLoaderSystem sys = registry.getSystem();
+ if (module != null && module.getDeterminedParentDomainName() != null)
+ {
+ //It is scoped
+ domain = sys.getDomain(module.getDeterminedDomainName());
+ }
+
+ if (domain == null)
+ {
+ domain = registry.getDefaultDomain();
+ }
+
+ return getDomain(cl, domain, sys, repository);
+ }
+
+ private ClassPoolDomain getDomain(ClassLoader cl, ClassLoaderDomain domain,
+ ClassLoaderSystem sys, ScopedClassPoolRepository repository)
+ {
+ ClassPoolDomain poolDomain = ClassPoolDomainRegistry.getInstance().getDomain(domain);
+ if (poolDomain == null)
+ {
+ String parentDomainName = domain.getParentDomainName();
+ if (parentDomainName != null)
+ {
+ ClassLoaderDomain parentDomain = sys.getDomain(parentDomainName);
+ if (parentDomain == null)
+ {
+ throw new RuntimeException("No domain found, domain name: " + parentDomainName);
+ }
+ ClassPoolDomain parentPoolDomain = this.getDomain(null, parentDomain, sys, repository);
+ poolDomain = new JBossClClassPoolDomain(domain.getName(), parentPoolDomain, domain.getParentPolicy(), registry);
+ }
+ else
+ {
+ ClassLoader parentUnitLoader = registry.getParentUnitLoader(cl);
+ if (this.currentClassLoaders.contains(parentUnitLoader))
+ {
+ return null;
+ }
+ ClassPool parentUnitPool = parentUnitLoader == null? null: repository.registerClassLoader(parentUnitLoader);
+ if (parentUnitPool == null)
+ {
+ poolDomain = new JBossClClassPoolDomain(domain.getName(), domain.getParentPolicy(), registry);
+ }
+ else
+ {
+ poolDomain = new JBossClClassPoolDomain(domain.getName(), parentUnitPool, domain.getParentPolicy(), registry);
+ }
+ }
+ ClassPoolDomainRegistry.getInstance().addClassPoolDomain(domain, poolDomain);
+ }
+ return poolDomain;
+ }
+
+ @Override
+ protected ClassPool getCreateParentClassPools(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository)
+ {
+ ClassPool parent = super.getCreateParentClassPools(cl, src, repository);
+ if (parent == ClassPool.getDefault())
+ {
+ //In AS BaseClassLoader seems to normally have a null parent
+ return null;
+ }
+ return parent;
+ }
+
+ private void registerBootstrapLoaders(Module skip, ScopedClassPoolRepository repository)
+ {
+ Collection<Module> unregistered = registerModuleCallback.getUnregisteredModules();
+ if (unregistered.size() > 0)
+ {
+ for (Module module : unregistered)
+ {
+ if (module == skip)
+ {
+ continue;
+ }
+ ClassLoader loader = getClassLoaderForModule(module);
+ if (this.currentClassLoaders.contains(loader))
+ {
+ continue;
+ }
+ ClassPool classPool = repository.registerClassLoader(loader);
+ if (classPool == null)
+ {
+ repository.unregisterClassLoader(loader);
+ }
+ }
+ }
+ }
+
+ private ClassLoader getClassLoaderForModule(final Module module)
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+ {
+
+ public ClassLoader run()
+ {
+ return ClassLoading.getClassLoaderForModule(module);
+ }
+ });
+ }
+
+ private Module getModuleForClassLoader(final ClassLoader classLoader)
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<Module>()
+ {
+ public Module run()
+ {
+ return ClassLoading.getModuleForClassLoader(classLoader);
+ }
+ });
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClDelegatingClassPoolFactory.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClDelegatingClassPoolRepository.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClDelegatingClassPoolRepository.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClDelegatingClassPoolRepository.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,110 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.classpool.plugins.jbosscl;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Collections;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import javassist.ClassPool;
+import javassist.scopedpool.ScopedClassPool;
+
+import org.jboss.classloading.spi.dependency.ClassLoading;
+import org.jboss.classloading.spi.dependency.Module;
+import org.jboss.classpool.spi.ClassPoolRepository;
+import org.jboss.logging.Logger;
+
+/**
+ * Repository for JBossclDelegatingClassPools.
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.org">Flavia Rainone</a>
+ *
+ * @version $Revision$
+ */
+
+public class JBossClDelegatingClassPoolRepository extends ClassPoolRepository
+{
+ Logger logger = Logger.getLogger(this.getClass());
+
+ private final static JBossClDelegatingClassPoolRepository instance = new JBossClDelegatingClassPoolRepository();
+
+ /**
+ * Returns the singleton instance.
+ *
+ * @return the singleton repository instance
+ */
+ public static JBossClDelegatingClassPoolRepository getInstance()
+ {
+ return instance;
+ }
+
+ /** The registered modules */
+ protected Map<Module, ScopedClassPool> registeredModules =
+ Collections.synchronizedMap(new WeakHashMap<Module, ScopedClassPool>());
+
+ @Override
+ public synchronized ClassPool registerClassLoader(ClassLoader classLoader)
+ {
+ ScopedClassPool classPool = (ScopedClassPool) super.registerClassLoader(classLoader);
+ if (classPool == null)
+ {
+ delegate.unregisterClassLoader(classLoader);
+ }
+ else
+ {
+ Module module = getModuleForClassLoader(classLoader);
+ this.registeredModules.put(module, classPool);
+ }
+ return classPool;
+ }
+
+
+ public synchronized void unregisterClassLoader(ClassLoader classLoader, Module module)
+ {
+ ScopedClassPool classPool = registeredModules.remove(module);
+ if (classLoader == null)
+ {
+ if (classPool == null)
+ {
+ throw new IllegalStateException("Module " + module + " is not registered");
+ }
+ classPool.close();
+ }
+ else
+ {
+ unregisterClassLoader(classLoader);
+ }
+ }
+
+ private Module getModuleForClassLoader(final ClassLoader classLoader)
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<Module>()
+ {
+ public Module run()
+ {
+ return ClassLoading.getModuleForClassLoader(classLoader);
+ }
+ });
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClDelegatingClassPoolRepository.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClParentDelegationStrategy.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClParentDelegationStrategy.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClParentDelegationStrategy.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,88 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.classpool.plugins.jbosscl;
+
+import javassist.ClassPool;
+
+import org.jboss.classloader.spi.ParentPolicy;
+import org.jboss.classloader.spi.filter.ClassFilter;
+import org.jboss.classpool.base.AbstractParentDelegationStrategy;
+import org.jboss.classpool.domain.ClassPoolDomain;
+import org.jboss.classpool.domain.ClassPoolToClassPoolDomainAdaptorFactory;
+import org.jboss.classpool.helpers.ClassLoaderUtils;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+class JBossClParentDelegationStrategy extends AbstractParentDelegationStrategy
+{
+ ParentPolicy parentPolicy;
+
+ JBossClParentDelegationStrategy(ParentPolicy parentPolicy, ClassPoolToClassPoolDomainAdaptorFactory adaptorFactory)
+ {
+ super((ClassPoolDomain) null, adaptorFactory);
+ if (parentPolicy == null)
+ {
+ throw new IllegalStateException("Null parent policy");
+ }
+ this.parentPolicy = parentPolicy;
+ }
+
+ JBossClParentDelegationStrategy(ClassPoolDomain parent, ParentPolicy parentPolicy, ClassPoolToClassPoolDomainAdaptorFactory adaptorFactory)
+ {
+ super(parent, adaptorFactory);
+ if (parentPolicy == null)
+ {
+ throw new IllegalStateException("Null parent policy");
+ }
+ this.parentPolicy = parentPolicy;
+ }
+
+ JBossClParentDelegationStrategy(ClassPool parent, ParentPolicy parentPolicy, ClassPoolToClassPoolDomainAdaptorFactory adaptorFactory)
+ {
+ super(parent, adaptorFactory);
+ if (parentPolicy == null)
+ {
+ throw new IllegalStateException("Null parent policy");
+ }
+ this.parentPolicy = parentPolicy;
+ }
+
+ public boolean isParentAfter(String classname)
+ {
+ ClassFilter filter = parentPolicy.getAfterFilter();
+ boolean isParentAfter = filter.matchesClassName(ClassLoaderUtils.stripArrayFromClassName(classname));
+ if (logger.isTraceEnabled()) logger.trace(this + " " + getDomain() + " isParentAfter " + isParentAfter);
+ return isParentAfter;
+ }
+
+ public boolean isParentBefore(String classname)
+ {
+ ClassFilter filter = parentPolicy.getBeforeFilter();
+ boolean isParentBefore = filter.matchesClassName(ClassLoaderUtils.stripArrayFromClassName(classname));
+ if (logger.isTraceEnabled()) logger.trace(this + " " + getDomain() + " isParentBefore " + isParentBefore);
+ return isParentBefore;
+ }
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClParentDelegationStrategy.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/RegisterModuleCallback.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/RegisterModuleCallback.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/RegisterModuleCallback.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,94 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.classpool.plugins.jbosscl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.classloading.spi.dependency.Module;
+import org.jboss.classloading.spi.dependency.ModuleRegistry;
+import org.jboss.logging.Logger;
+
+/**
+ * Use with org.jboss.classpool.jbosscl.JBossClDelegatingClassPoolFactory
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class RegisterModuleCallback implements ModuleRegistry
+{
+ Logger logger = Logger.getLogger(this.getClass());
+
+ private Set<Module> registeredModules = new HashSet<Module>();
+ private Set<Module> unregisteredModules = new HashSet<Module>();
+ private DomainRegistry domainRegistry;
+
+ public RegisterModuleCallback(DomainRegistry domainRegistry)
+ {
+ this.domainRegistry = domainRegistry;
+ }
+
+ public synchronized void addModule(Module module)
+ {
+ if (logger.isTraceEnabled())
+ {
+ logger.trace("Adding module " + module);
+ }
+ unregisteredModules.add(module);
+ }
+
+ public synchronized void removeModule(Module module)
+ {
+
+ ClassLoader classLoader = domainRegistry.getClassLoader(module);
+ if (logger.isTraceEnabled())
+ {
+ logger.trace("Removing module " + module + " and class loader " + classLoader);
+ }
+ JBossClDelegatingClassPoolRepository.getInstance().unregisterClassLoader(classLoader, module);
+ domainRegistry.cleanupModule(module);
+ registeredModules.remove(module);
+ unregisteredModules.remove(module);
+ }
+
+ public synchronized void registerModule(Module module)
+ {
+ if (logger.isTraceEnabled())
+ {
+ logger.trace("Registering module " + module);
+ }
+
+ registeredModules.add(module);
+ unregisteredModules.remove(module);
+
+ domainRegistry.initMapsForModule(module);
+ }
+
+ public synchronized Collection<Module> getUnregisteredModules()
+ {
+ return new ArrayList<Module>(unregisteredModules);
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/RegisterModuleCallback.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/ScopedJBoss5ClassPool.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/ScopedJBoss5ClassPool.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/ScopedJBoss5ClassPool.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,400 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.classpool.plugins.jbosscl;
+
+import java.lang.ref.WeakReference;
+import java.net.URL;
+import java.util.ArrayList;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.NotFoundException;
+import javassist.scopedpool.ScopedClassPoolRepository;
+
+import org.jboss.classloader.spi.ClassLoaderDomain;
+import org.jboss.classloader.spi.Loader;
+import org.jboss.classloading.spi.RealClassLoader;
+import org.jboss.classpool.spi.AbstractClassPool;
+import org.jboss.classpool.spi.ClassPoolRepository;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class ScopedJBoss5ClassPool extends JBoss5ClassPool
+{
+ ThreadLocal<ClassPool> lastPool = new ThreadLocal<ClassPool>();
+ WeakReference<ClassLoaderDomain> domainRef;
+ /** The classpool representing the parent domain of this one */
+ ClassPool parentDomainPool;
+
+ public ScopedJBoss5ClassPool(ClassLoader cl, ClassPool src, ClassPool parentDomainPool, ScopedClassPoolRepository repository,
+ URL tmpURL, boolean parentFirst, ClassLoaderDomain domain)
+ {
+ super(cl, src, repository, tmpURL);
+ super.childFirstLookup = !parentFirst;
+ this.parentDomainPool = parentDomainPool;
+ this.domainRef = new WeakReference<ClassLoaderDomain>(domain);
+
+ logger.debug("Created new ScopedJBoss5ClasPool for " + cl + ", with parent: " + src + ", parentDomain: " + parentDomainPool + ", parentFirst: " + parentFirst);
+ }
+
+ private URL getResourceUrlForClass(String resourcename)
+ {
+ ClassLoaderDomain domain = domainRef.get();
+ return domain.getResource(resourcename);
+ }
+
+ private boolean isMine(URL myURL, String resourceName)
+ {
+ if (myURL == null)
+ {
+ return false;
+ }
+
+ ClassLoaderDomain domain = domainRef.get();
+ Loader parent = domain.getParent();
+ URL parentURL = parent.getResource(resourceName);
+
+ if (parentURL == null)
+ {
+ return true;
+ }
+
+ if (!myURL.equals(parentURL))
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+
+ @Override
+ protected synchronized CtClass get0(String classname, boolean useCache) throws NotFoundException
+ {
+ CtClass clazz = null;
+ if (useCache)
+ {
+ clazz = getCached(classname);
+ if (clazz != null)
+ return clazz;
+ }
+
+ if (!childFirstLookup)
+ {
+ if (parentDomainPool != null)
+ {
+ clazz = performGet(parentDomainPool, classname);
+ if (clazz != null)
+ {
+ return clazz;
+ }
+ }
+ if (parent != null)
+ {
+ clazz = performGet(parent, classname);
+ if (clazz != null)
+ {
+ return clazz;
+ }
+ }
+ }
+
+ clazz = createCtClass(classname, useCache);
+ if (clazz != null)
+ {
+ // clazz.getName() != classname if classname is "[L<name>;".
+ if (useCache)
+ cacheCtClass(clazz.getName(), clazz, false);
+
+ return clazz;
+ }
+
+ if (childFirstLookup)
+ {
+ if (parent != null)
+ {
+ clazz = performGet(parent, classname);
+ if (clazz != null)
+ {
+ return clazz;
+ }
+ }
+ if (parentDomainPool != null)
+ {
+ clazz = performGet(parentDomainPool, classname);
+ if (clazz != null)
+ {
+ return clazz;
+ }
+ }
+ }
+
+ return clazz;
+ }
+
+ private CtClass performGet(ClassPool pool, String classname)
+ {
+ try
+ {
+ // TODO check whether we should enable this optimization
+ //Want to avoid calling get() if possible since that creates NotFoundExceptions
+ //on misses which is expensive
+ /*if (pool instanceof AbstractClassPool)
+ {
+ return ((AbstractClassPool)pool).internalGet0(classname, true);
+ }
+ else
+ {*/
+ return pool.getCtClass(classname);
+ }
+ catch (NotFoundException e)
+ {
+ return null;
+ }
+ }
+
+
+ public CtClass getCached(String classname)
+ {
+ boolean trace = logger.isTraceEnabled();
+
+ if (trace)
+ {
+ logger.trace("getCached() " + classname);
+ }
+
+ if (classname == null)
+ {
+ if (trace)
+ {
+ logger.trace("getCached() returning null (classname == null)");
+ }
+ return null;
+ }
+ if (isUnloadedClassLoader())
+ {
+ if (trace)
+ {
+ logger.trace("getCached() returning null (unloaded)");
+ }
+ return null;
+ }
+
+ if (generatedClasses.get(classname) != null)
+ {
+ //It is a new class, and this callback is probably coming from the frozen check when creating a new nested class
+ if (trace)
+ {
+ logger.trace("getCached() In generated classes - check super");
+ }
+ return super.getCached(classname);
+ }
+
+ //Is this from the scoped classloader itself of from the parent?
+ String resourcename = getResourceName(classname);
+ URL url = getResourceUrlForClass(resourcename);
+
+ if (isMine(url, resourcename))
+ {
+ if (super.childFirstLookup)
+ {
+ //Parent delegation is false, attempt to get this class out of ourselves
+ CtClass clazz = super.getCachedLocally(classname);
+ if (clazz == null)
+ {
+ if (trace)
+ {
+ logger.trace("getCached() Creating my class " + classname);
+ }
+ clazz = createCtClass(classname, false);
+ if (clazz != null)
+ {
+ lockInCache(clazz);
+ }
+ }
+ if (clazz != null)
+ {
+ if (trace)
+ {
+ logger.trace("getCached() Returning my class " + classname);
+ }
+ return clazz;
+ }
+ }
+ if (trace)
+ {
+ logger.trace("getCached() Checking super for my class " + classname);
+ }
+ return super.getCached(classname);
+ }
+ else if (url == null)
+ {
+ if (trace)
+ {
+ logger.trace("getCached() Checking super for my class " + classname + " (no url)");
+ }
+ return super.getCached(classname);
+ }
+
+
+ try
+ {
+ ClassPool pool = getCorrectPoolForResource(classname, resourcename, url, trace);
+ if (trace)
+ {
+ logger.trace("getCached() Found pool for class " + classname + " " + pool);
+ }
+ if (pool != lastPool.get())
+ {
+ lastPool.set(pool);
+ CtClass found = pool.get(classname);
+ if (trace)
+ {
+ logger.trace("getCached() Found clazz " + classname + " in " + pool + " : " + found);
+ }
+ return found;
+ }
+ }
+ catch (NotFoundException e)
+ {
+ }
+ catch(StackOverflowError e)
+ {
+ throw e;
+ }
+ finally
+ {
+ lastPool.set(null);
+ }
+
+ return null;
+ }
+
+ @Override
+ protected boolean includeInGlobalSearch()
+ {
+ return false;
+ }
+
+ private ClassPool getCorrectPoolForResource(String classname, String resourceName, URL url, boolean trace)
+ {
+ synchronized(ClassPoolRepository.getInstance().getRegisteredCLs())
+ {
+ //JBoss 5 has an extra NoAnnotationURLCLassLoader that is not on the default path, make sure that that is checked at the end
+ //FIXME This needs revisiting/removing once the
+ ArrayList<ClassPool> noAnnotationURLClassLoaderPools = null;
+
+ ClassPoolRepository classPoolRepository = ClassPoolRepository.getInstance();
+ for(ClassPool classPool: classPoolRepository.getRegisteredCLs().values())
+ {
+ AbstractClassPool candidate = (AbstractClassPool)classPool;
+ if (candidate.isUnloadedClassLoader())
+ {
+ classPoolRepository.unregisterClassLoader(candidate.getClassLoader());
+ continue;
+ }
+
+ if (candidate.getClassLoader() instanceof RealClassLoader)
+ {
+ //Sometimes the ClassLoader is a proxy for MBeanProxyExt?!
+ RealClassLoader bcl = (RealClassLoader)candidate.getClassLoader();
+ URL foundUrl = bcl.getResourceLocally(resourceName);
+ if (foundUrl != null)
+ {
+ if (url.equals(foundUrl))
+ {
+ if (trace)
+ {
+ logger.trace("getCorrectPoolForResource() Candidate classloader " + bcl + " has local resource " + foundUrl);
+ }
+ return candidate;
+ }
+ }
+ }
+ //FIXME Remove once we have the JBoss 5 version of pool
+ else if (isInstanceOfNoAnnotationURLClassLoader(candidate.getClassLoader()))
+ {
+ if (noAnnotationURLClassLoaderPools == null)
+ {
+ noAnnotationURLClassLoaderPools = new ArrayList<ClassPool>();
+ }
+ noAnnotationURLClassLoaderPools.add(candidate);
+ }
+ }
+
+ //FIXME Remove once we have the JBoss 5 version of pool
+ if (noAnnotationURLClassLoaderPools != null)
+ {
+ for (ClassPool pool : noAnnotationURLClassLoaderPools)
+ {
+ try
+ {
+ pool.get(classname);
+ if (trace)
+ {
+ logger.trace("getCorrectPoolForResource(() Found " + classname + " (no url)");
+ }
+ return pool;
+ }
+ catch(NotFoundException ignoreTryNext)
+ {
+ }
+ }
+ }
+ }
+ return createTempPool();
+ }
+
+ private ClassPool createTempPool()
+ {
+ //Rememeber that the stuff in jboss5/lib goes in a child classloader of the default classloader. We need
+ //to make this the parent of the temp classloader
+ ClassLoader loader = this.getClass().getClassLoader();// AspectManager.class.getClassLoader(); TODO validate this
+ ClassPool pool = ClassPoolRepository.getInstance().registerClassLoader(loader);
+ return ClassPoolRepository.getInstance().getClassPoolFactory().create(pool, ClassPoolRepository.getInstance());
+ }
+
+ /**
+ * NoAnnotationURLCLassLoader lives in different packages in JBoss 4 and 5
+ */
+ private boolean isInstanceOfNoAnnotationURLClassLoader(ClassLoader loader)
+ {
+ if (loader == null)
+ {
+ return false;
+ }
+ Class<?> parent = loader.getClass();
+ while (parent != null)
+ {
+ if ("NoAnnotationURLClassLoader".equals(parent.getSimpleName()))
+ {
+ return true;
+ }
+ parent = parent.getSuperclass();
+ }
+ return false;
+ }
+
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/ScopedJBoss5ClassPool.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/SecurityActions.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/SecurityActions.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/SecurityActions.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,118 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.classpool.plugins.jbosscl;
+
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+import org.jboss.classloader.spi.base.BaseClassLoaderSource;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+class SecurityActions
+{
+ interface GetParentAction
+ {
+ ClassLoader getParent(ClassLoader loader);
+
+ GetParentAction NON_PRIVILEGED = new GetParentAction()
+ {
+ public ClassLoader getParent(ClassLoader loader)
+ {
+ return loader.getParent();
+ }
+ };
+
+ GetParentAction PRIVILEGED = new GetParentAction()
+ {
+ public ClassLoader getParent(final ClassLoader loader)
+ {
+ try
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<ClassLoader>()
+ {
+ public ClassLoader run() throws Exception
+ {
+ return loader.getParent();
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw new RuntimeException(e.getException());
+ }
+ }
+ };
+ }
+
+ public static ClassLoader getParent(ClassLoader loader)
+ {
+ if (System.getSecurityManager() == null)
+ {
+ return GetParentAction.NON_PRIVILEGED.getParent(loader);
+ }
+ else
+ {
+ return GetParentAction.PRIVILEGED.getParent(loader);
+ }
+ }
+
+ private static final Method getClassLoader;
+
+ static
+ {
+ getClassLoader = AccessController.doPrivileged(new PrivilegedAction<Method>()
+ {
+ public Method run()
+ {
+ try
+ {
+ Method method = BaseClassLoaderSource.class.getDeclaredMethod("getClassLoader");
+ method.setAccessible(true);
+ return method;
+ }
+ catch (NoSuchMethodException e)
+ {
+ throw new RuntimeException("Cannot get classloader from " + BaseClassLoaderSource.class.getName(), e);
+ }
+ }
+ });
+ }
+
+ static ClassLoader getClassLoader(BaseClassLoaderSource clSource)
+ {
+ try
+ {
+ return (ClassLoader)getClassLoader.invoke(clSource);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/SecurityActions.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/ToClassInvoker.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/ToClassInvoker.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/ToClassInvoker.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,102 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.classpool.plugins.jbosscl;
+
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.net.URL;
+import java.security.ProtectionDomain;
+
+import javassist.CannotCompileException;
+import javassist.CtClass;
+
+import org.jboss.classloading.spi.RealClassLoader;
+import org.jboss.logging.Logger;
+import org.jboss.virtual.plugins.context.memory.MemoryContextFactory;
+
+/**
+ *
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class ToClassInvoker
+{
+ Logger logger = Logger.getLogger(this.getClass());
+
+ public URL tempURL;
+
+ public Object tmplock = new Object();
+
+ public ToClassInvoker(URL tempURL)
+ {
+ this.tempURL = tempURL;
+ }
+
+ public Class<?> toClass(ToClassInvokerPoolReference pool, CtClass cc, String classFileName, ClassLoader loader, ProtectionDomain domain) throws CannotCompileException
+ {
+ boolean trace = logger.isTraceEnabled();
+ pool.lockInCache(cc);
+ final ClassLoader myloader = pool.getClassLoader();
+ if (myloader == null || tempURL == null)
+ {
+ if (trace) logger.trace(this + " " + pool + ".toClass() myloader:" + myloader + " tempURL:" + tempURL + " default to superPool.toClass for " + cc.getName());
+ Class<?> clazz = pool.superPoolToClass(cc, loader, domain);
+ if (trace) logger.trace(this + " " + pool + " myloader:" + myloader + " created class:" + clazz);
+ return clazz;
+ }
+
+ try
+ {
+ URL outputURL = new URL(tempURL.toString() + "/" + classFileName);
+ //Write the classfile to the temporary url
+ synchronized (tmplock)
+ {
+ if (trace) logger.trace(this + " " + pool + ".toClass() myloader:" + myloader + " writing bytes to " + tempURL);
+ ByteArrayOutputStream byteout = new ByteArrayOutputStream();
+ BufferedOutputStream out = new BufferedOutputStream(byteout);
+ out.write(cc.toBytecode());
+ out.flush();
+ out.close();
+
+ byte[] classBytes = byteout.toByteArray();
+ MemoryContextFactory factory = MemoryContextFactory.getInstance();
+ factory.putFile(outputURL, classBytes);
+
+ if (myloader instanceof RealClassLoader)
+ {
+ ((RealClassLoader)myloader).clearBlackList(classFileName);
+ }
+
+ Class<?> clazz = myloader.loadClass(cc.getName());
+ if (trace) logger.trace(this + " " + pool + " myloader:" + myloader + " created class:" + clazz);
+ return clazz;
+ }
+ }
+ catch(Exception e)
+ {
+ ClassFormatError cfe = new ClassFormatError("Failed to load dyn class: " + cc.getName() + " on " + this + " loader:" + myloader);
+ cfe.initCause(e);
+ throw cfe;
+ }
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/ToClassInvoker.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/ToClassInvokerPoolReference.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/ToClassInvokerPoolReference.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/ToClassInvokerPoolReference.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,40 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.classpool.plugins.jbosscl;
+
+import java.security.ProtectionDomain;
+
+import javassist.CannotCompileException;
+import javassist.CtClass;
+
+/**
+ * Exposes methods on ClassPool needed by JBoss5ClassPool
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public interface ToClassInvokerPoolReference
+{
+ Class<?> superPoolToClass(CtClass cc, ClassLoader loader, ProtectionDomain domain) throws CannotCompileException;
+ ClassLoader getClassLoader();
+ void lockInCache(CtClass clazz);
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/ToClassInvokerPoolReference.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/VFSClassLoaderDomainRegistry.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/VFSClassLoaderDomainRegistry.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/VFSClassLoaderDomainRegistry.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,250 @@
+package org.jboss.classpool.plugins.jbosscl;
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.
+*/
+
+
+import java.lang.ref.WeakReference;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import org.jboss.classloader.plugins.loader.ClassLoaderToLoaderAdapter;
+import org.jboss.classloader.spi.ClassLoaderDomain;
+import org.jboss.classloader.spi.ClassLoaderSystem;
+import org.jboss.classloading.spi.dependency.ClassLoading;
+import org.jboss.classloading.spi.dependency.Module;
+import org.jboss.deployers.plugins.classloading.AbstractDeploymentClassLoaderPolicyModule;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class VFSClassLoaderDomainRegistry implements DomainRegistry
+{
+ protected final static ClassLoaderDomain domain = new ClassLoaderDomain("NOT_USED_PLACEHOLDER");
+
+ private static final VFSClassLoaderDomainRegistry instance = new VFSClassLoaderDomainRegistry();
+
+ public static final VFSClassLoaderDomainRegistry getInstance()
+ {
+ return instance;
+ }
+
+ private ClassLoaderSystem system;
+
+ private ClassLoaderDomain defaultDomain;
+
+ /** classloader domains by their classloaders */
+ protected Map<ClassLoader, WeakReference<ClassLoaderDomain>> classLoaderDomainsByLoader = new WeakHashMap<ClassLoader, WeakReference<ClassLoaderDomain>>();
+
+ /** parent deployment unit classloaders indexed by children */
+ private Map<ClassLoader, WeakReference<ClassLoader>> classLoaderUnitParents = new WeakHashMap<ClassLoader, WeakReference<ClassLoader>>();
+
+ /** Modules by classloader */
+ private Map<ClassLoader, WeakReference<Module>> classLoaderModules = new WeakHashMap<ClassLoader, WeakReference<Module>>();
+
+ /** classloaders by module */
+ private Map<Module, WeakReference<ClassLoader>> moduleClassLoaders = new WeakHashMap<Module, WeakReference<ClassLoader>>();
+
+ protected Map<ClassLoaderDomain, Integer> classLoaderDomainReferenceCounts = new WeakHashMap<ClassLoaderDomain, Integer>();
+
+ protected VFSClassLoaderDomainRegistry() {}
+
+ /**
+ * Needed for the tests, not expected to be needed in production
+ */
+ public void setSystem(ClassLoaderSystem system)
+ {
+ this.system = system;
+ }
+
+ /**
+ * Needed for the tests, not expected to be needed in production
+ */
+ public void setDefaultDomain(ClassLoaderDomain domain)
+ {
+ this.defaultDomain = domain;
+ }
+
+ public synchronized ClassLoaderSystem getSystem()
+ {
+ if (system == null)
+ {
+ system = ClassLoaderSystem.getInstance();
+ }
+ return system;
+ }
+
+ public synchronized ClassLoaderDomain getDefaultDomain()
+ {
+ if (defaultDomain == null)
+ {
+ defaultDomain = getSystem().getDefaultDomain();
+ }
+ return defaultDomain;
+ }
+
+ public synchronized boolean initMapsForModule(Module module)
+ {
+ ClassLoader loader = ClassLoading.getClassLoaderForModule(module);
+ ClassLoader parentUnitLoader = findParentUnitLoader(module);
+ if (loader == parentUnitLoader)
+ {
+ throw new IllegalArgumentException("initMapsForLoader() should only be called if parentUnitLoader is different from loader");
+ }
+ ClassLoaderSystem system = getSystem();
+
+ String domainName = module.getDeterminedDomainName();
+ ClassLoaderDomain clDomain = system.getDomain(domainName);
+ this.validateInitMaps(loader, clDomain, module, parentUnitLoader);
+
+ boolean ret = false;
+ if (!classLoaderDomainsByLoader.containsKey(loader))
+ {
+ Integer count = classLoaderDomainReferenceCounts.get(clDomain);
+ int cnt = count == null ? 0 : count.intValue();
+ classLoaderDomainReferenceCounts.put(clDomain, cnt);
+
+ classLoaderDomainsByLoader.put(loader, new WeakReference<ClassLoaderDomain>(clDomain));
+ classLoaderUnitParents.put(loader, new WeakReference<ClassLoader>(parentUnitLoader));
+ classLoaderModules.put(loader, new WeakReference<Module>(module));
+ moduleClassLoaders.put(module, new WeakReference<ClassLoader>(loader));
+ ret = true;
+ this.initMapsDone(loader, clDomain, module, parentUnitLoader);
+ }
+
+
+ return ret;
+ }
+
+ protected void validateInitMaps(ClassLoader loader, ClassLoaderDomain loaderDomain, Module module, ClassLoader parentUnitLoader)
+ {
+
+ }
+
+ protected void initMapsDone(ClassLoader loader, ClassLoaderDomain loaderDomain, Module module, ClassLoader parentUnitLoader)
+ {
+
+ }
+
+ public synchronized void cleanupModule(Module module)
+ {
+ ClassLoader loader = this.getClassLoader(module);
+ validateCleanupLoader(loader);
+ WeakReference<ClassLoaderDomain> clDomainRef = classLoaderDomainsByLoader.remove(loader);
+ ClassLoaderDomain clDomain = clDomainRef == null ? null : clDomainRef.get();
+ int cnt = 0;
+ if (clDomain != null)
+ {
+ Integer count = classLoaderDomainReferenceCounts.get(clDomain);
+ cnt = count == null ? 0 : count.intValue();
+ if (cnt > 0)
+ {
+ cnt--;
+ }
+ if (cnt == 0)
+ {
+ classLoaderDomainReferenceCounts.remove(clDomain);
+ }
+ else
+ {
+ classLoaderDomainReferenceCounts.put(clDomain, ++cnt);
+ }
+ classLoaderUnitParents.remove(loader);
+ classLoaderModules.remove(loader);
+ moduleClassLoaders.remove(module);
+ }
+ cleanupLoaderDone(loader, clDomain, cnt);
+ }
+
+ protected void validateCleanupLoader(ClassLoader loader) {}
+
+ protected void cleanupLoaderDone(ClassLoader loader, ClassLoaderDomain loaderDomain, int domainReferences) {}
+
+ public synchronized ClassLoaderDomain getClassLoaderDomainForLoader(ClassLoader cl)
+ {
+ WeakReference<ClassLoaderDomain> clDomainRef = classLoaderDomainsByLoader.get(cl);
+ if (clDomainRef != null)
+ {
+ return clDomainRef.get();
+ }
+
+ ClassLoader parent = SecurityActions.getParent(cl);
+ if (parent != null)
+ {
+ ClassLoaderDomain domain = getClassLoaderDomainForLoader(parent);
+ if (domain != null)
+ {
+ classLoaderDomainsByLoader.put(parent, new WeakReference<ClassLoaderDomain>(domain));
+ return domain;
+ }
+ }
+ return null;
+ }
+
+ public synchronized ClassLoader getParentUnitLoader(ClassLoader loader)
+ {
+ WeakReference<ClassLoader> parentRef = classLoaderUnitParents.get(loader);
+ if (parentRef != null)
+ {
+ return parentRef.get();
+ }
+ return null;
+ }
+
+ public synchronized Module getModule(ClassLoader loader)
+ {
+ WeakReference<Module> moduleRef = classLoaderModules.get(loader);
+ if (moduleRef != null)
+ {
+ return moduleRef.get();
+ }
+ return null;
+ }
+
+ public synchronized ClassLoader getClassLoader(Module module)
+ {
+ WeakReference<ClassLoader> loaderRef = moduleClassLoaders.get(module);
+ if (loaderRef != null)
+ {
+ return loaderRef.get();
+ }
+ return null;
+ }
+
+ private ClassLoader findParentUnitLoader(Module module)
+ {
+ if (module instanceof AbstractDeploymentClassLoaderPolicyModule)
+ {
+ DeploymentUnit unit = AbstractDeploymentClassLoaderPolicyModule.class.cast(module).getDeploymentUnit();
+ return unit.isTopLevel() ? null : unit.getParent().getClassLoader();
+ }
+ ClassLoaderDomain domain = ClassLoaderSystem.getInstance().getDomain(module.getDeterminedDomainName());
+ if (domain.getParent() instanceof ClassLoaderToLoaderAdapter)
+ {
+ ClassLoaderToLoaderAdapter cp2la = (ClassLoaderToLoaderAdapter)domain.getParent();
+ return SecurityActions.getClassLoader(cp2la);
+ }
+ return null;
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/VFSClassLoaderDomainRegistry.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/main/resources/jbossorg-eula.txt
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/main/resources/jbossorg-eula.txt (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/main/resources/jbossorg-eula.txt 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,107 @@
+LICENSE AGREEMENT
+JBOSS(r)
+
+This License Agreement governs the use of the Software Packages and any updates to the Software
+Packages, regardless of the delivery mechanism. Each Software Package is a collective work
+under U.S. Copyright Law. Subject to the following terms, Red Hat, Inc. ("Red Hat") grants to
+the user ("Client") a license to the applicable collective work(s) pursuant to the
+GNU Lesser General Public License v. 2.1 except for the following Software Packages:
+(a) JBoss Portal Forums and JBoss Transactions JTS, each of which is licensed pursuant to the
+GNU General Public License v.2;
+
+(b) JBoss Rules, which is licensed pursuant to the Apache License v.2.0;
+
+(c) an optional download for JBoss Cache for the Berkeley DB for Java database, which is licensed under the
+(open source) Sleepycat License (if Client does not wish to use the open source version of this database,
+it may purchase a license from Sleepycat Software);
+
+and (d) the BPEL extension for JBoss jBPM, which is licensed under the Common Public License v.1,
+and, pursuant to the OASIS BPEL4WS standard, requires parties wishing to redistribute to enter various
+royalty-free patent licenses.
+
+Each of the foregoing licenses is available at http://www.opensource.org/licenses/index.php.
+
+1. The Software. "Software Packages" refer to the various software modules that are created and made available
+for distribution by the JBoss.org open source community at http://www.jboss.org. Each of the Software Packages
+may be comprised of hundreds of software components. The end user license agreement for each component is located in
+the component's source code. With the exception of certain image files identified in Section 2 below,
+the license terms for the components permit Client to copy, modify, and redistribute the component,
+in both source code and binary code forms. This agreement does not limit Client's rights under,
+or grant Client rights that supersede, the license terms of any particular component.
+
+2. Intellectual Property Rights. The Software Packages are owned by Red Hat and others and are protected under copyright
+and other laws. Title to the Software Packages and any component, or to any copy, modification, or merged portion shall
+remain with the aforementioned, subject to the applicable license. The "JBoss" trademark, "Red Hat" trademark, the
+individual Software Package trademarks, and the "Shadowman" logo are registered trademarks of Red Hat and its affiliates
+in the U.S. and other countries. This agreement permits Client to distribute unmodified copies of the Software Packages
+using the Red Hat trademarks that Red Hat has inserted in the Software Packages on the condition that Client follows Red Hat's
+trademark guidelines for those trademarks located at http://www.redhat.com/about/corporate/trademark/. Client must abide by
+these trademark guidelines when distributing the Software Packages, regardless of whether the Software Packages have been modified.
+If Client modifies the Software Packages, then Client must replace all Red Hat trademarks and logos identified at
+http://www.jboss.com/company/logos, unless a separate agreement with Red Hat is executed or other permission granted.
+Merely deleting the files containing the Red Hat trademarks may corrupt the Software Packages.
+
+3. Limited Warranty. Except as specifically stated in this Paragraph 3 or a license for a particular
+component, to the maximum extent permitted under applicable law, the Software Packages and the
+components are provided and licensed "as is" without warranty of any kind, expressed or implied,
+including the implied warranties of merchantability, non-infringement or fitness for a particular purpose.
+Red Hat warrants that the media on which Software Packages may be furnished will be free from defects in
+materials and manufacture under normal use for a period of 30 days from the date of delivery to Client.
+Red Hat does not warrant that the functions contained in the Software Packages will meet Client's requirements
+or that the operation of the Software Packages will be entirely error free or appear precisely as described
+in the accompanying documentation. This warranty extends only to the party that purchases the Services
+pertaining to the Software Packages from Red Hat or a Red Hat authorized distributor.
+
+4. Limitation of Remedies and Liability. To the maximum extent permitted by applicable law, the remedies
+described below are accepted by Client as its only remedies. Red Hat's entire liability, and Client's
+exclusive remedies, shall be: If the Software media is defective, Client may return it within 30 days of
+delivery along with a copy of Client's payment receipt and Red Hat, at its option, will replace it or
+refund the money paid by Client for the Software. To the maximum extent permitted by applicable law,
+Red Hat or any Red Hat authorized dealer will not be liable to Client for any incidental or consequential
+damages, including lost profits or lost savings arising out of the use or inability to use the Software,
+even if Red Hat or such dealer has been advised of the possibility of such damages. In no event shall
+Red Hat's liability under this agreement exceed the amount that Client paid to Red Hat under this
+Agreement during the twelve months preceding the action.
+
+5. Export Control. As required by U.S. law, Client represents and warrants that it:
+(a) understands that the Software Packages are subject to export controls under the
+U.S. Commerce Department's Export Administration Regulations ("EAR");
+
+(b) is not located in a prohibited destination country under the EAR or U.S. sanctions regulations
+(currently Cuba, Iran, Iraq, Libya, North Korea, Sudan and Syria);
+
+(c) will not export, re-export, or transfer the Software Packages to any prohibited destination, entity,
+or individual without the necessary export license(s) or authorizations(s) from the U.S. Government;
+
+(d) will not use or transfer the Software Packages for use in any sensitive nuclear, chemical or
+biological weapons, or missile technology end-uses unless authorized by the U.S. Government by
+regulation or specific license;
+
+(e) understands and agrees that if it is in the United States and exports or transfers the Software
+Packages to eligible end users, it will, as required by EAR Section 740.17(e), submit semi-annual
+reports to the Commerce Department's Bureau of Industry & Security (BIS), which include the name and
+address (including country) of each transferee;
+
+and (f) understands that countries other than the United States may restrict the import, use, or
+export of encryption products and that it shall be solely responsible for compliance with any such
+import, use, or export restrictions.
+
+6. Third Party Programs. Red Hat may distribute third party software programs with the Software Packages
+that are not part of the Software Packages and which Client must install separately. These third party
+programs are subject to their own license terms. The license terms either accompany the programs or
+can be viewed at http://www.redhat.com/licenses/. If Client does not agree to abide by the applicable
+license terms for such programs, then Client may not install them. If Client wishes to install the programs
+on more than one system or transfer the programs to another party, then Client must contact the licensor
+of the programs.
+
+7. General. If any provision of this agreement is held to be unenforceable, that shall not affect the
+enforceability of the remaining provisions. This License Agreement shall be governed by the laws of the
+State of North Carolina and of the United States, without regard to any conflict of laws provisions,
+except that the United Nations Convention on the International Sale of Goods shall not apply.
+
+Copyright 2006 Red Hat, Inc. All rights reserved.
+"JBoss" and the JBoss logo are registered trademarks of Red Hat, Inc.
+All other trademarks are the property of their respective owners.
+
+ Page 1 of 1 18 October 2006
+
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/main/resources/jbossorg-eula.txt
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/JBossClClassPoolFullTestSuite.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/JBossClClassPoolFullTestSuite.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/JBossClClassPoolFullTestSuite.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.test.classpool.jbosscl;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * Contains all JBoss CL test cases.
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class JBossClClassPoolFullTestSuite extends TestSuite
+{
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("JBoss-cl All Tests");
+
+ suite.addTest(JBossClClassSanityTestSuite.suite());
+ suite.addTest(JBossClClassPoolTestSuite.suite());
+ return suite;
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/JBossClClassPoolFullTestSuite.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/JBossClClassPoolTestSuite.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/JBossClClassPoolTestSuite.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/JBossClClassPoolTestSuite.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.test.classpool.jbosscl;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import org.jboss.test.classpool.jbosscl.test.ArchiveClassPoolTestCase;
+import org.jboss.test.classpool.jbosscl.test.CtClassCreationTestCase;
+import org.jboss.test.classpool.jbosscl.test.HierarchicalDomainClassPoolTestCase;
+import org.jboss.test.classpool.jbosscl.test.HierarchicalParentLoaderClassPoolTestCase;
+import org.jboss.test.classpool.jbosscl.test.ModuleDependencyClassPoolTestCase;
+import org.jboss.test.classpool.jbosscl.test.PackageDependencyClassPoolTestCase;
+import org.jboss.test.classpool.jbosscl.test.ReExportModuleClassPoolTestCase;
+import org.jboss.test.classpool.jbosscl.test.ReExportPackageClassPoolTestCase;
+import org.jboss.test.classpool.jbosscl.test.ReplaceReferencesClassPoolTestCase;
+import org.jboss.test.classpool.jbosscl.test.RepositoryClassPoolTestCase;
+import org.jboss.test.classpool.jbosscl.test.UsesPackageClassPoolTestCase;
+
+/**
+ * TestSuite for all JBossClClassPool test cases.
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class JBossClClassPoolTestSuite extends TestSuite
+{
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("JBoss-cl Pool Tests");
+
+ suite.addTestSuite(ArchiveClassPoolTestCase.class);
+ suite.addTestSuite(CtClassCreationTestCase.class);
+ suite.addTestSuite(HierarchicalDomainClassPoolTestCase.class);
+ suite.addTestSuite(HierarchicalParentLoaderClassPoolTestCase.class);
+ suite.addTestSuite(ModuleDependencyClassPoolTestCase.class);
+ suite.addTestSuite(PackageDependencyClassPoolTestCase.class);
+ suite.addTestSuite(ReExportModuleClassPoolTestCase.class);
+ suite.addTestSuite(ReExportPackageClassPoolTestCase.class);
+ suite.addTestSuite(ReplaceReferencesClassPoolTestCase.class);
+ suite.addTestSuite(RepositoryClassPoolTestCase.class);
+ suite.addTestSuite(UsesPackageClassPoolTestCase.class);
+ return suite;
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/JBossClClassPoolTestSuite.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/JBossClClassSanityTestSuite.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/JBossClClassSanityTestSuite.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/JBossClClassSanityTestSuite.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.test.classpool.jbosscl;
+
+import org.jboss.test.classpool.jbosscl.test.ArchiveSanityTestCase;
+import org.jboss.test.classpool.jbosscl.test.HierarchicalDomainSanityTestCase;
+import org.jboss.test.classpool.jbosscl.test.HierarchicalParentLoaderSanityTestCase;
+import org.jboss.test.classpool.jbosscl.test.ModuleDependencySanityTestCase;
+import org.jboss.test.classpool.jbosscl.test.PackageDependencySanityTestCase;
+import org.jboss.test.classpool.jbosscl.test.ReExportModuleSanityTestCase;
+import org.jboss.test.classpool.jbosscl.test.ReExportPackageSanityTestCase;
+import org.jboss.test.classpool.jbosscl.test.RepositorySanityTestCase;
+import org.jboss.test.classpool.jbosscl.test.UsesPackageSanityTestCase;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * TestSuite for all JBossCl Sanity test cases.
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class JBossClClassSanityTestSuite extends TestSuite
+{
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("JBoss-cl Sanity Tests");
+
+ suite.addTestSuite(ArchiveSanityTestCase.class);
+ suite.addTestSuite(HierarchicalDomainSanityTestCase.class);
+ suite.addTestSuite(HierarchicalParentLoaderSanityTestCase.class);
+ suite.addTestSuite(ModuleDependencySanityTestCase.class);
+ suite.addTestSuite(PackageDependencySanityTestCase.class);
+ suite.addTestSuite(ReExportModuleSanityTestCase.class);
+ suite.addTestSuite(ReExportPackageSanityTestCase.class);
+ suite.addTestSuite(RepositorySanityTestCase.class);
+ suite.addTestSuite(UsesPackageSanityTestCase.class);
+
+ return suite;
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/JBossClClassSanityTestSuite.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/CLDeploymentBuilder.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/CLDeploymentBuilder.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/CLDeploymentBuilder.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,383 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.test.classpool.jbosscl.support;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.classloader.spi.ClassLoaderSystem;
+import org.jboss.classloading.spi.metadata.Capability;
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory;
+import org.jboss.classloading.spi.metadata.ExportAll;
+import org.jboss.classloading.spi.metadata.Requirement;
+import org.jboss.classloading.spi.version.VersionRange;
+import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory;
+import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.test.classpool.support.ClassLoaderInfo;
+
+/**
+ * Builds a CLDeployment that will result in the creation of a ClassLoader.
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class CLDeploymentBuilder implements ClassLoaderInfo
+{
+ private static ClassLoadingMetaDataFactory clmdf = ClassLoadingMetaDataFactory.getInstance();
+
+ List<Capability> capabilities = new ArrayList<Capability>();
+ List<Requirement> requirements = new ArrayList<Requirement>();
+
+ private String name;
+ private URL[] urls;
+ private URL[] excludes;
+ private boolean importAll;
+ private String domainName;
+ private String parentDomainName;
+ private boolean parentFirst;
+ private ClassLoader parent;
+ boolean domainDefined = false;
+ boolean domainCreated = false;
+
+ boolean deploymentCreated = false;
+ private KernelDeployment kernelDeployment = null;
+
+ private VFSClassLoaderFactory metaDataFactory;
+
+ public CLDeploymentBuilder(String name, URL... urls)
+ {
+ this.name = name;
+ this.urls = urls;
+ this.importAll = true;
+ }
+
+ public String getName()
+ {
+ return this.name;
+ }
+
+ public void setExcludes(URL... urls)
+ {
+ this.excludes = urls;
+ }
+
+ // TODO automatically call this after a createModule/createanything?
+ public void setImportAll(boolean importAll)
+ {
+ this.importAll = importAll;
+ }
+
+ public void createDomain(String domain, String parentDomain, boolean parentFirst)
+ {
+ if (DomainRegistry.contains(domain))
+ {
+ throw new IllegalStateException("Domain " + domain + " already exists");
+ }
+ DomainRegistry.registerDomain(domain);
+ domainCreated = true;
+ this.setDomain(domain, parentDomain, parentFirst);
+ }
+
+ public void createDomain(String domain, boolean parentFirst)
+ {
+ this.createDomain(domain, (String) null, parentFirst);
+ }
+
+ public boolean isDomainCreated()
+ {
+ return this.domainCreated;
+ }
+
+ public void createDomain(String domain, ClassLoader parent, boolean parentFirst)
+ {
+ this.createDomain(domain, (String) null, parentFirst);
+ this.setParent(parent);
+ }
+
+ public void setDomain(String domainName)
+ {
+ setDomain(domainName, null, false);
+ }
+
+ private void setDomain(String domain, String parentDomain, boolean parentFirst)
+ {
+ if (domainDefined)
+ {
+ throw new IllegalStateException("Duplicate definition of domain for CLDeployment " +
+ this.getName());
+ }
+ this.domainName = domain;
+ this.parentDomainName = parentDomain;
+ this.parentFirst = parentFirst;
+ domainDefined = true;
+ }
+
+ public String getDomain()
+ {
+ return this.domainName;
+ }
+
+ public void setParent(ClassLoader parent)
+ {
+ this.parent = parent;
+ }
+
+ public CLDeploymentBuilder createModule(String name)
+ {
+ capabilities.add(clmdf.createModule(name));
+ return this;
+ }
+
+ public CLDeploymentBuilder createModule(String name, Object version)
+ {
+ capabilities.add(clmdf.createModule(name, version));
+ return this;
+ }
+
+ public CLDeploymentBuilder createRequireModule(String name)
+ {
+ requirements.add(clmdf.createRequireModule(name, null));
+ return this;
+ }
+
+ public CLDeploymentBuilder createRequireModule(String name, VersionRange versionRange)
+ {
+ requirements.add(clmdf.createRequireModule(name, versionRange));
+ return this;
+ }
+
+ public CLDeploymentBuilder createRequireModule(String name, VersionRange versionRange, boolean optional, boolean reExport, boolean dynamic)
+ {
+ requirements.add(clmdf.createRequireModule(name, versionRange, optional, reExport, dynamic));
+ return this;
+ }
+
+ public CLDeploymentBuilder createPackage(String name)
+ {
+ capabilities.add(clmdf.createPackage(name));
+ return this;
+ }
+
+ public CLDeploymentBuilder createPackage(String name, Object version)
+ {
+ capabilities.add(clmdf.createPackage(name, version));
+ return this;
+ }
+
+ public CLDeploymentBuilder createRequirePackage(String name)
+ {
+ requirements.add(clmdf.createRequirePackage(name));
+ return this;
+ }
+
+ public CLDeploymentBuilder createRequirePackage(String name, VersionRange versionRange)
+ {
+ requirements.add(clmdf.createRequirePackage(name, versionRange));
+ return this;
+ }
+
+ public CLDeploymentBuilder createRequirePackage(String name, VersionRange versionRange, boolean optional, boolean reExport, boolean dynamic)
+ {
+ requirements.add(clmdf.createRequirePackage(name, versionRange, optional, reExport, dynamic));
+ return this;
+ }
+
+ public CLDeploymentBuilder createReExportModule(String name)
+ {
+ requirements.add(clmdf.createReExportModule(name));
+ return this;
+ }
+
+ public CLDeploymentBuilder createReExportModule(String name, VersionRange versionRange)
+ {
+ requirements.add(clmdf.createReExportModule(name, versionRange));
+ return this;
+ }
+
+ public CLDeploymentBuilder createReExportModule(String name, VersionRange versionRange, boolean optional)
+ {
+ requirements.add(clmdf.createReExportModule(name, versionRange, optional));
+ return this;
+ }
+
+ public CLDeploymentBuilder createReExportPackage(String name)
+ {
+ requirements.add(clmdf.createReExportPackage(name));
+ return this;
+ }
+
+ public CLDeploymentBuilder createReExportPackage(String name, VersionRange versionRange)
+ {
+ requirements.add(clmdf.createReExportPackage(name, versionRange));
+ return this;
+ }
+
+ public CLDeploymentBuilder createReExportPackage(String name, VersionRange versionRange, boolean optional)
+ {
+ requirements.add(clmdf.createReExportPackage(name, versionRange, optional));
+ return this;
+ }
+
+ public CLDeploymentBuilder createUsesPackage(String name)
+ {
+ requirements.add(clmdf.createUsesPackage(name));
+ return this;
+ }
+
+ public CLDeploymentBuilder createUsesPackage(String name, VersionRange versionRange)
+ {
+ requirements.add(clmdf.createUsesPackage(name, versionRange));
+ return this;
+ }
+
+ public CLDeploymentBuilder createUsesPackage(String name, VersionRange versionRange, boolean reExport)
+ {
+ requirements.add(clmdf.createUsesPackage(name, versionRange, reExport));
+ return this;
+ }
+
+ public synchronized KernelDeployment createDeployment()
+ {
+ Assert.assertFalse("Duplicate deployment created", deploymentCreated);
+ if (metaDataFactory == null)
+ {
+ metaDataFactory = createMetaDataFactory();
+ }
+ AbstractKernelDeployment deployment = new AbstractKernelDeployment();
+ deployment.setName(metaDataFactory.getName() + ":" + metaDataFactory.getVersion());
+ deployment.setBeanFactories(Collections.singletonList((BeanMetaDataFactory) metaDataFactory));
+ deploymentCreated = true;
+ this.kernelDeployment = deployment;
+ return deployment;
+ }
+
+ public synchronized KernelDeployment getDeployment()
+ {
+ return this.kernelDeployment;
+ }
+
+ public synchronized KernelDeployment undeploy()
+ {
+ this.deploymentCreated = false;
+ return this.kernelDeployment;
+ }
+
+ public VFSClassLoaderFactory getMetaDataFactory()
+ {
+ Assert.assertNotNull("MetaDataFactory can be retrieved only after deployment creation.",
+ metaDataFactory);
+ return metaDataFactory;
+ }
+
+ private VFSClassLoaderFactory createMetaDataFactory()
+ {
+
+ TestVFSClassLoaderFactory factory = new TestVFSClassLoaderFactory();
+ factory.setName(name);
+ factory.setImportAll(importAll);
+ if (importAll)
+ {
+ factory.setExportAll(ExportAll.NON_EMPTY);
+ }
+ factory.setRoots(urlsToStringList(urls));
+ factory.setExcludedRoots(urlsToStringList(excludes));
+
+ if (capabilities != null && !capabilities.isEmpty())
+ {
+ factory.getCapabilities().setCapabilities(capabilities);
+ }
+ if (requirements != null && !requirements.isEmpty())
+ {
+ factory.getRequirements().setRequirements(requirements);
+ }
+ setupDomain(factory, domainName, parentDomainName, parentFirst);
+ if (parent != null)
+ {
+ factory.setParent(parent);
+ }
+ return factory;
+ }
+
+
+ public ClassLoader getParent()
+ {
+ return this.parent;
+ }
+
+ private static void setupDomain(ClassLoadingMetaData md, String domainName, String parentDomainName, boolean parentFirst)
+ {
+ if (domainName != null)
+ {
+ md.setDomain(domainName);
+ md.setJ2seClassLoadingCompliance(parentFirst);
+ if (parentDomainName != null)
+ {
+ md.setParentDomain(parentDomainName);
+ }
+ else
+ {
+ md.setParentDomain(ClassLoaderSystem.DEFAULT_DOMAIN_NAME);
+ }
+ }
+ else
+ {
+ md.setDomain(ClassLoaderSystem.DEFAULT_DOMAIN_NAME);
+ }
+ }
+
+ public List<Capability> getCapabilities()
+ {
+ return capabilities;
+ }
+
+ public List<Requirement> getRequirements()
+ {
+ return requirements;
+ }
+
+ private static List<String> urlsToStringList(URL... urls)
+ {
+ if (urls == null)
+ {
+ return null;
+ }
+ List<String> urlList = new ArrayList<String>(urls.length);
+ if (urls.length > 0)
+ {
+ for (URL url : urls)
+ {
+ if (url != null)
+ {
+ urlList.add(url.toString());
+ }
+ }
+ }
+ return urlList;
+ }
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/CLDeploymentBuilder.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/DomainRegistry.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/DomainRegistry.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/DomainRegistry.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.classpool.jbosscl.support;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.classloader.spi.ClassLoaderDomain;
+import org.jboss.test.classpool.support.TestScenario;
+
+/**
+ * All domains to be cleaned up should be registered here.
+ * This registry is automatically populated by
+ * {@link TestScenario#createLoader(CLDeploymentBuilder)}.
+ * However, if a test creates a domain manually, the domain must be registered here for
+ * proper clean up.
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.org">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class DomainRegistry
+{
+ private static final Map<String, ClassLoaderDomain> domains = new HashMap<String, ClassLoaderDomain>();
+
+ public static synchronized boolean contains(String domainName)
+ {
+ return domains.containsKey(domainName);
+ }
+
+ public static synchronized void registerDomain(String domain)
+ {
+ domains.put(domain, null);
+ }
+
+ public static synchronized void registerDomain(ClassLoaderDomain domain)
+ {
+ domains.put(domain.getName(), domain);
+ }
+
+ public static synchronized Map<String, ClassLoaderDomain> clear()
+ {
+ Map<String, ClassLoaderDomain> registeredDomains = new HashMap<String, ClassLoaderDomain>(domains);
+ domains.clear();
+ return registeredDomains;
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/DomainRegistry.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/FilteredClassPool.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/FilteredClassPool.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/FilteredClassPool.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,269 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.classpool.jbosscl.support;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.security.ProtectionDomain;
+import java.util.Iterator;
+
+import javassist.CannotCompileException;
+import javassist.ClassPath;
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.CtMethod;
+import javassist.NotFoundException;
+
+import org.jboss.classloader.spi.filter.ClassFilter;
+
+/**
+ * Filters loading of support classes. For test purposes only.
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+
+public class FilteredClassPool extends ClassPool
+{
+ private ClassPool delegate;
+ private ClassFilter classFilter;
+
+ public FilteredClassPool(ClassPool delegate, ClassFilter classFilter)
+ {
+ this.delegate = delegate;
+ this.classFilter = classFilter;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "FilteredClassPool (" + delegate + ")";
+ }
+
+ @Override
+ public void importPackage(String packageName)
+ {
+ delegate.importPackage(packageName);
+ }
+
+ @Override
+ public void clearImportedPackages()
+ {
+ if (delegate != null)
+ {
+ delegate.clearImportedPackages();
+ }
+ else
+ {
+ super.clearImportedPackages();
+ }
+ }
+
+ @Override
+ public Iterator<?> getImportedPackages()
+ {
+ return delegate.getImportedPackages();
+ }
+
+ @Override
+ public void recordInvalidClassName(String name)
+ {
+ delegate.recordInvalidClassName(name);
+ }
+
+ @Override
+ public Object[] lookupCflow(String name)
+ {
+ return delegate.lookupCflow(name);
+ }
+
+ @Override
+ public CtClass getAndRename(String orgName, String newName) throws NotFoundException
+ {
+ return delegate.getAndRename(orgName, newName);
+ }
+
+ @Override
+ public CtClass get(String classname) throws NotFoundException
+ {
+ if (classFilter.matchesClassName(classname))
+ {
+ return delegate.get(classname);
+ }
+ throw new NotFoundException(classname);
+ }
+
+ @Override
+ public CtClass getCtClass(String classname) throws NotFoundException
+ {
+ if (classFilter.matchesClassName(classname))
+ {
+ return delegate.getCtClass(classname);
+ }
+ throw new NotFoundException(classname);
+ }
+
+ @Override
+ public URL find(String classname)
+ {
+ if (classFilter.matchesClassName(classname))
+ {
+ return delegate.find(classname);
+ }
+ return null;
+ }
+
+ @Override
+ public CtClass[] get(String[] classnames) throws NotFoundException
+ {
+ for (String classname: classnames)
+ {
+ if (!classFilter.matchesClassName(classname))
+ throw new NotFoundException(classname);
+ }
+ return delegate.get(classnames);
+ }
+
+ @Override
+ public CtMethod getMethod(String classname, String methodname) throws NotFoundException
+ {
+ if (classFilter.matchesClassName(classname))
+ {
+ return delegate.getMethod(classname, methodname);
+ }
+ throw new NotFoundException(classname);
+ }
+
+ @Override
+ public CtClass makeClass(InputStream classfile) throws IOException, RuntimeException
+ {
+ return delegate.makeClass(classfile);
+ }
+
+ @Override
+ public CtClass makeClass(InputStream classfile, boolean ifNotFrozen)
+ throws IOException, RuntimeException
+ {
+ return delegate.makeClass(classfile, ifNotFrozen);
+ }
+
+ @Override
+ public CtClass makeClassIfNew(InputStream classfile) throws IOException, RuntimeException
+ {
+ return delegate.makeClassIfNew(classfile);
+ }
+
+ @Override
+ public CtClass makeClass(String classname) throws RuntimeException
+ {
+ return delegate.makeClass(classname);
+ }
+
+ @Override
+ public synchronized CtClass makeClass(String classname, CtClass superclass)
+ throws RuntimeException
+ {
+ return delegate.makeClass(classname, superclass);
+ }
+
+ @Override
+ public CtClass makeInterface(String name) throws RuntimeException
+ {
+ return delegate.makeInterface(name);
+ }
+
+ @Override
+ public synchronized CtClass makeInterface(String name, CtClass superclass)
+ throws RuntimeException
+ {
+ return delegate.makeInterface(name, superclass);
+ }
+
+ @Override
+ public ClassPath appendSystemPath()
+ {
+ return delegate.appendSystemPath();
+ }
+
+ @Override
+ public ClassPath insertClassPath(ClassPath cp)
+ {
+ return delegate.insertClassPath(cp);
+ }
+
+ @Override
+ public ClassPath appendClassPath(ClassPath cp)
+ {
+ return delegate.appendClassPath(cp);
+ }
+
+ @Override
+ public ClassPath insertClassPath(String pathname) throws NotFoundException
+ {
+ return delegate.insertClassPath(pathname);
+ }
+
+ @Override
+ public ClassPath appendClassPath(String pathname) throws NotFoundException
+ {
+ return delegate.appendClassPath(pathname);
+ }
+
+ @Override
+ public void removeClassPath(ClassPath cp)
+ {
+ delegate.removeClassPath(cp);
+ }
+
+ @Override
+ public void appendPathList(String pathlist) throws NotFoundException
+ {
+ delegate.appendPathList(pathlist);
+ }
+
+ @Override
+ public Class<?> toClass(CtClass clazz) throws CannotCompileException
+ {
+ return delegate.toClass(clazz);
+ }
+
+ @Override
+ public ClassLoader getClassLoader()
+ {
+ return delegate.getClassLoader();
+ }
+
+ @Override
+ @SuppressWarnings("deprecation")
+ public Class<?> toClass(CtClass ct, ClassLoader loader) throws CannotCompileException
+ {
+ return delegate.toClass(ct, loader);
+ }
+
+ @Override
+ public Class<?> toClass(CtClass ct, ClassLoader loader, ProtectionDomain domain)
+ throws CannotCompileException
+ {
+ return delegate.toClass(ct, loader, domain);
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/FilteredClassPool.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/JBossCLFactory.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/JBossCLFactory.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/JBossCLFactory.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,211 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.classpool.jbosscl.support;
+
+import java.util.Collection;
+import java.util.Map;
+
+import junit.framework.Assert;
+
+import org.jboss.classloader.spi.ClassLoaderDomain;
+import org.jboss.classloader.spi.ClassLoaderSystem;
+import org.jboss.classloader.spi.base.BaseClassLoader;
+import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory;
+import org.jboss.classpool.plugins.jbosscl.VFSClassLoaderDomainRegistry;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.logging.Logger;
+import org.jboss.test.AbstractTestCase;
+import org.jboss.test.classpool.support.ClassLoaderFactory;
+import org.jboss.test.classpool.support.MicrocontainerFacade;
+
+/**
+ * Creates JBoss Class Loaders (AS5 and newer).
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.org">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class JBossCLFactory implements ClassLoaderFactory<CLDeploymentBuilder>
+{
+ /** The classloader helper */
+ protected ClassLoaderSystem system;
+ /** The domain registry */
+ protected VFSClassLoaderDomainRegistry domainRegistry;
+ /** The Microcontanier Facade */
+ private MicrocontainerFacade microcontainer;
+ /** The loader registry */
+ private LoaderRegistry loaderRegistry;
+
+
+ /**
+ * Constructor.
+ *
+ * @param mc used by this test to perform deploy/undeploy operations
+ */
+ public JBossCLFactory(MicrocontainerFacade mc)
+ {
+ this.microcontainer = mc;
+ this.system = (ClassLoaderSystem) mc.getBean("ClassLoaderSystem");
+ domainRegistry = (VFSClassLoaderDomainRegistry) mc.getBean("ClassLoaderScopingPolicy");
+ this.loaderRegistry = new LoaderRegistry(mc);
+ }
+
+ public synchronized ClassLoader create(CLDeploymentBuilder classLoaderBuilder) throws Exception
+ {
+ KernelDeployment deployment = classLoaderBuilder.createDeployment();
+ microcontainer.deploy(deployment);
+ VFSClassLoaderFactory factory = classLoaderBuilder.getMetaDataFactory();
+ factory.setContextName(getContextName(factory));
+ loaderRegistry.registerDeployment(classLoaderBuilder);
+ return retrieve(classLoaderBuilder);
+ }
+
+ public synchronized void destroy(CLDeploymentBuilder classLoaderBuilder) throws Exception
+ {
+ loaderRegistry.unregisterDeployment(classLoaderBuilder);
+ microcontainer.undeploy(classLoaderBuilder.undeploy());
+ isAvailable(classLoaderBuilder);
+ }
+
+ public synchronized void destroyAll()
+ {
+ destroyClassLoaders();
+ unregisterDomains();
+ assertCannotLoadSupportClasses();
+ }
+
+ public synchronized ClassLoader retrieve(CLDeploymentBuilder classLoaderBuilder) throws Exception
+ {
+ VFSClassLoaderFactory factory = classLoaderBuilder.getMetaDataFactory();
+ try
+ {
+ Object obj = microcontainer.getBean(factory.getContextName());
+ Assert.assertTrue(obj instanceof ClassLoader);
+ ClassLoader classLoader = (ClassLoader) obj;
+ loaderRegistry.registerClassLoader(classLoader, classLoaderBuilder);
+ return classLoader;
+ }
+ catch (IllegalStateException e)
+ {
+ throw new NoSuchClassLoaderException(e);
+ }
+ }
+
+ public synchronized Collection<ClassLoader> retrieveAll()
+ {
+ return loaderRegistry.getClassLoaders();
+ }
+
+ public synchronized boolean isAvailable(CLDeploymentBuilder classLoaderBuilder) throws Exception
+ {
+ String name = getContextName(classLoaderBuilder.getMetaDataFactory());
+ try
+ {
+ Object bean = microcontainer.getBean(name, null);
+ return bean != null;
+ }
+ catch (Throwable t)
+ {
+ AbstractTestCase.checkThrowable(IllegalStateException.class, t);
+ return false;
+ }
+ }
+
+ /************* HELPER METHODS **********************************************************/
+
+ private void assertCannotLoadSupportClasses()
+ {
+ ClassLoaderDomain domain = system.getDefaultDomain();
+ for (String className: SupportClasses.getAllSupportClasses())
+ {
+ try
+ {
+ Class<?> clazz = domain.loadClass(className);
+ if (clazz == null)
+ {
+ continue;
+ }
+ Assert.fail("Should not have been able to load " + className);
+ }
+ catch(Exception expected)
+ {
+ }
+ }
+ }
+
+ private void unregisterDomains()
+ {
+ for(Map.Entry<String, ClassLoaderDomain> entry: DomainRegistry.clear().entrySet())
+ {
+ ClassLoaderDomain domain = entry.getValue();
+ if (domain != null)
+ {
+ Logger.getLogger(AbstractTestCase.class).debug("Unregistering domain " + domain);
+ ClassLoaderDomain registeredDomain = system.getDomain(domain.getName());
+ if (registeredDomain == null)
+ throw new IllegalStateException("Domain is not registered: " + domain.getName());
+ if (registeredDomain != domain)
+ throw new IllegalStateException(domain + " is not the same as " + registeredDomain);
+ }
+ else
+ {
+ domain = system.getDomain(entry.getKey());
+ if (domain == null)
+ {
+ continue;
+ }
+ }
+ system.unregisterDomain(domain);
+ }
+ }
+
+ private void destroyClassLoaders()
+ {
+ for (ClassLoader classLoader: loaderRegistry.getClassLoaders())
+ {
+ destroy(classLoader);
+ try
+ {
+ Object bean = microcontainer.getBean(((BaseClassLoader) classLoader).getName(), null);
+ if (bean != null)
+ Assert.fail("Should not be here: " + bean);
+ }
+ catch (Throwable t)
+ {
+ AbstractTestCase.checkThrowable(IllegalStateException.class, t);
+ }
+ }
+ }
+
+ protected void destroy(ClassLoader classLoader)
+ {
+ KernelDeployment deployment = loaderRegistry.unregisterDeployment(classLoader);
+ microcontainer.undeploy(deployment);
+ }
+
+ private String getContextName(VFSClassLoaderFactory factory)
+ {
+ String contextName = factory.getContextName();
+ if (contextName == null)
+ contextName = factory.getName() + ":" + factory.getVersion();
+ return contextName;
+ }
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/JBossCLFactory.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/LoaderRegistry.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/LoaderRegistry.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/LoaderRegistry.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,161 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.classpool.jbosscl.support;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import junit.framework.Assert;
+
+import org.jboss.classloader.spi.ClassLoaderDomain;
+import org.jboss.classloader.spi.ClassLoaderSystem;
+import org.jboss.classloader.spi.base.BaseClassLoader;
+import org.jboss.classloading.spi.dependency.Module;
+import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory;
+import org.jboss.classpool.plugins.jbosscl.VFSClassLoaderDomainRegistry;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.logging.Logger;
+import org.jboss.test.AbstractTestCase;
+import org.jboss.test.classpool.support.MicrocontainerFacade;
+
+/**
+ * Registry used by TestScenario to keep track of created class loaders and to perform
+ * proper cleanup.
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.org">Flavia Rainone</a>
+ * @version $Revision$
+ */
+class LoaderRegistry
+{
+ /** The classloader helper */
+ protected ClassLoaderSystem system;
+
+ /** The domain registry */
+ protected VFSClassLoaderDomainRegistry domainRegistry;
+
+ /** The microcontainer facade */
+ private MicrocontainerFacade microcontainer;
+
+ /**
+ * Contains the same domains contained in domainRegistry. The difference is that
+ * this map is cleaned up later than domainRegistry.
+ */
+ private Map<ClassLoader, ClassLoaderDomain> scopedChildDomainsByLoader = new WeakHashMap<ClassLoader, ClassLoaderDomain>();
+
+ /** List of classLoaders */
+ private Map<String, ClassLoader> classLoaders = new HashMap<String, ClassLoader>();
+
+ /** Deployments */
+ private Map<String, KernelDeployment> deploymentsByName = new HashMap<String, KernelDeployment>();
+
+ /**
+ * Constructor.
+ *
+ * @param microcontainer necessary for retrieval of mc beans
+ */
+ public LoaderRegistry(MicrocontainerFacade microcontainer)
+ {
+ this.microcontainer = microcontainer;
+ this.system = (ClassLoaderSystem) microcontainer.getBean("ClassLoaderSystem");
+ this.domainRegistry = (VFSClassLoaderDomainRegistry) microcontainer.getBean(
+ "ClassLoaderScopingPolicy");
+ }
+
+ public synchronized void registerDeployment(CLDeploymentBuilder clDeploymentBuilder)
+ {
+ KernelDeployment deployment = clDeploymentBuilder.getDeployment();
+ VFSClassLoaderFactory factory = clDeploymentBuilder.getMetaDataFactory();
+ deploymentsByName.put(factory.getContextName() + "$MODULE", deployment);
+ String domainName = factory.getDomain();
+ if (clDeploymentBuilder.isDomainCreated())
+ {
+ ClassLoaderDomain domain = system.getDomain(domainName);
+ if (domain != null)
+ {
+ Logger.getLogger(AbstractTestCase.class).debug("Registering domain " + domain);
+ DomainRegistry.registerDomain(domain);
+ if (factory.getParentDomain() == null ||
+ factory.getParentDomain().equals(ClassLoaderSystem.DEFAULT_DOMAIN_NAME))
+ {
+ Assert.assertNull(domain.getParentDomain());
+ }
+ else
+ {
+ Assert.assertNotNull(domain.getParentDomainName());
+ Assert.assertEquals(factory.getParentDomain(), domain.getParentDomainName());
+ }
+ }
+ }
+ }
+
+ public synchronized void registerClassLoader(ClassLoader classLoader, CLDeploymentBuilder clDeploymentBuilder)
+ {
+ VFSClassLoaderFactory factory = clDeploymentBuilder.getMetaDataFactory();
+ String name = factory.getContextName() + "$MODULE";
+ Module module = microcontainer.assertBean(name, Module.class);
+ domainRegistry.initMapsForModule(module);
+ scopedChildDomainsByLoader.put(classLoader, system.getDomain(factory.getDomain()));
+ classLoaders.put(name, classLoader);
+ }
+
+ public synchronized void unregisterDeployment(CLDeploymentBuilder clDeploymentBuilder) throws Exception
+ {
+ String contextName = clDeploymentBuilder.getMetaDataFactory().getContextName();
+ String name = contextName + "$MODULE";
+ ClassLoader classLoader = (ClassLoader) microcontainer.getBean(contextName);
+ deploymentsByName.remove(name);
+ scopedChildDomainsByLoader.remove(classLoader);
+ classLoaders.remove(name);
+ if (clDeploymentBuilder.isDomainCreated())
+ {
+ ClassLoaderDomain domain = scopedChildDomainsByLoader.get(classLoader);
+ if (domain != null)
+ {
+ DomainRegistry.registerDomain(domain.getName());
+ system.unregisterDomain(domain);
+ }
+ }
+ }
+
+ public synchronized KernelDeployment unregisterDeployment(ClassLoader classLoader)
+ {
+ String name = ((BaseClassLoader) classLoader).getName();
+ classLoaders.remove(name);
+ return deploymentsByName.remove(name);
+ }
+
+ public synchronized Collection<ClassLoader> getClassLoaders()
+ {
+ return new ArrayList<ClassLoader>(classLoaders.values());
+ }
+
+ public synchronized ClassLoaderDomain getDomainForClassLoader(ClassLoader loader)
+ {
+ //(scopedChildDomainsByLoader.get(loader) != domainRegistry.getClassLoaderDomainForLoader(loader))
+ // this statement is true only when the module has already been cleaned up from domainRegistry
+ // that's why we need another collection here
+ return scopedChildDomainsByLoader.get(loader);
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/LoaderRegistry.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/NoMatchClassFilter.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/NoMatchClassFilter.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/NoMatchClassFilter.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,70 @@
+/*
+ * 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.test.classpool.jbosscl.support;
+
+import org.jboss.classloader.plugins.ClassLoaderUtils;
+import org.jboss.classloader.spi.filter.ClassFilter;
+
+/**
+ * NoMatchClassFilter.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision$
+ */
+public class NoMatchClassFilter implements ClassFilter
+{
+ String className;
+
+ public boolean filtered = false;
+
+ public NoMatchClassFilter(String classname)
+ {
+ this.className = classname;
+ }
+
+ public boolean matchesClassName(String className)
+ {
+ if (this.className.equals(className))
+ {
+ filtered = true;
+ return false;
+ }
+ return true;
+ }
+
+ public boolean matchesResourcePath(String resourcePath)
+ {
+ if (ClassLoaderUtils.classNameToPath(this.className).equals(resourcePath))
+ {
+ filtered = true;
+ return false;
+ }
+ return true;
+ }
+
+ public boolean matchesPackageName(String packageName)
+ {
+ if (ClassLoaderUtils.getClassPackageName(this.className).equals(packageName))
+ return false;
+ return true;
+ }
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/NoMatchClassFilter.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/NoSuchClassLoaderException.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/NoSuchClassLoaderException.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/NoSuchClassLoaderException.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.classpool.jbosscl.support;
+
+/**
+ * Indicates that a class loader is not completely deployed.
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class NoSuchClassLoaderException extends Exception
+{
+ private static final long serialVersionUID = 1873358454130997423L;
+
+ public NoSuchClassLoaderException(Exception e)
+ {
+ super(e);
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/NoSuchClassLoaderException.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/SupportArchives.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/SupportArchives.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/SupportArchives.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,137 @@
+package org.jboss.test.classpool.jbosscl.support;
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.
+ */
+
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+
+/**
+ * Contains the name of the support archives.
+ *
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class SupportArchives
+{
+ private static final String UTIL_JAR = "lib/util.jar";
+ private static final String EXT_JAR = "lib/ext.jar";
+ private static final String UI_JAR = "lib/ui.jar";
+ private static final String UI_UTIL_JAR = "lib/ui_util.jar";
+ private static String WAR_CP = "/WEB-INF/classes";
+
+ /************ ARCHIVE NAMES *************************************************************/
+
+ public final static String JAR_A = "a.jar";
+ public final static String JAR_B = "b.jar";
+ public final static String JAR_C = "c.jar";
+ public final static String JAR_D = "d.jar";
+ public final static String SIMPLE_JAR = "simple.jar";
+ public final static String SIMPLE_SAR = "simple.sar";
+ public final static String EJB_JAR = "ejbs.jar";
+ public final static String SIMPLE_WAR = "simple.war";
+ public final static String SIMPLE_EAR = "simple.ear";
+ public final static String SIMPLE_EAR_JAR = SIMPLE_EAR + '/' + SIMPLE_JAR;
+ public final static String SIMPLE_EAR_SAR = SIMPLE_EAR + '/' + SIMPLE_SAR;
+ public final static String SIMPLE_EAR_EJB = SIMPLE_EAR + '/' + EJB_JAR;
+ public final static String SIMPLE_EAR_LIB1 = SIMPLE_EAR + '/' + UTIL_JAR;
+ public final static String SIMPLE_EAR_LIB2 = SIMPLE_EAR + '/' + EXT_JAR;
+ public final static String SIMPLE_EAR_WAR1 = SIMPLE_EAR + "/simple_ui.war";
+ public final static String SIMPLE_EAR_WAR1_LIB = SIMPLE_EAR_WAR1 + "/WEB-INF/" + UI_JAR;
+ public final static String SIMPLE_EAR_WAR2 = SIMPLE_EAR + "/jsfapp.war";
+ public final static String SIMPLE_EAR_WAR2_LIB = SIMPLE_EAR_WAR2 + "/WEB-INF/" + UI_UTIL_JAR;
+ public final static String TOP_EAR = "top-level.ear";
+ public final static String TOP_EAR_UTIL = TOP_EAR + '/' + UTIL_JAR;
+ public final static String TOP_EAR_EXT = TOP_EAR + '/' + EXT_JAR;
+ public final static String WAR_IN_EAR = "war-in-ear.ear";
+ public final static String WAR_IN_EAR_WAR = WAR_IN_EAR + '/' + SIMPLE_WAR;
+ public final static String JAR_IN_EAR = "jar-in-ear.ear";
+ public final static String JAR_IN_EAR_JAR = JAR_IN_EAR + '/' + SIMPLE_JAR;
+ public final static String SERVLET_JAR = "servlet.jar";
+ public final static String PTD_EAR = "ptd-ear-1.0-SNAPSHOT.ear";
+ public final static String PTD_EAR_LIB = PTD_EAR + "/lib/common.jar";
+ public final static String PTD_JSF_WAR = PTD_EAR + "/ptd-jsf-1.0-SNAPSHOT.war";
+ public final static String PTD_JSF_WAR_LIB = PTD_JSF_WAR + "/WEB-INF/lib/wj1.jar";
+ public final static String PTD_WS_WAR = PTD_EAR + "/ptd-ws-1.0-SNAPSHOT.war";
+ public final static String PTD_WS_WAR_LIB = PTD_WS_WAR + "/WEB-INF/lib/wj2.jar";
+ public final static String PARENT_JAR = "replacereferences-parent.jar";
+ public final static String CHILD_JAR = "replacereferences-child.jar";
+ // TODO JBREFLECT-80
+ //public final static String EXCLUDED_CLASSPATH = "../test-classes";
+ public final static String EXCLUDED_CLASSPATH = "../test-excluded-classes";
+
+ /************ CLASSPATH URLS ************************************************************/
+
+ public final static URL JAR_A_URL = getURL(JAR_A);
+ public final static URL JAR_B_URL = getURL(JAR_B);
+ public final static URL JAR_C_URL = getURL(JAR_C);
+ public final static URL JAR_D_URL = getURL(JAR_D);
+ public final static URL SIMPLE_JAR_URL = getURL(SIMPLE_JAR);
+ public final static URL SIMPLE_SAR_URL = getURL(SIMPLE_SAR);
+ public final static URL EJB_JAR_URL = getURL(EJB_JAR);
+ public final static URL SIMPLE_WAR_CP_URL = getURL(SIMPLE_WAR + WAR_CP);
+ public final static URL SIMPLE_EAR_JAR_URL = getURL(SIMPLE_EAR_JAR);
+ public final static URL SIMPLE_EAR_SAR_URL = getURL(SIMPLE_EAR_SAR);
+ public final static URL SIMPLE_EAR_EJB_URL = getURL(SIMPLE_EAR_EJB);
+ public final static URL SIMPLE_EAR_LIB1_URL = getURL(SIMPLE_EAR_LIB1);
+ public final static URL SIMPLE_EAR_LIB2_URL = getURL(SIMPLE_EAR_LIB2);
+ public final static URL SIMPLE_EAR_WAR1_URL = getURL(SIMPLE_EAR_WAR1);
+ public final static URL SIMPLE_EAR_WAR1_CP_URL = getURL(SIMPLE_EAR_WAR1 + WAR_CP);
+ public final static URL SIMPLE_EAR_WAR1_LIB_URL = getURL(SIMPLE_EAR_WAR1_LIB);
+ public final static URL SIMPLE_EAR_WAR2_URL = getURL(SIMPLE_EAR_WAR2);
+ public final static URL SIMPLE_EAR_WAR2_CP_URL = getURL(SIMPLE_EAR_WAR2 + WAR_CP);
+ public final static URL SIMPLE_EAR_WAR2_LIB_URL = getURL(SIMPLE_EAR_WAR2_LIB);
+ public final static URL TOP_EAR_UTIL_URL = getURL(TOP_EAR_UTIL);
+ public final static URL TOP_EAR_EXT_URL = getURL(TOP_EAR_EXT);
+ public final static URL WAR_IN_EAR_WAR_URL = getURL(WAR_IN_EAR_WAR);
+ public final static URL WAR_IN_EAR_WAR_CP = getURL(WAR_IN_EAR_WAR + WAR_CP);
+ public final static URL JAR_IN_EAR_JAR_URL = getURL(JAR_IN_EAR_JAR);
+ public final static URL SERVLET_JAR_URL = getURL(SERVLET_JAR);
+ public final static URL PTD_EAR_LIB_URL = getURL(PTD_EAR_LIB);
+ public final static URL PTD_JSF_WAR_URL = getURL(PTD_JSF_WAR);
+ public final static URL PTD_JSF_WAR_LIB_URL = getURL(PTD_JSF_WAR_LIB);
+ public final static URL PTD_WS_WAR_URL = getURL(PTD_WS_WAR);
+ public final static URL PTD_WS_WAR_LIB_URL = getURL(PTD_WS_WAR_LIB);
+ public final static URL EXCLUDED_CLASSPATH_URL = getURL(EXCLUDED_CLASSPATH);
+ public final static URL PARENT_JAR_URL = getURL(PARENT_JAR);
+ public final static URL CHILD_JAR_URL = getURL(CHILD_JAR);
+
+ /** Returns the relative URL to the project root */
+ private static URL getURL(String relativePath)
+ {
+ try
+ {
+ URL url = SupportArchives.class.getProtectionDomain().getCodeSource().getLocation();
+ String location = url.toString();
+ int index = location.lastIndexOf("/target/") + "/target/".length();
+ location = location.substring(0, index) + "archives/";
+
+ location = location + relativePath;
+ return new URL(location);
+ }
+ catch (MalformedURLException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/SupportArchives.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/SupportClasses.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/SupportClasses.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/SupportClasses.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,82 @@
+package org.jboss.test.classpool.jbosscl.support;
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.
+ */
+
+
+
+
+/**
+ * Contains the name of all support classes.
+ *
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class SupportClasses
+{
+ public static final String PACKAGE_ROOT = SupportClasses.class.getPackage().getName() + ".excluded";
+ public final static String PACKAGE_A = PACKAGE_ROOT + ".a";
+ public final static String PACKAGE_B = PACKAGE_ROOT + ".b";
+ public final static String PACKAGE_C = PACKAGE_ROOT + ".c";
+ public final static String PACKAGE_D = PACKAGE_ROOT + ".d";
+ public final static String PACKAGE_JAR = PACKAGE_ROOT + ".jar";
+ public final static String PACKAGE_SAR = PACKAGE_ROOT + ".service";
+ public final static String PACKAGE_EJB = PACKAGE_ROOT + ".ejb";
+ public final static String PACKAGE_WEB = PACKAGE_ROOT + ".web";
+ public final static String PACKAGE_JSF = PACKAGE_ROOT + ".jsf";
+ public final static String PACKAGE_UTIL = PACKAGE_ROOT + ".util";
+ public final static String PACKAGE_EXT = PACKAGE_ROOT + ".ext";
+ public final static String PACKAGE_UI = PACKAGE_ROOT + ".ui";
+ public final static String PACKAGE_CRM = PACKAGE_ROOT + ".crm";
+ public final static String PACKAGE_TIF = PACKAGE_ROOT + ".tif";
+
+ public final static String CLASS_A = PACKAGE_A + ".A";
+ public final static String CLASS_B = PACKAGE_B + ".B";
+ public final static String CLASS_C = PACKAGE_C + ".C";
+ public final static String CLASS_D = PACKAGE_D + ".D";
+ public final static String CLASS_PLAIN = PACKAGE_JAR + ".PlainJavaBean";
+ public final static String CLASS_MBEAN = PACKAGE_SAR + ".SomeMBean";
+ public final static String CLASS_SLS_BEAN = PACKAGE_EJB + ".MySLSBean";
+ public final static String CLASS_SLS_INTERFACE = PACKAGE_EJB + ".BusinessInterface";
+ public final static String CLASS_SERVLET = PACKAGE_WEB + ".AnyServlet";
+ public final static String CLASS_JSF = PACKAGE_JSF + ".JsfBean";
+ public final static String CLASS_UTIL = PACKAGE_UTIL + ".SomeUtil";
+ public final static String CLASS_EXT = PACKAGE_EXT + ".External";
+ public final static String CLASS_UI = PACKAGE_UI + ".UIBean";
+ public final static String CLASS_CRM = PACKAGE_CRM + ".CrmFacade";
+ public final static String CLASS_TIF = PACKAGE_TIF + ".TIFTester";
+
+ private static final String[] SUPPORT_CLASSES = new String[]{CLASS_A, CLASS_B, CLASS_C,
+ CLASS_D, CLASS_PLAIN, CLASS_MBEAN, CLASS_SLS_BEAN, CLASS_SLS_INTERFACE, CLASS_SERVLET,
+ CLASS_JSF, CLASS_UTIL, CLASS_EXT, CLASS_UI, CLASS_CRM, CLASS_TIF};
+
+ public static final String[] getAllSupportClasses()
+ {
+ return SUPPORT_CLASSES;
+ }
+
+ public final static String PACKAGE_REPLACEMENT = PACKAGE_ROOT + ".replacereferences";
+ public final static String PACKAGE_REPLACEMENT_CHILD = PACKAGE_REPLACEMENT + ".child";
+ public final static String PACKAGE_REPLACEMENT_PARENT = PACKAGE_REPLACEMENT + ".parent";
+ public final static String CLASS_INVOKED = PACKAGE_REPLACEMENT + ".Invoked";
+ public final static String CLASS_PARENT_CALLER = PACKAGE_REPLACEMENT_PARENT + ".ParentCaller";
+ public final static String CLASS_CHILD_CALLER = PACKAGE_REPLACEMENT_CHILD + ".ChildCaller";
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/SupportClasses.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/TestVFSClassLoaderFactory.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/TestVFSClassLoaderFactory.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/TestVFSClassLoaderFactory.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,128 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.test.classpool.jbosscl.support;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.classloader.spi.ClassLoaderSystem;
+import org.jboss.classloading.spi.vfs.dependency.VFSClassLoaderPolicyModule;
+import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory;
+
+/**
+ * VFSClassLoaderFactory used by the tests
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+class TestVFSClassLoaderFactory extends VFSClassLoaderFactory
+{
+ private static final long serialVersionUID = 1L;
+
+ private ClassLoader parent;
+ private List<String> excludedRoots;
+
+ @Override
+ protected Class<? extends VFSClassLoaderPolicyModule> getModuleClass()
+ {
+ return TestVFSClassLoaderPolicyModule.class;
+ }
+
+ public void setParent(ClassLoader parent)
+ {
+ this.parent = parent;
+ }
+
+ public void setExcludedRoots(List<String> excludedRoots)
+ {
+ this.excludedRoots = excludedRoots;
+ }
+
+ @Override
+ public List<BeanMetaData> getBeans()
+ {
+
+ List<BeanMetaData> result = super.getBeans();
+ boolean overwriteClassLoader = parent != null;
+ boolean overwriteModule = this.excludedRoots != null && !this.excludedRoots.isEmpty();
+ if (overwriteClassLoader || overwriteModule)
+ {
+ //We need to modify the Module factory method used to create the classloader to pass in the parent
+ if (result.size() != 2)
+ {
+ throw new IllegalStateException("Expected size=2, was " + result.size());
+ }
+
+ BeanMetaData classLoader = null;
+ BeanMetaData module = null;
+ for (BeanMetaData bean : result)
+ {
+ if (bean.getBean().equals(ClassLoader.class.getName()))
+ {
+ classLoader = bean;
+ }
+ else
+ {
+ module = bean;
+ }
+ }
+
+ if (module == null)
+ {
+ throw new IllegalStateException("Could not find module");
+ }
+ if (classLoader == null)
+ {
+ throw new IllegalStateException("Could not find module");
+ }
+ String moduleName = module.getName();
+
+ if (overwriteClassLoader)
+ {
+ BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(classLoader.getName(), ClassLoader.class.getName());
+ builder.setNoClassLoader();
+ builder.setFactory(module.getName());
+ builder.setFactoryMethod("registerClassLoaderPolicy");
+ builder.addConstructorParameter(ClassLoaderSystem.class.getName(), builder.createInject(getClassLoaderSystemName()));
+ builder.addConstructorParameter(ClassLoader.class.getName(), parent);
+ classLoader = builder.getBeanMetaData();
+ }
+ if (overwriteModule)
+ {
+ // Create the module
+ BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(moduleName, getModuleClass().getName());
+ builder.addConstructorParameter(VFSClassLoaderFactory.class.getName(), this);
+ builder.addConstructorParameter(String.class.getName(), moduleName);
+ builder.addPropertyMetaData("roots", getRoots());
+ builder.addPropertyMetaData("excludedRoots", this.excludedRoots);
+ builder.setNoClassLoader();
+ builder.addUninstall("removeClassLoader");
+ module = builder.getBeanMetaData();
+ }
+ result = Arrays.asList(classLoader, module);
+ }
+ return result;
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/TestVFSClassLoaderFactory.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/TestVFSClassLoaderPolicyModule.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/TestVFSClassLoaderPolicyModule.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/TestVFSClassLoaderPolicyModule.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,248 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.test.classpool.jbosscl.support;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.jboss.classloading.spi.vfs.dependency.VFSClassLoaderPolicyModule;
+import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory;
+import org.jboss.classloading.spi.vfs.policy.VFSClassLoaderPolicy;
+import org.jboss.util.id.GUID;
+import org.jboss.virtual.MemoryFileFactory;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * VFSClassLoaderPolicyModule used by tests.
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class TestVFSClassLoaderPolicyModule extends VFSClassLoaderPolicyModule
+{
+ private static final long serialVersionUID = 1;
+
+
+ /** In AS we need a URL to create the temporary files */
+ URL dynamicClassRoot;
+ VirtualFile classes;
+ private List<String> excludedRoots;
+
+ public TestVFSClassLoaderPolicyModule(VFSClassLoaderFactory classLoadingMetaData, String contextName)
+ {
+ // FIXME TestMockClassLoaderPolicyModule constructor
+ super(classLoadingMetaData, contextName);
+ }
+
+ public void setExcludedRoots(List<String> excludedRoots)
+ {
+ this.excludedRoots = excludedRoots;
+ }
+
+ /**
+ * Get/Create the vfs memory file where we will create dynamic classes
+ */
+ @Override
+ public URL getDynamicClassRoot()
+ {
+ initDynamicClassRoot();
+ return dynamicClassRoot;
+ }
+
+ /**
+ * Prepend the dynamic URL location to the classpath
+ */
+ @Override
+ protected VirtualFile[] determineVFSRoots()
+ {
+ initDynamicClassRoot();
+ Map<Integer, String> truncatedRootPaths = truncateArchiveNestedPaths(this.getRoots());
+ VirtualFile[] roots = super.determineVFSRoots();
+ restoreArchiveNestedPaths(truncatedRootPaths, roots);
+ VirtualFile[] newRoots = new VirtualFile[roots.length + 1];
+ newRoots[0] = classes;
+ System.arraycopy(roots, 0, newRoots, 1, roots.length);
+ return newRoots;
+ }
+
+ @Override
+ // FIXME code copied from determinePolicy method in super class
+ protected VFSClassLoaderPolicy determinePolicy()
+ {
+ VirtualFile[] roots = determineVFSRoots();
+
+ // these are the only lines that are different from super class's determinePolicy()
+ VirtualFile[] excludedRoots = determineVFSExcludedRoots();
+ VFSClassLoaderPolicy policy = VFSClassLoaderPolicy.createVFSClassLoaderPolicy(
+ getContextName(), roots, excludedRoots);
+
+ String[] packageNames = getPackageNames();
+ policy.setExportedPackages(packageNames);
+ policy.setIncluded(getIncluded());
+ policy.setExcluded(getExcluded());
+ policy.setExcludedExport(getExcludedExport());
+ policy.setExportAll(getExportAll());
+ policy.setImportAll(isImportAll());
+ policy.setCacheable(isCacheable());
+ policy.setBlackListable(isBlackListable());
+ policy.setDelegates(getDelegates());
+ return policy;
+ }
+
+ protected VirtualFile[] determineVFSExcludedRoots()
+ {
+ if (this.excludedRoots == null || this.excludedRoots.isEmpty())
+ {
+ return new VirtualFile[0];
+ }
+ Map<Integer, String> truncatedRootPaths = truncateArchiveNestedPaths(this.excludedRoots);
+ VirtualFile[] roots = determineVFSRoots(this.excludedRoots);
+ restoreArchiveNestedPaths(truncatedRootPaths, roots);
+ return roots;
+ }
+
+ // FIXME: code copied from determineVFSRoots method in superclass
+ protected VirtualFile[] determineVFSRoots(List<String> roots)
+ {
+ if (roots == null)
+ {
+ return new VirtualFile[0];
+ }
+ VirtualFile[] vfsRoots = new VirtualFile[roots.size()];
+ for (int i = 0; i < roots.size(); ++i)
+ {
+ String root = roots.get(i);
+ try
+ {
+ URI uri = new URI(root);
+ vfsRoots[i] = getVirtualFile(uri);
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Error creating VFS file for " + root, e);
+ }
+ }
+ return vfsRoots;
+ }
+
+ private synchronized void initDynamicClassRoot()
+ {
+ if (dynamicClassRoot == null)
+ {
+ try
+ {
+ dynamicClassRoot = new URL("vfsmemory", GUID.asString(), "");
+ classes = MemoryFileFactory.createRoot(dynamicClassRoot).getRoot();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ /**
+ * This method truncated nested archives classpath.
+ * For example, the "/home/user_name/jboss-classpool/target/mywar.war/META-INF/classes"
+ * is replaced by "/home/user_name/jboss-classpool/target/mywar.war"
+ * The truncation is only performed on paths that involve subdirectories of archive files.
+ *
+ * @param paths a list of paths. After this method is executed, this list will contain the
+ * truncated paths
+ * @return a map that can be used to restore the truncated paths by invoking
+ * {@code #restoreArchiveNestedPaths(Map, VirtualFile[])}
+ */
+ private Map<Integer, String> truncateArchiveNestedPaths(List<String> paths)
+ {
+ Map<Integer, String> truncatedRootPaths = new HashMap<Integer, String>();
+ for (ListIterator<String> listIterator = paths.listIterator(); listIterator.hasNext();)
+ {
+ int rootIndex = listIterator.nextIndex();
+ String root = listIterator.next();
+ int archiveIndex = root.indexOf('.');
+ int lastSlash = archiveIndex > 0? root.indexOf('/', archiveIndex): -1;
+ if (lastSlash > 0)
+ {
+ listIterator.set(root.substring(0, lastSlash));
+ root = root.substring(lastSlash + 1);
+ if (root != null)
+ {
+ truncatedRootPaths.put(rootIndex, root);
+ }
+ }
+ }
+ return truncatedRootPaths;
+ }
+
+ /**
+ * Restores the truncated paths.
+ *
+ * @param truncatedPaths the result of a previous truncation
+ * ({@see #truncateArchiveNestedPaths(List)}).
+ * @param paths a list of virtual files representing the truncated paths. Every virtual file
+ * in this array that corresponds to a previously truncated path will be
+ * replaced the virtual file that represent the original path.
+ */
+ private void restoreArchiveNestedPaths(
+ Map<Integer, String> truncatedPaths, VirtualFile[] paths)
+ {
+ for (Entry<Integer, String> truncatedPath: truncatedPaths.entrySet())
+ {
+ int pathIndex = truncatedPath.getKey();
+ VirtualFile file = paths[pathIndex];
+ String path = truncatedPath.getValue();
+ do
+ {
+ int archiveIndex = path.indexOf('.');
+ int lastSlash = archiveIndex > 0? path.indexOf('/', archiveIndex): -1;
+ try
+ {
+ if (lastSlash > 0)
+ {
+ file = file.getChild(path.substring(0, lastSlash));
+ path = path.substring(lastSlash + 1);
+ }
+ else
+ {
+ file = file.getChild(path);
+ path = null;
+ }
+ } catch (IOException e)
+ {
+ throw new RuntimeException("Can't find path " + path + " on root " + file, e);
+ }
+ } while(path != null);
+ paths[pathIndex] = file;
+ }
+ }
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/TestVFSClassLoaderPolicyModule.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/a/A.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/a/A.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/a/A.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.test.classpool.jbosscl.support.excluded.a;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class A
+{
+
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/a/A.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/b/B.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/b/B.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/b/B.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.test.classpool.jbosscl.support.excluded.b;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class B
+{
+
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/b/B.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/c/C.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/c/C.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/c/C.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.test.classpool.jbosscl.support.excluded.c;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class C
+{
+
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/c/C.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/crm/CrmFacade.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/crm/CrmFacade.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/crm/CrmFacade.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.test.classpool.jbosscl.support.excluded.crm;
+
+/**
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.org">Flavia Rainone</a>
+ *
+ * @version $Revision$
+ */
+public class CrmFacade
+{
+
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/crm/CrmFacade.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/d/D.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/d/D.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/d/D.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+
+ * Copyright 2006, 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.test.classpool.jbosscl.support.excluded.d;
+
+import org.jboss.test.classpool.jbosscl.support.excluded.b.B;
+
+
+
+/**
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ *
+ * @version $Revision$
+ */
+public class D
+{
+ public B getB()
+ {
+ return new B();
+ }
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/d/D.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/ejb/BusinessInterface.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/ejb/BusinessInterface.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/ejb/BusinessInterface.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.test.classpool.jbosscl.support.excluded.ejb;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ *
+ * @version $Revision$
+ */
+public interface BusinessInterface
+{
+ int add(int x, int y);
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/ejb/BusinessInterface.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/ejb/MySLSBean.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/ejb/MySLSBean.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/ejb/MySLSBean.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.test.classpool.jbosscl.support.excluded.ejb;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ *
+ * @version $Revision$
+ */
+public class MySLSBean implements BusinessInterface
+{
+ public int add(int x, int y)
+ {
+ return x + y;
+ }
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/ejb/MySLSBean.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/ext/External.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/ext/External.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/ext/External.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.test.classpool.jbosscl.support.excluded.ext;
+
+/**
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ *
+ * @version $Revision$
+ */
+public class External
+{
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/ext/External.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/jar/PlainJavaBean.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/jar/PlainJavaBean.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/jar/PlainJavaBean.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.test.classpool.jbosscl.support.excluded.jar;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ *
+ * @version $Revision$
+ */
+public class PlainJavaBean
+{
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/jar/PlainJavaBean.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/jsf/JsfBean.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/jsf/JsfBean.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/jsf/JsfBean.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.test.classpool.jbosscl.support.excluded.jsf;
+
+
+/**
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.org">Flavia Rainone</a>
+ *
+ * @version $Revision$
+ */
+public class JsfBean
+{
+
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/jsf/JsfBean.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/replacereferences/Invoked.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/replacereferences/Invoked.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/replacereferences/Invoked.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,39 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.test.classpool.jbosscl.support.excluded.replacereferences;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class Invoked
+{
+ public static boolean invoked;
+
+ public static boolean getAndReset()
+ {
+ boolean inv = invoked;
+ invoked = false;
+ return inv;
+ }
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/replacereferences/Invoked.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/replacereferences/child/Child.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/replacereferences/child/Child.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/replacereferences/child/Child.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,34 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.test.classpool.jbosscl.support.excluded.replacereferences.child;
+
+import org.jboss.test.classpool.jbosscl.support.excluded.replacereferences.parent.Parent;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class Child extends Parent
+{
+ int child;
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/replacereferences/child/Child.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/replacereferences/child/ChildCaller.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/replacereferences/child/ChildCaller.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/replacereferences/child/ChildCaller.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,73 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.test.classpool.jbosscl.support.excluded.replacereferences.child;
+
+import junit.framework.Assert;
+
+import org.jboss.test.classpool.jbosscl.support.excluded.replacereferences.Invoked;
+import org.jboss.test.classpool.jbosscl.support.excluded.replacereferences.parent.Parent;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class ChildCaller
+{
+ public static void test()
+ {
+ Invoked.invoked = false;
+ Child child = new Child();
+ Assert.assertTrue("Invoked not called for Child constructor", Invoked.invoked);
+
+ Invoked.invoked = false;
+ child.child = 7;
+ Assert.assertTrue("Invoked not called for Child.child write", Invoked.invoked);
+
+ int i = child.child;
+ Assert.assertTrue("Invoked not called for Child.child read", Invoked.invoked);
+ Assert.assertEquals("Expected 7 for Child.child, was " + i, 7, i);
+
+ Invoked.invoked = false;
+ child.parent = 8;
+ Assert.assertTrue("Invoked not called for Child.parent write", Invoked.invoked);
+
+ Invoked.invoked = false;
+ i = child.parent;
+ Assert.assertTrue("Invoked not called for Child.parent read", Invoked.invoked);
+ Assert.assertEquals("Expected 8 for Child.parent, was " + i, 8, i);
+
+ Invoked.invoked = false;
+ Parent parent = new Parent();
+ Assert.assertTrue("Invoked not called for Parent constructor", Invoked.invoked);
+
+ Invoked.invoked = false;
+ parent.parent = 5;
+ Assert.assertTrue("Invoked not called for Parent.parent write", Invoked.invoked);
+
+ Invoked.invoked = false;
+ i = parent.parent;
+ Assert.assertTrue("Invoked not called for Parent.parent read", Invoked.invoked);
+ Assert.assertEquals("Expected 5 for Parent.parent, was " + i, 5, i);
+ }
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/replacereferences/child/ChildCaller.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/replacereferences/parent/Parent.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/replacereferences/parent/Parent.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/replacereferences/parent/Parent.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.test.classpool.jbosscl.support.excluded.replacereferences.parent;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class Parent
+{
+ public int parent;
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/replacereferences/parent/Parent.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/replacereferences/parent/ParentCaller.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/replacereferences/parent/ParentCaller.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/replacereferences/parent/ParentCaller.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,51 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.test.classpool.jbosscl.support.excluded.replacereferences.parent;
+
+import junit.framework.Assert;
+
+import org.jboss.test.classpool.jbosscl.support.excluded.replacereferences.Invoked;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class ParentCaller
+{
+ public static void test()
+ {
+ Invoked.invoked = false;
+ Parent parent = new Parent();
+ Assert.assertTrue("Invoked not called for Parent constructor", Invoked.invoked);
+
+ Invoked.invoked = false;
+ parent.parent = 5;
+ Assert.assertTrue("Invoked not called for Parent.parent write", Invoked.invoked);
+
+ Invoked.invoked = false;
+ int i = parent.parent;
+ Assert.assertTrue("Invoked not called for Parent.parent read", Invoked.invoked);
+ Assert.assertEquals("Expected 5 for Parent.parent, was " + i, 5 ,i);
+ }
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/replacereferences/parent/ParentCaller.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/service/SomeMBean.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/service/SomeMBean.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/service/SomeMBean.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.test.classpool.jbosscl.support.excluded.service;
+
+/**
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.org">Flavia Rainone</a>
+ *
+ * @version $Revision$
+ */
+public class SomeMBean
+{
+
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/service/SomeMBean.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/tif/TIFTester.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/tif/TIFTester.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/tif/TIFTester.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.test.classpool.jbosscl.support.excluded.tif;
+
+import org.jboss.test.classpool.jbosscl.support.excluded.web.AnyServlet;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class TIFTester
+{
+ public AnyServlet getAnys()
+ {
+ return new AnyServlet();
+ }
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/tif/TIFTester.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/ui/UIBean.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/ui/UIBean.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/ui/UIBean.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.test.classpool.jbosscl.support.excluded.ui;
+
+/**
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.org">Flavia Rainone</a>
+ *
+ * @version $Revision$
+ */
+public class UIBean
+{
+
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/ui/UIBean.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/util/SomeUtil.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/util/SomeUtil.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/util/SomeUtil.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.test.classpool.jbosscl.support.excluded.util;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ *
+ * @version $Revision$
+ */
+public class SomeUtil
+{
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/util/SomeUtil.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/web/AnyServlet.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/web/AnyServlet.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/web/AnyServlet.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.test.classpool.jbosscl.support.excluded.web;
+
+import org.jboss.test.classpool.jbosscl.support.excluded.jar.PlainJavaBean;
+
+
+
+/**
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.org">Flavia Rainone</a>
+ *
+ * @version $Revision$
+ */
+public class AnyServlet
+{
+ public PlainJavaBean getBean()
+ {
+ return new PlainJavaBean();
+ }
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/support/excluded/web/AnyServlet.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ArchiveClassPoolTestCase.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ArchiveClassPoolTestCase.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ArchiveClassPoolTestCase.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.classpool.jbosscl.test;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+import org.jboss.test.classpool.support.ClassPoolTestScenario;
+import org.jboss.test.classpool.support.TestScenario;
+
+/**
+ * Executes the archive tests against a class pool test scenario.
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class ArchiveClassPoolTestCase extends ArchiveTest<CtClass, ClassPool>
+{
+ public ArchiveClassPoolTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected TestScenario<CtClass, ClassPool, CLDeploymentBuilder> getTestScenario()
+ {
+ return new ClassPoolTestScenario<CLDeploymentBuilder>(getClassLoaderFactory());
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ArchiveClassPoolTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ArchiveSanityTestCase.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ArchiveSanityTestCase.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ArchiveSanityTestCase.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.classpool.jbosscl.test;
+
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+import org.jboss.test.classpool.support.SanityTestScenario;
+import org.jboss.test.classpool.support.TestScenario;
+
+/**
+ * Executes the archive tests against a sanity test scenario (for class loader behavior sanity
+ * checking).
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class ArchiveSanityTestCase extends ArchiveTest<Class<?>, ClassLoader>
+{
+ public ArchiveSanityTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected TestScenario<Class<?>, ClassLoader, CLDeploymentBuilder> getTestScenario()
+ {
+ return new SanityTestScenario<CLDeploymentBuilder>(getClassLoaderFactory());
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ArchiveSanityTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ArchiveTest.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ArchiveTest.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ArchiveTest.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,488 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.classpool.jbosscl.test;
+
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.EJB_JAR;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.EJB_JAR_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.EXCLUDED_CLASSPATH_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.JAR_A;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.JAR_A_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.JAR_IN_EAR;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.JAR_IN_EAR_JAR_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.PTD_EAR;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.PTD_EAR_LIB_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.PTD_JSF_WAR;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.PTD_JSF_WAR_LIB_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.PTD_JSF_WAR_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.PTD_WS_WAR;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.PTD_WS_WAR_LIB_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.PTD_WS_WAR_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.SERVLET_JAR;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.SERVLET_JAR_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.SIMPLE_EAR;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.SIMPLE_EAR_EJB_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.SIMPLE_EAR_JAR_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.SIMPLE_EAR_LIB1_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.SIMPLE_EAR_LIB2_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.SIMPLE_EAR_SAR_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.SIMPLE_EAR_WAR1;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.SIMPLE_EAR_WAR1_CP_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.SIMPLE_EAR_WAR1_LIB_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.SIMPLE_EAR_WAR1_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.SIMPLE_EAR_WAR2;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.SIMPLE_EAR_WAR2_CP_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.SIMPLE_EAR_WAR2_LIB_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.SIMPLE_EAR_WAR2_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.SIMPLE_JAR;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.SIMPLE_JAR_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.SIMPLE_SAR;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.SIMPLE_SAR_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.SIMPLE_WAR;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.SIMPLE_WAR_CP_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.TOP_EAR;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.TOP_EAR_EXT_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.TOP_EAR_UTIL_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.WAR_IN_EAR;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.WAR_IN_EAR_WAR;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.WAR_IN_EAR_WAR_CP;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.WAR_IN_EAR_WAR_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_A;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_CRM;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_EXT;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_JSF;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_MBEAN;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_PLAIN;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_SERVLET;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_SLS_BEAN;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_SLS_INTERFACE;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_TIF;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_UI;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_UTIL;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.PACKAGE_JAR;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.PACKAGE_TIF;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.PACKAGE_WEB;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.beans.metadata.plugins.AbstractDependencyValueMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+import org.jboss.test.classpool.jbosscl.support.SupportClasses;
+
+/**
+ * This class contains tests ported from deployers-vfs tests.
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.org">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public abstract class ArchiveTest<C, L> extends JBossClClassPoolTest<C, L>
+{
+ public ArchiveTest(String name)
+ {
+ super(name);
+ }
+
+ // TODO do an assertNotFound for all classes not included in the package being tested
+
+ public void testJar() throws Exception
+ {
+ CLDeploymentBuilder classLoaderBuilder = new CLDeploymentBuilder(SIMPLE_JAR, SIMPLE_JAR_URL);
+ L loader = testScenario.createLoader(classLoaderBuilder);
+ assertCanLoad(loader, CLASS_PLAIN);
+ }
+
+ public void testSar() throws Exception
+ {
+ CLDeploymentBuilder classLoaderBuilder = new CLDeploymentBuilder(SIMPLE_SAR, SIMPLE_SAR_URL);
+ L loader = testScenario.createLoader(classLoaderBuilder);
+ assertCanLoad(loader, CLASS_MBEAN);
+ }
+
+ public void testEjbJar() throws Exception
+ {
+ CLDeploymentBuilder classLoaderBuilder = new CLDeploymentBuilder(EJB_JAR, EJB_JAR_URL);
+ L loader = testScenario.createLoader(classLoaderBuilder);
+ assertCanLoad(loader, CLASS_SLS_BEAN, CLASS_SLS_INTERFACE);
+ }
+
+ public void testWar() throws Exception
+ {
+ CLDeploymentBuilder clBuilder = new CLDeploymentBuilder(SIMPLE_WAR, SIMPLE_WAR_CP_URL);
+ clBuilder.createDomain(getDomain(SIMPLE_WAR), false);
+ L loader = testScenario.createLoader(clBuilder);
+ assertCanLoad(loader, CLASS_SERVLET);
+ }
+
+ public void testEar() throws Exception
+ {
+ // create the ear loader
+ CLDeploymentBuilder earCLBuilder = new CLDeploymentBuilder(SIMPLE_EAR, SIMPLE_EAR_JAR_URL,
+ SIMPLE_EAR_SAR_URL, SIMPLE_EAR_EJB_URL, SIMPLE_EAR_LIB1_URL, SIMPLE_EAR_LIB2_URL);
+ earCLBuilder.setExcludes(SIMPLE_EAR_WAR1_URL, SIMPLE_EAR_WAR1_CP_URL, SIMPLE_EAR_WAR1_LIB_URL,
+ SIMPLE_EAR_WAR2_URL, SIMPLE_EAR_WAR2_CP_URL, SIMPLE_EAR_WAR2_LIB_URL);
+ L earLoader = testScenario.createLoader(earCLBuilder);
+
+ // create the simple_ui.war loader
+ ClassLoader earClassLoader = testScenario.getClassLoader(earLoader);
+ CLDeploymentBuilder war1CLBuilder = new CLDeploymentBuilder(
+ SIMPLE_EAR_WAR1, SIMPLE_EAR_WAR1_CP_URL, SIMPLE_EAR_WAR1_LIB_URL);
+ war1CLBuilder.createDomain(getDomain(SIMPLE_EAR_WAR1), earClassLoader, false);
+ L war1Loader = testScenario.createLoader(war1CLBuilder);
+
+ // create the jsfapp.war loader
+ CLDeploymentBuilder war2CLBuilder = new CLDeploymentBuilder(SIMPLE_EAR_WAR2,
+ SIMPLE_EAR_WAR2_CP_URL, SIMPLE_EAR_WAR2_LIB_URL);
+ war2CLBuilder.createDomain(getDomain(SIMPLE_EAR_WAR2), earClassLoader, false);
+ L war2Loader = testScenario.createLoader(war2CLBuilder);
+
+ // assert that the loaderse can load the classes
+ Map<String, L> classes = new HashMap<String, L>();
+ classes.put(CLASS_UTIL, earLoader);
+ classes.put(CLASS_EXT, earLoader);
+ classes.put(CLASS_PLAIN, earLoader);
+ classes.put(CLASS_SLS_BEAN, earLoader);
+ classes.put(CLASS_SLS_INTERFACE, earLoader);
+ classes.put(CLASS_SERVLET, war1Loader);
+ classes.put(CLASS_UI, war1Loader);
+ classes.put(CLASS_JSF, war2Loader);
+ classes.put(CLASS_CRM, war2Loader);
+ classes.put(CLASS_MBEAN, earLoader);
+ assertCanLoad(classes);
+
+ // assert simple hierarchy
+ assertSimpleHierarchy(earLoader, war1Loader);
+ }
+
+ public void testTopLevelWithUtil() throws Exception
+ {
+ CLDeploymentBuilder clBuilder = new CLDeploymentBuilder(TOP_EAR, TOP_EAR_UTIL_URL, TOP_EAR_EXT_URL);
+ L earLoader = testScenario.createLoader(clBuilder);
+ assertCanLoad(earLoader, CLASS_UTIL, CLASS_EXT);
+ }
+
+ public void testWarInEar() throws Exception
+ {
+ // create ear loader
+ CLDeploymentBuilder earCLBuilder = new CLDeploymentBuilder(WAR_IN_EAR);
+ earCLBuilder.setExcludes(WAR_IN_EAR_WAR_URL, WAR_IN_EAR_WAR_CP);
+ L earLoader = testScenario.createLoader(earCLBuilder);
+
+ // create war loader
+ CLDeploymentBuilder warCLBuilder = new CLDeploymentBuilder(WAR_IN_EAR_WAR, WAR_IN_EAR_WAR_CP);
+ warCLBuilder.createDomain(getDomain(WAR_IN_EAR_WAR), testScenario.getClassLoader(earLoader), false);
+ L warLoader = testScenario.createLoader(warCLBuilder);
+
+ // assert warLoader can load CLASS_SERVLET
+ Map<String, L> classes = new HashMap<String, L>();
+ classes.put(CLASS_SERVLET, warLoader);
+ assertCanLoad(classes);
+ }
+
+ public void testJarInEar() throws Exception
+ {
+ CLDeploymentBuilder earCLBuilder = new CLDeploymentBuilder(JAR_IN_EAR, JAR_IN_EAR_JAR_URL);
+ L earLoader = testScenario.createLoader(earCLBuilder);
+ assertCanLoad(earLoader, CLASS_PLAIN);
+ }
+
+ public void testIsolatedJars() throws Exception
+ {
+ // create a1.jar loader
+ CLDeploymentBuilder cl1Builder = new CLDeploymentBuilder(JAR_A + 1, JAR_A_URL);
+ cl1Builder.createDomain(getDomain(JAR_A) + 1, true);
+ L loader1 = testScenario.createLoader(cl1Builder);
+ // create a2.jar loader
+ CLDeploymentBuilder cl2Builder = new CLDeploymentBuilder(JAR_A + 2, JAR_A_URL);
+ cl2Builder.createDomain(getDomain(JAR_A) + 2, true);
+ L loader2 = testScenario.createLoader(cl2Builder);
+ // assert proper isolation between the loaders
+ assertIsolated(loader1, loader2);
+ }
+
+ public void testHierarchyJarsChildFirst() throws Exception
+ {
+ // creeate a1.jar loader
+ String domain1 = getDomain(JAR_A) + 1;
+ CLDeploymentBuilder clBuilder1 = new CLDeploymentBuilder(JAR_A + 1, JAR_A_URL);
+ clBuilder1.createDomain(domain1, true);
+ L loader1 = testScenario.createLoader(clBuilder1);
+
+ // create a2.jar loader
+ CLDeploymentBuilder clBuilder2 = new CLDeploymentBuilder(JAR_A + 2, JAR_A_URL);
+ clBuilder2.createDomain(getDomain(JAR_A) + 2, domain1, false);
+ L loader2 = testScenario.createLoader(clBuilder2);
+ assertIsolated(loader1, loader2);
+ }
+
+ public void testDomainHierarchy() throws Exception
+ {
+ // create simple.jar loader
+ String topDomain = getDomain(SIMPLE_JAR);
+ CLDeploymentBuilder topCLBuilder = new CLDeploymentBuilder(SIMPLE_JAR, SIMPLE_JAR_URL);
+ topCLBuilder.createDomain(topDomain, true);
+ L topLoader = testScenario.createLoader(topCLBuilder);
+
+ // create servlet.jar "left" loader
+ CLDeploymentBuilder leftCLBuilder = new CLDeploymentBuilder(SERVLET_JAR + 'L', SERVLET_JAR_URL);
+ leftCLBuilder.createDomain(getDomain(SERVLET_JAR) + 'L', topDomain, true);
+ L leftLoader = testScenario.createLoader(leftCLBuilder);
+
+ // create servlet.jar "right" loader
+ CLDeploymentBuilder rightCLBuilder = new CLDeploymentBuilder(SERVLET_JAR + 'R', SERVLET_JAR_URL);
+ rightCLBuilder.createDomain(getDomain(SERVLET_JAR) + 'R', topDomain, true);
+ L rightLoader = testScenario.createLoader(rightCLBuilder);
+
+ // assert domain hierarchy
+ assertDomainHierarchy(topLoader, leftLoader, rightLoader);
+ }
+
+ public void testEar2War() throws Exception
+ {
+ // create ptd-ear-1.0-SNAPSHOT.ear loader
+ String topDomain = getDomain(PTD_EAR);
+ CLDeploymentBuilder topCLBuilder = new CLDeploymentBuilder(PTD_EAR, PTD_EAR_LIB_URL);
+ topCLBuilder.createDomain(topDomain, false);
+ topCLBuilder.setExcludes(PTD_JSF_WAR_URL, PTD_JSF_WAR_LIB_URL, PTD_WS_WAR_URL, PTD_WS_WAR_LIB_URL);
+ L topLoader = testScenario.createLoader(topCLBuilder);
+
+ // create ptd-jsf-1.0.-SNAPSHOT.war loader
+ CLDeploymentBuilder leftCLBuilder = new CLDeploymentBuilder(PTD_JSF_WAR, PTD_JSF_WAR_LIB_URL);
+ leftCLBuilder.createDomain(getDomain(PTD_JSF_WAR), topDomain, true);
+ L leftLoader = testScenario.createLoader(leftCLBuilder);
+
+ // create ptd-ws-1.0-SNAPSHOT.war loader
+ CLDeploymentBuilder rightCLBuilder = new CLDeploymentBuilder(PTD_WS_WAR, PTD_WS_WAR_LIB_URL);
+ rightCLBuilder.createDomain(getDomain(PTD_WS_WAR), topDomain, true);
+ L rightLoader = testScenario.createLoader(rightCLBuilder);
+
+ // assert domain hierarchy
+ assertDomainHierarchy(topLoader, leftLoader, rightLoader);
+ }
+
+ public void testJarAndExcludedClassPath() throws Exception
+ {
+ // create simple.jar loader
+ CLDeploymentBuilder jarCLBuilder = new CLDeploymentBuilder(SIMPLE_JAR, SIMPLE_JAR_URL);
+ L jarLoader = testScenario.createLoader(jarCLBuilder);
+
+ // create anys loader
+ CLDeploymentBuilder anysCLBuilder = new CLDeploymentBuilder("anys-classloader",
+ EXCLUDED_CLASSPATH_URL);
+ anysCLBuilder.createPackage(PACKAGE_WEB);
+ L anysLoader = testScenario.createLoader(anysCLBuilder);
+
+ // create AnyServlet bean meta data
+ String beanName = "AnyServlet";
+ BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(beanName, CLASS_SERVLET);
+ builder.setClassLoader(new AbstractDependencyValueMetaData("anys-classloader:0.0.0"));
+ super.deploy(builder.getBeanMetaData());
+
+ // assert AnyServlet bean
+ Object anys = assertBean(beanName, Object.class);
+ Class<?> anysClass = anys.getClass();
+ ClassLoader anysCL = anysClass.getClassLoader();
+ assertSame(anysCL, testScenario.getClassLoader(anysLoader));
+ assertNotSame(anysCL, testScenario.getClassLoader(jarLoader));
+
+ // assert "nondeployment" module (nomenclature used by corresponding vfs-deployer test)
+ assertNonDeploymentModule(jarLoader, anysLoader);
+ }
+
+ public void testTifHierarchy() throws Exception
+ {
+ // create simple.jar loader
+ CLDeploymentBuilder jarCLBuilder = new CLDeploymentBuilder(SIMPLE_JAR, SIMPLE_JAR_URL);
+ L jarLoader = testScenario.createLoader(jarCLBuilder);
+
+ // create anys loader
+ String anysDomain = getDomain("Anys");
+ CLDeploymentBuilder anysCLBuilder = new CLDeploymentBuilder("anys-classloader",
+ EXCLUDED_CLASSPATH_URL);
+ anysCLBuilder.createDomain(anysDomain, true);
+ anysCLBuilder.createPackage(SupportClasses.PACKAGE_WEB);
+ L anysLoader = testScenario.createLoader(anysCLBuilder);
+
+ // create tif loader
+ CLDeploymentBuilder tifCLBuilder = new CLDeploymentBuilder("tif-classloader",
+ EXCLUDED_CLASSPATH_URL);
+ tifCLBuilder.createDomain(getDomain("TIF"), anysDomain,true);
+ tifCLBuilder.createPackage(PACKAGE_TIF);
+ L tifLoader = testScenario.createLoader(tifCLBuilder);
+
+ // create AnyServlet and TifTester beans
+ createHierarchyBeans(jarLoader);
+
+ // assert "nondeployment" module (nomenclature used by corresponding vfs-deployer test)
+ assertNonDeploymentModule(jarLoader, anysLoader, tifLoader);
+ }
+
+ public void testTifHierarchyWithRequirements() throws Exception
+ {
+ // create simple.jar loader
+ CLDeploymentBuilder jarCLBuilder = new CLDeploymentBuilder(SIMPLE_JAR, SIMPLE_JAR_URL);
+ jarCLBuilder.createPackage(PACKAGE_JAR);
+ L jarLoader = testScenario.createLoader(jarCLBuilder);
+
+ // create anys loader
+ CLDeploymentBuilder anysCLBuilder = new CLDeploymentBuilder("anys-classloader",
+ EXCLUDED_CLASSPATH_URL);
+ anysCLBuilder.createModule("any-classloader:0.0.0$Module");
+ anysCLBuilder.createPackage(PACKAGE_WEB);
+ anysCLBuilder.createRequirePackage(PACKAGE_JAR);
+ L anysLoader = testScenario.createLoader(anysCLBuilder);
+
+ // create tif loader
+ CLDeploymentBuilder tifCLBuilder = new CLDeploymentBuilder("tif-classloader",
+ EXCLUDED_CLASSPATH_URL);
+ tifCLBuilder.createModule("tif-classloader:0.0.0$Module");
+ tifCLBuilder.createPackage(PACKAGE_TIF);
+ tifCLBuilder.createRequirePackage(PACKAGE_WEB);
+ L tifLoader = testScenario.createLoader(tifCLBuilder);
+
+ // create AnyServlet and TifTester beans
+ createHierarchyBeans(jarLoader);
+
+ // assert "nondeployment" module (nomenclature used by corresponding vfs-deployer test)
+ assertNonDeploymentModule(jarLoader, anysLoader, tifLoader);
+ }
+
+ // ASSERT METHODS
+
+ protected void assertCanLoad(L parentLoader, String... classNames) throws Exception
+ {
+ Map<String, L> map = new HashMap<String, L>();
+ for (String className : classNames)
+ {
+ map.put(className, parentLoader);
+ }
+ assertCanLoad(map);
+ }
+
+ protected void assertCanLoad(Map<String, L> classes) throws Exception
+ {
+ for (Map.Entry<String, L> entry : classes.entrySet())
+ {
+ String className = entry.getKey();
+ L loader = entry.getValue();
+ testScenario.loadClass(loader, className);
+ }
+ }
+
+ private void assertSimpleHierarchy(L topLoader, L childLoader) throws
+ Exception
+ {
+ C clazz = testScenario.loadClass(childLoader, CLASS_SERVLET);
+ C returnClass = testScenario.getMethodReturnType(clazz, "getBean");
+ C returnClass2 = testScenario.loadClass(topLoader, CLASS_PLAIN);
+ assertSame(returnClass, returnClass2);
+ }
+
+ protected void assertIsolated(L loader1, L loader2) throws Exception
+ {
+ assertFalse(loader1.equals(loader2));
+
+ C class1 = testScenario.loadClass(loader1, CLASS_A);
+ C class2 = testScenario.loadClass(loader2, CLASS_A);
+ assertNotSame("Should NOT be the same " + class1 +" and " + class2, class1, class2);
+
+ L loader3 = testScenario.getLoader(class1);
+ C class3 = testScenario.loadClass(loader3, CLASS_A);
+ assertEquals(class1, class3);
+
+ L loader4 = testScenario.getLoader(class2);
+ C class4 = testScenario.loadClass(loader4, CLASS_A);
+ assertEquals(class2, class4);
+ assertNotSame(class3, class4);
+ }
+
+ protected void assertDomainHierarchy(L topLoader, L leftLoader, L rightLoader) throws Exception
+ {
+ C servletClassLeft = testScenario.loadClass(leftLoader, CLASS_SERVLET);
+ C servletClassRight = testScenario.loadClass(rightLoader, CLASS_SERVLET);
+ assertFalse(servletClassLeft.equals(servletClassRight));
+ C plainClassLeft = testScenario.loadClass(leftLoader, topLoader, CLASS_PLAIN);
+ C plainClassRight = testScenario.loadClass(rightLoader, topLoader, CLASS_PLAIN);
+ assertEquals(plainClassLeft, plainClassRight);
+
+ C plainClass = testScenario.loadClass(topLoader, CLASS_PLAIN);
+
+ C returnClassLeft = testScenario.getMethodReturnType(servletClassLeft, "getBean");
+ assertEquals(plainClass, returnClassLeft);
+
+ C returnClassRight = testScenario.getMethodReturnType(servletClassRight, "getBean");
+ assertEquals(plainClass, returnClassRight);
+ }
+
+ protected void assertNonDeploymentModule(L jarLoader, L anysLoader) throws Exception
+ {
+ C anysClass = testScenario.loadClass(jarLoader, anysLoader, CLASS_SERVLET);
+ C plainClass = testScenario.loadClass(anysLoader, jarLoader, CLASS_PLAIN);
+ C returnC = testScenario.getMethodReturnType(anysClass, "getBean");
+ assertEquals(plainClass, returnC);
+ }
+
+ protected void assertNonDeploymentModule(L loader, L anysLoader,
+ L tifLoader) throws Exception
+ {
+ C tifClass = testScenario.loadClass(tifLoader, CLASS_TIF);
+ C tifReturn = testScenario.getMethodReturnType(tifClass, "getAnys");
+ C servletClass = testScenario.loadClass(anysLoader, CLASS_SERVLET);
+ assertEquals(tifReturn, servletClass);
+
+ C plainClass = testScenario.loadClass(loader, CLASS_PLAIN);
+ C plainReturn = testScenario.getMethodReturnType(servletClass, "getBean");
+ assertEquals(plainClass, plainReturn);
+ }
+
+ private void createHierarchyBeans(L jarLoader) throws Exception
+ {
+ String servletName = "AnyServlet";
+ BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(servletName, CLASS_SERVLET);
+ builder.setClassLoader(new AbstractDependencyValueMetaData("anys-classloader:0.0.0"));
+ super.deploy(builder.getBeanMetaData());
+
+ String tifName = "TifTester";
+ builder = BeanMetaDataBuilder.createBuilder(tifName, CLASS_TIF);
+ builder.setClassLoader(new AbstractDependencyValueMetaData("tif-classloader:0.0.0"));
+ super.deploy(builder.getBeanMetaData());
+
+ Object anys = assertBean(servletName, Object.class);
+ Class<?> anysClass = anys.getClass();
+ ClassLoader anysCL = anysClass.getClassLoader();
+
+ Object tif = assertBean(tifName, Object.class);
+ Class<?> tifClass = tif.getClass();
+ ClassLoader tifCL = tifClass.getClassLoader();
+
+ ClassLoader jarCL = testScenario.getClassLoader(jarLoader);
+
+ assertNotSame(jarCL, anysCL);
+ assertNotSame(jarCL, tifCL);
+ assertNotSame(anysCL, tifCL);
+ }
+
+ private String getDomain(String name)
+ {
+ return name + "_Domain";
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ArchiveTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/CtClassCreationTestCase.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/CtClassCreationTestCase.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/CtClassCreationTestCase.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,241 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.classpool.jbosscl.test;
+
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.JAR_A_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.JAR_B_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_A;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_B;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.PACKAGE_A;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.PACKAGE_B;
+
+import java.util.ArrayList;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+import org.jboss.test.classpool.support.ClassFactory;
+import org.jboss.test.classpool.support.ClassPoolTestScenario;
+import org.jboss.test.classpool.support.TestScenario;
+
+/**
+ * Tests creation of CtClasses using ClassPools for JBoss ClassLoaders.
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class CtClassCreationTestCase extends JBossClClassPoolTest<CtClass, ClassPool>
+{
+ public CtClassCreationTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected TestScenario<CtClass, ClassPool, CLDeploymentBuilder> getTestScenario()
+ {
+ return new ClassPoolTestScenario<CLDeploymentBuilder>(getClassLoaderFactory());
+ }
+
+ public void testCreatedClassInSamePackage() throws Exception
+ {
+ ClassPool poolA = testScenario.createLoader(new CLDeploymentBuilder("A", JAR_A_URL));
+ ClassPool poolB = testScenario.createLoader(new CLDeploymentBuilder("B", JAR_B_URL));
+
+ ClassLoader loaderA = poolA.getClassLoader();
+ ClassLoader loaderB = poolB.getClassLoader();
+
+ Class<?> classA = loaderA.loadClass(CLASS_A);
+ Class<?> classB = loaderB.loadClass(CLASS_B);
+
+ Object createdA = ClassFactory.create(classA, loaderA);
+ Object createdB = ClassFactory.create(classB, loaderB);
+
+ Class<?> createdClassA = createdA.getClass();
+ Class<?> createdClassB = createdB.getClass();
+
+ assertTrue(classA.isAssignableFrom(createdClassA));
+ assertTrue(classB.isAssignableFrom(createdClassB));
+ assertTrue(createdClassA.getName().startsWith(PACKAGE_A));
+ assertTrue(createdClassB.getName().startsWith(PACKAGE_B));
+
+ assertSame(createdClassA, loaderA.loadClass(createdClassA.getName()));
+ assertSame(createdClassB, loaderA.loadClass(createdClassB.getName()));
+ assertSame(createdClassA, loaderB.loadClass(createdClassA.getName()));
+ assertSame(createdClassB, loaderB.loadClass(createdClassB.getName()));
+ }
+
+ // TODO check commented out tests. They should be deleted after JBAOP-742 being merged to
+ // JBoss AOP trunk
+ /*public void testMakeContainerProxyInSamePackage() throws Exception
+ {
+ ClassPool globalPoolA = null;
+ ClassPool globalPoolB = null;
+ try
+ {
+ globalPoolA = createClassPool("A", true, JAR_A_1);
+ globalPoolB = createClassPool("B", true, JAR_B_1);
+
+ ClassLoader loaderA = globalPoolA.getClassLoader();
+ ClassLoader loaderB = globalPoolB.getClassLoader();
+
+ loaderA.loadClass(ProxyTemplate.class.getName());
+
+ Object proxyA = assertMakeContainerProxy(loaderA.loadClass(CLASS_A), loaderA);
+ Object proxyB = assertMakeContainerProxy(loaderB.loadClass(CLASS_B), loaderB);
+
+ Class<?> clazzA = proxyA.getClass();
+ Class<?> clazzB = proxyB.getClass();
+
+ assertTrue(AspectManaged.class.isAssignableFrom(clazzA));
+ assertTrue(AspectManaged.class.isAssignableFrom(clazzB));
+ assertTrue(clazzA.getName().startsWith(PACKAGE_A));
+ assertTrue(clazzB.getName().startsWith(PACKAGE_B));
+
+ assertSame(clazzA, loaderA.loadClass(clazzA.getName()));
+ assertSame(clazzB, loaderA.loadClass(clazzB.getName()));
+ assertSame(clazzA, loaderB.loadClass(clazzA.getName()));
+ assertSame(clazzB, loaderB.loadClass(clazzB.getName()));
+ }
+ finally
+ {
+ unregisterClassPool(globalPoolA);
+ unregisterClassPool(globalPoolB);
+ }
+ }*/
+
+ /*public void testMakeContainerProxyForSystemClass() throws Exception
+ {
+ ClassPool globalPoolA = null;
+ ClassPool globalPoolB = null;
+ try
+ {
+ BundleInfoBuilder builderA = BundleInfoBuilder.getBuilder().
+ createModule("ModuleA").
+ createPackage(PACKAGE_A).
+ createPackage(ContainerProxyFactory.PROXY_CLASSES_DEFAULT_PACKAGE);
+ globalPoolA = createClassPool("A", true, builderA, JAR_A_1);
+
+ BundleInfoBuilder builderB = BundleInfoBuilder.getBuilder().
+ createModule("ModuleB").
+ createPackage(PACKAGE_B).
+ createPackage(ContainerProxyFactory.PROXY_CLASSES_DEFAULT_PACKAGE);
+ globalPoolB = createClassPool("B", true, builderB, JAR_B_1);
+
+ ClassLoader loaderA = globalPoolA.getClassLoader();
+ ClassLoader loaderB = globalPoolB.getClassLoader();
+
+ loaderA.loadClass(ProxyTemplate.class.getName());
+
+ Object proxyA = assertMakeContainerProxy(ArrayList.class, loaderA);
+ Object proxyB = assertMakeContainerProxy(ArrayList.class, loaderB);
+
+ Class<?> clazzA = proxyA.getClass();
+ Class<?> clazzB = proxyB.getClass();
+
+ assertTrue(AspectManaged.class.isAssignableFrom(clazzA));
+ assertTrue(AspectManaged.class.isAssignableFrom(clazzB));
+ assertTrue(clazzA.getName().startsWith(ContainerProxyFactory.PROXY_CLASSES_DEFAULT_PACKAGE));
+ assertTrue(clazzB.getName().startsWith(ContainerProxyFactory.PROXY_CLASSES_DEFAULT_PACKAGE));
+
+ assertSame(clazzA, loaderA.loadClass(clazzA.getName()));
+ assertSame(clazzB, loaderA.loadClass(clazzB.getName()));
+ assertSame(clazzA, loaderB.loadClass(clazzA.getName()));
+ assertSame(clazzB, loaderB.loadClass(clazzB.getName()));
+ }
+ finally
+ {
+ unregisterClassPool(globalPoolA);
+ unregisterClassPool(globalPoolB);
+ }
+ }*/
+
+ public void testCreateClassForSystemClass() throws Exception
+ {
+ CLDeploymentBuilder clBuilderA = new CLDeploymentBuilder("A", JAR_A_URL);
+ clBuilderA.createModule("ModuleA").createPackage(PACKAGE_A);
+ clBuilderA.createPackage(ClassFactory.PACKAGE).setImportAll(true);
+ ClassPool poolA = testScenario.createLoader(clBuilderA);
+
+ CLDeploymentBuilder clBuilderB = new CLDeploymentBuilder("B", JAR_B_URL);
+ clBuilderB.createModule("ModuleB").createPackage(PACKAGE_B);
+ clBuilderB.createPackage(ClassFactory.PACKAGE).setImportAll(true);
+ ClassPool poolB = testScenario.createLoader(clBuilderB);
+
+ ClassLoader loaderA = poolA.getClassLoader();
+ ClassLoader loaderB = poolB.getClassLoader();
+
+ Object createdA = ClassFactory.create(ArrayList.class, loaderA);
+ Object createdB = ClassFactory.create(ArrayList.class, loaderB);
+
+ Class<?> createdClassA = createdA.getClass();
+ Class<?> createdClassB = createdB.getClass();
+
+ assertTrue(ArrayList.class.isAssignableFrom(createdClassA));
+ assertTrue(ArrayList.class.isAssignableFrom(createdClassB));
+ assertTrue(createdClassA.getName().startsWith(ClassFactory.PACKAGE));
+ assertTrue(createdClassB.getName().startsWith(ClassFactory.PACKAGE));
+
+ assertSame(createdClassA, loaderA.loadClass(createdClassA.getName()));
+ assertSame(createdClassB, loaderA.loadClass(createdClassB.getName()));
+ assertSame(createdClassA, loaderB.loadClass(createdClassA.getName()));
+ assertSame(createdClassB, loaderB.loadClass(createdClassB.getName()));
+ }
+
+ /*private Object assertMakeContainerProxy(Class<?> parent, ClassLoader loader) throws Exception
+ {
+ AOPProxyFactoryParameters params = new AOPProxyFactoryParameters();
+ params.setProxiedClass(parent);
+ params.setTarget(parent.newInstance());
+ params.setClassLoader(loader);
+ params.setInterfaces(new Class<?>[] {java.io.Serializable.class});
+ GeneratedAOPProxyFactory factory = new GeneratedAOPProxyFactory();
+ Object proxy = factory.createAdvisedProxy(params);
+ assertFalse(parent.getName() == proxy.getClass().getName());
+ assertSame(loader, proxy.getClass().getClassLoader());
+ return proxy;
+ }*/
+
+ /*private static final String PROXY_PACKAGE = "org.test.classpool.proxy";
+ private static final String PROXY_CLASS = PROXY_PACKAGE + ".Proxy";
+ private static int counter = 0;
+
+ private Object assertMakeSimpleProxy(Class<?> parent, ClassLoader loader) throws Exception
+ {
+ //AOPProxyFactoryParameters params = new AOPProxyFactoryParameters();
+ //params.setProxiedClass(parent);
+ //params.setTarget(parent.newInstance());
+ //params.setClassLoader(loader);
+ ClassPool pool = ClassPoolRepository.getInstance().getRegisteredCLs().get(loader);
+ CtClass ctClazz = pool.makeClass(PROXY_CLASS + counter++);
+ ctClazz.setSuperclass(pool.get(parent.getName()));
+ Class<?> clazz = pool.toClass(ctClazz);
+ //params.setInterfaces(new Class<?>[] {java.io.Serializable.class});
+ //GeneratedAOPProxyFactory factory = new GeneratedAOPProxyFactory();
+ //Object proxy = factory.createAdvisedProxy(params);
+ //assertFalse(parent.getName() == proxy.getClass().getName());
+ assertSame(loader, clazz.getClassLoader());
+ //return proxy;
+ return clazz.newInstance();
+ }*/
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/CtClassCreationTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/DependencyTest.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/DependencyTest.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/DependencyTest.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,250 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.test.classpool.jbosscl.test;
+
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.JAR_A_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.JAR_B_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_A;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_B;
+
+import org.jboss.classloading.spi.version.VersionRange;
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+import org.jboss.test.classpool.jbosscl.support.NoSuchClassLoaderException;
+
+/**
+ * Contains tests for dependency test scenarios,such as dependency on modules and on packages.
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public abstract class DependencyTest<C, L> extends JBossClClassPoolTest<C, L>
+{
+ public DependencyTest(String name)
+ {
+ super(name);
+ }
+
+ public void testImportNoVersionCheck() throws Exception
+ {
+ CLDeploymentBuilder clBuilderA = createExportCLBuilder("A");
+
+ CLDeploymentBuilder clBuilderB = createRequireCLBuilder();
+
+ assertRequiredModule(clBuilderA, clBuilderB);
+ }
+
+ public void testImportVersionCheck() throws Exception
+ {
+ CLDeploymentBuilder clBuilderA = createExportCLBuilder("A", "1.0.0");
+ CLDeploymentBuilder clBuilderB = createRequireCLBuilder(new VersionRange("1.0.0", "2.0.0"));
+
+ assertRequiredModule(clBuilderA, clBuilderB);
+ }
+
+ public void testImportVersionCheckFailed() throws Exception
+ {
+ CLDeploymentBuilder clBuilderA = createExportCLBuilder("A", "3.0.0");
+ L loaderA = testScenario.createLoader(clBuilderA);
+
+ C classA = testScenario.loadClass(loaderA, CLASS_A);
+ testScenario.cannotLoadClass(loaderA, CLASS_B);
+
+ CLDeploymentBuilder clBuilderB = createRequireCLBuilder(new VersionRange("1.0.0", "2.0.0"));
+ try
+ {
+ testScenario.createLoader(clBuilderB);
+ fail("Should not have been able to create loader");
+ }
+ catch(NoSuchClassLoaderException expected) {}
+
+ testScenario.cannotGetLoader(clBuilderB);
+ C classA1 = testScenario.loadClass(loaderA, CLASS_A);
+ assertSame(classA, classA1);
+ testScenario.cannotLoadClass(loaderA, CLASS_B);
+ }
+
+ //These are my extra tests
+ public abstract void testSeveralModulesWithSamePackages() throws Exception;
+
+ //These are my extra tests
+ public void testSeveralModulesWithSamePackages(String exporterLoader) throws Exception
+ {
+ CLDeploymentBuilder clAModuleXBuilder = createExportCLBuilder("X");
+ CLDeploymentBuilder clAModuleABuilder = createExportCLBuilder("A");
+ CLDeploymentBuilder clAModuleYBuilder = createExportCLBuilder("Y");
+ CLDeploymentBuilder clBuilderB = createRequireCLBuilder();
+
+ int exporterLoaderIndex = 0;
+ if (exporterLoader.equals("X"))
+ {
+ exporterLoaderIndex = 1;
+ }
+ else if (exporterLoader.equals("A"))
+ {
+ exporterLoaderIndex = 2;
+ }
+ else if (exporterLoader.equals("Y"))
+ {
+ exporterLoaderIndex = 3;
+ }
+ else
+ {
+ throw new IllegalStateException("Exporter loader should be one of: \"X\", \"A\" or \"Y\"");
+ }
+ assertRequireModule(clAModuleXBuilder, clAModuleABuilder,
+ clAModuleYBuilder, clBuilderB, exporterLoaderIndex);
+ }
+
+ public void testSeveralModulesWithSameNamesDifferentVersions() throws Exception
+ {
+ CLDeploymentBuilder clAModuleA1Builder = createExportCLBuilder("X", "1.0.0");
+ CLDeploymentBuilder clAModuleA2Builder = createExportCLBuilder("A", "2.0.0");
+ CLDeploymentBuilder clAModuleA3Builder = createExportCLBuilder("Y", "3.0.0");
+ CLDeploymentBuilder clBuilderB = createRequireCLBuilder(
+ new VersionRange("2.0.0", true, "3.0.0", false));
+
+ assertRequireModule(clAModuleA1Builder, clAModuleA2Builder,
+ clAModuleA3Builder, clBuilderB, 2);
+ }
+
+ private void assertRequiredModule(CLDeploymentBuilder clBuilderA,
+ CLDeploymentBuilder clBuilderB) throws NoSuchClassLoaderException,
+ Exception
+ {
+ L loaderA = testScenario.createLoader(clBuilderA);
+ testScenario.cannotLoadClass(loaderA, CLASS_B);
+ C aFromA = testScenario.loadClass(loaderA, CLASS_A);
+
+ L loaderB = testScenario.createLoader(clBuilderB);
+
+ C aFromA1 = testScenario.loadClass(loaderA, CLASS_A);
+ assertSame(aFromA, aFromA1);
+
+ testScenario.cannotLoadClass(loaderA, CLASS_B);
+ testScenario.loadClass(loaderB, CLASS_B);
+
+ C aFromB = testScenario.loadClass(loaderB, loaderA, CLASS_A);
+ assertSame(aFromA, aFromB);
+
+ testScenario.destroyLoader(clBuilderB);
+
+ aFromA1 = testScenario.loadClass(loaderA, CLASS_A);
+ assertSame(aFromA, aFromA1);
+ testScenario.cannotLoadClass(loaderA, CLASS_B);
+ }
+
+ private void assertRequireModule(CLDeploymentBuilder moduleBuilder1,
+ CLDeploymentBuilder moduleBuilder2,
+ CLDeploymentBuilder moduleBuilder3, CLDeploymentBuilder clBuilder,
+ int exporterModule)
+ throws NoSuchClassLoaderException, Exception
+ {
+ L moduleLoader1 = testScenario.createLoader(moduleBuilder1);
+ L moduleLoader2 = testScenario.createLoader(moduleBuilder2);
+ L moduleLoader3 = testScenario.createLoader(moduleBuilder3);
+
+ C classA1 = testScenario.loadClass(moduleLoader1, CLASS_A);
+ C classA2 = testScenario.loadClass(moduleLoader2, CLASS_A);
+ C classA3 = testScenario.loadClass(moduleLoader3, CLASS_A);
+ testScenario.cannotLoadClass(moduleLoader1, CLASS_B);
+ testScenario.cannotLoadClass(moduleLoader2, CLASS_B);
+ testScenario.cannotLoadClass(moduleLoader3, CLASS_B);
+
+
+ L loaderB = testScenario.createLoader(clBuilder);
+
+ C classA1_ = testScenario.loadClass(moduleLoader1, CLASS_A);
+ assertSame(classA1, classA1_);
+ C classA2_ = testScenario.loadClass(moduleLoader2, CLASS_A);
+ assertSame(classA2, classA2_);
+ C classA3_ = testScenario.loadClass(moduleLoader3, CLASS_A);
+ assertSame(classA3, classA3_);
+ testScenario.cannotLoadClass(moduleLoader1, CLASS_B);
+ testScenario.cannotLoadClass(moduleLoader2, CLASS_B);
+ testScenario.cannotLoadClass(moduleLoader3, CLASS_B);
+
+ testScenario.loadClass(loaderB, CLASS_B);
+ L exporterLoader = null;
+ C exporterLoaderClass = null;
+ switch(exporterModule)
+ {
+ case 1:
+ exporterLoader = moduleLoader1;
+ exporterLoaderClass = classA1;
+ break;
+ case 2:
+ exporterLoader = moduleLoader2;
+ exporterLoaderClass = classA2;
+ break;
+ case 3:
+ exporterLoader = moduleLoader3;
+ exporterLoaderClass = classA3;
+ break;
+ default: throw new IllegalStateException("Exporter loader should range from 1 to 3");
+ }
+ C aFromB = testScenario.loadClass(loaderB, exporterLoader, CLASS_A);
+ assertSame(aFromB, exporterLoaderClass);
+
+ testScenario.destroyLoader(clBuilder);
+
+ classA1_ = testScenario.loadClass(moduleLoader1, CLASS_A);
+ assertSame(classA1, classA1_);
+ classA2_ = testScenario.loadClass(moduleLoader2, CLASS_A);
+ assertSame(classA2, classA2_);
+ classA3_ = testScenario.loadClass(moduleLoader3, CLASS_A);
+ assertSame(classA3, classA3_);
+ testScenario.cannotLoadClass(moduleLoader1, CLASS_B);
+ testScenario.cannotLoadClass(moduleLoader2, CLASS_B);
+ testScenario.cannotLoadClass(moduleLoader3, CLASS_B);
+ }
+
+
+
+ private CLDeploymentBuilder createExportCLBuilder(String name)
+ {
+ return createExportCLBuilder(name, null);
+ }
+
+ private CLDeploymentBuilder createExportCLBuilder(String name, String version)
+ {
+ CLDeploymentBuilder clBuilderA = new CLDeploymentBuilder(name, JAR_A_URL);
+ createExportCapabilities(clBuilderA, "Module" + name, version);
+ return clBuilderA;
+ }
+
+ protected abstract void createExportCapabilities(CLDeploymentBuilder clBuilderA, String moduleName, String version);
+
+ private CLDeploymentBuilder createRequireCLBuilder()
+ {
+ return createRequireCLBuilder(null);
+ }
+
+ private CLDeploymentBuilder createRequireCLBuilder(VersionRange requiredVersion)
+ {
+ CLDeploymentBuilder clBuilderB = new CLDeploymentBuilder("B", JAR_B_URL);
+ createRequireCapabilities(clBuilderB, requiredVersion);
+ return clBuilderB;
+ }
+
+ protected abstract void createRequireCapabilities(CLDeploymentBuilder clBuilderB, VersionRange version);
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/DependencyTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/HierarchicalDomainClassPoolTestCase.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/HierarchicalDomainClassPoolTestCase.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/HierarchicalDomainClassPoolTestCase.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.classpool.jbosscl.test;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+import org.jboss.test.classpool.support.ClassPoolTestScenario;
+import org.jboss.test.classpool.support.TestScenario;
+
+
+/**
+ * Executes the hierarchical domain tests against a class pool test scenario.
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class HierarchicalDomainClassPoolTestCase extends HierarchicalDomainTest<CtClass, ClassPool>
+{
+ public HierarchicalDomainClassPoolTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected TestScenario<CtClass, ClassPool, CLDeploymentBuilder> getTestScenario()
+ {
+ return new ClassPoolTestScenario<CLDeploymentBuilder>(getClassLoaderFactory());
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/HierarchicalDomainClassPoolTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/HierarchicalDomainSanityTestCase.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/HierarchicalDomainSanityTestCase.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/HierarchicalDomainSanityTestCase.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.classpool.jbosscl.test;
+
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+import org.jboss.test.classpool.support.SanityTestScenario;
+import org.jboss.test.classpool.support.TestScenario;
+
+
+/**
+ * Executes the hierarchical domain tests against a sanity test scenario (for class loader
+ * behavior sanity checking).
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class HierarchicalDomainSanityTestCase extends
+ HierarchicalDomainTest<Class<?>, ClassLoader>
+{
+ public HierarchicalDomainSanityTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected TestScenario<Class<?>, ClassLoader, CLDeploymentBuilder> getTestScenario()
+ {
+ return new SanityTestScenario<CLDeploymentBuilder>(getClassLoaderFactory());
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/HierarchicalDomainSanityTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/HierarchicalDomainTest.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/HierarchicalDomainTest.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/HierarchicalDomainTest.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,295 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.test.classpool.jbosscl.test;
+
+import static org.jboss.classloader.spi.ClassLoaderSystem.DEFAULT_DOMAIN_NAME;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.JAR_A_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.JAR_B_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_A;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_B;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.PACKAGE_A;
+
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+import org.jboss.test.classpool.jbosscl.support.NoSuchClassLoaderException;
+
+/**
+ * Reproduces org.jboss.test.classloading.dependency.test.HierarchicalDomainUnitTestCase using
+ * our test framework.
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public abstract class HierarchicalDomainTest<C, L> extends JBossClClassPoolTest<C, L>
+{
+ private static final String PARENT_DOMAIN = "ParentDomain";
+ private static final String CHILD_DOMAIN = "ChildDomain";
+
+ public HierarchicalDomainTest(String name)
+ {
+ super(name);
+ }
+
+ public void testParentFirst() throws Exception
+ {
+ testParentTwoChildren(true, false);
+ }
+
+ public void testParentFirstImportAll() throws Exception
+ {
+ testParentTwoChildren(true, true);
+ }
+
+ public void testParentLast() throws Exception
+ {
+ testParentTwoChildren(false, false);
+ }
+
+ public void testParentLastImportAll() throws Exception
+ {
+ testParentTwoChildren(false, true);
+ }
+
+ public void testParentLastNotInChild() throws Exception
+ {
+ CLDeploymentBuilder parentCLBuilder = createParentCLBuilder();
+ L parentLoader = testScenario.createLoader(parentCLBuilder);
+ assertCanLoadAButNotB(parentLoader);
+
+ CLDeploymentBuilder childCLBuilder = createChildCLBuilder(false, DEFAULT_DOMAIN_NAME);
+ L childLoader = testScenario.createLoader(childCLBuilder);
+ assertHierarchicalDomain(parentLoader, childLoader);
+ }
+
+
+ public void testParentFirstWrongWayAround() throws Exception
+ {
+ testParentWrongWayAround(true);
+ }
+
+ public void testParentLastWrongWayAround() throws Exception
+ {
+ testParentWrongWayAround(false);
+ }
+
+ public void testParentRedeploy() throws Exception
+ {
+ CLDeploymentBuilder childCLBuilder = createChildCLBuilder(true, DEFAULT_DOMAIN_NAME);
+ try
+ {
+ testScenario.createLoader(childCLBuilder);
+ fail("Should be no loader");
+ }
+ catch(NoSuchClassLoaderException e) {}
+ testScenario.cannotGetLoader(childCLBuilder);
+
+ CLDeploymentBuilder parentCLBuilder = createParentCLBuilder();
+ L parentLoader = testScenario.createLoader(parentCLBuilder);
+ assertCanLoadAButNotB(parentLoader);
+
+ L childLoader = testScenario.getLoader(childCLBuilder);
+ assertHierarchicalDomain(parentLoader, childLoader);
+
+ assertRedeploy(childCLBuilder, parentCLBuilder);
+ }
+
+ public void testParentOtherDomain() throws Exception
+ {
+ CLDeploymentBuilder parentCLBuilder = createParentCLBuilderWithDomain();
+ L parentLoader = testScenario.createLoader(parentCLBuilder);
+ assertCanLoadAButNotB(parentLoader);
+
+ CLDeploymentBuilder childCLBuilder = createChildCLBuilder(true, PARENT_DOMAIN);
+ L childLoader = testScenario.createLoader(childCLBuilder);
+
+ assertHierarchicalDomain(parentLoader, childLoader);
+ }
+
+ public void testParentOtherDomainLazy() throws Exception
+ {
+ CLDeploymentBuilder childCLBuilder = createChildCLBuilder(true, PARENT_DOMAIN);
+ try
+ {
+ testScenario.createLoader(childCLBuilder);
+ fail("Should be no loader");
+ }
+ catch(NoSuchClassLoaderException e) {}
+ testScenario.cannotGetLoader(childCLBuilder);
+
+ CLDeploymentBuilder parentCLBuilder = createParentCLBuilderWithDomain();
+ L parentLoader = testScenario.createLoader(parentCLBuilder);
+ assertCanLoadAButNotB(parentLoader);
+
+ L childLoader = testScenario.getLoader(childCLBuilder);
+ assertHierarchicalDomain(parentLoader, childLoader);
+ }
+
+ public void testParentRedeployOtherDomain() throws Exception
+ {
+ CLDeploymentBuilder childCLBuilder = createChildCLBuilder(true, PARENT_DOMAIN);
+ try
+ {
+ testScenario.createLoader(childCLBuilder);
+ fail("Should be no loader");
+ }
+ catch(NoSuchClassLoaderException e) {}
+ testScenario.cannotGetLoader(childCLBuilder);
+
+ CLDeploymentBuilder parentCLBuilder = createParentCLBuilderWithDomain();
+ L parentLoader = testScenario.createLoader(parentCLBuilder);
+ assertCanLoadAButNotB(parentLoader);
+
+ L childLoader = testScenario.getLoader(childCLBuilder);
+ assertHierarchicalDomain(parentLoader, childLoader);
+
+ assertRedeploy(childCLBuilder, parentCLBuilder);
+ }
+
+ private void testParentTwoChildren(boolean parentFirst, boolean childImportAll)
+ throws NoSuchClassLoaderException, Exception
+ {
+ CLDeploymentBuilder parentCLBuilder = createParentCLBuilder();
+ L parentLoader = testScenario.createLoader(parentCLBuilder);
+ assertCanLoadAButNotB(parentLoader);
+
+ CLDeploymentBuilder childCLBuilderA = new CLDeploymentBuilder("aChild", JAR_A_URL);
+ childCLBuilderA.createDomain(CHILD_DOMAIN, parentFirst);
+ L childLoaderA = testScenario.createLoader(childCLBuilderA);
+ assertCanLoadAButNotB(parentLoader);
+ if (parentFirst)
+ {
+ assertCanLoadAButNotB(childLoaderA, parentLoader);
+ }
+ else
+ {
+ assertCanLoadAButNotB(childLoaderA);
+ }
+
+ CLDeploymentBuilder childCLBuilderB = createChildCLBuilder(childImportAll);
+ L childLoaderB = testScenario.createLoader(childCLBuilderB);
+ if (parentFirst)
+ {
+ testScenario.loadClass(childLoaderA, parentLoader, CLASS_A);
+ }
+ else
+ {
+ testScenario.loadClass(childLoaderA, CLASS_A);
+ }
+ if (childImportAll)
+ {
+ testScenario.loadClass(childLoaderA, childLoaderB, CLASS_B);
+ }
+ else
+ {
+ testScenario.cannotLoadClass(childLoaderA, CLASS_B);
+ }
+ testScenario.loadClass(childLoaderB, CLASS_B);
+ testScenario.loadClass(childLoaderB, parentFirst? parentLoader: childLoaderA, CLASS_A);
+ }
+
+ private void testParentWrongWayAround(boolean parentFirst) throws Exception
+ {
+ CLDeploymentBuilder childBuilder = createChildCLBuilder(parentFirst, DEFAULT_DOMAIN_NAME);
+ try
+ {
+ testScenario.createLoader(childBuilder);
+ fail("Should be no loader");
+ }
+ catch(NoSuchClassLoaderException e) {}
+ testScenario.cannotGetLoader(childBuilder);
+
+ CLDeploymentBuilder parentBuilder = createParentCLBuilder();
+ L parentLoader = testScenario.createLoader(parentBuilder);
+ assertCanLoadAButNotB(parentLoader);
+
+ L childLoader = testScenario.getLoader(childBuilder);
+ assertHierarchicalDomain(parentLoader, childLoader);
+ }
+
+
+ private void assertRedeploy(CLDeploymentBuilder childCLBuilder,
+ CLDeploymentBuilder parentCLBuilder)
+ throws NoSuchClassLoaderException, Exception
+ {
+ L parentLoader;
+ L childLoader;
+ testScenario.destroyLoader(parentCLBuilder);
+
+ testScenario.cannotGetLoader(parentCLBuilder);
+ testScenario.cannotGetLoader(childCLBuilder);
+
+ parentLoader = testScenario.createLoader(parentCLBuilder);
+ assertCanLoadAButNotB(parentLoader);
+
+ childLoader = testScenario.getLoader(childCLBuilder);
+ assertHierarchicalDomain(parentLoader, childLoader);
+ }
+
+ private CLDeploymentBuilder createParentCLBuilder()
+ {
+ return new CLDeploymentBuilder("aParent", JAR_A_URL);
+ }
+
+ private CLDeploymentBuilder createParentCLBuilderWithDomain()
+ {
+ CLDeploymentBuilder parentCLBuilder = createParentCLBuilder();
+ parentCLBuilder.createDomain(PARENT_DOMAIN, true);
+ return parentCLBuilder;
+ }
+
+ private CLDeploymentBuilder createChildCLBuilder(boolean importAll)
+ {
+ CLDeploymentBuilder childCLBuilderB = new CLDeploymentBuilder("b", JAR_B_URL);
+ childCLBuilderB.setDomain(CHILD_DOMAIN);
+ childCLBuilderB.createRequirePackage(PACKAGE_A);
+ childCLBuilderB.setImportAll(importAll);
+ return childCLBuilderB;
+ }
+
+ private CLDeploymentBuilder createChildCLBuilder(boolean parentFirst, String parentDomain)
+ {
+ CLDeploymentBuilder childBuilder = new CLDeploymentBuilder("b", JAR_B_URL);
+ childBuilder.createDomain(CHILD_DOMAIN, parentDomain, parentFirst);
+ childBuilder.createRequirePackage(PACKAGE_A);
+ childBuilder.setImportAll(false);
+ return childBuilder;
+ }
+
+ private void assertCanLoadAButNotB(L parentLoader) throws Exception
+ {
+ assertCanLoadAButNotB(parentLoader, parentLoader);
+ }
+
+ private void assertCanLoadAButNotB(L parentLoader, L actualLoader) throws Exception
+ {
+ testScenario.loadClass(parentLoader, actualLoader, CLASS_A);
+ testScenario.cannotLoadClass(parentLoader, CLASS_B);
+ }
+
+ private void assertHierarchicalDomain(L parentLoader, L childLoader)
+ throws Exception
+ {
+ assertCanLoadAButNotB(parentLoader);
+ testScenario.loadClass(childLoader, CLASS_B);
+ testScenario.loadClass(childLoader, parentLoader, CLASS_A);
+ }
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/HierarchicalDomainTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/HierarchicalParentLoaderClassPoolTestCase.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/HierarchicalParentLoaderClassPoolTestCase.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/HierarchicalParentLoaderClassPoolTestCase.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.classpool.jbosscl.test;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+import org.jboss.test.classpool.support.ClassPoolTestScenario;
+import org.jboss.test.classpool.support.TestScenario;
+
+
+/**
+ * Executes the hierarchical parent loader tests against a class pool test scenario.
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class HierarchicalParentLoaderClassPoolTestCase extends
+ HierarchicalParentLoaderTest<CtClass, ClassPool>
+{
+ public HierarchicalParentLoaderClassPoolTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected TestScenario<CtClass, ClassPool, CLDeploymentBuilder> getTestScenario()
+ {
+ return new ClassPoolTestScenario<CLDeploymentBuilder>(getClassLoaderFactory());
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/HierarchicalParentLoaderClassPoolTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/HierarchicalParentLoaderSanityTestCase.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/HierarchicalParentLoaderSanityTestCase.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/HierarchicalParentLoaderSanityTestCase.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.classpool.jbosscl.test;
+
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+import org.jboss.test.classpool.support.SanityTestScenario;
+import org.jboss.test.classpool.support.TestScenario;
+
+
+
+/**
+ * Executes the hierarchical parent loader tests against a sanity test scenario (for class
+ * loader behavior sanity checking).
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class HierarchicalParentLoaderSanityTestCase extends
+ HierarchicalParentLoaderTest<Class<?>, ClassLoader>
+{
+ public HierarchicalParentLoaderSanityTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected TestScenario<Class<?>, ClassLoader, CLDeploymentBuilder> getTestScenario()
+ {
+ return new SanityTestScenario<CLDeploymentBuilder>(getClassLoaderFactory());
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/HierarchicalParentLoaderSanityTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/HierarchicalParentLoaderTest.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/HierarchicalParentLoaderTest.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/HierarchicalParentLoaderTest.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,117 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.test.classpool.jbosscl.test;
+
+
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.JAR_A_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_A;
+
+import java.net.URL;
+
+import org.jboss.classloader.spi.ClassLoaderDomain;
+import org.jboss.classloader.spi.ParentPolicy;
+import org.jboss.classloader.spi.filter.ClassFilter;
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+import org.jboss.test.classpool.jbosscl.support.DomainRegistry;
+import org.jboss.test.classpool.jbosscl.support.NoMatchClassFilter;
+
+/**
+ * Reproduces org.jboss.test.classloader.domain.test.HierarchicalParentLoaderUnitTestCase using
+ * our test framework.
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public abstract class HierarchicalParentLoaderTest<C, L> extends JBossClClassPoolTest<C, L>
+{
+ public HierarchicalParentLoaderTest(String name)
+ {
+ super(name);
+ }
+
+ public void testHierarchyBefore() throws Exception
+ {
+ runTest(ParentPolicy.BEFORE_BUT_JAVA_ONLY, ParentPolicy.BEFORE, true);
+ }
+
+
+ public void testHierarchyBeforeNotFound() throws Exception
+ {
+ runTest(ParentPolicy.BEFORE_BUT_JAVA_ONLY, ParentPolicy.BEFORE, false, false);
+ }
+
+ public void testHierarchyAfterNotReached() throws Exception
+ {
+ runTest(ParentPolicy.BEFORE_BUT_JAVA_ONLY, ParentPolicy.AFTER_BUT_JAVA_BEFORE, false);
+ }
+
+ public void testHierarchyAfterReached() throws Exception
+ {
+ runTest(ParentPolicy.BEFORE_BUT_JAVA_ONLY, ParentPolicy.AFTER_BUT_JAVA_BEFORE, null, true);
+ }
+
+ public void testHierarchyFiltered() throws Exception
+ {
+ NoMatchClassFilter filter = new NoMatchClassFilter(CLASS_A);
+ runTest(ParentPolicy.BEFORE_BUT_JAVA_ONLY, new ParentPolicy(filter, ClassFilter.NOTHING), false);
+
+ assertTrue("Should have been filtered", filter.filtered);
+ }
+
+
+ private void runTest(ParentPolicy parentParentPolicy, ParentPolicy childParentPolicy, boolean expectedParent) throws Exception
+ {
+ runTest(parentParentPolicy, childParentPolicy, true, JAR_A_URL, expectedParent);
+ }
+
+ private void runTest(ParentPolicy parentParentPolicy, ParentPolicy childParentPolicy, boolean createParent, boolean expectedParent) throws Exception
+ {
+ runTest(parentParentPolicy, childParentPolicy, createParent, JAR_A_URL, expectedParent);
+ }
+
+ private void runTest(ParentPolicy parentParentPolicy, ParentPolicy childParentPolicy, URL url, boolean expectedParent) throws Exception
+ {
+ runTest(parentParentPolicy, childParentPolicy, true, url, expectedParent);
+ }
+
+ private void runTest(ParentPolicy parentParentPolicy, ParentPolicy childParentPolicy, boolean createParent, URL childURL, boolean expectedParent) throws Exception
+ {
+ final String parentName = "parent";
+ final String childName = "child";
+ ClassLoaderDomain parent = system.createAndRegisterDomain(parentName, parentParentPolicy);
+ DomainRegistry.registerDomain(parent);
+ ClassLoaderDomain child = system.createAndRegisterDomain(childName, childParentPolicy, parent);
+ DomainRegistry.registerDomain(child);
+ L parentLoader = null;
+ if (createParent)
+ {
+ CLDeploymentBuilder parentCLBuilder = new CLDeploymentBuilder("ParentLoader", JAR_A_URL);
+ parentCLBuilder.setDomain(parentName);
+ parentLoader = testScenario.createLoader(parentCLBuilder);
+ }
+ CLDeploymentBuilder childCLBuilder = new CLDeploymentBuilder("ChildLoader", childURL);
+ childCLBuilder.setDomain(childName);
+ L childLoader = testScenario.createLoader(childCLBuilder);
+ testScenario.loadClass(childLoader, expectedParent ? parentLoader : childLoader, CLASS_A);
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/HierarchicalParentLoaderTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/JBossClClassPoolTest.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/JBossClClassPoolTest.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/JBossClClassPoolTest.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,184 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.test.classpool.jbosscl.test;
+
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_A;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_B;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_C;
+import junit.framework.Test;
+
+import org.jboss.classloader.spi.ClassLoaderSystem;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.test.AbstractTestCaseWithSetup;
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+import org.jboss.test.classpool.jbosscl.support.JBossCLFactory;
+import org.jboss.test.classpool.support.ClassLoaderFactory;
+import org.jboss.test.classpool.support.MicrocontainerFacade;
+import org.jboss.test.classpool.support.TestScenario;
+import org.jboss.test.kernel.junit.MicrocontainerTest;
+import org.jboss.virtual.VFS;
+
+/**
+ * Base class for testing the JBossClDelegatingClassPools.
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public abstract class JBossClClassPoolTest<C, L> extends MicrocontainerTest
+{
+ public static JBossClClassPoolTestDelegate getDelegate(Class<?> clazz) throws Exception
+ {
+ return new JBossClClassPoolTestDelegate(clazz);
+ }
+
+ protected JBossClClassPoolTestDelegate getDelegate()
+ {
+ return (JBossClClassPoolTestDelegate) super.getDelegate();
+ }
+
+ public static Test suite(Class<?> clazz)
+ {
+ return AbstractTestCaseWithSetup.suite(clazz);
+ }
+
+ /****** HELPER FIELDS ********************************************************************/
+
+ /** The classloader helper */
+ protected ClassLoaderSystem system;
+
+ /****** CONSTRUCTOR **********************************************************************/
+
+ /**
+ * Constructor.
+ * @param name name of the test
+ */
+ public JBossClClassPoolTest(String name)
+ {
+ super(name);
+ }
+
+ /****** OVERRIDDEN METHODS ***************************************************************/
+
+ protected TestScenario<C, L, CLDeploymentBuilder> testScenario;
+
+ protected abstract TestScenario<C, L, CLDeploymentBuilder> getTestScenario();
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ VFS.init();
+ // TODO JBREFLECT-80
+ // excluding class that knows hot to load from system classloader
+ //Set<Class<?>> excluded = AbstractJDKChecker.getExcluded();
+ //excluded.add(BeanMetaDataFactoryVisitor.class);
+ // This is a hack for a hack. ;-)
+ //excluded.add(SanityTestScenario.class);
+ //excluded.add(TestScenario.class);
+ //excluded.add(ClassPoolTestScenario.class);
+ system = (ClassLoaderSystem) getBean("ClassLoaderSystem");
+ this.testScenario = getTestScenario();
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ try
+ {
+ this.testScenario.destroyLoaders();
+ }
+ finally
+ {
+ super.tearDown();
+ }
+ }
+
+ /****** ASSERT METHODS ***************************************************************/
+
+ private void assertCannotLoadClass(String className, ClassLoader cl)
+ {
+ try
+ {
+ cl.loadClass(className);
+ fail("Should not have been able to load " + className);
+ }
+ catch(ClassNotFoundException expected)
+ {
+ }
+ }
+
+
+ /****** TEST METHOD ******************************************************************/
+
+ /**
+ * The test classes should not be on the launcher classpath
+ */
+ // TODO JBREFLECT-80
+ public void testClassesNotOnClasspath()
+ {
+ assertCannotLoadClass(CLASS_A, this.getClass().getClassLoader());
+ assertCannotLoadClass(CLASS_B, this.getClass().getClassLoader());
+ assertCannotLoadClass(CLASS_C, this.getClass().getClassLoader());
+ }
+
+ /****** AUXILIARY INTERNAL CLASS *****************************************************/
+
+ protected ClassLoaderFactory<CLDeploymentBuilder> getClassLoaderFactory()
+ {
+ return new JBossCLFactory(getMicrocontainerFacade());
+ }
+
+ private MicrocontainerFacade getMicrocontainerFacade()
+ {
+ return new MicrocontainerFacadeImpl();
+ }
+
+ private class MicrocontainerFacadeImpl implements MicrocontainerFacade
+ {
+ public void deploy(KernelDeployment deployment) throws Exception
+ {
+ JBossClClassPoolTest.this.deploy(deployment);
+ }
+
+ public Object getBean(Object name)
+ {
+ return JBossClClassPoolTest.this.getBean(name);
+ }
+
+ public Object getBean(Object name, ControllerState state)
+ {
+ return JBossClClassPoolTest.this.getBean(name, state);
+ }
+
+ public <T> T assertBean(Object name, Class<T> expected)
+ {
+ return JBossClClassPoolTest.this.assertBean(name, expected);
+ }
+
+ public void undeploy(KernelDeployment deployment)
+ {
+ JBossClClassPoolTest.this.undeploy(deployment);
+ }
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/JBossClClassPoolTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/JBossClClassPoolTestDelegate.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/JBossClClassPoolTestDelegate.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/JBossClClassPoolTestDelegate.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,139 @@
+/*
+ * 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.test.classpool.jbosscl.test;
+
+import java.net.URL;
+
+import javassist.ClassPool;
+
+import javax.management.MBeanServer;
+
+import org.jboss.classloader.plugins.ClassLoaderUtils;
+import org.jboss.classloader.plugins.filter.PatternClassFilter;
+import org.jboss.classloader.spi.ParentPolicy;
+import org.jboss.classloader.spi.filter.ClassFilter;
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData10;
+import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory10;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.deployers.plugins.main.MainDeployerImpl;
+import org.jboss.test.classpool.jbosscl.support.FilteredClassPool;
+import org.jboss.test.kernel.junit.MicrocontainerTestDelegate;
+import org.jboss.xb.binding.resolver.MutableSchemaResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
+
+/**
+ * BootstrapDeployersTestDelegate.
+ *
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class JBossClClassPoolTestDelegate extends MicrocontainerTestDelegate
+{
+ @SuppressWarnings("unused")
+ private static ParentPolicy parentPolicy;
+ @SuppressWarnings("unused")
+ private static ClassPool defaultClassPool;
+
+ private MainDeployerImpl mainDeployer;
+
+ private MBeanServer server = null;
+
+ static
+ {
+ MutableSchemaResolver resolver = SingletonSchemaResolverFactory.getInstance().getSchemaBindingResolver();
+ resolver.mapURIToClass("urn:jboss:classloader:1.0", VFSClassLoaderFactory10.class);
+ resolver.mapURIToClass("urn:jboss:classloading:1.0", ClassLoadingMetaData10.class);
+ // FIXME JBREFLECT-80
+ //String packageA = A.class.getPackage().getName();
+ String packageA = "org.jboss.test.classpool.support";
+ final String packageName = packageA.substring(0, packageA.lastIndexOf('.'));
+ ClassFilter classFilter = new ClassFilter()
+ {
+ String packagePath = ClassLoaderUtils.packageNameToPath(packageName);
+ ClassFilter patternFilter = new PatternClassFilter(
+ new String[] { packageName + "\\..+" },
+ new String[] { packagePath + "/.+" },
+ new String[] { packageName, packageName + "\\..*"}
+ );
+ public boolean matchesClassName(String className)
+ {
+ return patternFilter.matchesClassName(className) == false;
+ }
+
+ public boolean matchesPackageName(String packageName)
+ {
+ return patternFilter.matchesPackageName(packageName) == false;
+ }
+
+ public boolean matchesResourcePath(String resourcePath)
+ {
+ return patternFilter.matchesResourcePath(resourcePath) == false;
+ }
+
+ public String toString()
+ {
+ return "EXCLUDE " + patternFilter;
+ }
+ };
+
+ parentPolicy = new ParentPolicy(classFilter, ClassFilter.NOTHING, "BEFORE");
+
+ defaultClassPool = new FilteredClassPool(ClassPool.getDefault(), classFilter);
+ }
+
+ public JBossClClassPoolTestDelegate(Class<?> clazz) throws Exception
+ {
+ super(clazz);
+ }
+
+ public MBeanServer getMBeanServer()
+ {
+ return server;
+ }
+
+ public void setMBeanServer(MBeanServer server)
+ {
+ this.server = server;
+ }
+
+ protected void deploy() throws Exception
+ {
+ String common = "/org/jboss/test/classpool/jbosscl/Common.xml";
+ URL url = getClass().getResource(common);
+ if (url == null)
+ throw new IllegalStateException(common + " not found");
+ deploy(url);
+ // TODO JBREFLECT-80
+ //ClassLoaderSystem system = getBean("ClassLoaderSystem", ControllerState.INSTALLED, ClassLoaderSystem.class);
+ //ClassLoaderDomain domain = system.getDefaultDomain();
+ //domain.setParentPolicy(parentPolicy);
+ //AbstractClassPoolFactory.setDefaultClassPool(defaultClassPool);
+ super.deploy();
+ }
+
+ protected MainDeployerImpl getMainDeployer()
+ {
+ if (mainDeployer == null)
+ mainDeployer = getBean("MainDeployer", ControllerState.INSTALLED, MainDeployerImpl.class);
+ return mainDeployer;
+ }
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/JBossClClassPoolTestDelegate.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ModuleDependencyClassPoolTestCase.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ModuleDependencyClassPoolTestCase.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ModuleDependencyClassPoolTestCase.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.classpool.jbosscl.test;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+import org.jboss.test.classpool.support.ClassPoolTestScenario;
+import org.jboss.test.classpool.support.TestScenario;
+
+
+/**
+ * Executes the module dependency tests against a class pool test scenario.
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class ModuleDependencyClassPoolTestCase extends ModuleDependencyTest<CtClass, ClassPool>
+{
+ public ModuleDependencyClassPoolTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected TestScenario<CtClass, ClassPool, CLDeploymentBuilder> getTestScenario()
+ {
+ return new ClassPoolTestScenario<CLDeploymentBuilder>(getClassLoaderFactory());
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ModuleDependencyClassPoolTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ModuleDependencySanityTestCase.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ModuleDependencySanityTestCase.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ModuleDependencySanityTestCase.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.classpool.jbosscl.test;
+
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+import org.jboss.test.classpool.support.SanityTestScenario;
+import org.jboss.test.classpool.support.TestScenario;
+
+/**
+ * Executes the module dependency tests against a sanity test scenario (for class loader
+ * behavior sanity checking).
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class ModuleDependencySanityTestCase extends ModuleDependencyTest<Class<?>, ClassLoader>
+{
+ public ModuleDependencySanityTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected TestScenario<Class<?>, ClassLoader, CLDeploymentBuilder> getTestScenario()
+ {
+ return new SanityTestScenario<CLDeploymentBuilder>(getClassLoaderFactory());
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ModuleDependencySanityTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ModuleDependencyTest.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ModuleDependencyTest.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ModuleDependencyTest.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,82 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.test.classpool.jbosscl.test;
+
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.PACKAGE_A;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.PACKAGE_B;
+
+import org.jboss.classloading.spi.version.VersionRange;
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+
+/**
+ * Reproduces org.jboss.test.classloading.vfs.metadata.test.ModuleDependencyUnitTestCase using
+ * our test framework. The original tests are testImportNoVersionCheck, testImportVersionCheck
+ * and testImportVersionCheckFailed.
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public abstract class ModuleDependencyTest<C, L> extends DependencyTest<C, L>
+{
+ public ModuleDependencyTest(String name)
+ {
+ super(name);
+ }
+
+ public void testSeveralModulesWithSamePackages() throws Exception
+ {
+ testSeveralModulesWithSamePackages("A");
+ }
+
+ @Override
+ protected void createExportCapabilities(CLDeploymentBuilder clBuilderA, String moduleName,
+ String version)
+ {
+ if (version == null)
+ {
+ clBuilderA.createModule(moduleName);
+ }
+ else
+ {
+ clBuilderA.createModule(moduleName, version);
+ }
+ clBuilderA.createPackage(PACKAGE_A);
+ clBuilderA.setImportAll(false);
+ }
+
+ @Override
+ protected void createRequireCapabilities(CLDeploymentBuilder clBuilderB, VersionRange version)
+ {
+ if (version == null)
+ {
+ clBuilderB.createRequireModule("ModuleA");
+ }
+ else
+ {
+ clBuilderB.createRequireModule("ModuleA", version);
+ }
+ clBuilderB.createModule("ModuleB");
+ clBuilderB.createPackage(PACKAGE_B);
+ clBuilderB.setImportAll(false);
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ModuleDependencyTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/PackageDependencyClassPoolTestCase.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/PackageDependencyClassPoolTestCase.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/PackageDependencyClassPoolTestCase.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.classpool.jbosscl.test;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+import org.jboss.test.classpool.support.ClassPoolTestScenario;
+import org.jboss.test.classpool.support.TestScenario;
+
+/**
+ * Executes the package dependency tests against a class pool test scenario.
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class PackageDependencyClassPoolTestCase extends PackageDependencyTest<CtClass, ClassPool>
+{
+ public PackageDependencyClassPoolTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected TestScenario<CtClass, ClassPool, CLDeploymentBuilder> getTestScenario()
+ {
+ return new ClassPoolTestScenario<CLDeploymentBuilder>(getClassLoaderFactory());
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/PackageDependencyClassPoolTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/PackageDependencySanityTestCase.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/PackageDependencySanityTestCase.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/PackageDependencySanityTestCase.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.classpool.jbosscl.test;
+
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+import org.jboss.test.classpool.support.SanityTestScenario;
+import org.jboss.test.classpool.support.TestScenario;
+
+/**
+ * Executes the package dependency tests against a sanity test scenario (for class loader
+ * behavior sanity checking).
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class PackageDependencySanityTestCase extends PackageDependencyTest<Class<?>, ClassLoader>
+{
+ public PackageDependencySanityTestCase(String name)
+ {
+ super(name);
+ }
+
+
+ @Override
+ protected TestScenario<Class<?>, ClassLoader, CLDeploymentBuilder> getTestScenario()
+ {
+ return new SanityTestScenario<CLDeploymentBuilder>(getClassLoaderFactory());
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/PackageDependencySanityTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/PackageDependencyTest.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/PackageDependencyTest.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/PackageDependencyTest.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,82 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.test.classpool.jbosscl.test;
+
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.PACKAGE_A;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.PACKAGE_B;
+
+import org.jboss.classloading.spi.version.VersionRange;
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+
+/**
+ * Reproduces org.jboss.test.classloading.vfs.metadata.test.PackageDependencyUnitTestCase using
+ * our test framework. The original tests are testImportNoVersionCheck, testImportVersionCheck
+ * and testImportVersionCheckFailed.
+ *
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public abstract class PackageDependencyTest<C, L> extends DependencyTest<C, L>
+{
+ public PackageDependencyTest(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ public void testSeveralModulesWithSamePackages() throws Exception
+ {
+ testSeveralModulesWithSamePackages("X");
+ }
+
+ @Override
+ protected void createExportCapabilities(CLDeploymentBuilder clBuilderA, String moduleName,
+ String version)
+ {
+ clBuilderA.createModule(moduleName);
+ if (version == null)
+ {
+ clBuilderA.createPackage(PACKAGE_A);
+ }
+ else
+ {
+ clBuilderA.createPackage(PACKAGE_A, version);
+ }
+ clBuilderA.setImportAll(false);
+ }
+
+ @Override
+ protected void createRequireCapabilities(CLDeploymentBuilder clBuilderB, VersionRange version)
+ {
+ if (version == null)
+ {
+ clBuilderB.createRequirePackage(PACKAGE_A);
+ }
+ else
+ {
+ clBuilderB.createRequirePackage(PACKAGE_A, version);
+ }
+ clBuilderB.createPackage(PACKAGE_B);
+ clBuilderB.setImportAll(false);
+ }
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/PackageDependencyTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportModuleClassPoolTestCase.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportModuleClassPoolTestCase.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportModuleClassPoolTestCase.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.classpool.jbosscl.test;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+import org.jboss.test.classpool.support.ClassPoolTestScenario;
+import org.jboss.test.classpool.support.TestScenario;
+
+
+/**
+ * Executes the ReExportModule tests against a class pool test scenario.
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class ReExportModuleClassPoolTestCase extends
+ ReExportModuleTest<CtClass, ClassPool>
+{
+ public ReExportModuleClassPoolTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected TestScenario<CtClass, ClassPool, CLDeploymentBuilder> getTestScenario()
+ {
+ return new ClassPoolTestScenario<CLDeploymentBuilder>(getClassLoaderFactory());
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportModuleClassPoolTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportModuleSanityTestCase.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportModuleSanityTestCase.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportModuleSanityTestCase.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.classpool.jbosscl.test;
+
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+import org.jboss.test.classpool.support.SanityTestScenario;
+import org.jboss.test.classpool.support.TestScenario;
+
+
+/**
+ * Executes the ReExportModule tests against a sanity test scenario (for class loader behavior
+ * sanity checking).
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class ReExportModuleSanityTestCase extends ReExportModuleTest<Class<?>, ClassLoader>
+{
+ public ReExportModuleSanityTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected TestScenario<Class<?>, ClassLoader, CLDeploymentBuilder> getTestScenario()
+ {
+ return new SanityTestScenario<CLDeploymentBuilder>(getClassLoaderFactory());
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportModuleSanityTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportModuleTest.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportModuleTest.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportModuleTest.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.test.classpool.jbosscl.test;
+
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+
+/**
+ * Reproduces org.jboss.test.classloading.vfs.metadata.test.ReExportPackageUnitTestCase using
+ * our test framework.
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public abstract class ReExportModuleTest<C, L> extends ReExportTest<C, L>
+{
+ public ReExportModuleTest(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected void createReExport(CLDeploymentBuilder clBuilder)
+ {
+ clBuilder.createReExportModule(MODULE_A);
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportModuleTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportPackageClassPoolTestCase.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportPackageClassPoolTestCase.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportPackageClassPoolTestCase.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.classpool.jbosscl.test;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+import org.jboss.test.classpool.support.ClassPoolTestScenario;
+import org.jboss.test.classpool.support.TestScenario;
+
+/**
+ * Executes the ReExportPackage tests against a class pool test scenario.
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class ReExportPackageClassPoolTestCase extends ReExportPackageTest<CtClass, ClassPool>
+{
+ public ReExportPackageClassPoolTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected TestScenario<CtClass, ClassPool, CLDeploymentBuilder> getTestScenario()
+ {
+ return new ClassPoolTestScenario<CLDeploymentBuilder>(getClassLoaderFactory());
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportPackageClassPoolTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportPackageSanityTestCase.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportPackageSanityTestCase.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportPackageSanityTestCase.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.classpool.jbosscl.test;
+
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+import org.jboss.test.classpool.support.SanityTestScenario;
+import org.jboss.test.classpool.support.TestScenario;
+
+
+/**
+ * Executes the ReExportPackage tests against a sanity test scenario (for class loader behavior
+ * sanity checking).
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class ReExportPackageSanityTestCase extends ReExportPackageTest<Class<?>, ClassLoader>
+{
+ public ReExportPackageSanityTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected TestScenario<Class<?>, ClassLoader, CLDeploymentBuilder> getTestScenario()
+ {
+ return new SanityTestScenario<CLDeploymentBuilder>(getClassLoaderFactory());
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportPackageSanityTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportPackageTest.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportPackageTest.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportPackageTest.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,48 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.test.classpool.jbosscl.test;
+
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.PACKAGE_A;
+
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+
+/**
+ * Reproduces org.jboss.test.classloading.vfs.metadata.test.ReExportPackageUnitTestCase using
+ * our test framework.
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public abstract class ReExportPackageTest<C, L> extends ReExportTest<C, L>
+{
+ public ReExportPackageTest(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected void createReExport(CLDeploymentBuilder clBuilder)
+ {
+ clBuilder.createReExportPackage(PACKAGE_A);
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportPackageTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportTest.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportTest.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportTest.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,145 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.test.classpool.jbosscl.test;
+
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.JAR_A_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.JAR_B_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.JAR_C_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_A;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_B;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_C;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.PACKAGE_A;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.PACKAGE_B;
+
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+
+/**
+ * Contains tests for reExport test scenarios, such as reExportModule and ReExportPackage.
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public abstract class ReExportTest<C, L> extends JBossClClassPoolTest<C, L>
+{
+ protected static final String MODULE_B = "b";
+ protected static final String MODULE_A = "a";
+
+
+ public ReExportTest(String name)
+ {
+ super(name);
+ }
+ public void testReExport() throws Exception
+ {
+ assertReExport(true);
+ }
+
+ public void testNoReExport() throws Exception
+ {
+ assertReExport(false);
+ }
+
+ private void assertReExport(boolean reExport) throws Exception
+ {
+ CLDeploymentBuilder clBuilderA = new CLDeploymentBuilder("A", JAR_A_URL);
+ clBuilderA.createModule(MODULE_A).createPackage(PACKAGE_A).setImportAll(false);
+ L loaderA = testScenario.createLoader(clBuilderA);
+
+ C classA = testScenario.loadClass(loaderA, CLASS_A);
+ testScenario.cannotLoadClass(loaderA, CLASS_B);
+ testScenario.cannotLoadClass(loaderA, CLASS_C);
+
+ CLDeploymentBuilder clBuilderB = new CLDeploymentBuilder("B", JAR_B_URL);
+ clBuilderB.createModule(MODULE_B).createPackage(PACKAGE_B).setImportAll(false);
+ createReExport(clBuilderB);
+ L loaderB = testScenario.createLoader(clBuilderB);
+
+ C classA1 = testScenario.loadClass(loaderA, CLASS_A);
+ assertSame(classA, classA1);
+ testScenario.cannotLoadClass(loaderA, CLASS_B);
+ testScenario.cannotLoadClass(loaderA, CLASS_C);
+
+ classA1 = testScenario.loadClass(loaderB, loaderA, CLASS_A);
+ assertSame(classA, classA1);
+ C classB = testScenario.loadClass(loaderB, CLASS_B);
+ testScenario.cannotLoadClass(loaderB, CLASS_C);
+
+ CLDeploymentBuilder clBuilderC = new CLDeploymentBuilder("C", JAR_C_URL);
+ clBuilderC.setImportAll(false);
+ if (reExport)
+ {
+ clBuilderC.createRequireModule(MODULE_B);
+ }
+ else
+ {
+ clBuilderC.createRequirePackage(PACKAGE_B);
+ }
+ L loaderC = testScenario.createLoader(clBuilderC);
+
+ classA1 = testScenario.loadClass(loaderA, CLASS_A);
+ assertSame(classA, classA1);
+ testScenario.cannotLoadClass(loaderA, CLASS_B);
+ testScenario.cannotLoadClass(loaderA, CLASS_C);
+
+ classA1 = testScenario.loadClass(loaderB, loaderA, CLASS_A);
+ assertSame(classA, classA1);
+ C classB1 = testScenario.loadClass(loaderB, CLASS_B);
+ assertSame(classB, classB1);
+ testScenario.cannotLoadClass(loaderB, CLASS_C);
+
+ if (reExport)
+ {
+ classA1 = testScenario.loadClass(loaderC, loaderA, CLASS_A);
+ assertSame(classA, classA1);
+ }
+ else
+ {
+ testScenario.cannotLoadClass(loaderC, CLASS_A);
+ }
+ classB1 = testScenario.loadClass(loaderC, loaderB, CLASS_B);
+ assertSame(classB, classB1);
+ testScenario.loadClass(loaderC, CLASS_C);
+
+ testScenario.destroyLoader(clBuilderC);
+
+ classA1 = testScenario.loadClass(loaderA, CLASS_A);
+ assertSame(classA, classA1);
+ testScenario.cannotLoadClass(loaderA, CLASS_B);
+ testScenario.cannotLoadClass(loaderA, CLASS_C);
+
+ classA1 = testScenario.loadClass(loaderB, loaderA, CLASS_A);
+ assertSame(classA, classA1);
+ classB1 = testScenario.loadClass(loaderB, CLASS_B);
+ assertSame(classB, classB1);
+ testScenario.cannotLoadClass(loaderB, CLASS_C);
+
+ testScenario.destroyLoader(clBuilderB);
+
+ classA1 = testScenario.loadClass(loaderA, CLASS_A);
+ assertSame(classA, classA1);
+ testScenario.cannotLoadClass(loaderA, CLASS_B);
+ testScenario.cannotLoadClass(loaderA, CLASS_C);
+ }
+
+ protected abstract void createReExport(CLDeploymentBuilder clBuilder);
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReExportTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReplaceReferencesClassPoolTestCase.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReplaceReferencesClassPoolTestCase.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReplaceReferencesClassPoolTestCase.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,313 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.test.classpool.jbosscl.test;
+
+
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.CHILD_JAR_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.PARENT_JAR_URL;
+
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.ProtectionDomain;
+import java.util.Collection;
+
+import javassist.ClassPool;
+import javassist.CodeConverter;
+import javassist.CtClass;
+import javassist.CtConstructor;
+import javassist.CtField;
+import javassist.CtMethod;
+import javassist.CtNewMethod;
+import javassist.Modifier;
+import javassist.scopedpool.ScopedClassPool;
+
+import org.jboss.classloading.spi.DomainClassLoader;
+import org.jboss.classpool.spi.ClassPoolRepository;
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+import org.jboss.test.classpool.jbosscl.support.SupportClasses;
+import org.jboss.test.classpool.support.ClassPoolTestScenario;
+import org.jboss.test.classpool.support.TestScenario;
+import org.jboss.util.loading.Translator;
+
+/**
+ * Test that field/constructor wrapper replacement works since there were some problems in AS5
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class ReplaceReferencesClassPoolTestCase extends JBossClClassPoolTest<CtClass, ClassPool>
+{
+ final static String STRING = String.class.getName();
+
+ public final String x = "org.jboss.test.classpool.support.excluded";
+
+ private final static Translator TRANSLATOR = new MyTranslator();
+
+ public ReplaceReferencesClassPoolTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected TestScenario<CtClass, ClassPool, CLDeploymentBuilder> getTestScenario()
+ {
+ return new ClassPoolTestScenario<CLDeploymentBuilder>(getClassLoaderFactory());
+ }
+
+ @Override
+ @SuppressWarnings("all")
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ system.setTranslator(TRANSLATOR);
+ }
+
+ @Override
+ @SuppressWarnings("all")
+ public void tearDown() throws Exception
+ {
+ system.setTranslator(null);
+ super.tearDown();
+ }
+
+ public void testParentLoadedParentDelegation() throws Exception
+ {
+ ClassPool globalPool = testScenario.createLoader(new CLDeploymentBuilder("GLOBAL", PARENT_JAR_URL));
+ CLDeploymentBuilder childCLBuilder = new CLDeploymentBuilder("SCOPED", CHILD_JAR_URL);
+ childCLBuilder.createDomain("SCOPED", true);
+ ClassPool scopedPool = testScenario.createLoader(childCLBuilder);
+
+ loadClassAndRunTest(SupportClasses.CLASS_PARENT_CALLER, globalPool.getClassLoader());
+ loadClassAndRunTest(SupportClasses.CLASS_CHILD_CALLER, scopedPool.getClassLoader());
+ }
+
+ public void testParentLoadedNoParentDelegation() throws Exception
+ {
+ ClassPool globalPool = testScenario.createLoader(new CLDeploymentBuilder("GLOBAL", PARENT_JAR_URL));
+ CLDeploymentBuilder childCLBuilder = new CLDeploymentBuilder("SCOPED", CHILD_JAR_URL);
+ childCLBuilder.createDomain("SCOPED", false);
+ ClassPool scopedPool = testScenario.createLoader(childCLBuilder);
+
+ loadClassAndRunTest(SupportClasses.CLASS_PARENT_CALLER, globalPool.getClassLoader());
+ loadClassAndRunTest(SupportClasses.CLASS_CHILD_CALLER, scopedPool.getClassLoader());
+ }
+
+ public void testParentNotLoadedParentDelegation() throws Exception
+ {
+ testScenario.createLoader(new CLDeploymentBuilder("GLOBAL", PARENT_JAR_URL));
+ CLDeploymentBuilder childCLBuilder = new CLDeploymentBuilder("SCOPED", CHILD_JAR_URL);
+ childCLBuilder.createDomain("SCOPED", true);
+ ClassPool scopedPool = testScenario.createLoader(childCLBuilder);
+
+ loadClassAndRunTest(SupportClasses.CLASS_CHILD_CALLER, scopedPool.getClassLoader());
+ }
+
+ public void testParentNotLoadedNoParentDelegation() throws Exception
+ {
+ testScenario.createLoader(new CLDeploymentBuilder("GLOBAL", PARENT_JAR_URL));
+ CLDeploymentBuilder childCLBuilder = new CLDeploymentBuilder("SCOPED", CHILD_JAR_URL);
+ childCLBuilder.createDomain("SCOPED", false);
+ ClassPool scopedPool = testScenario.createLoader(childCLBuilder);
+
+ loadClassAndRunTest(SupportClasses.CLASS_CHILD_CALLER, scopedPool.getClassLoader());
+ }
+
+ private void loadClassAndRunTest(String classname, ClassLoader loader) throws Exception
+ {
+ Class<?> caller = loader.loadClass(classname);
+ Method m = caller.getMethod("test");
+ m.invoke(null, new Object[]
+ {});
+ }
+
+ final static class MyTranslator implements Translator
+ {
+ public void unregisterClassLoader(DomainClassLoader loader)
+ {
+ }
+
+ public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined,
+ ProtectionDomain protectionDomain, byte[] classfileBuffer) throws Exception
+ {
+ if (!className.startsWith(SupportClasses.PACKAGE_REPLACEMENT))
+ {
+ return null;
+ }
+ if (className.endsWith("Invoked"))
+ {
+ return null;
+ }
+
+ ClassPool pool = ClassPoolRepository.getInstance().registerClassLoader(loader);
+ CtClass clazz = pool.get(className);
+ if (className.endsWith("Caller"))
+ {
+ instrumentReplaceReferences(clazz);
+ }
+ else
+ {
+ instrumentCreateWrappers(clazz);
+ }
+
+ if (clazz.isModified())
+ {
+ return clazz.toBytecode();
+ }
+ return null;
+ }
+
+ private CtClass instrumentCreateWrappers(CtClass clazz)
+ {
+ try
+ {
+ if (!clazz.getName().startsWith(SupportClasses.PACKAGE_REPLACEMENT))
+ {
+ return clazz;
+ }
+ addWrappersToClass(clazz);
+ }
+ catch (Exception e)
+ {
+ System.err.println("Exception creating wrappers for " + clazz);
+ e.printStackTrace();
+ }
+ return clazz;
+ }
+
+ private CtClass instrumentReplaceReferences(CtClass clazz) throws Exception
+ {
+ if (!clazz.getName().startsWith(SupportClasses.PACKAGE_REPLACEMENT))
+ {
+ return clazz;
+ }
+ replaceReferences(clazz);
+ return clazz;
+ }
+
+ public void unregisterClassLoader(ClassLoader loader)
+ {
+ }
+
+ private void addWrappersToClass(CtClass clazz) throws Exception
+ {
+ addFieldWrappers(clazz);
+ addConstructorWrappers(clazz);
+ }
+
+ private void addFieldWrappers(CtClass clazz) throws Exception
+ {
+ CtClass objectCt = clazz.getClassPool().getCtClass(Object.class.getName());
+
+ for (CtField field : clazz.getFields())
+ {
+ if (field.getDeclaringClass() == objectCt)
+ {
+ continue;
+ }
+ CtMethod rmethod =
+ CtNewMethod.make(
+ Modifier.PUBLIC | Modifier.STATIC,
+ CtClass.intType,
+ getFieldReadWrapperName(field.getName()),
+ new CtClass[]{objectCt},
+ null,
+ "{" + SupportClasses.CLASS_INVOKED + ".invoked = true; return ((" + clazz.getName() + ")$1)." + field.getName() + ";}",
+ clazz);
+ clazz.addMethod(rmethod);
+
+
+ CtMethod wmethod =
+ CtNewMethod.make(
+ Modifier.PUBLIC | Modifier.STATIC,
+ CtClass.voidType,
+ getFieldWriteWrapperName(field.getName()),
+ new CtClass[]{objectCt, field.getType()},
+ null,
+ "{" + SupportClasses.CLASS_INVOKED + ".invoked = true; ((" + clazz.getName() + ")$1)." + field.getName() + "=(int)$2;}",
+ clazz);
+ clazz.addMethod(wmethod);
+ }
+ }
+
+ private void addConstructorWrappers(CtClass clazz) throws Exception
+ {
+ for (CtConstructor ctor : clazz.getConstructors())
+ {
+ CtMethod wrapper = CtNewMethod.make(clazz, getConstructorName(clazz), ctor.getParameterTypes(), null,
+ "{" + SupportClasses.CLASS_INVOKED + ".invoked = true; return new " + clazz.getName() + "($$);}", clazz);
+ wrapper.setModifiers(Modifier.PUBLIC | Modifier.STATIC);
+ clazz.addMethod(wrapper);
+ }
+ }
+
+ private void replaceReferences(final CtClass clazz) throws Exception
+ {
+ CodeConverter conv = new CodeConverter();
+ ScopedClassPool pool = ClassPoolRepository.getInstance().getClassPoolFactory().
+ create(clazz.getClassPool(), ClassPoolRepository.getInstance());
+ Collection<String> refs = AccessController.doPrivileged(new PrivilegedAction<Collection<String>>() {
+
+ @SuppressWarnings("all")
+ public Collection<String> run()
+ {
+ return clazz.getRefClasses();
+ }});
+
+ for (String ref : refs)
+ {
+ if (ref.startsWith(SupportClasses.PACKAGE_REPLACEMENT_CHILD) || ref.startsWith(SupportClasses.PACKAGE_REPLACEMENT_PARENT))
+ {
+ if (ref.endsWith("Caller"))
+ {
+ continue;
+ }
+ CtClass ctRef = pool.get(ref);
+ CtField[] fields = ctRef.getDeclaredFields();
+ for (CtField fld : fields)
+ {
+ conv.replaceFieldRead(fld, ctRef, getFieldReadWrapperName(fld.getName()));
+ conv.replaceFieldWrite(fld, ctRef, getFieldWriteWrapperName(fld.getName()));
+ }
+ conv.replaceNew(ctRef, ctRef, getConstructorName(ctRef));
+ }
+ }
+ clazz.instrument(conv);
+ }
+
+ private String getFieldReadWrapperName(String fieldName)
+ {
+ return fieldName + "_read";
+ }
+
+ private String getFieldWriteWrapperName(String fieldName)
+ {
+ return fieldName + "_write";
+ }
+
+ private String getConstructorName(CtClass clazz)
+ {
+ return clazz.getSimpleName() + "_new";
+ }
+ }
+}
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ReplaceReferencesClassPoolTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/RepositoryClassPoolTestCase.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/RepositoryClassPoolTestCase.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/RepositoryClassPoolTestCase.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.classpool.jbosscl.test;
+
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.JAR_A_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.JAR_B_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_A;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_B;
+import javassist.ClassPool;
+import javassist.CtClass;
+
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+import org.jboss.test.classpool.support.ClassPoolTestScenario;
+import org.jboss.test.classpool.support.TestScenario;
+
+/**
+ * Executes the repository tests against a class pool test scenario.
+ * This class also contains extra tests that are targeted expecifically to ClassPools.
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class RepositoryClassPoolTestCase extends RepositoryTest<CtClass, ClassPool>
+{
+ public RepositoryClassPoolTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected TestScenario<CtClass, ClassPool, CLDeploymentBuilder> getTestScenario()
+ {
+ return new ClassPoolTestScenario<CLDeploymentBuilder>(getClassLoaderFactory());
+ }
+
+ public void testCanLoadArrayCtClass() throws Exception
+ {
+ ClassPool poolA = testScenario.createLoader(new CLDeploymentBuilder("A", JAR_A_URL));
+ ClassPool poolB = testScenario.createLoader(new CLDeploymentBuilder("B", JAR_B_URL));
+ accessCanLoadCtArray(poolA, poolB);
+ accessCanLoadCtArray(poolA, poolB);
+ }
+
+ private void accessCanLoadCtArray(ClassPool poolA, ClassPool poolB) throws Exception
+ {
+ poolA.get(String.class.getName() + "[][]");
+ CtClass a = poolA.get(CLASS_A);
+ CtClass aArray = poolA.get(CLASS_A + "[]");
+ CtClass bArray = poolA.get(CLASS_B + "[][]");
+ CtClass b = poolA.get(CLASS_B);
+
+ CtClass byteClassA = poolA.get("byte");
+ CtClass byteClassB = poolB.get("byte");
+ assertSame(byteClassA, byteClassB);
+ assertNotSame(poolA, byteClassA.getClassPool());
+ assertNotSame(poolB, byteClassA.getClassPool());
+ CtClass intArrayClass = poolA.get("int[]");
+ CtClass intClass = poolB.get("int");
+ assertSame(intClass, intArrayClass.getComponentType());
+ assertSame(byteClassA.getClassPool(), intClass.getClassPool());
+
+ assertTrue(aArray.isArray());
+ assertSame(a, aArray.getComponentType());
+ assertTrue(bArray.isArray());
+ assertTrue(bArray.getComponentType().isArray());
+ assertSame(b, bArray.getComponentType().getComponentType());
+ assertNotSame(aArray.getClassPool(), bArray.getClassPool());
+ assertSame(poolA, aArray.getClassPool());
+ assertSame(poolB, bArray.getClassPool());
+ assertSame(a.getClassPool(), aArray.getClassPool());
+ assertSame(b.getClassPool(), bArray.getClassPool());
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/RepositoryClassPoolTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/RepositorySanityTestCase.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/RepositorySanityTestCase.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/RepositorySanityTestCase.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.classpool.jbosscl.test;
+
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+import org.jboss.test.classpool.support.SanityTestScenario;
+import org.jboss.test.classpool.support.TestScenario;
+
+/**
+ * Executes the repository tests against a sanity test scenario (for class loader behavior
+ * sanity checking).
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class RepositorySanityTestCase extends RepositoryTest<Class<?>, ClassLoader>
+{
+ public RepositorySanityTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected TestScenario<Class<?>, ClassLoader, CLDeploymentBuilder> getTestScenario()
+ {
+ return new SanityTestScenario<CLDeploymentBuilder>(getClassLoaderFactory());
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/RepositorySanityTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/RepositoryTest.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/RepositoryTest.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/RepositoryTest.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,411 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.test.classpool.jbosscl.test;
+
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.JAR_A_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.JAR_B_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.JAR_C_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.JAR_D_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_A;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_B;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_C;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_D;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Collection;
+import java.util.HashSet;
+
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+
+/**
+ * Tests the behaviour of the new classloaders.
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public abstract class RepositoryTest<C, L> extends JBossClClassPoolTest<C, L>
+{
+ // keep a hard reference to created class loaders to avoid garbage collection during
+ // test execution
+ private Collection<ClassLoader> createdURLClassLoaders = new HashSet<ClassLoader>();
+
+
+ public RepositoryTest(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ public void tearDown() throws Exception
+ {
+ try
+ {
+ super.tearDown();
+ }
+ finally
+ {
+ createdURLClassLoaders.clear();
+ }
+ }
+
+ public void testGlobalScope() throws Exception
+ {
+ CLDeploymentBuilder clBuilderA = new CLDeploymentBuilder("A", JAR_A_URL);
+ L loaderA = testScenario.createLoader(clBuilderA);
+
+ CLDeploymentBuilder clBuilderB = new CLDeploymentBuilder("B", JAR_B_URL);
+ L loaderB = testScenario.createLoader(clBuilderB);
+
+ C aFromA = testScenario.loadClass(loaderA, CLASS_A);
+ C bFromA = testScenario.loadClass(loaderA, loaderB, CLASS_B);
+ C aFromB = testScenario.loadClass(loaderB, loaderA, CLASS_A);
+ C bFromB = testScenario.loadClass(loaderB, CLASS_B);
+ assertSame(aFromA, aFromB);
+ assertSame(bFromA, bFromB);
+
+ testScenario.destroyLoader(clBuilderB);
+
+ aFromA = testScenario.loadClass(loaderA, CLASS_A);
+ testScenario.cannotLoadClass(loaderA, CLASS_B);
+ }
+
+ public void testChildDomain() throws Exception
+ {
+ L loaderA = testScenario.createLoader(new CLDeploymentBuilder("A", JAR_A_URL));
+ L loaderB = testScenario.createLoader(new CLDeploymentBuilder("B", JAR_B_URL));
+
+ CLDeploymentBuilder childCLBuilder = new CLDeploymentBuilder("C", JAR_C_URL);
+ childCLBuilder.createDomain("CHILD", true);
+ L childLoader = testScenario.createLoader(childCLBuilder);
+
+ C aFromA = testScenario.loadClass(loaderA, CLASS_A);
+ C bFromB = testScenario.loadClass(loaderB, CLASS_B);
+ testScenario.loadClass(childLoader, CLASS_C);
+ C aFromC = testScenario.loadClass(childLoader, loaderA, CLASS_A);
+ C bFromC = testScenario.loadClass(childLoader, loaderB, CLASS_B);
+
+ assertSame(aFromA, aFromC);
+ assertSame(bFromB, bFromC);
+ testScenario.cannotLoadClass(loaderA, CLASS_C);
+ testScenario.cannotLoadClass(loaderB, CLASS_C);
+ }
+
+ public void testSiblingDomains() throws Exception
+ {
+ CLDeploymentBuilder clBuilderA = new CLDeploymentBuilder("A", JAR_A_URL);
+ clBuilderA.createDomain("ChildA", true);
+ L loaderA = testScenario.createLoader(clBuilderA);
+
+ CLDeploymentBuilder clBuilderB = new CLDeploymentBuilder("B", JAR_B_URL);
+ clBuilderB.createDomain("ChildB", true);
+ L loaderB = testScenario.createLoader(clBuilderB);
+
+ testScenario.loadClass(loaderA, CLASS_A);
+ testScenario.loadClass(loaderB, CLASS_B);
+ testScenario.cannotLoadClass(loaderA, CLASS_B);
+ testScenario.cannotLoadClass(loaderB, CLASS_A);
+ }
+
+ public void testChildWithNewClassesInParent() throws Exception
+ {
+ CLDeploymentBuilder clScopedBuilder = new CLDeploymentBuilder("SCOPED", JAR_B_URL);
+ clScopedBuilder.createDomain("SCOPED", true);
+ L scopedLoader = testScenario.createLoader(clScopedBuilder);
+
+ testScenario.cannotLoadClass(scopedLoader, CLASS_A);
+
+ L globalLoader = testScenario.createLoader(new CLDeploymentBuilder("GLOBAL", JAR_A_URL));
+
+ C aFromChild = testScenario.loadClass(scopedLoader, globalLoader, CLASS_A);
+ C aFromParent = testScenario.loadClass(globalLoader, CLASS_A);
+ assertSame(aFromChild, aFromParent);
+ }
+
+ public void testChildOverrideWithParentDelegation() throws Exception
+ {
+ L globalLoader = testScenario.createLoader(new CLDeploymentBuilder("GLOBAL", JAR_A_URL));
+
+ CLDeploymentBuilder clScopedBuilder = new CLDeploymentBuilder("SCOPED", JAR_B_URL);
+ clScopedBuilder.createDomain("SCOPED", true);
+ L scopedLoader = testScenario.createLoader(clScopedBuilder);
+
+ C aFromParent = testScenario.loadClass(globalLoader, CLASS_A);
+ C aFromChild = testScenario.loadClass(scopedLoader, globalLoader, CLASS_A);
+ assertSame(aFromParent, aFromChild);
+ }
+
+ public void testChildOverrideWithNoParentDelegation() throws Exception
+ {
+ L globalLoader = testScenario.createLoader(new CLDeploymentBuilder("GLOBAL", JAR_A_URL));
+
+ CLDeploymentBuilder clScopedBuilder = new CLDeploymentBuilder("CHILD", JAR_A_URL);
+ clScopedBuilder.createDomain("CHILD", false);
+ L scopedLoader = testScenario.createLoader(clScopedBuilder);
+
+ C aFromParent = testScenario.loadClass(globalLoader, CLASS_A);
+ C aFromChild = testScenario.loadClass(scopedLoader, CLASS_A);
+ assertNotSame(aFromParent, aFromChild);
+ }
+
+ public void testURLChildOfGlobalUcl() throws Exception
+ {
+ L globalLoader = testScenario.createLoader(new CLDeploymentBuilder("GLOBAL", JAR_A_URL));
+ L childALoader = createChildURLLoader(globalLoader, JAR_B_URL);
+
+ testScenario.loadClass(childALoader, globalLoader, CLASS_A);
+ testScenario.loadClass(childALoader, CLASS_B);
+
+ L childBLoader = createChildURLLoader(globalLoader, JAR_A_URL);
+ testScenario.loadClass(childBLoader, globalLoader, CLASS_A);
+
+ }
+
+ public void testUndeploySibling() throws Exception
+ {
+ L globalLoader = testScenario.createLoader(new CLDeploymentBuilder("GLOBAL", JAR_A_URL));
+ testScenario.cannotLoadClass(globalLoader, CLASS_B);
+
+ CLDeploymentBuilder bCLBuilder = new CLDeploymentBuilder("B", JAR_B_URL);
+ L bLoader = testScenario.createLoader(bCLBuilder);
+ testScenario.loadClass(globalLoader, bLoader, CLASS_B);
+ testScenario.destroyLoader(bCLBuilder);
+ testScenario.cannotLoadClass(globalLoader, CLASS_B);
+ }
+
+
+ public void testUndeployParentDomainClassLoader() throws Exception
+ {
+ L globalLoaderA = testScenario.createLoader(new CLDeploymentBuilder("GLOBAL", JAR_A_URL));
+ testScenario.cannotLoadClass(globalLoaderA, CLASS_B);
+
+ CLDeploymentBuilder childCLBuilder = new CLDeploymentBuilder("C", JAR_C_URL);
+ childCLBuilder.createDomain("C", false);
+ L childLoader = testScenario.createLoader(childCLBuilder);
+ testScenario.cannotLoadClass(childLoader, CLASS_B);
+
+ CLDeploymentBuilder globalCLBuilderB = new CLDeploymentBuilder("B", JAR_B_URL);
+ L globalLoaderB = testScenario.createLoader(globalCLBuilderB);
+
+ C bFromChild = testScenario.loadClass(childLoader, globalLoaderB, CLASS_B);
+ C bFromA = testScenario.loadClass(globalLoaderA, globalLoaderB, CLASS_B);
+ assertSame(bFromA, bFromChild);
+
+ testScenario.destroyLoader(globalCLBuilderB);
+
+ testScenario.cannotLoadClass(childLoader, CLASS_B);
+ }
+
+ public void testClassLoaderWithParentClassLoader() throws Exception
+ {
+ L parentLoader = createChildURLLoader((L) null, JAR_B_URL);
+
+ CLDeploymentBuilder globalCLBuilder = new CLDeploymentBuilder("A", JAR_A_URL);
+ globalCLBuilder.createDomain("A", testScenario.getClassLoader(parentLoader), true);
+ L globalLoader = testScenario.createLoader(globalCLBuilder);
+
+ testScenario.loadClass(globalLoader, CLASS_A);
+ C bFromGlobal = testScenario.loadClass(globalLoader, parentLoader, CLASS_B);
+ C bFromParent = testScenario.loadClass(parentLoader, CLASS_B);
+ assertSame(bFromGlobal, bFromParent);
+ testScenario.cannotLoadClass(parentLoader, CLASS_A);
+ }
+
+ public void testClassLoaderWithParentClassLoaderAndCrossReference() throws Exception
+ {
+ L parentLoader = createChildURLLoader(null, JAR_B_URL);
+
+ CLDeploymentBuilder globalCLBuilder = new CLDeploymentBuilder("D", JAR_D_URL);
+ globalCLBuilder.createDomain("D", testScenario.getClassLoader(parentLoader), true);
+ L globalLoader = testScenario.createLoader(globalCLBuilder);
+
+ C dFromGlobal = testScenario.loadClass(globalLoader, CLASS_D);
+ C bFromGlobal = testScenario.loadClass(globalLoader, parentLoader, CLASS_B);
+ C bFromParent = testScenario.loadClass(parentLoader, CLASS_B);
+ assertSame(bFromGlobal, bFromParent);
+ testScenario.cannotLoadClass(parentLoader, CLASS_D);
+
+ C returnType = testScenario.getMethodReturnType(dFromGlobal, "getB");
+ assertSame(returnType, bFromParent);
+ }
+
+
+ public void testClassLoaderWithParentClassLoaderAndSameClassInDomain() throws Exception
+ {
+ L parentLoader = createChildURLLoader(null, JAR_B_URL);
+
+ String domain = "CHILD";
+ CLDeploymentBuilder globalCLBuilderA = new CLDeploymentBuilder("A", JAR_A_URL);
+ globalCLBuilderA.createDomain(domain, testScenario.getClassLoader(parentLoader), true);
+ L globalLoaderA = testScenario.createLoader(globalCLBuilderA);
+
+ testScenario.loadClass(globalLoaderA, CLASS_A);
+ C bFromGlobalA = testScenario.loadClass(globalLoaderA, parentLoader, CLASS_B);
+
+ CLDeploymentBuilder globalCLBuilderB = new CLDeploymentBuilder("B", JAR_B_URL);
+ globalCLBuilderB.setDomain(domain);
+ L globalLoaderB = testScenario.createLoader(globalCLBuilderB);
+
+ C bFromParent = testScenario.loadClass(parentLoader, CLASS_B);
+ assertSame(bFromGlobalA, bFromParent);
+
+ C bFromGlobalB = testScenario.loadClass(globalLoaderB, parentLoader, CLASS_B);
+ assertSame(bFromGlobalB, bFromParent);
+
+ CLDeploymentBuilder globalCLBuilderC = new CLDeploymentBuilder("C", JAR_B_URL);
+ globalCLBuilderC.createDomain(domain + "2", testScenario.getClassLoader(parentLoader), false);
+ L globalLoaderC = testScenario.createLoader(globalCLBuilderC);
+ testScenario.loadClass(globalLoaderC, CLASS_B);
+ }
+
+ public void testSeveralLevelsOfDomain() throws Exception
+ {
+ L parentLoader = testScenario.createLoader(new CLDeploymentBuilder("A", JAR_A_URL));
+ C aFromParent = testScenario.loadClass(parentLoader, CLASS_A);
+
+ String domain1 = "1";
+ CLDeploymentBuilder clDeploymentBuilder1B = new CLDeploymentBuilder("1B", JAR_B_URL);
+ clDeploymentBuilder1B.createDomain(domain1, true);
+ L loader1B = testScenario.createLoader(clDeploymentBuilder1B);
+
+ CLDeploymentBuilder clDeploymentBuilder1C = new CLDeploymentBuilder("1C", JAR_C_URL);
+ clDeploymentBuilder1C.setDomain(domain1);
+ L loader1C = testScenario.createLoader(clDeploymentBuilder1C);
+
+ C aFrom1B = testScenario.loadClass(loader1B, parentLoader, CLASS_A);
+ C bFrom1B = testScenario.loadClass(loader1B, CLASS_B);
+ C cFrom1B = testScenario.loadClass(loader1B, loader1C, CLASS_C);
+ C aFrom1C = testScenario.loadClass(loader1C, parentLoader, CLASS_A);
+ C bFrom1C = testScenario.loadClass(loader1C, loader1B, CLASS_B);
+ C cFrom1C = testScenario.loadClass(loader1C, CLASS_C);
+ assertSame(aFromParent, aFrom1B);
+ assertSame(aFromParent, aFrom1C);
+ assertSame(bFrom1B, bFrom1C);
+ assertSame(cFrom1B, cFrom1C);
+
+ String domain2 = "2";
+
+ CLDeploymentBuilder clDeploymentBuilder2B = new CLDeploymentBuilder("2B", JAR_B_URL);
+ clDeploymentBuilder2B.createDomain(domain2, true);
+ L loader2B = testScenario.createLoader(clDeploymentBuilder2B);
+
+ CLDeploymentBuilder clDeploymentBuilder2C = new CLDeploymentBuilder("2C", JAR_C_URL);
+ clDeploymentBuilder2C.setDomain(domain2);
+ L loader2C = testScenario.createLoader(clDeploymentBuilder2C);
+
+ C aFrom2B = testScenario.loadClass(loader2B, parentLoader, CLASS_A);
+ C bFrom2B = testScenario.loadClass(loader2B, CLASS_B);
+ C cFrom2B = testScenario.loadClass(loader2B, loader2C, CLASS_C);
+ C aFrom2C = testScenario.loadClass(loader2C, parentLoader, CLASS_A);
+ C bFrom2C = testScenario.loadClass(loader2C, loader2B, CLASS_B);
+ C cFrom2C = testScenario.loadClass(loader2C, CLASS_C);
+ assertSame(aFromParent, aFrom2B);
+ assertSame(aFromParent, aFrom2C);
+ assertSame(bFrom2B, bFrom2C);
+ assertSame(cFrom2B, cFrom2C);
+ assertNotSame(bFrom1B, bFrom2B);
+ assertNotSame(bFrom2C, bFrom1C);
+ assertNotSame(cFrom2C, cFrom1C);
+
+ final String domain11 = "11";
+ CLDeploymentBuilder clBuilder11A = new CLDeploymentBuilder("11A", JAR_A_URL);
+ clBuilder11A.createDomain(domain11, domain1, true);
+ L loader11A = testScenario.createLoader(clBuilder11A);
+ CLDeploymentBuilder clBuilder11B = new CLDeploymentBuilder("11B", JAR_B_URL);
+ clBuilder11B.setDomain(domain11);
+ L loader11B = testScenario.createLoader(clBuilder11B);
+ CLDeploymentBuilder clBuilder11C = new CLDeploymentBuilder("11C", JAR_C_URL);
+ clBuilder11C.setDomain(domain11);
+ L loader11C = testScenario.createLoader(clBuilder11C);
+
+ String domain12 = "12";
+ CLDeploymentBuilder clBuilder12A = new CLDeploymentBuilder("12A", JAR_A_URL);
+ clBuilder12A.createDomain(domain12, domain1, false);
+ L loader12A = testScenario.createLoader(clBuilder12A);
+ CLDeploymentBuilder clBuilder12B = new CLDeploymentBuilder("12B", JAR_B_URL);
+ clBuilder12B.setDomain(domain12);
+ L loader12B = testScenario.createLoader(clBuilder12B);
+ CLDeploymentBuilder clBuilder12C = new CLDeploymentBuilder("12C", JAR_C_URL);
+ clBuilder12C.setDomain(domain12);
+ L loader12C = testScenario.createLoader(clBuilder12C);
+
+ C aFrom11A = testScenario.loadClass(loader11A, parentLoader, CLASS_A);
+ C aFrom11B = testScenario.loadClass(loader11B, parentLoader, CLASS_A);
+ C aFrom11C = testScenario.loadClass(loader11C, parentLoader, CLASS_A);
+ assertSame(aFromParent, aFrom11A);
+ assertSame(aFromParent, aFrom11B);
+ assertSame(aFromParent, aFrom11C);
+
+ C aFrom12A = testScenario.loadClass(loader12A, CLASS_A);
+ C aFrom12B = testScenario.loadClass(loader12B, loader12A, CLASS_A);
+ C aFrom12C = testScenario.loadClass(loader12C, loader12A, CLASS_A);
+ assertNotSame(aFromParent, aFrom12A);
+ assertSame(aFrom12A, aFrom12B);
+ assertSame(aFrom12A, aFrom12C);
+
+ C bFrom11A = testScenario.loadClass(loader11A, loader1B, CLASS_B);
+ C bFrom11B = testScenario.loadClass(loader11B, loader1B, CLASS_B);
+ C bFrom11C = testScenario.loadClass(loader11C, loader1B, CLASS_B);
+ assertSame(bFrom11A, bFrom11B);
+ assertSame(bFrom11A, bFrom11C);
+
+ C cFrom11A = testScenario.loadClass(loader11A, loader1C, CLASS_C);
+ C cFrom11B = testScenario.loadClass(loader11B, loader1C, CLASS_C);
+ C cFrom11C = testScenario.loadClass(loader11C, loader1C, CLASS_C);
+ assertSame(cFrom11A, cFrom11B);
+ assertSame(cFrom11A, cFrom11C);
+
+ C bFrom12A = testScenario.loadClass(loader12A, loader12B, CLASS_B);
+ C bFrom12B = testScenario.loadClass(loader12B, CLASS_B);
+ C bFrom12C = testScenario.loadClass(loader12C, loader12B, CLASS_B);
+ assertSame(bFrom12A, bFrom12B);
+ assertSame(bFrom12A, bFrom12C);
+ assertNotSame(bFrom11B, bFrom12B);
+
+ C cFrom12A = testScenario.loadClass(loader12A, loader12C, CLASS_C);
+ C cFrom12B = testScenario.loadClass(loader12B, loader12C, CLASS_C);
+ C cFrom12C = testScenario.loadClass(loader12C, CLASS_C);
+ assertSame(cFrom12A, cFrom12B);
+ assertSame(cFrom12A, cFrom12C);
+ assertNotSame(cFrom11C, cFrom12C);
+ }
+
+ public void testUclLoaderOrdering() throws Exception
+ {
+ L globalLoaderA1 = testScenario.createLoader(new CLDeploymentBuilder("A1", JAR_A_URL));
+ L globalLoaderA2 = testScenario.createLoader(new CLDeploymentBuilder("A2", JAR_A_URL));
+ L globalLoaderA3 = testScenario.createLoader(new CLDeploymentBuilder("A3", JAR_A_URL));
+
+ testScenario.loadClass(globalLoaderA1, CLASS_A);
+ testScenario.loadClass(globalLoaderA2, globalLoaderA1, CLASS_A);
+ testScenario.loadClass(globalLoaderA3, globalLoaderA1, CLASS_A);
+ }
+
+ protected L createChildURLLoader(L parentLoader, URL url)
+ {
+ ClassLoader parentClassLoader = parentLoader == null? null: testScenario.getClassLoader(parentLoader);
+ URLClassLoader classLoader = new URLClassLoader(new URL[] {url}, parentClassLoader);
+ createdURLClassLoaders.add(classLoader);
+ return testScenario.getLoader(classLoader);
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/RepositoryTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/UsesPackageClassPoolTestCase.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/UsesPackageClassPoolTestCase.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/UsesPackageClassPoolTestCase.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.classpool.jbosscl.test;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+import org.jboss.test.classpool.support.ClassPoolTestScenario;
+import org.jboss.test.classpool.support.TestScenario;
+
+
+/**
+ * Executes the uses package tests against a class pool test scenario.
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class UsesPackageClassPoolTestCase extends UsesPackageTest<CtClass, ClassPool>
+{
+ public UsesPackageClassPoolTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected TestScenario<CtClass, ClassPool, CLDeploymentBuilder> getTestScenario()
+ {
+ return new ClassPoolTestScenario<CLDeploymentBuilder>(getClassLoaderFactory());
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/UsesPackageClassPoolTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/UsesPackageSanityTestCase.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/UsesPackageSanityTestCase.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/UsesPackageSanityTestCase.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.classpool.jbosscl.test;
+
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+import org.jboss.test.classpool.support.SanityTestScenario;
+import org.jboss.test.classpool.support.TestScenario;
+
+
+/**
+ * Executes the uses package tests against a sanity test scenario (for class loader behavior
+ * sanity checking).
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class UsesPackageSanityTestCase extends UsesPackageTest<Class<?>, ClassLoader>
+{
+ public UsesPackageSanityTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected TestScenario<Class<?>, ClassLoader, CLDeploymentBuilder> getTestScenario()
+ {
+ return new SanityTestScenario<CLDeploymentBuilder>(getClassLoaderFactory());
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/UsesPackageSanityTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/UsesPackageTest.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/UsesPackageTest.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/UsesPackageTest.java 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.test.classpool.jbosscl.test;
+
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.JAR_A_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_A;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.PACKAGE_A;
+
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+
+/**
+ * Reproduces org.jboss.test.classloading.vfs.metadata.test.UsesPackageUnitTestCase using our
+ * test framework.
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public abstract class UsesPackageTest<C, L> extends JBossClClassPoolTest<C, L>
+{
+ public UsesPackageTest(String name)
+ {
+ super(name);
+ }
+
+ public void testUsesImport() throws Exception
+ {
+ CLDeploymentBuilder clBuilderA1 = new CLDeploymentBuilder("A1", JAR_A_URL);
+ clBuilderA1.createModule("a1").createPackage(PACKAGE_A).setImportAll(false);
+ L loaderA1 = testScenario.createLoader(clBuilderA1);
+ C classA = testScenario.loadClass(loaderA1, CLASS_A);
+
+ CLDeploymentBuilder clBuilderA2 = new CLDeploymentBuilder("A2", JAR_A_URL);
+ clBuilderA2.createModule("a2").createUsesPackage(PACKAGE_A).setImportAll(false);
+ L loaderA2 = testScenario.createLoader(clBuilderA2);
+
+ C classA1 = testScenario.loadClass(loaderA1, CLASS_A);
+ assertSame(classA, classA1);
+ classA1 = testScenario.loadClass(loaderA2, loaderA1, CLASS_A);
+ assertSame(classA, classA1);
+
+ testScenario.destroyLoader(clBuilderA2);
+
+ classA1 = testScenario.loadClass(loaderA1, CLASS_A);
+ assertSame(classA, classA1);
+ }
+
+ public void testUsesNoImport() throws Exception
+ {
+ CLDeploymentBuilder clBuilder = new CLDeploymentBuilder("A1", JAR_A_URL);
+ clBuilder.createModule("a1").createUsesPackage(PACKAGE_A).setImportAll(false);
+ L loader = testScenario.createLoader(clBuilder);
+ testScenario.loadClass(loader, CLASS_A);
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/UsesPackageTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/ear/META-INF/application.properties
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/ear/META-INF/application.properties (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/ear/META-INF/application.properties 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,5 @@
+jar-module=simple.jar
+ejb-module=ejbs.jar
+web-module=simple_ui.war
+jsf-module=jsfapp.war
+sar-module=simple.sar
Added: projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/ear2war/META-INF/application.properties
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/ear2war/META-INF/application.properties (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/ear2war/META-INF/application.properties 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,2 @@
+jsf-module=ptd-jsf-1.0-SNAPSHOT.war
+ws-module=ptd-ws-1.0-SNAPSHOT.war
Added: projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/earutil/META-INF/application.properties
===================================================================
Added: projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/ejb-jar/META-INF/ejb-jar.xml
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/ejb-jar/META-INF/ejb-jar.xml (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/ejb-jar/META-INF/ejb-jar.xml 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,2 @@
+<ejb-jar>
+</ejb-jar>
\ No newline at end of file
Added: projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/jarinear/META-INF/application.properties
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/jarinear/META-INF/application.properties (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/jarinear/META-INF/application.properties 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1 @@
+ejb-module=simple.jar
Added: projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/sar/META-INF/jboss-service.xml
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/sar/META-INF/jboss-service.xml (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/sar/META-INF/jboss-service.xml 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1 @@
+<server/>
Added: projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/war/WEB-INF/web.xml
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/war/WEB-INF/web.xml (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/war/WEB-INF/web.xml 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,2 @@
+<web>
+</web>
\ No newline at end of file
Added: projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/warinear/META-INF/application.properties
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/warinear/META-INF/application.properties (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/resources/archive/warinear/META-INF/application.properties 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1 @@
+web-module=simple.war
Added: projects/jboss-classpool/trunk/jbosscl/src/test/resources/log4j.xml
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/resources/log4j.xml (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/resources/log4j.xml 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ <appender name="ConsoleAppender" class="org.apache.log4j.ConsoleAppender">
+ <layout class="org.apache.log4j.SimpleLayout"/>
+ </appender>
+
+ <root>
+ <priority value ="debug" />
+ <appender-ref ref="ConsoleAppender"/>
+ </root>
+
+</log4j:configuration>
Property changes on: projects/jboss-classpool/trunk/jbosscl/src/test/resources/log4j.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: projects/jboss-classpool/trunk/jbosscl/src/test/resources/org/jboss/test/classpool/jbosscl/Common.xml
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/resources/org/jboss/test/classpool/jbosscl/Common.xml (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/resources/org/jboss/test/classpool/jbosscl/Common.xml 2009-12-11 13:48:25 UTC (rev 97735)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="ClassLoaderSystem" class="org.jboss.classloader.spi.ClassLoaderSystem">
+ <constructor factoryMethod="getInstance"/>
+ </bean>
+
+ <bean name="ClassLoading" class="org.jboss.classloading.spi.dependency.ClassLoading">
+ <incallback method="addModule" state="Configured"/>
+ <uncallback method="removeModule" state="Configured"/>
+ </bean>
+
+ <bean name="ClassLoaderScopingPolicy" class="org.jboss.classpool.plugins.jbosscl.VFSClassLoaderDomainRegistry">
+ <constructor factoryMethod="getInstance"/>
+ </bean>
+
+ <bean name="RegisterModuleCallback" class="org.jboss.classpool.plugins.jbosscl.RegisterModuleCallback">
+ <constructor>
+ <parameter><inject bean="ClassLoaderScopingPolicy"/></parameter>
+ </constructor>
+ <install method="addModuleRegistry" bean="ClassLoading" whenRequired="Start">
+ <parameter><this/></parameter>
+ </install>
+ <uninstall method="removeModuleRegistry" bean="ClassLoading" whenRequired="Start">
+ <parameter><this/></parameter>
+ </uninstall>
+ </bean>
+
+ <bean name="ClassPoolFactory" class="org.jboss.classpool.plugins.jbosscl.JBossClDelegatingClassPoolFactory">
+ <constructor>
+ <parameter><inject bean="ClassLoaderScopingPolicy"/></parameter>
+ <parameter><inject bean="RegisterModuleCallback"/></parameter>
+ </constructor>
+ </bean>
+
+ <bean name="ClassPoolRepository" class="org.jboss.classpool.plugins.jbosscl.JBossClDelegatingClassPoolRepository">
+ <constructor factoryMethod="getInstance"/>
+ <property name="classPoolFactory"><inject bean="ClassPoolFactory"/></property>
+ </bean>
+
+</deployment>
More information about the jboss-cvs-commits
mailing list