[jboss-cvs] JBossAS SVN: r68486 - in projects/ejb3/trunk: interceptors and 23 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Dec 21 04:36:22 EST 2007
Author: wolfc
Date: 2007-12-21 04:36:21 -0500 (Fri, 21 Dec 2007)
New Revision: 68486
Added:
projects/ejb3/trunk/interceptors/
projects/ejb3/trunk/interceptors/.classpath
projects/ejb3/trunk/interceptors/.project
projects/ejb3/trunk/interceptors/.settings/
projects/ejb3/trunk/interceptors/.settings/org.eclipse.jdt.core.prefs
projects/ejb3/trunk/interceptors/pom.xml
projects/ejb3/trunk/interceptors/src/
projects/ejb3/trunk/interceptors/src/main/
projects/ejb3/trunk/interceptors/src/main/java/
projects/ejb3/trunk/interceptors/src/main/java/org/
projects/ejb3/trunk/interceptors/src/main/java/org/jboss/
projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/
projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/
projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/
projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/AroundInvokeInterceptor.java
projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/BootstrapInterceptor.java
projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/BusinessMethodInterceptorMethodInterceptor.java
projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/ClassContainer.java
projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/Destructable.java
projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/DomainClassLoader.java
projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/InterceptorSequencer.java
projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/InterceptorsFactory.java
projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/InterceptorsInterceptor.java
projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/InvocationContextInterceptor.java
projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/InvokeSpecInterceptorInterceptor.java
projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/LifecycleCallbackBeanMethodInterceptor.java
projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/LifecycleCallbackInterceptorMethodInterceptor.java
projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/PostConstructInterceptor.java
projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/lang/
projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/lang/BootstrapClassLoader.java
projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/lang/ClassHelper.java
projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/lang/ScopedClassLoader.java
projects/ejb3/trunk/interceptors/src/test/
projects/ejb3/trunk/interceptors/src/test/java/
projects/ejb3/trunk/interceptors/src/test/java/org/
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/BasicBean.java
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/BasicInterceptor.java
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/BasicMethodInterceptor.java
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/unit/
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/unit/BasicInterceptorTestCase.java
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/unit/BasicTestRunner.java
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/unit/BasicTestSuite.java
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/common/
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/common/aop/
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/common/aop/LoggingInterceptor.java
projects/ejb3/trunk/interceptors/src/test/resources/
projects/ejb3/trunk/interceptors/src/test/resources/basic/
projects/ejb3/trunk/interceptors/src/test/resources/basic/jboss-aop.xml
projects/ejb3/trunk/interceptors/src/test/resources/log4j.xml
Log:
Spec interceptors using AOP
Property changes on: projects/ejb3/trunk/interceptors
___________________________________________________________________
Name: svn:ignore
+ target
eclipse-target
Added: projects/ejb3/trunk/interceptors/.classpath
===================================================================
--- projects/ejb3/trunk/interceptors/.classpath (rev 0)
+++ projects/ejb3/trunk/interceptors/.classpath 2007-12-21 09:36:21 UTC (rev 68486)
@@ -0,0 +1,31 @@
+<classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" path="src/test/java" output="eclipse-target/tests-classes"/>
+ <classpathentry kind="src" path="src/test/resources" output="eclipse-target/tests-classes" excluding="**/*.java"/>
+ <classpathentry kind="output" path="eclipse-target/classes"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var" path="M2_REPO/apache-xerces/xercesImpl/2.7.1/xercesImpl-2.7.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/wutka-dtdparser/dtdparser121/1.2.1/dtdparser121-1.2.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-transaction-api/1.0.1.20070913080910/jboss-transaction-api-1.0.1.20070913080910.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-transaction-api/1.0.1.20070913080910/jboss-transaction-api-1.0.1.20070913080910-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-container/2.0.0.Beta8/jboss-container-2.0.0.Beta8.jar" sourcepath="M2_REPO/org/jboss/microcontainer/jboss-container/2.0.0.Beta8/jboss-container-2.0.0.Beta8-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-ejb-api/3.0.0.20070913080910/jboss-ejb-api-3.0.0.20070913080910.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-ejb-api/3.0.0.20070913080910/jboss-ejb-api-3.0.0.20070913080910-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jbossxb/2.0.0.CR4/jbossxb-2.0.0.CR4.jar" sourcepath="M2_REPO/org/jboss/jbossxb/2.0.0.CR4/jbossxb-2.0.0.CR4-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/aop/jboss-aop/2.0.0.beta1/jboss-aop-2.0.0.beta1.jar" sourcepath="M2_REPO/org/jboss/aop/jboss-aop/2.0.0.beta1/jboss-aop-2.0.0.beta1-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar" sourcepath="M2_REPO/junit/junit/3.8.1/junit-3.8.1-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-slide/webdavlib/2.0/webdavlib-2.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-log4j/log4j/1.2.8/log4j-1.2.8.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-logging-spi/2.0.2.GA/jboss-logging-spi-2.0.2.GA.jar" sourcepath="M2_REPO/jboss/jboss-logging-spi/2.0.2.GA/jboss-logging-spi-2.0.2.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-common-core/2.2.1.GA/jboss-common-core-2.2.1.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-common-core/2.2.1.GA/jboss-common-core-2.2.1.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-common-logging-spi/2.0.4.GA/jboss-common-logging-spi-2.0.4.GA.jar" sourcepath="M2_REPO/jboss/jboss-common-logging-spi/2.0.4.GA/jboss-common-logging-spi-2.0.4.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/oswego-concurrent/concurrent/1.3.4/concurrent-1.3.4.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-logging-log4j/2.0.2.GA/jboss-logging-log4j-2.0.2.GA.jar" sourcepath="M2_REPO/jboss/jboss-logging-log4j/2.0.2.GA/jboss-logging-log4j-2.0.2.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-xerces/xml-apis/2.7.1/xml-apis-2.7.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-httpclient/commons-httpclient/2.0.2/commons-httpclient-2.0.2.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/javassist/3.6.0.GA/javassist-3.6.0.GA.jar" sourcepath="M2_REPO/org/jboss/javassist/3.6.0.GA/javassist-3.6.0.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/qdox/qdox/1.6/qdox-1.6.jar" sourcepath="M2_REPO/qdox/qdox/1.6/qdox-1.6-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/javax/activation/activation/1.0.2/activation-1.0.2.jar"/>
+ <classpathentry kind="var" path="M2_REPO/ant/ant/1.6.5/ant-1.6.5.jar" sourcepath="M2_REPO/ant/ant/1.6.5/ant-1.6.5-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/trove/trove/2.1.1/trove-2.1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-common-core/2.0.2.GA/jboss-common-core-2.0.2.GA.jar" sourcepath="M2_REPO/jboss/jboss-common-core/2.0.2.GA/jboss-common-core-2.0.2.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jbossws/jboss-jaxrpc/1.0.4.GA/jboss-jaxrpc-1.0.4.GA.jar"/>
+</classpath>
\ No newline at end of file
Added: projects/ejb3/trunk/interceptors/.project
===================================================================
--- projects/ejb3/trunk/interceptors/.project (rev 0)
+++ projects/ejb3/trunk/interceptors/.project 2007-12-21 09:36:21 UTC (rev 68486)
@@ -0,0 +1,14 @@
+<projectDescription>
+ <name>jboss-ejb3-interceptors</name>
+ <comment>The JBoss EJB 3 Interceptors component implements all functionality
+ specified in Chapter 12 (Interceptors) of the EJB 3 specification.</comment>
+ <projects/>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
\ No newline at end of file
Added: projects/ejb3/trunk/interceptors/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- projects/ejb3/trunk/interceptors/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ projects/ejb3/trunk/interceptors/.settings/org.eclipse.jdt.core.prefs 2007-12-21 09:36:21 UTC (rev 68486)
@@ -0,0 +1,5 @@
+#Wed Dec 19 09:58:43 CET 2007
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
Added: projects/ejb3/trunk/interceptors/pom.xml
===================================================================
--- projects/ejb3/trunk/interceptors/pom.xml (rev 0)
+++ projects/ejb3/trunk/interceptors/pom.xml 2007-12-21 09:36:21 UTC (rev 68486)
@@ -0,0 +1,69 @@
+<!--
+ vi:ts=2:sw=2:expandtab
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3</artifactId>
+ <version>0.11.0-SNAPSHOT</version>
+ <relativePath>../build/pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>jboss-ejb3-interceptors</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss EJB 3 Interceptors</name>
+ <url>http://www.jboss.org</url>
+ <description>
+ The JBoss EJB 3 Interceptors component implements all functionality
+ specified in Chapter 12 (Interceptors) of the EJB 3 specification.
+ </description>
+
+ <dependencies>
+ <!-- internal -->
+ <!--
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-pool</artifactId>
+ </dependency>
+ -->
+
+ <!-- external -->
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jnpserver</artifactId>
+ <scope>test</scope>
+ </dependency>
+ -->
+ <dependency>
+ <groupId>org.jboss.aop</groupId>
+ <artifactId>jboss-aop</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.javaee</groupId>
+ <artifactId>jboss-ejb-api</artifactId>
+ </dependency>
+
+ <!-- broken transitive dependencies of AOP -->
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-container</artifactId>
+ <version>2.0.0.Beta8</version> <!-- FIXME: move to build -->
+ </dependency>
+ </dependencies>
+</project>
Property changes on: projects/ejb3/trunk/interceptors/pom.xml
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/AroundInvokeInterceptor.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/AroundInvokeInterceptor.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/AroundInvokeInterceptor.java 2007-12-21 09:36:21 UTC (rev 68486)
@@ -0,0 +1,52 @@
+/*
+ * 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.ejb3.interceptors.aop;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.logging.Logger;
+
+/**
+ * Invoke around invoke
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class AroundInvokeInterceptor implements Interceptor
+{
+ private static final Logger log = Logger.getLogger(AroundInvokeInterceptor.class);
+
+ public String getName()
+ {
+ return "AroundInvokeInterceptor";
+ }
+
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ log.debug("invoke " + invocation);
+ log.debug(" " + invocation.getAdvisor());
+ log.debug(" " + invocation.getTargetObject());
+ log.debug("classInterceptors = " + invocation.getMetaData(InterceptorsFactory.class, "classInterceptors"));
+ return invocation.invokeNext();
+ }
+
+}
Property changes on: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/AroundInvokeInterceptor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/BootstrapInterceptor.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/BootstrapInterceptor.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/BootstrapInterceptor.java 2007-12-21 09:36:21 UTC (rev 68486)
@@ -0,0 +1,55 @@
+/*
+ * 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.ejb3.interceptors.aop;
+
+import javax.interceptor.Interceptors;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.logging.Logger;
+
+/**
+ * The mother of interceptors
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class BootstrapInterceptor implements Interceptor
+{
+ private static final Logger log = Logger.getLogger(BootstrapInterceptor.class);
+
+ public String getName()
+ {
+ return "BootstrapInterceptor";
+ }
+
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ log.debug("invoke " + invocation);
+ log.debug(" " + invocation.getAdvisor());
+ log.debug(" " + invocation.getTargetObject());
+ Interceptors interceptors = (Interceptors) invocation.getAdvisor().resolveAnnotation(Interceptors.class);
+ assert interceptors != null : "interceptors annotation not found";
+ return invocation.invokeNext();
+ }
+
+}
Property changes on: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/BootstrapInterceptor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/BusinessMethodInterceptorMethodInterceptor.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/BusinessMethodInterceptorMethodInterceptor.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/BusinessMethodInterceptorMethodInterceptor.java 2007-12-21 09:36:21 UTC (rev 68486)
@@ -0,0 +1,89 @@
+/*
+ * 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.ejb3.interceptors.aop;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+
+import javax.interceptor.InvocationContext;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+
+/**
+ * Chapter 12.3
+ *
+ * AroundInvoke methods have the following signature:
+ * Object <METHOD>(InvocationContext) throws Exception
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class BusinessMethodInterceptorMethodInterceptor implements Interceptor
+{
+ private static final Class<?> PARAMETER_TYPES[] = { InvocationContext.class };
+
+ private Object interceptor;
+ private Method method;
+
+ /**
+ *
+ * @param interceptor an spec interceptor
+ * @param businessMethodInterceptorMethod a business method interceptor on the spec interceptor
+ */
+ public BusinessMethodInterceptorMethodInterceptor(Object interceptor, Method businessMethodInterceptorMethod)
+ {
+ assert interceptor != null : "interceptor is null";
+ assert businessMethodInterceptorMethod != null : "businessMethodInterceptorMethod is null";
+ assert businessMethodInterceptorMethod.getReturnType() == Object.class : "return type must be Object " + businessMethodInterceptorMethod;
+ assert Arrays.equals(businessMethodInterceptorMethod.getParameterTypes(), PARAMETER_TYPES) : "wrong parameter signature";
+ // Ignore throw clause
+
+ this.interceptor = interceptor;
+ this.method = businessMethodInterceptorMethod;
+ }
+
+ public String getName()
+ {
+ return "BusinessMethodInterceptorMethodInterceptor";
+ }
+
+ public Object invoke(final Invocation invocation) throws Throwable
+ {
+ InvocationContext ctx = InvocationContextInterceptor.getInvocationContext(invocation);
+ try
+ {
+ Object args[] = { ctx };
+ return method.invoke(interceptor, args);
+ }
+ catch(InvocationTargetException e)
+ {
+ throw e.getCause();
+ }
+ }
+
+ public String toString()
+ {
+ return method.toString();
+ }
+}
Property changes on: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/BusinessMethodInterceptorMethodInterceptor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/ClassContainer.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/ClassContainer.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/ClassContainer.java 2007-12-21 09:36:21 UTC (rev 68486)
@@ -0,0 +1,114 @@
+/*
+ * 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.ejb3.interceptors.aop;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Arrays;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.ClassAdvisor;
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.ConstructorInvocation;
+import org.jboss.logging.Logger;
+
+/**
+ * A hack to get to a proper class container.
+ *
+ * @deprecated use DomainClassLoader
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Deprecated
+public class ClassContainer extends ClassAdvisor
+{
+ private static final Logger log = Logger.getLogger(ClassContainer.class);
+
+ public ClassContainer(String name, Class<?> clazz, AspectManager manager) throws ClassNotFoundException
+ {
+ super(clazz, manager);
+
+ // Wickedness: we load up a weaved class, so we must call interceptors ourselves
+ //clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
+
+// super.setChainOverridingForInheritedMethods(true);
+
+// initializeClassContainer();
+
+ attachClass(clazz);
+
+ rebuildInterceptors();
+ }
+
+ public Object construct()
+ {
+ assert constructionInfos.length == 1 : "FIXME: Need to find the default constructor";
+ int defaultConstructorIndex = 0; // FIXME
+
+ log.debug("constructInfos = " + Arrays.toString(constructorInfos));
+ log.debug("constructionInfos = " + Arrays.toString(constructionInfos));
+ log.debug(Arrays.toString(constructionInfos[0].getInterceptors()));
+
+ Interceptor[] cInterceptors = constructionInfos[0].getInterceptors();
+ if (cInterceptors == null)
+ {
+ try
+ {
+ return constructors[defaultConstructorIndex].newInstance();
+ }
+ catch (InstantiationException e)
+ {
+ throw new RuntimeException(e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new RuntimeException(e);
+ }
+ catch (InvocationTargetException e)
+ {
+ if(e.getCause() instanceof Error)
+ throw (Error) e.getCause();
+ if(e.getCause() instanceof RuntimeException)
+ throw (RuntimeException) e.getCause();
+ throw new RuntimeException(e);
+ }
+ }
+
+ log.debug("fire constructor invocation");
+
+ ConstructorInvocation invocation = new ConstructorInvocation(cInterceptors);
+ invocation.setAdvisor(this);
+ invocation.setConstructor(constructors[defaultConstructorIndex]);
+ try
+ {
+ return invocation.invokeNext();
+ }
+ catch (Throwable t)
+ {
+ if(t instanceof Error)
+ throw (Error) t;
+ if(t instanceof RuntimeException)
+ throw (RuntimeException) t;
+ throw new RuntimeException(t);
+ }
+ }
+}
Property changes on: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/ClassContainer.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/Destructable.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/Destructable.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/Destructable.java 2007-12-21 09:36:21 UTC (rev 68486)
@@ -0,0 +1,33 @@
+/*
+ * 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.ejb3.interceptors.aop;
+
+/**
+ * So we can call _preDestroy
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface Destructable
+{
+ void _preDestroy();
+}
Property changes on: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/Destructable.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/DomainClassLoader.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/DomainClassLoader.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/DomainClassLoader.java 2007-12-21 09:36:21 UTC (rev 68486)
@@ -0,0 +1,343 @@
+/*
+ * 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.ejb3.interceptors.aop;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.CodeSource;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.security.ProtectionDomain;
+import java.security.cert.Certificate;
+
+import org.jboss.aop.Advised;
+import org.jboss.aop.Domain;
+import org.jboss.ejb3.interceptors.lang.BootstrapClassLoader;
+import org.jboss.logging.Logger;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class DomainClassLoader extends ClassLoader
+{
+ private static final Logger log = Logger.getLogger(DomainClassLoader.class);
+
+ /**
+ * Load domain classes from here.
+ */
+ private ClassLoader delegate;
+
+ /**
+ * Load JDK classes from here.
+ *
+ * Do not confuse this with interceptor bootstrapping
+ */
+ private ClassLoader bootstrapClassLoader = new BootstrapClassLoader();
+
+ private Domain domain;
+
+ public DomainClassLoader(ClassLoader parent, ClassLoader delegate, Domain domain)
+ {
+ super(parent);
+
+ assert delegate != null : "delegate is null";
+ assert domain != null : "domain is null";
+
+ this.delegate = delegate;
+ this.domain = domain;
+
+ //domain.registerClassLoader(this); // TODO: What does this do?
+ }
+
+ /**
+ * Copy of SystemClassLoader.defineClassFromBytes
+ * @param name
+ * @param bytes
+ * @param resolve
+ * @return
+ */
+ private Class<?> defineClassFromBytes(String name, ClassBytes bytes, boolean resolve)
+ {
+ definePackage(name);
+ byte[] b = bytes.bytes;
+ Class<?> clazz = defineClass(name, b, 0, b.length, bytes.protectionDomain);
+ if (resolve) resolveClass(clazz);
+ return clazz;
+ }
+
+ /**
+ * Copy of SystemClassLoader.definePackage
+ *
+ * TODO: do this properly
+ *
+ * @param className
+ */
+ private void definePackage(String className)
+ {
+ int i = className.lastIndexOf('.');
+ if (i == -1)
+ return;
+
+ // we are not allowed to synchronize on ClassLoader.packages
+ try
+ {
+ definePackage(className.substring(0, i), null, null, null, null, null, null, null);
+ }
+ catch (IllegalArgumentException alreadyDone)
+ {
+ }
+ }
+
+ private ClassLoader getDelegate()
+ {
+ return delegate;
+ }
+
+ /**
+ * Purely for scoping class loader policy
+ *
+ * Do not use, it might be gone in later versions.
+ *
+ * @return the domain of this class loader
+ */
+ public Domain getDomain()
+ {
+ return domain;
+ }
+
+ /**
+ * Load a class, overridden to transform aop enhanced classes
+ * and load non jre classes through this classloader.
+ *
+ * @param name the class name
+ * @param resolve whether to resolve the class
+ * @return the class
+ * @throws ClassNotFoundException when there is no class
+ */
+ protected synchronized Class<?> loadClass(String name, boolean resolve)
+ throws ClassNotFoundException
+ {
+ if(log.isTraceEnabled()) log.trace("loadClass " + name);
+
+ // Have we already loaded the class?
+ Class<?> clazz = findLoadedClass(name);
+ if (clazz != null)
+ {
+ if (resolve) resolveClass(clazz);
+ return clazz;
+ }
+
+ // Is it a JRE class?
+ try
+ {
+ clazz = bootstrapClassLoader.loadClass(name);
+ if (resolve) resolveClass(clazz);
+ return clazz;
+ }
+ catch(ClassNotFoundException e)
+ {
+ // it's not a jdk class
+ log.trace("Can't find class '" + name + "' in bootstrap.");
+ }
+
+ final String classFileName = name.replace('.', '/') + ".class";
+ final URL url = getDelegate().getResource(classFileName);
+ if(url == null)
+ {
+ if(log.isTraceEnabled()) log.trace("Did not find an url for '" + name + "'.");
+ clazz = getParent().loadClass(name);
+ if(resolve) resolveClass(clazz);
+ return clazz;
+ }
+
+ log.debug(name + " found on " + url);
+ // Load the class
+ try
+ {
+ ClassBytes origBytes = loadClassBytes(name, classFileName, url);
+ ClassBytes classBytes = new ClassBytes();
+
+ assert !name.startsWith("org.jboss.aop") : "We should not have found a valid url";
+
+ classBytes.bytes = domain.transform(this, name, null, origBytes.protectionDomain, origBytes.bytes);
+ classBytes.protectionDomain = origBytes.protectionDomain;
+
+ if (classBytes.bytes == null)
+ classBytes = origBytes;
+
+ // Define the class
+ Class<?> cls = defineClassFromBytes(name, classBytes, resolve);
+ if(resolve) resolveClass(cls);
+ assert Advised.class.isAssignableFrom(cls) : "Class " + cls + " is not really transformed";
+ return cls;
+ }
+ catch(ClassNotFoundException e)
+ {
+ // TODO: We can't find any bytes for it, let's just pass it over
+ log.warn("Unable to instrument '" + name + "'", e);
+ return super.loadClass(name, resolve);
+ }
+ catch (IOException ioe)
+ {
+ throw new ClassNotFoundException("Unable to load " + name, ioe);
+ }
+ catch (IllegalAccessException iae)
+ {
+ // TODO: this might kill a thread
+ throw new Error(iae);
+ }
+ catch (Exception e)
+ {
+ // TODO: this might kill a thread
+ throw new Error("Error transforming the class " + name, e);
+ }
+ }
+
+ /**
+ * Load the bytecode for a class
+ */
+ private ClassBytes loadClassBytes(String name, final String classFileName, final URL url)
+ throws ClassNotFoundException, IOException
+ {
+// final String classFileName = name.replace('.', '/') + ".class";
+// final URL url = AccessController.doPrivileged(new PrivilegedAction<URL>()
+// {
+// public URL run()
+// {
+// return getParent().getResource(classFileName);
+// }
+// });
+ ProtectionDomain protectionDomain = null;
+ InputStream in = null;
+ if (url != null)
+ {
+ try
+ {
+ in = AccessController.doPrivileged(new PrivilegedExceptionAction<InputStream>()
+ {
+ public InputStream run() throws Exception
+ {
+ return url.openStream();
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw new ClassNotFoundException(name, e);
+ }
+ String urlstring = url.toExternalForm();
+ URL urlCS = url;
+ if (urlstring.startsWith("jar:"))
+ {
+ int i = urlstring.indexOf('!');
+ String cs = urlstring.substring(4, i);
+ urlCS = new URL(cs);
+ }
+ else
+ {
+ int i = urlstring.indexOf(classFileName);
+ if (i != -1)
+ {
+ String cs = urlstring.substring(0, i);
+ urlCS = new URL(cs);
+ }
+ }
+ CodeSource codeSource = new CodeSource(urlCS, (Certificate[]) null);
+ protectionDomain = new ProtectionDomain(codeSource, null, this, null);
+ }
+ else
+ {
+ /* Try the system tmpdir/aopdynclasses, the default location
+ the AOPClassPool writes dynamic class files to.
+ */
+ try
+ {
+ in = AccessController.doPrivileged(new PrivilegedExceptionAction<InputStream>()
+ {
+ public InputStream run() throws Exception
+ {
+ String tmpdir = System.getProperty("java.io.tmpdir");
+ File aopdynclasses = new File(tmpdir, "aopdynclasses");
+ File classFile = new File(aopdynclasses, classFileName);
+ return new FileInputStream(classFile);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw new ClassNotFoundException(name, e);
+ }
+ }
+
+ byte[][] bufs = new byte[8][];
+ int bufsize = 4096;
+
+ for (int i = 0; i < 8; ++i)
+ {
+ bufs[i] = new byte[bufsize];
+ int size = 0;
+ int len = 0;
+ do
+ {
+ len = in.read(bufs[i], size, bufsize - size);
+ if (len >= 0)
+ size += len;
+ else
+ {
+ byte[] result = new byte[bufsize - 4096 + size];
+ int s = 0;
+ for (int j = 0; j < i; ++j)
+ {
+ System.arraycopy(bufs[j], 0, result, s, s + 4096);
+ s = s + s + 4096;
+ }
+
+ System.arraycopy(bufs[i], 0, result, s, size);
+ ClassBytes classBytes = new ClassBytes();
+ classBytes.bytes = result;
+ classBytes.protectionDomain = protectionDomain;
+ return classBytes;
+ }
+ }
+ while (size < bufsize);
+ bufsize *= 2;
+ }
+
+ throw new IOException("too much data loading class " + name);
+ }
+
+ /**
+ * ClassBytes.
+ */
+ private static class ClassBytes
+ {
+ public ProtectionDomain protectionDomain;
+ public byte[] bytes;
+ }
+}
Property changes on: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/DomainClassLoader.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/InterceptorSequencer.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/InterceptorSequencer.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/InterceptorSequencer.java 2007-12-21 09:36:21 UTC (rev 68486)
@@ -0,0 +1,53 @@
+/*
+ * 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.ejb3.interceptors.aop;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+
+/**
+ * Invokes some interceptors in sequence.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class InterceptorSequencer implements Interceptor
+{
+ private Interceptor[] interceptors;
+
+ public InterceptorSequencer(Interceptor interceptors[])
+ {
+ this.interceptors = interceptors;
+ }
+
+ public String getName()
+ {
+ // TODO: might need a dynamic name
+ return "InterceptorSequence";
+ }
+
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ Invocation newInvocation = invocation.getWrapper(interceptors);
+ return newInvocation.invokeNext();
+ }
+}
Property changes on: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/InterceptorSequencer.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/InterceptorsFactory.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/InterceptorsFactory.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/InterceptorsFactory.java 2007-12-21 09:36:21 UTC (rev 68486)
@@ -0,0 +1,166 @@
+/*
+ * 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.ejb3.interceptors.aop;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.annotation.PostConstruct;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptors;
+
+import org.jboss.aop.Advised;
+import org.jboss.aop.Advisor;
+import org.jboss.aop.InstanceAdvisor;
+import org.jboss.aop.advice.AspectFactory;
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Joinpoint;
+import org.jboss.ejb3.interceptors.lang.ClassHelper;
+import org.jboss.logging.Logger;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class InterceptorsFactory implements AspectFactory
+{
+ private static final Logger log = Logger.getLogger(InterceptorsFactory.class);
+
+ public Object createPerClass(Advisor advisor)
+ {
+ throw new IllegalStateException("Only per instance scope is supported");
+ }
+
+ public Object createPerInstance(Advisor advisor, InstanceAdvisor instanceAdvisor)
+ {
+ try
+ {
+ log.debug("createPerInstance");
+ log.debug(" advisor " + advisor.getName());
+ log.debug(" instanceAdvisor " + instanceAdvisor);
+
+ Interceptors interceptorsAnnotation = (Interceptors) advisor.resolveAnnotation(Interceptors.class);
+ assert interceptorsAnnotation != null : "interceptors annotation not found"; // FIXME: not correct, bean can be without interceptors
+ List<Interceptor> postConstructs = new ArrayList<Interceptor>();
+ List<Interceptor> classInterceptors = new ArrayList<Interceptor>();
+ for(Class<?> interceptorClass : interceptorsAnnotation.value())
+ {
+ Object interceptor = interceptorClass.newInstance();
+ Advisor interceptorAdvisor = ((Advised) interceptor)._getAdvisor();
+ log.info("interceptorAdvisor = " + interceptorAdvisor.getName());
+ InstanceAdvisor interceptorInstanceAdvisor = ((Advised) interceptor)._getInstanceAdvisor();
+ log.info("interceptorInstanceAdvisor = " + interceptorInstanceAdvisor);
+ for(Method method : ClassHelper.getAllMethods(interceptorClass))
+ {
+ if(interceptorAdvisor.hasAnnotation(method, PostConstruct.class))
+ {
+ postConstructs.add(new LifecycleCallbackInterceptorMethodInterceptor(interceptor, method));
+ }
+ if(interceptorAdvisor.hasAnnotation(method, AroundInvoke.class))
+ {
+ classInterceptors.add(new BusinessMethodInterceptorMethodInterceptor(interceptor, method));
+ }
+ }
+ //instanceAdvisor.appendInterceptorStack(stackName);
+ //instanceAdvisor.appendInterceptor(new InvokeSpecInterceptorInterceptor());
+ }
+
+ Class<?> beanClass = advisor.getClazz();
+ for(Method beanMethod : ClassHelper.getAllMethods(beanClass))
+ {
+ interceptorsAnnotation = (Interceptors) advisor.resolveAnnotation(beanMethod, Interceptors.class);
+ if(interceptorsAnnotation != null)
+ {
+ List<Interceptor> businessMethodInterceptors = new ArrayList<Interceptor>();
+ // TODO: use visitors
+ for(Class<?> interceptorClass : interceptorsAnnotation.value())
+ {
+ // TODO: do not create perse, we might already have done that
+ Object interceptor = interceptorClass.newInstance();
+ Advisor interceptorAdvisor = ((Advised) interceptor)._getAdvisor();
+ for(Method method : ClassHelper.getAllMethods(interceptorClass))
+ {
+ /* EJB 3 12.7 footnote 57: no lifecycle callbacks on business method interceptors
+ if(interceptorAdvisor.hasAnnotation(method, PostConstruct.class))
+ {
+ postConstructs.add(new LifecycleCallbackInterceptorMethodInterceptor(interceptor, method));
+ }
+ */
+ if(interceptorAdvisor.hasAnnotation(method, AroundInvoke.class))
+ {
+ businessMethodInterceptors.add(new BusinessMethodInterceptorMethodInterceptor(interceptor, method));
+ }
+ }
+ }
+ assert businessMethodInterceptors.size() > 0 : "TODO: lucky guess";
+ instanceAdvisor.getMetaData().addMetaData(InterceptorsFactory.class, beanMethod, businessMethodInterceptors.toArray(new Interceptor[0]));
+ }
+ }
+
+ log.debug("classInterceptors " + classInterceptors);
+ // Class Interceptors
+ instanceAdvisor.getMetaData().addMetaData(InterceptorsFactory.class, "classInterceptors", classInterceptors.toArray(new Interceptor[0]));
+
+ // Put the postConstructs interceptors here in the chain
+ // TODO: why? We may need more control
+ return new InterceptorSequencer(postConstructs.toArray(new Interceptor[0]));
+ }
+ catch(InstantiationException e)
+ {
+ Throwable cause = e.getCause();
+ if(cause instanceof Error)
+ throw (Error) cause;
+ if(cause instanceof RuntimeException)
+ throw (RuntimeException) cause;
+ throw new RuntimeException(e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public Object createPerJoinpoint(Advisor advisor, Joinpoint jp)
+ {
+ throw new IllegalStateException("Only per instance scope is supported");
+ }
+
+ public Object createPerJoinpoint(Advisor advisor, InstanceAdvisor instanceAdvisor, Joinpoint jp)
+ {
+ log.warn("Only per instance scope is supported");
+ return createPerInstance(advisor, instanceAdvisor);
+ }
+
+ public Object createPerVM()
+ {
+ throw new IllegalStateException("Only per instance scope is supported");
+ }
+
+ public String getName()
+ {
+ return "InterceptorsFactory";
+ }
+
+}
Property changes on: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/InterceptorsFactory.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/InterceptorsInterceptor.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/InterceptorsInterceptor.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/InterceptorsInterceptor.java 2007-12-21 09:36:21 UTC (rev 68486)
@@ -0,0 +1,66 @@
+/*
+ * 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.ejb3.interceptors.aop;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+import org.jboss.logging.Logger;
+
+/**
+ * Invoke the correct spec interceptors.
+ *
+ * See EJB 3 12.3.1.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class InterceptorsInterceptor
+{
+ private static final Logger log = Logger.getLogger(InterceptorsInterceptor.class);
+
+ public InterceptorsInterceptor()
+ {
+ log.debug("InterceptorsInterceptor");
+ }
+
+ public Object invokeBusinessMethodInterceptors(Invocation invocation) throws Throwable
+ {
+ assert invocation instanceof MethodInvocation : "Can only have business method interceptors on a method invocation";
+ MethodInvocation mi = (MethodInvocation) invocation;
+ Interceptor interceptors[] = (Interceptor[]) invocation.getMetaData(InterceptorsFactory.class, mi.getMethod());
+ return invocation.getWrapper(interceptors).invokeNext();
+ }
+
+ public Object invokeClassInterceptors(Invocation invocation) throws Throwable
+ {
+ Interceptor interceptors[] = (Interceptor[]) invocation.getMetaData(InterceptorsFactory.class, "classInterceptors");
+ return invocation.getWrapper(interceptors).invokeNext();
+ }
+
+ public Object invokeDefaultInterceptors(Invocation invocation) throws Throwable
+ {
+ log.warn("Invoking defaults interceptors is NYI");
+ log.debug("advisor " + invocation.getAdvisor().getName());
+ return invocation.invokeNext();
+ }
+}
Property changes on: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/InterceptorsInterceptor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/InvocationContextInterceptor.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/InvocationContextInterceptor.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/InvocationContextInterceptor.java 2007-12-21 09:36:21 UTC (rev 68486)
@@ -0,0 +1,156 @@
+package org.jboss.ejb3.interceptors.aop;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+
+/*
+ * 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.
+ */
+
+/**
+ * The invocation context interceptor makes sure that invocation context
+ * is available.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class InvocationContextInterceptor
+{
+ public static final String INVOCATION_CONTEXT_KEY = InvocationContextInterceptor.class.getName() + ".invocationContext";
+
+ public static InvocationContext getInvocationContext(Invocation invocation)
+ {
+ InvocationContext ctx = (InvocationContext) invocation.getResponseAttachment(INVOCATION_CONTEXT_KEY);
+ if(ctx == null)
+ throw new IllegalStateException("InvocationContextInterceptor must be in the interceptor chain");
+ return ctx;
+ }
+
+ public String getName()
+ {
+ return "InvocationContextInterceptor";
+ }
+
+ public Object fillMethod(final Invocation invocation) throws Throwable
+ {
+ assert invocation instanceof MethodInvocation : "InvocationContextInterceptor.fillMethod only works on method invocation " + invocation;
+ MethodInvocation mi = (MethodInvocation) invocation;
+ InvocationContext ctx = getInvocationContext(invocation);
+ ctx.setBusinessMethodInvocation(mi.getActualMethod(), mi.getArguments());
+ return invocation.invokeNext();
+ }
+
+ /**
+ * Setup an empty invocation context which can be used for lifecycle callbacks.
+ *
+ * @param invocation
+ * @return
+ * @throws Throwable
+ */
+ public Object setup(final Invocation invocation) throws Throwable
+ {
+ InvocationContext ctx = new InvocationContext(invocation);
+ invocation.addResponseAttachment(INVOCATION_CONTEXT_KEY, ctx);
+ try
+ {
+ return invocation.invokeNext();
+ }
+ finally
+ {
+ // TODO: I can't remove the ctx, invalidate it somehow
+ invocation.addResponseAttachment(INVOCATION_CONTEXT_KEY, null);
+ }
+ }
+
+ private static class InvocationContext implements javax.interceptor.InvocationContext
+ {
+ private Invocation invocation;
+ private Map<String, Object> contextData = new HashMap<String, Object>();
+ private Method method = null;
+ private Object params[] = null;
+
+ private InvocationContext(Invocation invocation)
+ {
+ this.invocation = invocation;
+ // Whether we're calling a business method or a lifecycle callback is beyond scope
+ // here. This must be explicitly set via setBusinessMethodInvocation.
+ }
+
+ public Map<String, Object> getContextData()
+ {
+ return contextData;
+ }
+
+ public Method getMethod()
+ {
+ if(method == null)
+ throw new IllegalStateException("Get method is not allowed on lifecycle callbacks (EJB 3 12)");
+ return method;
+ }
+
+ public Object[] getParameters()
+ {
+ if(method == null)
+ throw new IllegalStateException("Get parameters is not allowed on lifecycle callbacks (EJB 3 12)");
+ return params;
+ }
+
+ public Object getTarget()
+ {
+ return invocation.getTargetObject();
+ }
+
+ public Object proceed() throws Exception
+ {
+ try
+ {
+ return invocation.invokeNext();
+ }
+ catch(Exception e)
+ {
+ throw e;
+ }
+ catch(Throwable t)
+ {
+ throw new RuntimeException(t);
+ }
+ }
+
+ private void setBusinessMethodInvocation(Method method, Object params[])
+ {
+ this.method = method;
+ this.params = params;
+ }
+
+ public void setParameters(Object[] params)
+ {
+ if(method == null)
+ throw new IllegalStateException("Setting parameters is not allowed on lifecycle callbacks (EJB 3 12)");
+ // TODO: might need more checks
+ this.params = params;
+ ((MethodInvocation) invocation).setArguments(params);
+ }
+ }
+}
Property changes on: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/InvocationContextInterceptor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/InvokeSpecInterceptorInterceptor.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/InvokeSpecInterceptorInterceptor.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/InvokeSpecInterceptorInterceptor.java 2007-12-21 09:36:21 UTC (rev 68486)
@@ -0,0 +1,50 @@
+/*
+ * 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.ejb3.interceptors.aop;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.logging.Logger;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Deprecated
+public class InvokeSpecInterceptorInterceptor implements Interceptor
+{
+ private static final Logger log = Logger.getLogger(InvokeSpecInterceptorInterceptor.class);
+
+ public String getName()
+ {
+ return "InvokeSpecInterceptorInterceptor";
+ }
+
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ log.debug("invoke");
+ return invocation.invokeNext();
+ }
+
+}
Property changes on: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/InvokeSpecInterceptorInterceptor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/LifecycleCallbackBeanMethodInterceptor.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/LifecycleCallbackBeanMethodInterceptor.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/LifecycleCallbackBeanMethodInterceptor.java 2007-12-21 09:36:21 UTC (rev 68486)
@@ -0,0 +1,78 @@
+/*
+ * 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.ejb3.interceptors.aop;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+
+/**
+ * Chapter 12.4
+ *
+ * Lifecycle callback interceptor methods defined on a bean class have the following signature:
+ * void <METHOD>()
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class LifecycleCallbackBeanMethodInterceptor implements Interceptor
+{
+ private Object interceptor;
+ private Method method;
+
+ /**
+ *
+ * @param interceptor an spec interceptor
+ * @param lifecycleCallbackMethod a lifecycle callback on the spec interceptor
+ */
+ public LifecycleCallbackBeanMethodInterceptor(Object interceptor, Method lifecycleCallbackMethod)
+ {
+ assert interceptor != null : "interceptor is null";
+ assert lifecycleCallbackMethod != null : "lifecycleCallbackMethod is null";
+ assert lifecycleCallbackMethod.getReturnType() == Void.TYPE : "return type must be void";
+ assert lifecycleCallbackMethod.getParameterTypes().length == 0 : "wrong parameter signature";
+
+ this.interceptor = interceptor;
+ this.method = lifecycleCallbackMethod;
+ }
+
+ public String getName()
+ {
+ return "LifecycleCallbackBeanMethodInterceptor";
+ }
+
+ public Object invoke(final Invocation invocation) throws Throwable
+ {
+ try
+ {
+ method.invoke(interceptor);
+ // TODO: return null or invokeTarget?
+ return invocation.invokeNext();
+ }
+ catch(InvocationTargetException e)
+ {
+ throw e.getCause();
+ }
+ }
+}
Property changes on: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/LifecycleCallbackBeanMethodInterceptor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/LifecycleCallbackInterceptorMethodInterceptor.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/LifecycleCallbackInterceptorMethodInterceptor.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/LifecycleCallbackInterceptorMethodInterceptor.java 2007-12-21 09:36:21 UTC (rev 68486)
@@ -0,0 +1,85 @@
+/*
+ * 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.ejb3.interceptors.aop;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+
+import javax.interceptor.InvocationContext;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+
+/**
+ * Chapter 12.4
+ *
+ * Lifecycle callback interceptor methods defined on an interceptor class have the following signature:
+ * void <METHOD> (InvocationContext)
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class LifecycleCallbackInterceptorMethodInterceptor implements Interceptor
+{
+ private static final Class<?> PARAMETER_TYPES[] = { InvocationContext.class };
+
+ private Object interceptor;
+ private Method method;
+
+ /**
+ *
+ * @param interceptor an spec interceptor
+ * @param lifecycleCallbackMethod a lifecycle callback on the spec interceptor
+ */
+ public LifecycleCallbackInterceptorMethodInterceptor(Object interceptor, Method lifecycleCallbackMethod)
+ {
+ assert interceptor != null : "interceptor is null";
+ assert lifecycleCallbackMethod != null : "lifecycleCallbackMethod is null";
+ assert lifecycleCallbackMethod.getReturnType() == Void.TYPE : "return type must be void " + lifecycleCallbackMethod;
+ assert Arrays.equals(lifecycleCallbackMethod.getParameterTypes(), PARAMETER_TYPES) : "wrong parameter signature";
+
+ this.interceptor = interceptor;
+ this.method = lifecycleCallbackMethod;
+ }
+
+ public String getName()
+ {
+ return "InvokeCallbackInterceptorMethodInterceptor";
+ }
+
+ public Object invoke(final Invocation invocation) throws Throwable
+ {
+ InvocationContext ctx = InvocationContextInterceptor.getInvocationContext(invocation);
+ try
+ {
+ Object args[] = { ctx };
+ method.invoke(interceptor, args);
+ // TODO: return null or invokeTarget?
+ return invocation.invokeNext();
+ }
+ catch(InvocationTargetException e)
+ {
+ throw e.getCause();
+ }
+ }
+}
Property changes on: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/LifecycleCallbackInterceptorMethodInterceptor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/PostConstructInterceptor.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/PostConstructInterceptor.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/PostConstructInterceptor.java 2007-12-21 09:36:21 UTC (rev 68486)
@@ -0,0 +1,51 @@
+/*
+ * 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.ejb3.interceptors.aop;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.logging.Logger;
+
+/**
+ * Invoke post constructs
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class PostConstructInterceptor implements Interceptor
+{
+ private static final Logger log = Logger.getLogger(PostConstructInterceptor.class);
+
+ public String getName()
+ {
+ return "PostConstructInterceptor";
+ }
+
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ log.debug("invoke " + invocation);
+ log.debug(" " + invocation.getAdvisor());
+ log.debug(" " + invocation.getTargetObject());
+ return invocation.invokeNext();
+ }
+
+}
Property changes on: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/PostConstructInterceptor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/lang/BootstrapClassLoader.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/lang/BootstrapClassLoader.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/lang/BootstrapClassLoader.java 2007-12-21 09:36:21 UTC (rev 68486)
@@ -0,0 +1,38 @@
+/*
+ * 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.ejb3.interceptors.lang;
+
+
+/**
+ * Only loads classes from the JDK bootstrap.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class BootstrapClassLoader extends ClassLoader
+{
+ public BootstrapClassLoader()
+ {
+ //super(new URL[0], null);
+ super(null);
+ }
+}
Property changes on: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/lang/BootstrapClassLoader.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/lang/ClassHelper.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/lang/ClassHelper.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/lang/ClassHelper.java 2007-12-21 09:36:21 UTC (rev 68486)
@@ -0,0 +1,68 @@
+/*
+ * 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.ejb3.interceptors.lang;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Methods which should have been in Class.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class ClassHelper
+{
+ /**
+ * Returns all public, private and package protected methods including
+ * inherited ones.
+ *
+ * (Slow method)
+ *
+ * @param cls
+ * @return
+ */
+ public static Method[] getAllMethods(Class<?> cls)
+ {
+ ArrayList<Method> list = new ArrayList<Method>();
+ populateAllMethods(cls, list);
+ return list.toArray(new Method[0]);
+ }
+
+ /**
+ * Find all methods starting with the most general super class.
+ * (See 12.4.1 bullet 4)
+ *
+ * This makes the class unusable for other scenarios.
+ *
+ * @param cls
+ * @param methods
+ */
+ private static void populateAllMethods(Class<?> cls, List<Method> methods)
+ {
+ if(cls == null) return;
+ populateAllMethods(cls.getSuperclass(), methods);
+ for(Method method : cls.getDeclaredMethods())
+ methods.add(method);
+ }
+}
Property changes on: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/lang/ClassHelper.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/lang/ScopedClassLoader.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/lang/ScopedClassLoader.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/lang/ScopedClassLoader.java 2007-12-21 09:36:21 UTC (rev 68486)
@@ -0,0 +1,61 @@
+/*
+ * 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.ejb3.interceptors.lang;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+
+/**
+ * Only load classes and resources from the given urls.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class ScopedClassLoader extends URLClassLoader
+{
+ public ScopedClassLoader(URL[] urls)
+ {
+ super(urls, null);
+ }
+
+ protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
+ {
+ // First, check if the class has already been loaded
+ Class<?> c = findLoadedClass(name);
+ if (c == null)
+ {
+ try
+ {
+ c = findClass(name);
+ }
+ catch(ClassNotFoundException e)
+ {
+ return super.loadClass(name, resolve);
+ }
+ }
+ if (resolve)
+ {
+ resolveClass(c);
+ }
+ return c;
+ }
+}
Property changes on: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/lang/ScopedClassLoader.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/BasicBean.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/BasicBean.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/BasicBean.java 2007-12-21 09:36:21 UTC (rev 68486)
@@ -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.ejb3.test.interceptors.basic;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptors;
+import javax.interceptor.InvocationContext;
+
+import org.jboss.logging.Logger;
+
+/**
+ * The basic bean has one class interceptor: BasicInterceptor
+ *
+ * On the intercepter method there is a business method interceptor: BasicMethodInterceptor
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Interceptors(BasicInterceptor.class)
+public class BasicBean
+{
+ private static final Logger log = Logger.getLogger(BasicBean.class);
+
+ public static int constructors = 0, aroundInvokes = 0;
+
+ public BasicBean()
+ {
+ log.debug("BasicBean");
+ constructors++;
+ }
+
+ @AroundInvoke
+ Object aroundInvoke(InvocationContext ctx) throws Exception
+ {
+ log.debug("aroundInvoke " + ctx);
+ aroundInvokes++;
+ return ctx.proceed();
+ }
+
+ public String sayHi(String name)
+ {
+ log.debug("sayHi");
+ return "Hi " + name;
+ }
+
+ @Interceptors(BasicMethodInterceptor.class)
+ public void intercept()
+ {
+ log.debug("intercept");
+ }
+}
Property changes on: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/BasicBean.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/BasicInterceptor.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/BasicInterceptor.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/BasicInterceptor.java 2007-12-21 09:36:21 UTC (rev 68486)
@@ -0,0 +1,67 @@
+/*
+ * 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.ejb3.test.interceptors.basic;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+import org.jboss.logging.Logger;
+
+/**
+ * A basic interceptor, does nothing useful.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class BasicInterceptor
+{
+ private static final Logger log = Logger.getLogger(BasicInterceptor.class);
+
+ public static int preDestroys = 0, postConstructs = 0, aroundInvokes = 0;
+
+ @PreDestroy
+ public void preDestroy(InvocationContext ctx) throws Exception
+ {
+ log.debug("preDestroy " + ctx);
+ preDestroys++;
+ ctx.proceed();
+ }
+
+ @PostConstruct
+ public void postConstruct(InvocationContext ctx) throws Exception
+ {
+ log.debug("postConstruct " + ctx);
+ try { ctx.getMethod(); throw new Exception("should not come here"); } catch(IllegalStateException e) { }
+ postConstructs++;
+ ctx.proceed();
+ }
+
+ @AroundInvoke
+ public Object aroundInvoke(InvocationContext ctx) throws Exception
+ {
+ log.debug("aroundInvoke " + ctx);
+ aroundInvokes++;
+ return ctx.proceed();
+ }
+}
Property changes on: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/BasicInterceptor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/BasicMethodInterceptor.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/BasicMethodInterceptor.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/BasicMethodInterceptor.java 2007-12-21 09:36:21 UTC (rev 68486)
@@ -0,0 +1,56 @@
+/*
+ * 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.ejb3.test.interceptors.basic;
+
+import javax.annotation.PostConstruct;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+import org.jboss.logging.Logger;
+
+/**
+ * To be put on a method.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class BasicMethodInterceptor
+{
+ private static final Logger log = Logger.getLogger(BasicMethodInterceptor.class);
+
+ public static int postConstructs = 0, aroundInvokes = 0;
+
+ @PostConstruct
+ public void postConstruct(InvocationContext ctx) throws Exception
+ {
+ log.info("postConstruct");
+ postConstructs++;
+ }
+
+ @AroundInvoke
+ public Object aroundInvoke(InvocationContext ctx) throws Exception
+ {
+ log.info("aroundInvoke");
+ aroundInvokes++;
+ return ctx.proceed();
+ }
+}
Property changes on: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/BasicMethodInterceptor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/unit/BasicInterceptorTestCase.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/unit/BasicInterceptorTestCase.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/unit/BasicInterceptorTestCase.java 2007-12-21 09:36:21 UTC (rev 68486)
@@ -0,0 +1,180 @@
+/*
+ * 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.ejb3.test.interceptors.basic.unit;
+
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.AspectXmlLoader;
+import org.jboss.aop.Domain;
+import org.jboss.aop.DomainDefinition;
+import org.jboss.aop.classpool.AOPClassLoaderScopingPolicy;
+import org.jboss.ejb3.interceptors.aop.DomainClassLoader;
+import org.jboss.ejb3.interceptors.lang.ScopedClassLoader;
+import org.jboss.logging.Logger;
+
+/**
+ * TODO: this is no longer true<br/>
+ * Run with: -Djava.system.class.loader=org.jboss.aop.standalone.SystemClassLoader
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class BasicInterceptorTestCase extends TestCase
+{
+ private static final Logger log = Logger.getLogger(BasicInterceptorTestCase.class);
+
+ public void _test1() throws Exception
+ {
+ System.setProperty("java.io.tmpdir", "/tmp/aop");
+
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+
+// AspectManager.verbose = true;
+
+ // Bootstrap AOP
+ URL url = Thread.currentThread().getContextClassLoader().getResource("basic/jboss-aop.xml");
+ System.out.println(url);
+ AspectXmlLoader.deployXML(url);
+
+ // Bootstrap the basic container
+ String containerName = "BasicContainer";
+
+ DomainDefinition domain = AspectManager.instance().getContainer(containerName);
+ if(domain == null)
+ throw new IllegalArgumentException("Domain definition for container '" + containerName + "' can not be found");
+
+ AspectManager manager = domain.getManager();
+
+// ClassContainer container = new ClassContainer("BasicBean", BasicBean.class, manager);
+
+ //container.setClass(classLoader.loadClass("org.jboss.ejb3.test.interceptors.basic.BasicBean"));
+ //container.setClass(BasicBean.class);
+
+ //container.initializeClassContainer();
+ //container.rebuildInterceptors();
+
+// Object obj = classLoader.loadClass("org.jboss.ejb3.test.interceptors.basic.BasicBean").newInstance();
+
+ log.info("pointCuts = " + domain.getManager().getPointcuts());
+
+// obj = container.getConstructors()[0].newInstance();
+
+// BasicBean bean;
+// {
+// bean = (BasicBean) container.getConstructors()[0].newInstance();
+// String result = bean.sayHi("Test");
+// }
+
+// {
+// BasicBean bean = (BasicBean) container.construct();
+// String result = bean.sayHi("Test 2");
+// }
+ }
+
+ public void _test2() throws Throwable
+ {
+ //System.setProperty("java.io.tmpdir", "/tmp/aop");
+ //System.setProperty("jboss.aop.optimized", "false"); // no effect
+
+// AspectManager.verbose = true;
+ //AspectManager.debugClasses = true;
+ //AspectManager.classicOrder = true;
+
+ // A trick to get a nice 'deployment' class loader
+ // eclipse
+// URLClassLoader ucl = (URLClassLoader) ClassLoader.getSystemClassLoader();
+// URL deploymentURL = ucl.getURLs()[0];
+ // both eclipse & maven
+ URL deploymentURL = getClass().getClassLoader().getResource(".");
+ System.out.println(deploymentURL);
+ ScopedClassLoader deploymentClassLoader = new ScopedClassLoader(new URL[] { deploymentURL });
+
+ // Bootstrap AOP
+ URL url = Thread.currentThread().getContextClassLoader().getResource("basic/jboss-aop.xml");
+ log.info("deploying AOP from " + url);
+ AspectXmlLoader.deployXML(url);
+
+ // Bootstrap the basic container
+ String containerName = "InterceptorContainer";
+
+ DomainDefinition domainDefinition = AspectManager.instance().getContainer(containerName);
+ if(domainDefinition == null)
+ throw new IllegalArgumentException("Domain definition for container '" + containerName + "' can not be found");
+
+ final Domain domain = (Domain) domainDefinition.getManager();
+
+ ClassLoader classLoader = new DomainClassLoader(Thread.currentThread().getContextClassLoader(), deploymentClassLoader, domain);
+ Thread.currentThread().setContextClassLoader(classLoader);
+
+ // The moment an instrumented class comes up it does AspectManager.instance(classLoader), which
+ // should return the classLoader created above. So we tie in a class loader scoping policy.
+ // Note that this won't work in AS.
+ AOPClassLoaderScopingPolicy classLoaderScopingPolicy = new AOPClassLoaderScopingPolicy() {
+ public Domain getDomain(ClassLoader classLoader, AspectManager parent)
+ {
+ //log.debug("getDomain");
+ if(classLoader instanceof DomainClassLoader)
+ return ((DomainClassLoader) classLoader).getDomain();
+ return null;
+ }
+
+ public Domain getTopLevelDomain(AspectManager parent)
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public boolean isScoped(ClassLoader classLoader)
+ {
+ throw new RuntimeException("NYI");
+ }
+ };
+ AspectManager.setClassLoaderScopingPolicy(classLoaderScopingPolicy);
+
+ Class<?> testRunnerClass = classLoader.loadClass("org.jboss.ejb3.test.interceptors.basic.BasicTestRunner");
+ Object testRunner = testRunnerClass.newInstance();
+
+ try
+ {
+ testRunnerClass.getMethod("test2").invoke(testRunner);
+ }
+ catch(InvocationTargetException e)
+ {
+ throw e.getCause();
+ }
+
+// Class<?> beanClass = classLoader.loadClass("org.jboss.ejb3.test.interceptors.basic.BasicBean");
+// Object obj = beanClass.newInstance();
+// System.out.println(obj.getClass() + " " + obj.getClass().getClassLoader());
+// System.out.println(" " + Arrays.toString(obj.getClass().getInterfaces()));
+// Method method = obj.getClass().getMethod("sayHi", String.class);
+// String result = (String) method.invoke(obj, "Test");
+// System.out.println(result);
+//
+// obj.getClass().getMethod("intercepted").invoke(obj);
+
+// System.out.println(AdvisorFactory.getClassAdvisor(obj.getClass(), domain));
+ }
+}
Property changes on: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/unit/BasicInterceptorTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/unit/BasicTestRunner.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/unit/BasicTestRunner.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/unit/BasicTestRunner.java 2007-12-21 09:36:21 UTC (rev 68486)
@@ -0,0 +1,69 @@
+/*
+ * 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.ejb3.test.interceptors.basic.unit;
+
+import java.util.Arrays;
+
+import org.jboss.ejb3.test.interceptors.basic.BasicBean;
+import org.jboss.ejb3.test.interceptors.basic.BasicInterceptor;
+import org.jboss.ejb3.test.interceptors.basic.BasicMethodInterceptor;
+
+import junit.framework.TestCase;
+
+/**
+ * This one runs within the class loader scope.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class BasicTestRunner extends TestCase
+{
+ public void test2() throws Exception
+ {
+ assertEquals(0, BasicInterceptor.postConstructs);
+
+ BasicBean bean = new BasicBean();
+
+ assertEquals("BasicInterceptor postConstruct must have been called once", 1, BasicInterceptor.postConstructs);
+
+ System.out.println(bean.getClass() + " " + bean.getClass().getClassLoader());
+ System.out.println(" " + Arrays.toString(bean.getClass().getInterfaces()));
+ String result = bean.sayHi("Test");
+ System.out.println(result);
+
+ assertEquals("sayHi didn't invoke BasicInterceptor.aroundInvoke once", 1, BasicInterceptor.aroundInvokes);
+// assertEquals("sayHi didn't invoke BasicBean.aroundInvoke once", 1, BasicBean.aroundInvokes);
+
+ bean.intercept();
+ assertEquals("intercept didn't invoke BasicMethodInterceptor.aroundInvoke", 1, BasicMethodInterceptor.aroundInvokes);
+ bean.intercept();
+ assertEquals("intercept didn't invoke BasicMethodInterceptor.aroundInvoke", 2, BasicMethodInterceptor.aroundInvokes);
+
+ assertEquals("intercept didn't invoke BasicInterceptor.aroundInvoke", 3, BasicInterceptor.aroundInvokes);
+ assertEquals("BasicInterceptor postConstruct must have been called once", 1, BasicInterceptor.postConstructs);
+ // 12.7 footnote 57
+ assertEquals("BasicMethodInterceptor.postConstruct must not have been called", 0, BasicMethodInterceptor.postConstructs);
+
+ //((Destructable) bean)._preDestroy();
+ bean = null;
+ }
+}
Property changes on: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/unit/BasicTestRunner.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/unit/BasicTestSuite.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/unit/BasicTestSuite.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/unit/BasicTestSuite.java 2007-12-21 09:36:21 UTC (rev 68486)
@@ -0,0 +1,130 @@
+/*
+ * 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.ejb3.test.interceptors.basic.unit;
+
+import java.net.URL;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.AspectXmlLoader;
+import org.jboss.aop.Domain;
+import org.jboss.aop.DomainDefinition;
+import org.jboss.aop.classpool.AOPClassLoaderScopingPolicy;
+import org.jboss.ejb3.interceptors.aop.DomainClassLoader;
+import org.jboss.ejb3.interceptors.lang.ScopedClassLoader;
+import org.jboss.logging.Logger;
+
+/**
+ * Bootstrap the interceptor container.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class BasicTestSuite extends TestSuite
+{
+ private static final Logger log = Logger.getLogger(BasicTestSuite.class);
+
+ private ClassLoader classLoader;
+
+ public BasicTestSuite() throws Exception
+ {
+ // Neat trick to find the deployment URL
+ URL deploymentURL = getClass().getClassLoader().getResource(".");
+ log.info(deploymentURL);
+ ScopedClassLoader deploymentClassLoader = new ScopedClassLoader(new URL[] { deploymentURL });
+
+ // Bootstrap AOP
+ URL url = Thread.currentThread().getContextClassLoader().getResource("basic/jboss-aop.xml");
+ log.info("deploying AOP from " + url);
+ AspectXmlLoader.deployXML(url);
+
+ // Bootstrap the basic container
+ String containerName = "InterceptorContainer";
+
+ DomainDefinition domainDefinition = AspectManager.instance().getContainer(containerName);
+ if(domainDefinition == null)
+ throw new IllegalArgumentException("Domain definition for container '" + containerName + "' can not be found");
+
+ final Domain domain = (Domain) domainDefinition.getManager();
+
+ this.classLoader = new DomainClassLoader(Thread.currentThread().getContextClassLoader(), deploymentClassLoader, domain);
+ Thread.currentThread().setContextClassLoader(classLoader);
+
+ // The moment an instrumented class comes up it does AspectManager.instance(classLoader), which
+ // should return the classLoader created above. So we tie in a class loader scoping policy.
+ // Note that this won't work in AS.
+ AOPClassLoaderScopingPolicy classLoaderScopingPolicy = new AOPClassLoaderScopingPolicy() {
+ public Domain getDomain(ClassLoader classLoader, AspectManager parent)
+ {
+ //log.debug("getDomain");
+ if(classLoader instanceof DomainClassLoader)
+ return ((DomainClassLoader) classLoader).getDomain();
+ return null;
+ }
+
+ public Domain getTopLevelDomain(AspectManager parent)
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public boolean isScoped(ClassLoader classLoader)
+ {
+ throw new RuntimeException("NYI");
+ }
+ };
+ AspectManager.setClassLoaderScopingPolicy(classLoaderScopingPolicy);
+
+ // We're done
+ }
+
+ public static Test suite() throws Exception
+ {
+ BasicTestSuite suite = new BasicTestSuite();
+ suite.addTestSuite(BasicTestRunner.class);
+ return suite;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public void addTestSuite(Class testClass)
+ {
+ // trick or treat
+ try
+ {
+ super.addTestSuite(classLoader.loadClass(testClass.getName()));
+ }
+ catch(final ClassNotFoundException e)
+ {
+ Test test = new TestCase("error") {
+ @Override
+ protected void runTest() throws Throwable
+ {
+ fail("Failed to load class" + e.getMessage());
+ }
+ };
+ super.addTest(test);
+ }
+ }
+}
Property changes on: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/unit/BasicTestSuite.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/common/aop/LoggingInterceptor.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/common/aop/LoggingInterceptor.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/common/aop/LoggingInterceptor.java 2007-12-21 09:36:21 UTC (rev 68486)
@@ -0,0 +1,52 @@
+/*
+ * 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.ejb3.test.interceptors.common.aop;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.logging.Logger;
+
+/**
+ * Log as much as we can about the invocation, then proceed.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class LoggingInterceptor implements Interceptor
+{
+ private static final Logger log = Logger.getLogger(LoggingInterceptor.class);
+
+ public String getName()
+ {
+ return "LoggingInterceptor";
+ }
+
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ log.info("invoke " + invocation);
+ log.info(" advisor " + invocation.getAdvisor().getName());
+ log.info(" target object " + invocation.getTargetObject());
+ //log.info(" " + invocation.getResponseContextInfo());
+ return invocation.invokeNext();
+ }
+
+}
Property changes on: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/common/aop/LoggingInterceptor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/interceptors/src/test/resources/basic/jboss-aop.xml
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/resources/basic/jboss-aop.xml (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/resources/basic/jboss-aop.xml 2007-12-21 09:36:21 UTC (rev 68486)
@@ -0,0 +1,112 @@
+<aop>
+ <aspect name="AroundInvokeInterceptor" class="org.jboss.ejb3.interceptors.aop.AroundInvokeInterceptor" scope="PER_INSTANCE"/>
+ <aspect name="InterceptorsFactory" factory="org.jboss.ejb3.interceptors.aop.InterceptorsFactory" scope="PER_INSTANCE"/>
+ <aspect name="InterceptorsInterceptor" class="org.jboss.ejb3.interceptors.aop.InterceptorsInterceptor" scope="PER_INSTANCE"/>
+ <aspect name="InvocationContextInterceptor" class="org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor" scope="PER_VM"/>
+ <aspect name="PostConstructInterceptor" class="org.jboss.ejb3.interceptors.aop.PostConstructInterceptor" scope="PER_INSTANCE"/>
+
+ <interceptor name="BootstrapInterceptor" class="org.jboss.ejb3.interceptors.aop.BootstrapInterceptor" scope="PER_VM"/>
+ <interceptor name="LoggingInterceptor" class="org.jboss.ejb3.test.interceptors.common.aop.LoggingInterceptor" scope="PER_VM"/>
+
+ <!-- Not needed we can do this in the domain itself
+ <bind pointcut="construction(org.jboss.ejb3.interceptors.aop.ClassContainer->new(..))">
+ <interceptor-ref name="BootstrapInterceptor"/>
+ </bind>
+ -->
+
+ <!-- This one works
+ <bind pointcut="construction(org.jboss.ejb3.test.*->new(..))">
+ <interceptor-ref name="BootstrapInterceptor"/>
+ </bind>
+
+ <bind pointcut="execution(org.jboss.ejb3.test.*->new(..))">
+ <interceptor-ref name="BootstrapInterceptor"/>
+ </bind>
+
+ <bind pointcut="execution(* org.jboss.ejb3.test.*->*(..))">
+ <interceptor-ref name="BootstrapInterceptor"/>
+ </bind>
+ -->
+
+ <!-- TODO: this is actually the bootstrap container -->
+ <domain name="InterceptorContainer">
+ <prepare expr="all(*)"/>
+
+ <!-- Why does this not work? -->
+ <!--
+ <bind pointcut="execution(@javax.interceptor.Interceptors->new(..))">
+ <interceptor-ref name="LoggingInterceptor"/>
+ <interceptor-ref name="BootstrapInterceptor"/>
+ </bind>
+ -->
+
+ <!-- Make sure we can _preDestroy -->
+ <introduction expr="constructor(@javax.interceptor.Interceptors->new(..)) OR has(* *->@javax.interceptor.Interceptors(..))">
+ <interfaces>org.jboss.ejb3.interceptors.aop.Destructable</interfaces>
+ </introduction>
+
+ <!-- This one does work -->
+ <!-- Setup AOP interceptors based on spec interceptors -->
+ <bind pointcut="construction(@javax.interceptor.Interceptors->new(..)) OR has(* *->@javax.interceptor.Interceptors(..))">
+ <interceptor-ref name="LoggingInterceptor"/>
+ <around name="setup" aspect="InvocationContextInterceptor"/>
+ <!--
+ <interceptor-ref name="InterceptorsFactory"/>
+ -->
+ <around name="invoke" aspect="InterceptorsFactory"/>
+ <!--
+ <after name="invoke" aspect="PostConstructInterceptor"/>
+ -->
+ </bind>
+
+ <!-- TODO: Junk
+ <bind pointcut="execution(* *->@javax.interceptor.Interceptors(..))">
+ <interceptor-ref name="LoggingInterceptor"/>
+ <around name="setup" aspect="InvocationContextInterceptor"/>
+ <around name="invoke" aspect="AroundInvokeInterceptor"/>
+ </bind>
+ -->
+
+ <!-- Make sure we an invocation context -->
+ <!--
+ <bind pointcut="execution(* *->@javax.interceptor.Interceptors(..))">
+ <around name="setup" aspect="InvocationContextInterceptor"/>
+ <around name="fillMethod" aspect="InvocationContextInterceptor"/>
+ </bind>
+ -->
+
+ <bind pointcut="execution(* *->*(..)) AND (has(* *->@javax.interceptor.Interceptors(..)) OR has(@javax.interceptor.Interceptors->new(..)))">
+ <around name="setup" aspect="InvocationContextInterceptor"/>
+ <around name="fillMethod" aspect="InvocationContextInterceptor"/>
+ </bind>
+
+ <!-- The bootstrap interceptor container doesn't do default interceptors
+ <bind pointcut="!execution(* *->@javax.interceptor.ExcludeDefaultInterceptors(..)) AND !execution(* @javax.interceptor.ExcludeDefaultInterceptors(..))">
+ <around name="invokeDefaultInterceptors" aspect="InterceptorsInterceptor"/>
+ </bind>
+ -->
+
+ <bind pointcut="!execution(* *->@javax.interceptor.ExcludeClassInterceptors(..))">
+ <around name="invokeClassInterceptors" aspect="InterceptorsInterceptor"/>
+ </bind>
+
+ <bind pointcut="execution(* *->*(..)) AND has(* *->@javax.interceptor.Interceptors(..))">
+ <around name="invokeBusinessMethodInterceptors" aspect="InterceptorsInterceptor"/>
+ </bind>
+
+ <!-- TODO: Junk: Log everything
+ <bind pointcut="execution(* *->*(..)) AND !execution(* org.jboss.ejb3.test.interceptors.common.aop.LoggingInterceptor->*(..))">
+ <interceptor-ref name="LoggingInterceptor"/>
+ </bind>
+ <bind pointcut="call(*->new(..)) AND !withincode(* org.jboss.ejb3.test.interceptors.common.aop.LoggingInterceptor->*(..))">
+ <interceptor-ref name="LoggingInterceptor"/>
+ </bind>
+ -->
+
+ <!-- TODO: Junk
+ <bind pointcut="construction(*->@javax.interceptor.PostConstruct(javax.interceptor.InvocationContext))">
+ <interceptor-ref name="LoggingInterceptor"/>
+ </bind>
+ -->
+ </domain>
+</aop>
\ No newline at end of file
Property changes on: projects/ejb3/trunk/interceptors/src/test/resources/basic/jboss-aop.xml
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/interceptors/src/test/resources/log4j.xml
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/resources/log4j.xml (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/resources/log4j.xml 2007-12-21 09:36:21 UTC (rev 68486)
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Log4j Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id$ -->
+
+<!--
+ | For more configuration infromation and examples see the Jakarta Log4j
+ | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <!-- ================================= -->
+ <!-- Preserve messages in a local file -->
+ <!-- ================================= -->
+
+ <!-- A time/date based rolling appender -->
+ <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
+ <param name="File" value="target/test.log"/>
+ <param name="Threshold" value="INFO"/>
+ <param name="Append" value="false"/>
+
+ <!-- Rollover at midnight each day -->
+ <param name="DatePattern" value="'.'yyyy-MM-dd"/>
+
+ <!-- Rollover at the top of each hour
+ <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
+ -->
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+
+ <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
+ <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
+ -->
+ </layout>
+ </appender>
+
+ <!-- A size based file rolling appender
+ <appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender">
+ <param name="File" value="${jboss.server.home.dir}/log/server.log"/>
+ <param name="Append" value="false"/>
+ <param name="MaxFileSize" value="500KB"/>
+ <param name="MaxBackupIndex" value="1"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- ============================== -->
+ <!-- Append messages to the console -->
+ <!-- ============================== -->
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+
+ <!-- ================ -->
+ <!-- Limit categories -->
+ <!-- ================ -->
+
+ <!-- Limit JBoss categories to INFO
+ <category name="org.jboss">
+ <priority value="INFO" class="org.jboss.logging.XLevel"/>
+ </category>
+ -->
+
+ <!-- Increase the priority threshold for the DefaultDS category
+ <category name="DefaultDS">
+ <priority value="FATAL"/>
+ </category>
+ -->
+
+ <!-- Decrease the priority threshold for the org.jboss.varia category
+ <category name="org.jboss.varia">
+ <priority value="DEBUG"/>
+ </category>
+ -->
+
+ <!--
+ | An example of enabling the custom TRACE level priority that is used
+ | by the JBoss internals to diagnose low level details. This example
+ | turns on TRACE level msgs for the org.jboss.ejb.plugins package and its
+ | subpackages. This will produce A LOT of logging output.
+ <category name="org.jboss.system">
+ <priority value="TRACE" class="org.jboss.logging.XLevel"/>
+ </category>
+ -->
+
+ <category name="org.jboss.aop">
+ <priority value="ALL"/>
+ </category>
+
+ <category name="org.jboss">
+ <priority value="ALL"/>
+ </category>
+
+ <category name="org.jboss.ejb3.interceptors.aop.DomainClassLoader">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="FILE"/>
+ </root>
+
+</log4j:configuration>
Property changes on: projects/ejb3/trunk/interceptors/src/test/resources/log4j.xml
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
More information about the jboss-cvs-commits
mailing list