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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jan 16 13:05:47 EST 2008


Author: wolfc
Date: 2008-01-16 13:05:47 -0500 (Wed, 16 Jan 2008)
New Revision: 69040

Added:
   projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/signature/
   projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/signature/PackageProtectedInterceptor.java
   projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/signature/SignatureTestBean.java
   projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/signature/unit/
   projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/signature/unit/SignatureTestCase.java
Modified:
   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/LifecycleCallbackInterceptorMethodInterceptor.java
Log:
Fixed non-public signatures

Modified: 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	2008-01-16 17:59:46 UTC (rev 69039)
+++ projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/BusinessMethodInterceptorMethodInterceptor.java	2008-01-16 18:05:47 UTC (rev 69040)
@@ -74,7 +74,16 @@
       try
       {
          Object args[] = { ctx };
-         return method.invoke(interceptor, args);
+         boolean accessible = method.isAccessible();
+         method.setAccessible(true);
+         try
+         {
+            return method.invoke(interceptor, args);
+         }
+         finally
+         {
+            method.setAccessible(accessible);
+         }
       }
       catch(InvocationTargetException e)
       {

Modified: 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	2008-01-16 17:59:46 UTC (rev 69039)
+++ projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/aop/LifecycleCallbackInterceptorMethodInterceptor.java	2008-01-16 18:05:47 UTC (rev 69040)
@@ -73,7 +73,16 @@
       try
       {
          Object args[] = { ctx };
-         method.invoke(interceptor, args);
+         boolean accessible = method.isAccessible();
+         method.setAccessible(true);
+         try
+         {
+            method.invoke(interceptor, args);
+         }
+         finally
+         {
+            method.setAccessible(accessible);
+         }
          // TODO: return null or invokeTarget?
          return invocation.invokeNext();
       }

Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/signature/PackageProtectedInterceptor.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/signature/PackageProtectedInterceptor.java	                        (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/signature/PackageProtectedInterceptor.java	2008-01-16 18:05:47 UTC (rev 69040)
@@ -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.signature;
+
+import java.util.List;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+import org.jboss.ejb3.test.interceptors.signature.unit.SignatureTestCase;
+import org.jboss.logging.Logger;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class PackageProtectedInterceptor
+{
+   private static final Logger log = Logger.getLogger(PackageProtectedInterceptor.class);
+   
+   @SuppressWarnings("unchecked")
+   @AroundInvoke
+   Object aroundInvoke(InvocationContext ctx) throws Exception
+   {
+      ((List<Class<?>>) ctx.getParameters()[0]).add(this.getClass());
+      return ctx.proceed();
+   }
+   
+   @SuppressWarnings("unchecked")
+   @PreDestroy
+   void preDestroy(InvocationContext ctx) throws Exception
+   {
+      SignatureTestCase.addLifeCycleVisit(PackageProtectedInterceptor.class, "preDestroy");
+      ctx.proceed();
+   }
+   
+   @SuppressWarnings("unchecked")
+   @PostConstruct
+   void postConstruct(InvocationContext ctx) throws Exception
+   {
+      SignatureTestCase.addLifeCycleVisit(PackageProtectedInterceptor.class, "postConstruct");
+      ctx.proceed();
+   }
+}


Property changes on: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/signature/PackageProtectedInterceptor.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/signature/SignatureTestBean.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/signature/SignatureTestBean.java	                        (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/signature/SignatureTestBean.java	2008-01-16 18:05:47 UTC (rev 69040)
@@ -0,0 +1,57 @@
+/*
+ * 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.signature;
+
+import java.util.List;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptors;
+import javax.interceptor.InvocationContext;
+
+import org.jboss.ejb3.interceptors.ManagedObject;
+import org.jboss.logging.Logger;
+
+/**
+ * Access private bean method interceptor.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Interceptors(PackageProtectedInterceptor.class)
+ at ManagedObject
+public class SignatureTestBean
+{
+   private static final Logger log = Logger.getLogger(SignatureTestBean.class);
+   
+   @SuppressWarnings({"unused", "unchecked"})
+   @AroundInvoke
+   private Object aroundInvoke(InvocationContext ctx) throws Exception
+   {
+      ((List<Class<?>>) ctx.getParameters()[0]).add(this.getClass());
+      return ctx.proceed();
+   }
+   
+   public int test(List<Class<?>> visits)
+   {
+      return visits.size();
+   }
+}


Property changes on: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/signature/SignatureTestBean.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/signature/unit/SignatureTestCase.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/signature/unit/SignatureTestCase.java	                        (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/signature/unit/SignatureTestCase.java	2008-01-16 18:05:47 UTC (rev 69040)
@@ -0,0 +1,84 @@
+/*
+ * 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.signature.unit;
+
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.jboss.aop.AspectXmlLoader;
+import org.jboss.ejb3.interceptors.direct.DirectContainer;
+import org.jboss.ejb3.test.interceptors.signature.PackageProtectedInterceptor;
+import org.jboss.ejb3.test.interceptors.signature.SignatureTestBean;
+import org.jboss.logging.Logger;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class SignatureTestCase extends TestCase
+{
+   private static final Logger log = Logger.getLogger(SignatureTestCase.class);
+   
+   private static List<String> lifeCycleVisits = new ArrayList<String>();
+   
+   public static boolean addLifeCycleVisit(Class<?> cls, String methodName)
+   {
+      return lifeCycleVisits.add(cls.getName() + "." + methodName);
+   }
+   
+   public void test() throws Throwable
+   {
+      //AspectManager.verbose = true;
+      
+      // To make surefire happy
+      Thread.currentThread().setContextClassLoader(SignatureTestBean.class.getClassLoader());
+      
+      // Bootstrap AOP
+      // FIXME: use the right jboss-aop.xml
+      URL url = Thread.currentThread().getContextClassLoader().getResource("proxy/jboss-aop.xml");
+      log.info("deploying AOP from " + url);
+      AspectXmlLoader.deployXML(url);
+      
+      lifeCycleVisits.clear();
+      
+      DirectContainer<SignatureTestBean> container = new DirectContainer<SignatureTestBean>("SignatureTestBean", "Test", SignatureTestBean.class);
+      
+      SignatureTestBean bean = container.construct();
+      
+      List<String> expectedLifeCycleVisits = Arrays.asList("org.jboss.ejb3.test.interceptors.signature.PackageProtectedInterceptor.postConstruct");
+      assertEquals(expectedLifeCycleVisits, lifeCycleVisits);
+      
+      List<Class<?>> visits = new ArrayList<Class<?>>();
+      Integer numVisits = container.invoke(bean, "test", visits);
+      
+      assertEquals(2, numVisits.intValue());
+      List<Class<?>> expectedVisits = Arrays.asList(PackageProtectedInterceptor.class, SignatureTestBean.class);
+      assertEquals(expectedVisits, visits);
+   }
+}


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




More information about the jboss-cvs-commits mailing list