[jboss-cvs] JBossAS SVN: r68672 - in projects/ejb3/trunk/sandbox/src: main/java/org/jboss/ejb3/sandbox/interceptorcontainer/impl and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jan 8 05:06:21 EST 2008


Author: wolfc
Date: 2008-01-08 05:06:21 -0500 (Tue, 08 Jan 2008)
New Revision: 68672

Removed:
   projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/interceptors/direct/DirectContainer.java
   projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/interceptors/direct/IndirectContainer.java
Modified:
   projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/interceptorcontainer/InterceptorContainer.java
   projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/interceptorcontainer/impl/LifecycleCallbackInterceptorMethodInterceptor.java
   projects/ejb3/trunk/sandbox/src/test/java/org/jboss/ejb3/test/sandbox/stateless/unit/SimpleStatelessUnitTestCase.java
Log:
Moved direct container to interceptors

Modified: projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/interceptorcontainer/InterceptorContainer.java
===================================================================
--- projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/interceptorcontainer/InterceptorContainer.java	2008-01-08 10:04:25 UTC (rev 68671)
+++ projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/interceptorcontainer/InterceptorContainer.java	2008-01-08 10:06:21 UTC (rev 68672)
@@ -29,9 +29,9 @@
 
 import org.jboss.aop.Advised;
 import org.jboss.ejb3.interceptors.ManagedObject;
+import org.jboss.ejb3.interceptors.direct.DirectContainer;
+import org.jboss.ejb3.interceptors.direct.IndirectContainer;
 import org.jboss.ejb3.sandbox.interceptorcontainer.impl.ContainersInterceptorsInterceptor;
-import org.jboss.ejb3.sandbox.interceptors.direct.DirectContainer;
-import org.jboss.ejb3.sandbox.interceptors.direct.IndirectContainer;
 
 /**
  * An interceptor container keeps track of container interceptors

Modified: projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/interceptorcontainer/impl/LifecycleCallbackInterceptorMethodInterceptor.java
===================================================================
--- projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/interceptorcontainer/impl/LifecycleCallbackInterceptorMethodInterceptor.java	2008-01-08 10:04:25 UTC (rev 68671)
+++ projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/interceptorcontainer/impl/LifecycleCallbackInterceptorMethodInterceptor.java	2008-01-08 10:06:21 UTC (rev 68672)
@@ -21,6 +21,7 @@
  */
 package org.jboss.ejb3.sandbox.interceptorcontainer.impl;
 
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.Arrays;
 
@@ -67,9 +68,21 @@
 
    public Object invoke(final InvocationContext ctx) throws Exception
    {
-      Object args[] = { ctx };
-      method.invoke(interceptor, args);
-      // TODO: return null or invokeTarget?
-      return ctx.proceed();
+      try
+      {
+         Object args[] = { ctx };
+         method.invoke(interceptor, args);
+         // TODO: return null or invokeTarget?
+         return ctx.proceed();
+      }
+      catch(InvocationTargetException e)
+      {
+         Throwable cause = e.getCause();
+         if(cause instanceof Error)
+            throw (Error) cause;
+         if(cause instanceof RuntimeException)
+            throw (RuntimeException) cause;
+         throw (Exception) cause;
+      }
    }
 }

