[jboss-cvs] JBossAS SVN: r70766 - in projects/ejb3/trunk/interceptors/src: test/java/org/jboss/ejb3/test/interceptors and 6 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Mar 12 09:23:40 EDT 2008


Author: wolfc
Date: 2008-03-12 09:23:40 -0400 (Wed, 12 Mar 2008)
New Revision: 70766

Added:
   projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/ejbthree1215/
   projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/ejbthree1215/GetMethodInterceptor.java
   projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/ejbthree1215/Hello.java
   projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/ejbthree1215/HelloBean.java
   projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/ejbthree1215/unit/
   projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/ejbthree1215/unit/ContextGetMethodTestCase.java
Modified:
   projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/InvocationContextInterceptor.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/common/CommonInterceptor.java
   projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/direct/DirectInterceptor.java
   projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/proxy/ProxiedInterceptor.java
Log:
EJBTHREE-1215: InvocationContext returns the associated method

Modified: 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	2008-03-12 12:36:54 UTC (rev 70765)
+++ projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/InvocationContextInterceptor.java	2008-03-12 13:23:40 UTC (rev 70766)
@@ -116,8 +116,6 @@
 
       public Method getMethod()
       {
-         if(method == null)
-            throw new IllegalStateException("Get method is not allowed on lifecycle callbacks (EJB 3 12)");
          return method;
       }
 

Modified: 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	2008-03-12 12:36:54 UTC (rev 70765)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/basic/BasicInterceptor.java	2008-03-12 13:23:40 UTC (rev 70766)
@@ -54,7 +54,6 @@
       log.debug("postConstruct " + ctx);
       if(ctx.getTarget() == null)
          throw new IllegalStateException("target is null");
-      try { ctx.getMethod(); throw new Exception("should not come here"); } catch(IllegalStateException e) { }
       postConstructs++;
       ctx.proceed();
    }

Modified: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/common/CommonInterceptor.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/common/CommonInterceptor.java	2008-03-12 12:36:54 UTC (rev 70765)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/common/CommonInterceptor.java	2008-03-12 13:23:40 UTC (rev 70766)
@@ -51,7 +51,6 @@
       log.debug("postConstruct " + ctx);
       if(ctx.getTarget() == null)
          throw new IllegalStateException("target is null");
-      try { ctx.getMethod(); throw new Exception("should not come here"); } catch(IllegalStateException e) { }
       postConstructs++;
       ctx.proceed();
    }

Modified: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/direct/DirectInterceptor.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/direct/DirectInterceptor.java	2008-03-12 12:36:54 UTC (rev 70765)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/direct/DirectInterceptor.java	2008-03-12 13:23:40 UTC (rev 70766)
@@ -54,7 +54,6 @@
       log.debug("postConstruct " + ctx);
       if(ctx.getTarget() == null)
          throw new IllegalStateException("target is null");
