[jboss-cvs] JBossAS SVN: r57924 - in trunk: aspects aspects/src/main/org/jboss/aop/deployers aspects/src/main/org/jboss/aop/deployment testsuite/imports/sections testsuite/src/main/org/jboss/test/aop/scoped testsuite/src/main/org/jboss/test/aop/test
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Oct 30 12:24:27 EST 2006
Author: kabir.khan at jboss.com
Date: 2006-10-30 12:24:20 -0500 (Mon, 30 Oct 2006)
New Revision: 57924
Added:
trunk/testsuite/src/main/org/jboss/test/aop/scoped/AnnotatedInterceptor.java
Modified:
trunk/aspects/build-test50.xml
trunk/aspects/src/main/org/jboss/aop/deployers/AspectDeployer.java
trunk/aspects/src/main/org/jboss/aop/deployment/AspectDeployer.java
trunk/testsuite/imports/sections/aop.xml
trunk/testsuite/src/main/org/jboss/test/aop/scoped/ScopedTester.java
trunk/testsuite/src/main/org/jboss/test/aop/scoped/ScopedTesterMBean.java
trunk/testsuite/src/main/org/jboss/test/aop/test/ScopedUnitTestCase.java
Log:
[JBAOP-293] Get scoped AOP working with AspectAnnotationLoader
Modified: trunk/aspects/build-test50.xml
===================================================================
--- trunk/aspects/build-test50.xml 2006-10-30 16:45:41 UTC (rev 57923)
+++ trunk/aspects/build-test50.xml 2006-10-30 17:24:20 UTC (rev 57924)
@@ -107,7 +107,7 @@
<path id="dependentmodule.classpath">
<path refid="jboss.j2ee.classpath"/>
<path refid="jboss.j2se.classpath"/>
- <path refid="jboss.aop50.classpath"/>
+ <path refid="jboss.aop.classpath"/>
<path refid="jboss.aspects50.classpath"/>
<path refid="jboss.common.core.classpath"/>
<path refid="jboss.common.logging.spi.classpath"/>
@@ -136,7 +136,7 @@
<!-- Where build generated files will go -->
<property name="build.reports" value="${module.output}/reports"/>
<property name="build.testlog" value="${module.output}/log"/>
- <property name="build.classes" value="${module.output}/classes15"/>
+ <property name="build.classes" value="${module.output}/classes"/>
<property name="build.lib" value="${module.output}/lib"/>
<property name="build.api" value="${module.output}/api"/>
<property name="build.etc" value="${module.output}/etc"/>
Modified: trunk/aspects/src/main/org/jboss/aop/deployers/AspectDeployer.java
===================================================================
--- trunk/aspects/src/main/org/jboss/aop/deployers/AspectDeployer.java 2006-10-30 16:45:41 UTC (rev 57923)
+++ trunk/aspects/src/main/org/jboss/aop/deployers/AspectDeployer.java 2006-10-30 17:24:20 UTC (rev 57924)
@@ -28,7 +28,6 @@
import org.jboss.deployers.plugins.deployer.AbstractSimpleDeployer;
import org.jboss.deployers.spi.deployer.DeploymentUnit;
import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployment.DeploymentInfo;
import org.jboss.virtual.VirtualFile;
import org.jboss.virtual.VirtualFileFilter;
import org.jboss.virtual.VisitorAttributes;
@@ -41,7 +40,6 @@
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.net.URL;
import java.util.List;
import javassist.bytecode.ClassFile;
@@ -68,6 +66,7 @@
public void deploy(DeploymentUnit unit) throws DeploymentException
{
List<VirtualFile> files = unit.getMetaDataFiles(null, AOP_DD_SUFFIX);
+ ClassLoader scl = getScopedClassLoader(unit);
if (isAopArchiveOrFolder(unit))
{
@@ -169,7 +168,16 @@
private void deployAnnotations(DeploymentUnit unit) throws DeploymentException
{
- AspectAnnotationLoader loader = new AspectAnnotationLoader(AspectManager.instance());
+ ClassLoader scl = getScopedClassLoader(unit);
+
+ if (scl != null)
+ {
+ log.info("AOP deployment is scoped using classloader " + scl);
+ }
+
+ AspectManager manager = (scl != null) ? AspectManager.instance(scl) : AspectManager.instance();
+ AspectAnnotationLoader loader = new AspectAnnotationLoader(manager);
+ loader.setClassLoader(scl);
List<VirtualFile> files = getClasses(unit);
for(VirtualFile file : files)
{
Modified: trunk/aspects/src/main/org/jboss/aop/deployment/AspectDeployer.java
===================================================================
--- trunk/aspects/src/main/org/jboss/aop/deployment/AspectDeployer.java 2006-10-30 16:45:41 UTC (rev 57923)
+++ trunk/aspects/src/main/org/jboss/aop/deployment/AspectDeployer.java 2006-10-30 17:24:20 UTC (rev 57924)
@@ -160,7 +160,9 @@
if (!di.isXML)
{
Iterator it = ArchiveBrowser.getBrowser(di.localUrl, new ClassFileFilter());
- AspectAnnotationLoader loader = new AspectAnnotationLoader(AspectManager.instance());
+ AspectManager manager = (scl != null) ? AspectManager.instance(scl) : AspectManager.instance();
+ AspectAnnotationLoader loader = new AspectAnnotationLoader(manager);
+ loader.setClassLoader(scl);
loader.deployInputStreamIterator(it);
}
Modified: trunk/testsuite/imports/sections/aop.xml
===================================================================
--- trunk/testsuite/imports/sections/aop.xml 2006-10-30 16:45:41 UTC (rev 57923)
+++ trunk/testsuite/imports/sections/aop.xml 2006-10-30 17:24:20 UTC (rev 57924)
@@ -240,6 +240,7 @@
<jar destfile="${build.lib}/aop-scopedtest2.sar">
<fileset dir="${build.classes}">
<include name="org/jboss/test/aop/scoped/*.class"/>
+ <exclude name="org/jboss/test/aop/scoped/Annotated*.class"/>
</fileset>
<fileset dir="${build.resources}/aop/scoped/sar2/META-INF">
<include name="scoped-aop.xml"/>
Added: trunk/testsuite/src/main/org/jboss/test/aop/scoped/AnnotatedInterceptor.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/aop/scoped/AnnotatedInterceptor.java 2006-10-30 16:45:41 UTC (rev 57923)
+++ trunk/testsuite/src/main/org/jboss/test/aop/scoped/AnnotatedInterceptor.java 2006-10-30 17:24:20 UTC (rev 57924)
@@ -0,0 +1,50 @@
+/*
+* 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.aop.scoped;
+
+import org.jboss.aop.Bind;
+import org.jboss.aop.InterceptorDef;
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at InterceptorDef()
+ at Bind(pointcut="all(org.jboss.test.aop.scoped.POJO)")
+public class AnnotatedInterceptor implements Interceptor
+{
+ static boolean invoked;
+ public String getName()
+ {
+ return this.getClass().getName();
+ }
+
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ invoked = true;
+ return invocation.invokeNext();
+ }
+
+}
Modified: trunk/testsuite/src/main/org/jboss/test/aop/scoped/ScopedTester.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/aop/scoped/ScopedTester.java 2006-10-30 16:45:41 UTC (rev 57923)
+++ trunk/testsuite/src/main/org/jboss/test/aop/scoped/ScopedTester.java 2006-10-30 17:24:20 UTC (rev 57924)
@@ -138,6 +138,25 @@
}
}
+ public void testAnnotatedScopedAnnotationsDeployed()
+ {
+ AnnotatedInterceptor.invoked = false;
+ POJO pojo = new POJO();
+ if (!AnnotatedInterceptor.invoked) throw new RuntimeException("AnnotatedInterceptor should have been invoked");
+ }
+
+ public void testAnnotatedScopedAnnotationsNotDeployed()
+ {
+ try
+ {
+ AnnotatedInterceptor.invoked = false;
+ throw new RuntimeException("AnnotatedInterceptor should not be available in this deployment");
+ }
+ catch (NoClassDefFoundError expected)
+ {
+ }
+ }
+
public void testIntroduction1()
{
IntroducedPOJO pojo = new IntroducedPOJO();
Modified: trunk/testsuite/src/main/org/jboss/test/aop/scoped/ScopedTesterMBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/aop/scoped/ScopedTesterMBean.java 2006-10-30 16:45:41 UTC (rev 57923)
+++ trunk/testsuite/src/main/org/jboss/test/aop/scoped/ScopedTesterMBean.java 2006-10-30 17:24:20 UTC (rev 57924)
@@ -38,4 +38,6 @@
void testScoped() throws Exception;
void testIntroduction1();
void testIntroduction2();
+ void testAnnotatedScopedAnnotationsDeployed();
+ void testAnnotatedScopedAnnotationsNotDeployed();
}
Modified: trunk/testsuite/src/main/org/jboss/test/aop/test/ScopedUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/aop/test/ScopedUnitTestCase.java 2006-10-30 16:45:41 UTC (rev 57923)
+++ trunk/testsuite/src/main/org/jboss/test/aop/test/ScopedUnitTestCase.java 2006-10-30 17:24:20 UTC (rev 57924)
@@ -90,7 +90,24 @@
server.invoke(testerName, "testScoped", params, sig);
}
+ public void testAnnotations1() throws Exception
+ {
+ MBeanServerConnection server = getServer();
+ ObjectName testerName = new ObjectName("jboss.aop:name=ScopedTester1");
+ Object[] params = {};
+ String[] sig = {};
+ server.invoke(testerName, "testAnnotatedScopedAnnotationsDeployed", params, sig);
+ }
+ public void testAnnotations2() throws Exception
+ {
+ MBeanServerConnection server = getServer();
+ ObjectName testerName = new ObjectName("jboss.aop:name=ScopedTester2");
+ Object[] params = {};
+ String[] sig = {};
+ server.invoke(testerName, "testAnnotatedScopedAnnotationsNotDeployed", params, sig);
+ }
+
public void testIntroduction1() throws Exception
{
MBeanServerConnection server = getServer();
More information about the jboss-cvs-commits
mailing list