Deleted: projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/interceptors/direct/DirectContainer.java
===================================================================
--- projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/interceptors/direct/DirectContainer.java	2008-01-08 10:04:25 UTC (rev 68671)
+++ projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/interceptors/direct/DirectContainer.java	2008-01-08 10:06:21 UTC (rev 68672)
@@ -1,156 +0,0 @@
-/*
- * 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.sandbox.interceptors.direct;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-
-import org.jboss.aop.AspectManager;
-import org.jboss.aop.Domain;
-import org.jboss.aop.DomainDefinition;
-import org.jboss.aop.MethodInfo;
-import org.jboss.aop.advice.Interceptor;
-import org.jboss.aop.joinpoint.ConstructionInvocation;
-import org.jboss.aop.joinpoint.MethodInvocation;
-import org.jboss.aop.util.MethodHashing;
-import org.jboss.ejb3.interceptors.proxy.aop.ManagedObjectContainer;
-import org.jboss.logging.Logger;
-
-/**
- * The direct container invokes interceptors directly on an instance.
- * 
- * It's useful in an environment where we don't want to fiddle with the
- * classloader and still have control on how instances are called.
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class DirectContainer<T>
-{
-   private static final Logger log = Logger.getLogger(DirectContainer.class);
-   
-   private ManagedObjectContainer advisor;
-   
-   public DirectContainer(String name, Domain domain, Class<? extends T> beanClass)
-   {
-      assert name != null : "name is null";
-      assert domain != null : "domain is null";
-      assert beanClass != null : "beanClass is null";
-      
-      this.advisor = new ManagedObjectContainer(name, domain, beanClass);
-   }
-   
-   public DirectContainer(String name, String domainName, Class<? extends T> beanClass)
-   {
-      this(name, getDomain(domainName), beanClass);
-   }
-   
-   public T construct() throws SecurityException, NoSuchMethodException
-   {
-      return construct(null, null);
-   }
-   
-   @SuppressWarnings("unchecked")
-   public T construct(Object initargs[], Class<?> parameterTypes[]) throws SecurityException, NoSuchMethodException
-   {
-      Constructor<T> constructor = advisor.getClazz().getConstructor(parameterTypes);
-      int idx = advisor.getConstructorIndex(constructor);
-      assert idx != -1 : "can't find constructor in the advisor";
-      try
-      {
-         T targetObject = (T) advisor.invokeNew(initargs, idx);
-         
-         Interceptor interceptors[] = advisor.getConstructionInfos()[idx].getInterceptors();
-         ConstructionInvocation invocation = new ConstructionInvocation(interceptors, constructor, initargs);
-         invocation.setAdvisor(advisor);
-         invocation.setTargetObject(targetObject);
-         invocation.invokeNext();
-         
-         if(targetObject instanceof IndirectContainer)
-            ((IndirectContainer<T>) targetObject).setDirectContainer(this);
-         
-         return targetObject;
-      }
-      catch(Throwable t)
-      {
-         // TODO: disect
-         if(t instanceof RuntimeException)
-            throw (RuntimeException) t;
-         throw new RuntimeException(t);
-      }
-   }
-   
-   /**
-    * Do not call, for use in indirect container implementations.
-    * @return
-    */
-   public Class<?> getBeanClass()
-   {
-      return advisor.getClazz();
-   }
-   
-   /*
-    * TODO: this should not be here, it's an AspectManager helper function.
-    */
-   private static final Domain getDomain(String domainName)
-   {
-      DomainDefinition domainDefinition = AspectManager.instance().getContainer(domainName);
-      if(domainDefinition == null)
-         throw new IllegalArgumentException("Domain definition '" + domainName + "' can not be found");
-      
-      final Domain domain = (Domain) domainDefinition.getManager();
-      return domain;
-   }
-   
-   // FIXME: copy of ProxyContainer.invoke
-   public Object invoke(Object target, Method method, Object arguments[]) throws Throwable
-   {
-      long methodHash = MethodHashing.calculateHash(method);
-      MethodInfo info = advisor.getMethodInfo(methodHash);
-      if(info == null)
-         throw new IllegalArgumentException("method " + method + " is not under advisement by " + this);
-      MethodInvocation invocation = new MethodInvocation(info, info.getInterceptors());
-      invocation.setArguments(arguments);
-      invocation.setTargetObject(target);
-      return invocation.invokeNext();
-   }
-
-   public Object invokeIndirect(Object target, Method method, Object arguments[]) throws Throwable
-   {
-      long methodHash = MethodHashing.calculateHash(method);
-      MethodInfo info = advisor.getMethodInfo(methodHash);
-      if(info == null)
-         throw new IllegalArgumentException("method " + method + " is not under advisement by " + this);
-      MethodInvocation invocation = new MethodInvocation(info, info.getInterceptors())
-      {
-         @Override
-         public Object invokeTarget() throws Throwable
-         {
-            // TODO: invoke the real target in special modus
-            return null;
-         }
-      };
-      invocation.setArguments(arguments);
-      invocation.setTargetObject(target);
-      return invocation.invokeNext();
-   }
-}

Deleted: projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/interceptors/direct/IndirectContainer.java
===================================================================
--- projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/interceptors/direct/IndirectContainer.java	2008-01-08 10:04:25 UTC (rev 68671)
+++ projects/ejb3/trunk/sandbox/src/main/java/org/jboss/ejb3/sandbox/interceptors/direct/IndirectContainer.java	2008-01-08 10:06:21 UTC (rev 68672)
@@ -1,34 +0,0 @@
-/*
- * 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.sandbox.interceptors.direct;
-
-
-/**
- * Comment
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public interface IndirectContainer<T>
-{
-   void setDirectContainer(DirectContainer<T> container);
-}

Modified: projects/ejb3/trunk/sandbox/src/test/java/org/jboss/ejb3/test/sandbox/stateless/unit/SimpleStatelessUnitTestCase.java
===================================================================
--- projects/ejb3/trunk/sandbox/src/test/java/org/jboss/ejb3/test/sandbox/stateless/unit/SimpleStatelessUnitTestCase.java	2008-01-08 10:04:25 UTC (rev 68671)
+++ projects/ejb3/trunk/sandbox/src/test/java/org/jboss/ejb3/test/sandbox/stateless/unit/SimpleStatelessUnitTestCase.java	2008-01-08 10:06:21 UTC (rev 68672)
@@ -28,8 +28,8 @@
 import junit.framework.TestCase;
 
 import org.jboss.aop.AspectXmlLoader;
+import org.jboss.ejb3.interceptors.direct.DirectContainer;
 import org.jboss.ejb3.sandbox.interceptorcontainer.InterceptorContainer;
-import org.jboss.ejb3.sandbox.interceptors.direct.DirectContainer;
 import org.jboss.ejb3.test.sandbox.stateless.SimpleStatelessBean;
 import org.jboss.ejb3.test.sandbox.stateless.SimpleStatelessLocal;
 import org.jboss.logging.Logger;




More information about the jboss-cvs-commits mailing list