[jboss-cvs] JBossAS SVN: r70730 - in projects/ejb3/trunk/interceptors/src: test/java/org/jboss/ejb3/test/interceptors and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Mar 11 04:38:31 EDT 2008
Author: wolfc
Date: 2008-03-11 04:38:31 -0400 (Tue, 11 Mar 2008)
New Revision: 70730
Added:
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/supermethod/
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/supermethod/AroundInvokeBase.java
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/supermethod/AroundInvokeBean.java
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/supermethod/AroundInvokeIF.java
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/supermethod/SessionSynchronizationInterceptor.java
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/supermethod/unit/
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/supermethod/unit/SuperMethodTestCase.java
projects/ejb3/trunk/interceptors/src/test/resources/supermethod/
projects/ejb3/trunk/interceptors/src/test/resources/supermethod/jboss-aop.xml
Modified:
projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/container/ManagedObjectAdvisor.java
Log:
EJBTHREE-1214: chainOverridingForInheritedMethods returns true
Modified: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/container/ManagedObjectAdvisor.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/container/ManagedObjectAdvisor.java 2008-03-11 08:27:30 UTC (rev 70729)
+++ projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/container/ManagedObjectAdvisor.java 2008-03-11 08:38:31 UTC (rev 70730)
@@ -95,7 +95,19 @@
annotations.addClassAnnotation(ManagedObject.class, annotation);
}
+ /*
+ * To match point cut expressions on super methods which apply only
+ * to the sub class, this value must be set to true.
+ *
+ * @see org.jboss.aop.Advisor#chainOverridingForInheritedMethods()
+ */
@Override
+ public boolean chainOverridingForInheritedMethods()
+ {
+ return true;
+ }
+
+ @Override
protected void createInterceptorChain(InterceptorFactory[] factories, ArrayList newinterceptors, Joinpoint joinpoint)
{
// This is an ugly hack to make sure we have got an PER_JOINPOINT_INSTANCE interceptor.
Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/supermethod/AroundInvokeBase.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/supermethod/AroundInvokeBase.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/supermethod/AroundInvokeBase.java 2008-03-11 08:38:31 UTC (rev 70730)
@@ -0,0 +1,40 @@
+/*
+ * 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.supermethod;
+
+import org.jboss.logging.Logger;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class AroundInvokeBase implements AroundInvokeIF
+{
+ private static final Logger log = Logger.getLogger(AroundInvokeBase.class);
+
+ public void afterBeginTest()
+ {
+
+ }
+}
Property changes on: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/supermethod/AroundInvokeBase.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/supermethod/AroundInvokeBean.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/supermethod/AroundInvokeBean.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/supermethod/AroundInvokeBean.java 2008-03-11 08:38:31 UTC (rev 70730)
@@ -0,0 +1,73 @@
+/*
+ * 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.supermethod;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.EJBException;
+import javax.ejb.SessionSynchronization;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+import org.jboss.ejb3.interceptors.ManagedObject;
+import org.jboss.logging.Logger;
+
+/**
+ * The real implementation of the methods is on the super class.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at ManagedObject
+//@Stateful(name="AroundInvokeBean")
+//@Remote({AroundInvokeIF.class})
+public class AroundInvokeBean extends AroundInvokeBase implements AroundInvokeIF, SessionSynchronization
+{
+ private static final Logger log = Logger.getLogger(AroundInvokeBean.class);
+
+ private boolean afterBeginCalled;
+ private boolean afterCompletionCalled;
+ private boolean beforeCompletionCalled;
+
+ public void afterBegin() throws EJBException, RemoteException
+ {
+ afterBeginCalled = true;
+ }
+
+ public void afterCompletion(boolean committed) throws EJBException, RemoteException
+ {
+ afterCompletionCalled = true;
+ }
+
+ public void beforeCompletion() throws EJBException, RemoteException
+ {
+ beforeCompletionCalled = true;
+ }
+
+ @AroundInvoke
+ public Object interceptor(InvocationContext ctx) throws Exception
+ {
+ if(!afterBeginCalled)
+ throw new IllegalStateException("afterBegin should have been called");
+ return ctx.proceed();
+ }
+}
Property changes on: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/supermethod/AroundInvokeBean.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/supermethod/AroundInvokeIF.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/supermethod/AroundInvokeIF.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/supermethod/AroundInvokeIF.java 2008-03-11 08:38:31 UTC (rev 70730)
@@ -0,0 +1,34 @@
+/*
+ * 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.supermethod;
+
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface AroundInvokeIF
+{
+ void afterBeginTest();
+}
Property changes on: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/supermethod/AroundInvokeIF.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/supermethod/SessionSynchronizationInterceptor.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/supermethod/SessionSynchronizationInterceptor.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/supermethod/SessionSynchronizationInterceptor.java 2008-03-11 08:38:31 UTC (rev 70730)
@@ -0,0 +1,58 @@
+/*
+ * 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.supermethod;
+
+import javax.ejb.SessionSynchronization;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.logging.Logger;
+
+/**
+ * A dummy session synchronization AOP interceptor.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class SessionSynchronizationInterceptor implements Interceptor
+{
+ private static final Logger log = Logger.getLogger(SessionSynchronizationInterceptor.class);
+
+ public String getName()
+ {
+ return SessionSynchronizationInterceptor.class.getName();
+ }
+
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ Object target = invocation.getTargetObject();
+ if(!(target instanceof SessionSynchronization))
+ throw new IllegalArgumentException("target not an instance of SessionSynchronization " + target);
+ SessionSynchronization synch = (SessionSynchronization) invocation.getTargetObject();
+ // fake tx semantics
+ synch.afterBegin();
+ Object result = invocation.invokeNext();
+ synch.beforeCompletion();
+ synch.afterCompletion(true);
+ return result;
+ }
+}
Property changes on: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/supermethod/SessionSynchronizationInterceptor.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/supermethod/unit/SuperMethodTestCase.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/supermethod/unit/SuperMethodTestCase.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/supermethod/unit/SuperMethodTestCase.java 2008-03-11 08:38:31 UTC (rev 70730)
@@ -0,0 +1,62 @@
+/*
+ * 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.supermethod.unit;
+
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.jboss.aop.AspectXmlLoader;
+import org.jboss.ejb3.interceptors.proxy.ProxyContainer;
+import org.jboss.ejb3.test.interceptors.supermethod.AroundInvokeBean;
+import org.jboss.ejb3.test.interceptors.supermethod.AroundInvokeIF;
+import org.jboss.logging.Logger;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class SuperMethodTestCase extends TestCase
+{
+ private static final Logger log = Logger.getLogger(SuperMethodTestCase.class);
+
+ public void test1() throws Throwable
+ {
+ //AspectManager.verbose = true;
+
+ // Bootstrap AOP
+ URL url = Thread.currentThread().getContextClassLoader().getResource("supermethod/jboss-aop.xml");
+ log.info("deploying AOP from " + url);
+ AspectXmlLoader.deployXML(url);
+
+ Thread.currentThread().setContextClassLoader(AroundInvokeIF.class.getClassLoader());
+
+ ProxyContainer<AroundInvokeBean> container = new ProxyContainer<AroundInvokeBean>("SuperMethodTestCase", "InterceptorContainer", AroundInvokeBean.class);
+
+ Class<?> interfaces[] = { AroundInvokeIF.class };
+ AroundInvokeIF proxy = container.constructProxy(interfaces);
+
+ proxy.afterBeginTest();
+ }
+}
Property changes on: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/supermethod/unit/SuperMethodTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: projects/ejb3/trunk/interceptors/src/test/resources/supermethod/jboss-aop.xml
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/resources/supermethod/jboss-aop.xml (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/resources/supermethod/jboss-aop.xml 2008-03-11 08:38:31 UTC (rev 70730)
@@ -0,0 +1,74 @@
+<aop>
+ <aspect name="AroundInvokeInterceptor" class="org.jboss.ejb3.interceptors.aop.AroundInvokeInterceptor" scope="PER_INSTANCE"/>
+ <aspect name="InjectInterceptorsFactory" factory="org.jboss.ejb3.interceptors.aop.InjectInterceptorsFactory" scope="PER_JOINPOINT"/>
+ <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"/>
+
+ <!-- Create AOP interceptors out of spec interceptors -->
+ <aspect name="ClassInterceptors" factory="org.jboss.ejb3.interceptors.aop.InjectInterceptorsFactory" scope="PER_INSTANCE">
+ <attribute name="interceptors" value="class"/>
+ </aspect>
+ <aspect name="DefaultInterceptors" factory="org.jboss.ejb3.interceptors.aop.DefaultInterceptorsFactory" scope="PER_INSTANCE"/>
+
+ <!-- TODO: deprecated -->
+ <interceptor name="BootstrapInterceptor" class="org.jboss.ejb3.interceptors.aop.BootstrapInterceptor" scope="PER_VM"/>
+
+ <!-- test only -->
+ <interceptor name="LoggingInterceptor" class="org.jboss.ejb3.test.interceptors.common.aop.LoggingInterceptor" scope="PER_VM"/>
+
+ <interceptor name="SessionSynchronization" class="org.jboss.ejb3.test.interceptors.supermethod.SessionSynchronizationInterceptor" scope="PER_VM"/>
+
+ <!-- TODO: this is actually the bootstrap container -->
+ <domain name="InterceptorContainer">
+ <pointcut name="beanAroundInvokeCallbackMethods" expr="execution(* @org.jboss.ejb3.interceptors.ManagedObject->@javax.interceptor.AroundInvoke(..))"/>
+ <pointcut name="beanPostConstructCallbackMethods" expr="execution(* @org.jboss.ejb3.interceptors.ManagedObject->@javax.annotation.PostConstruct(..))"/>
+ <pointcut name="beanPreDestroyCallbackMethods" expr="execution(* @org.jboss.ejb3.interceptors.ManagedObject->@javax.annotation.PreDestroy(..))"/>
+
+ <pointcut name="beanLifecycleCallbackMethods" expr="beanAroundInvokeCallbackMethods OR beanPostConstructCallbackMethods OR beanPreDestroyCallbackMethods"/>
+
+ <!-- Prepare for dynamic AOP -->
+ <!-- TODO: optimize, we only need managed objects (and interceptors!) to be aspectized -->
+ <!-- prepare expr="all(*) AND has(@org.jboss.ejb3.interceptors.ManagedObject->new(..))"/ -->
+ <prepare expr="all(*)"/>
+
+ <!-- Make sure we can _preDestroy -->
+ <introduction expr="constructor(@org.jboss.ejb3.interceptors.ManagedObject->new(..))">
+ <interfaces>org.jboss.ejb3.interceptors.aop.Destructable</interfaces>
+ </introduction>
+
+ <!-- This one does work -->
+ <!-- Setup AOP interceptors based on spec interceptors -->
+ <bind pointcut="construction(@org.jboss.ejb3.interceptors.ManagedObject->new(..))">
+ <!-- interceptor-ref name="LoggingInterceptor"/ -->
+ <!-- TODO: we don't need invocation context here -->
+ <!-- TODO: we do until we've seperated the post constructs -->
+ <around name="setup" aspect="InvocationContextInterceptor"/>
+ <around name="invoke" aspect="InterceptorsFactory"/>
+ </bind>
+
+ <!-- Lifecycle Event Callbacks (EJB 3 12.4) -->
+
+ <bind pointcut="construction(@org.jboss.ejb3.interceptors.ManagedObject->new(..))">
+ <interceptor-ref name="LoggingInterceptor"/>
+ <around name="setup" aspect="InvocationContextInterceptor"/>
+ <around name="postConstruct" aspect="InjectInterceptorsFactory"/>
+ </bind>
+
+ <bind pointcut="execution(public * $instanceof{javax.ejb.SessionSynchronization}->*(..))">
+ <interceptor-ref name="SessionSynchronization"/>
+ </bind>
+
+ <bind pointcut="execution(* @org.jboss.ejb3.interceptors.ManagedObject->*(..))">
+ <around name="setup" aspect="InvocationContextInterceptor"/>
+ <around name="fillMethod" aspect="InvocationContextInterceptor"/>
+ </bind>
+
+ <bind pointcut="execution(* @org.jboss.ejb3.interceptors.ManagedObject->*(..)) AND !beanLifecycleCallbackMethods">
+ <around name="setup" aspect="InvocationContextInterceptor"/>
+ <around name="fillMethod" aspect="InvocationContextInterceptor"/>
+ <around name="aroundInvoke" aspect="InjectInterceptorsFactory"/>
+ </bind>
+ </domain>
+</aop>
\ No newline at end of file
Property changes on: projects/ejb3/trunk/interceptors/src/test/resources/supermethod/jboss-aop.xml
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
More information about the jboss-cvs-commits
mailing list