-      try { ctx.getMethod(); throw new Exception("should not come here"); } catch(IllegalStateException e) { }
       postConstructs++;
       ctx.proceed();
    }

Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/ejbthree1215/GetMethodInterceptor.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/ejbthree1215/GetMethodInterceptor.java	                        (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/ejbthree1215/GetMethodInterceptor.java	2008-03-12 13:23:40 UTC (rev 70766)
@@ -0,0 +1,49 @@
+/*
+ * 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.ejbthree1215;
+
+import javax.annotation.PostConstruct;
+import javax.interceptor.InvocationContext;
+
+import org.jboss.logging.Logger;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class GetMethodInterceptor
+{
+   private static final Logger log = Logger.getLogger(GetMethodInterceptor.class);
+   
+   public static int invocations = 0;
+   
+   @PostConstruct
+   public void postConstruct(InvocationContext ctx) throws Exception
+   {
+      if(ctx.getMethod() != null)
+         throw new IllegalStateException("EJBTHREE-1215: getMethod must return null");
+      GetMethodInterceptor.invocations++;
+      ctx.proceed();
+   }
+}


Property changes on: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/ejbthree1215/GetMethodInterceptor.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/ejbthree1215/Hello.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/ejbthree1215/Hello.java	                        (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/ejbthree1215/Hello.java	2008-03-12 13:23:40 UTC (rev 70766)
@@ -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.ejbthree1215;
+
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface Hello
+{
+   String sayHiTo(String name);
+}


Property changes on: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/ejbthree1215/Hello.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/ejbthree1215/HelloBean.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/ejbthree1215/HelloBean.java	                        (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/ejbthree1215/HelloBean.java	2008-03-12 13:23:40 UTC (rev 70766)
@@ -0,0 +1,45 @@
+/*
+ * 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.ejbthree1215;
+
+import javax.interceptor.Interceptors;
+
+import org.jboss.ejb3.interceptors.ManagedObject;
+import org.jboss.logging.Logger;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at ManagedObject
+ at Interceptors(GetMethodInterceptor.class)
+public class HelloBean implements Hello
+{
+   private static final Logger log = Logger.getLogger(HelloBean.class);
+
+   public String sayHiTo(String name)
+   {
+      return "Hi " + name;
+   }
+}


Property changes on: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/ejbthree1215/HelloBean.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/ejbthree1215/unit/ContextGetMethodTestCase.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/ejbthree1215/unit/ContextGetMethodTestCase.java	                        (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/ejbthree1215/unit/ContextGetMethodTestCase.java	2008-03-12 13:23:40 UTC (rev 70766)
@@ -0,0 +1,77 @@
+/*
+ * 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.ejbthree1215.unit;
+
+import java.net.URL;
+import java.util.Date;
+
+import junit.framework.TestCase;
+
+import org.jboss.aop.AspectXmlLoader;
+import org.jboss.ejb3.interceptors.proxy.ProxyContainer;
+import org.jboss.ejb3.test.interceptors.ejbthree1215.GetMethodInterceptor;
+import org.jboss.ejb3.test.interceptors.ejbthree1215.Hello;
+import org.jboss.ejb3.test.interceptors.ejbthree1215.HelloBean;
+import org.jboss.logging.Logger;
+
+/**
+ * EJBTHREE-1215: InvocationContext.getMethod must return null in lifecycle callback.
+ * 
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class ContextGetMethodTestCase extends TestCase
+{
+   private static final Logger log = Logger.getLogger(ContextGetMethodTestCase.class);
+
+   public void test1() throws Throwable
+   {
+      //AspectManager.verbose = true;
+      
+//      // TODO: During inventory surefire boots up BasicTestSuite
+//      LinkedHashMap pointcuts = AspectManager.instance().getPointcuts();
+//      if(!pointcuts.isEmpty())
+//      {
+//         //System.err.println("AspectManager still contains: " + pointcuts);
+//         URL url = Thread.currentThread().getContextClassLoader().getResource("basic/jboss-aop.xml");
+//         AspectXmlLoader.undeployXML(url);
+//      }
+      
+      // Bootstrap AOP
+      URL url = Thread.currentThread().getContextClassLoader().getResource("proxy/jboss-aop.xml");
+      log.info("deploying AOP from " + url);
+      AspectXmlLoader.deployXML(url);
+
+      Thread.currentThread().setContextClassLoader(Hello.class.getClassLoader());
+      
+      ProxyContainer<HelloBean> container = new ProxyContainer<HelloBean>("ContextGetMethodTestCase", "InterceptorContainer", HelloBean.class);
+      
+      Class<?> interfaces[] = { Hello.class };
+      Hello proxy = container.constructProxy(interfaces);
+      
+      String name = new Date().toString();
+      String result = proxy.sayHiTo(name);
+      
+      assertEquals(1, GetMethodInterceptor.invocations);
+      assertEquals("Hi " + name, result);
+   }
+}


Property changes on: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/ejbthree1215/unit/ContextGetMethodTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Modified: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/proxy/ProxiedInterceptor.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/proxy/ProxiedInterceptor.java	2008-03-12 12:36:54 UTC (rev 70765)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/proxy/ProxiedInterceptor.java	2008-03-12 13:23:40 UTC (rev 70766)
@@ -52,7 +52,6 @@
    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();
    }




More information about the jboss-cvs-commits mailing list