[jboss-cvs] JBossAS SVN: r60560 - in branches/Branch_4_2: testsuite and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Feb 15 05:32:14 EST 2007
Author: kabir.khan at jboss.com
Date: 2007-02-15 05:32:13 -0500 (Thu, 15 Feb 2007)
New Revision: 60560
Modified:
branches/Branch_4_2/aspects/src/main/org/jboss/aop/deployment/AspectDeployer.java
branches/Branch_4_2/aspects/src/main/org/jboss/aop/deployment/JBossClassPool.java
branches/Branch_4_2/aspects/src/main/org/jboss/aop/deployment/JBossScopedClassLoaderHelper.java
branches/Branch_4_2/aspects/src/main/org/jboss/aop/deployment/ScopedClassLoaderDomain.java
branches/Branch_4_2/testsuite/build.xml
branches/Branch_4_2/testsuite/imports/sections/aop.xml
Log:
[JBAOP-356] Ability to attach a .aop deployment to a particular scoped classloader.
Register ScopedClassLoaderDomains per LoaderRepository instead of per (scoped) classloader.
Modified: branches/Branch_4_2/aspects/src/main/org/jboss/aop/deployment/AspectDeployer.java
===================================================================
--- branches/Branch_4_2/aspects/src/main/org/jboss/aop/deployment/AspectDeployer.java 2007-02-15 10:26:38 UTC (rev 60559)
+++ branches/Branch_4_2/aspects/src/main/org/jboss/aop/deployment/AspectDeployer.java 2007-02-15 10:32:13 UTC (rev 60560)
@@ -25,6 +25,8 @@
import java.net.URL;
import java.util.Iterator;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanInfo;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.Notification;
@@ -38,8 +40,14 @@
import org.jboss.deployment.DeploymentState;
import org.jboss.deployment.SubDeployer;
import org.jboss.deployment.SubDeployerSupport;
+import org.jboss.mx.loading.HeirarchicalLoaderRepository3;
+import org.jboss.mx.loading.LoaderRepository;
import org.jboss.util.file.ArchiveBrowser;
import org.jboss.util.file.ClassFileFilter;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
/**
* Deployer for Aspects
@@ -290,7 +298,7 @@
return docURL;
}
- private ClassLoader getScopedClassLoader(DeploymentInfo di, URL docUrl)
+ private ClassLoader getScopedClassLoader(DeploymentInfo di, URL docUrl) throws Exception
{
//Scoped AOP deployments are only available when deployed as part of a scoped sar, ear etc.
//It can contain an aop.xml file, or it can be part of a .aop file
@@ -300,6 +308,83 @@
return di.ucl;
}
+ LoaderRepository attachToRepository = getLoaderRepositoryIfAttaching(di, docUrl);
+ if (attachToRepository != null)
+ {
+ di.ucl.setRepository(attachToRepository);
+ attachToRepository.addClassLoader(di.ucl);
+ return di.ucl;
+ }
+
return null;
}
+
+
+ private LoaderRepository getLoaderRepositoryIfAttaching(DeploymentInfo di, URL docUrl) throws Exception
+ {
+ if (di.parent == null)
+ {
+ //We are a top-level deployment, check if we are meant to be attaching to a scoped repository
+
+ //TODO Use AspectXmlLoader.loadURL once AOP is added to repository
+ Document doc = AspectXmlLoader.loadURL(docUrl);
+ Element top = doc.getDocumentElement();
+ NodeList children = top.getChildNodes();
+ int childlength = children.getLength();
+ for (int i = 0; i < childlength ; i++)
+ {
+ Node child = children.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE)
+ {
+ Element element = (Element)child;
+ if (element.getTagName().equals("loader-repository"))
+ {
+ String repositoryName = null;
+ NodeList nestedChildren = child.getChildNodes();
+ int nestedChildLength = nestedChildren.getLength();
+ for (int j = 0 ; j < nestedChildLength ; j++)
+ {
+ Node nestedChild = nestedChildren.item(j);
+ if (nestedChild.getNodeType() == Node.TEXT_NODE || nestedChild.getNodeType() == Node.CDATA_SECTION_NODE)
+ {
+ repositoryName = nestedChild.getNodeValue().trim();
+ break;
+ }
+ }
+ log.info("Should attach deployment to loader repository " + repositoryName);
+ ObjectName on;
+ try
+ {
+ on = new ObjectName(repositoryName);
+ }
+ catch (MalformedObjectNameException e)
+ {
+ throw new RuntimeException("loader-repository='" + repositoryName + "' is not a valid object name", e);
+ }
+
+ try
+ {
+ MBeanInfo info = server.getMBeanInfo(on);
+ }
+ catch (InstanceNotFoundException e)
+ {
+ log.warn("No scoped loader repository exists with the name " + on);
+ }
+
+ LoaderRepository repository = (LoaderRepository)server.getAttribute(on, "Instance");
+ if (repository instanceof HeirarchicalLoaderRepository3)
+ {
+ return repository;
+ }
+ else
+ {
+ log.warn("Loader repository " + on + " is not a isolated loader repository. Deploying aspects in default domain.");
+ }
+ }
+ }
+ }
+ }
+
+ return null;
+ }
}
\ No newline at end of file
Modified: branches/Branch_4_2/aspects/src/main/org/jboss/aop/deployment/JBossClassPool.java
===================================================================
--- branches/Branch_4_2/aspects/src/main/org/jboss/aop/deployment/JBossClassPool.java 2007-02-15 10:26:38 UTC (rev 60559)
+++ branches/Branch_4_2/aspects/src/main/org/jboss/aop/deployment/JBossClassPool.java 2007-02-15 10:32:13 UTC (rev 60560)
@@ -109,7 +109,7 @@
}
catch (Exception ex)
{
- ClassFormatError cfe = new ClassFormatError("Failed to load dyn class: " + cc.getName());
+ ClassFormatError cfe = new ClassFormatError("Failed to load dyn class: " + cc.getName() + " with " + getClassLoader());
cfe.initCause(ex);
throw cfe;
}
Modified: branches/Branch_4_2/aspects/src/main/org/jboss/aop/deployment/JBossScopedClassLoaderHelper.java
===================================================================
--- branches/Branch_4_2/aspects/src/main/org/jboss/aop/deployment/JBossScopedClassLoaderHelper.java 2007-02-15 10:26:38 UTC (rev 60559)
+++ branches/Branch_4_2/aspects/src/main/org/jboss/aop/deployment/JBossScopedClassLoaderHelper.java 2007-02-15 10:32:13 UTC (rev 60560)
@@ -99,4 +99,13 @@
return new ScopedClassLoaderDomain(cl, name, parentDelegation, parent, false);
}
+ public Object getLoaderRepository(ClassLoader loader)
+ {
+ ClassLoader cl = ifScopedDeploymentGetScopedParentUclForCL(loader);
+ if (cl != null)
+ {
+ return ((RepositoryClassLoader)cl).getLoaderRepository();
+ }
+ return null;
+ }
}
Modified: branches/Branch_4_2/aspects/src/main/org/jboss/aop/deployment/ScopedClassLoaderDomain.java
===================================================================
--- branches/Branch_4_2/aspects/src/main/org/jboss/aop/deployment/ScopedClassLoaderDomain.java 2007-02-15 10:26:38 UTC (rev 60559)
+++ branches/Branch_4_2/aspects/src/main/org/jboss/aop/deployment/ScopedClassLoaderDomain.java 2007-02-15 10:32:13 UTC (rev 60560)
@@ -64,6 +64,15 @@
return null;
}
+ public void removeAspectDefinition(String name)
+ {
+ AspectDefinition def = super.internalRemoveAspectDefintion(name);
+ if (def != null)
+ {
+ Object o = myPerVMAspects.remove(name);
+ }
+ }
+
public Object getPerVMAspect(AspectDefinition def)
{
return getPerVMAspect(def.getName());
Modified: branches/Branch_4_2/testsuite/build.xml
===================================================================
--- branches/Branch_4_2/testsuite/build.xml 2007-02-15 10:26:38 UTC (rev 60559)
+++ branches/Branch_4_2/testsuite/build.xml 2007-02-15 10:32:13 UTC (rev 60560)
@@ -2403,30 +2403,38 @@
<server:stop name="webservice-ssl"/>
</target>
- <target name="tests-aop-scoped" description="AOP tests requiring a native classloader hook">
- <!--
- Generate the JDK 1.4 classloader hook (we use this both when running with JDK 1.4 and 5.0 since
- the JDK 5.0 pluggable instrumentor depends on the jboss-aop-jdk50.deployer being deployed), and
- the testsuite uses the config with the jboss-aop.deployer.
- -->
- <java classname="org.jboss.aop.hook.GeneratePluggableInstrumentedClassLoader">
- <classpath>
- <path refid="javassist.classpath"/>
- <path refid="jboss.aop.classpath"/>
- </classpath>
- <arg value="${jboss.dist}/bin/woven-classloader"/>
- </java>
- <!-- copy across the jdk 1.4 pluggable instrumentor -->
- <copy todir="${jboss.dist}/bin" file="${jboss.aop.lib}/jdk14-pluggable-instrumentor.jar"/>
- <server:start name="scoped-aop"/>
+ <target name="tests-aop-scoped"
+ description="AOP tests requiring a native classloader hook">
- <run-junit junit.patternset="aop-with-classloader.includes" junit.configuration="aop-scoped"/>
+ <!--
+ Generate the JDK 1.4 classloader hook (we use this both when running with JDK 1.4 and 5.0 since
+ the JDK 5.0 pluggable instrumentor depends on the jboss-aop-jdk50.deployer being deployed), and
+ the testsuite uses the config with the jboss-aop.deployer.
+ -->
+ <java classname="org.jboss.aop.hook.GeneratePluggableInstrumentedClassLoader">
+ <classpath>
+ <path refid="javassist.classpath"/>
+ <path refid="jboss.aop.classpath"/>
+ </classpath>
+ <arg value="${jboss.dist}/bin/woven-classloader"/>
+ </java>
+ <!-- copy across the jdk 1.4 pluggable instrumentor -->
+ <copy todir="${jboss.dist}/bin" file="${jboss.aop.lib}/jdk14-pluggable-instrumentor.jar"/>
+ <server:start name="scoped-aop"/>
- <server:stop name="scoped-aop"/>
- <delete dir="${jboss.dist}/bin/woven-classloader"/>
- <delete file="${jboss.dist}/bin/jdk14-pluggable-instrumentor.jar"/>
+ <antcall target="run-tests-aop-scoped" inheritRefs="true"/>
+
+
+ <server:stop name="scoped-aop"/>
+ <delete dir="${jboss.dist}/bin/woven-classloader"/>
+ <delete file="${jboss.dist}/bin/jdk14-pluggable-instrumentor.jar"/>
</target>
+ <target name="run-tests-aop-scoped"
+ description="AOP tests requiring a native classloader hook">
+ <run-junit junit.patternset="aop-with-classloader.includes" junit.configuration="aop-scoped"/>
+ </target>
+
<!--
| Standard jaxr tests that should run successfully against a
| JBoss server distribution build that contains jaxr.
Modified: branches/Branch_4_2/testsuite/imports/sections/aop.xml
===================================================================
--- branches/Branch_4_2/testsuite/imports/sections/aop.xml 2007-02-15 10:26:38 UTC (rev 60559)
+++ branches/Branch_4_2/testsuite/imports/sections/aop.xml 2007-02-15 10:32:13 UTC (rev 60560)
@@ -302,8 +302,52 @@
</fileset>
</jar>
+ <!-- jars for scoped attachment test -->
+ <jar destfile="${build.lib}/aop-scopedattachtest1.aop">
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/test/aop/scopedattach/**/*.class"/>
+ <exclude name="org/jboss/test/aop/scopedattach/ScopedTester*.class"/>
+ <exclude name="org/jboss/test/aop/scopedattach/POJO.class"/>
+ </fileset>
+ <fileset dir="${build.resources}/aop/scoped-attach/sar1">
+ <include name="META-INF/jboss-aop.xml"/>
+ </fileset>
+ </jar>
+ <jar destfile="${build.lib}/aop-scopedattachtest1.sar">
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/test/aop/scopedattach/ScopedTester*.class"/>
+ <include name="org/jboss/test/aop/scopedattach/POJO.class"/>
+ </fileset>
+ <fileset dir="${build.resources}/aop/scoped-attach/sar1">
+ <include name="META-INF/jboss-service.xml"/>
+ </fileset>
+ <fileset dir="${build.resources}/aop/scoped-attach/sar1/META-INF">
+ <include name="prepare-aop.xml"/>
+ </fileset>
+ </jar>
+ <jar destfile="${build.lib}/aop-scopedattachtest2.aop">
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/test/aop/scopedattach/**/*.class"/>
+ <exclude name="org/jboss/test/aop/scopedattach/ScopedTester*.class"/>
+ <exclude name="org/jboss/test/aop/scopedattach/POJO.class"/>
+ </fileset>
+ <fileset dir="${build.resources}/aop/scoped-attach/sar2">
+ <include name="META-INF/jboss-aop.xml"/>
+ </fileset>
+ </jar>
+ <jar destfile="${build.lib}/aop-scopedattachtest2.sar">
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/test/aop/scopedattach/ScopedTester*.class"/>
+ <include name="org/jboss/test/aop/scopedattach/POJO.class"/>
+ </fileset>
+ <fileset dir="${build.resources}/aop/scoped-attach/sar2">
+ <include name="META-INF/jboss-service.xml"/>
+ </fileset>
+ <fileset dir="${build.resources}/aop/scoped-attach/sar2/META-INF">
+ <include name="prepare-aop.xml"/>
+ </fileset>
+ </jar>
-
<!-- Create jars for earwithwebinf test -->
<jar destfile="${build.lib}/aop-classesinwebinf.aop">
<fileset dir="${build.classes}">
More information about the jboss-cvs-commits
mailing list