[jboss-cvs] JBossAS SVN: r85749 - in projects/ejb3/trunk: proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/service and 6 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Mar 11 19:06:42 EDT 2009


Author: ALRubinger
Date: 2009-03-11 19:06:42 -0400 (Wed, 11 Mar 2009)
New Revision: 85749

Added:
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/NotEligibleForDirectInvocationException.java
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionSpecLocalProxyInvocationHandler.java
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionSpecRemoteProxyInvocationHandler.java
Removed:
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/NotEligibleForDirectInvocationException.java
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/ProxyInvocationHandler.java
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/ProxyInvocationHandlerBase.java
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/service/
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateful/
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateless/
Modified:
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/unit/PassivationDoesNotPreventNewActivityUnitTestCase.java
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/service/ServiceLocalProxyFactory.java
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/service/ServiceProxyFactoryBase.java
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/service/ServiceRemoteProxyFactory.java
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionLocalProxyFactory.java
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionProxyFactoryBase.java
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionRemoteProxyFactory.java
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionLocalProxyFactory.java
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionRemoteProxyFactory.java
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionProxyInvocationHandler.java
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionProxyInvocationHandlerBase.java
   projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/ejbthree1529/unit/RemoteBindingInvokerNameTestCase.java
   projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/unit/JNDIBindingTestCase.java
Log:
[EJBTHREE-1765] Unify InvocationHandlers into one implementation, breaking down the hierarchy for SLSB/SFSB/@Service

Modified: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/unit/PassivationDoesNotPreventNewActivityUnitTestCase.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/unit/PassivationDoesNotPreventNewActivityUnitTestCase.java	2009-03-11 22:39:18 UTC (rev 85748)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/unit/PassivationDoesNotPreventNewActivityUnitTestCase.java	2009-03-11 23:06:42 UTC (rev 85749)
@@ -25,7 +25,6 @@
 import static org.junit.Assert.assertFalse;
 
 import java.io.Serializable;
-import java.lang.reflect.Proxy;
 import java.util.concurrent.BrokenBarrierException;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutorService;
@@ -45,7 +44,7 @@
 import org.jboss.ejb3.core.test.ejbthree1549.ForceEventsCacheFactory;
 import org.jboss.ejb3.core.test.ejbthree1549.MyStatefulBean;
 import org.jboss.ejb3.core.test.ejbthree1549.MyStatefulLocal;
-import org.jboss.ejb3.proxy.handler.session.stateful.StatefulLocalProxyInvocationHandler;
+import org.jboss.ejb3.proxy.intf.SessionProxy;
 import org.jboss.ejb3.stateful.StatefulContainer;
 import org.jboss.logging.Logger;
 import org.junit.After;
@@ -167,11 +166,10 @@
        * Force passivation, but block it from completing (because we don't 
        * await on the PM)
        */
-      
+
       // Force passivation
       ForceEventsCache.forcePassivation();
       ForceEventsCache.PRE_PASSIVATE_BARRIER.await();
-      
 
       /*
        * Spawn off the test in another Thread
@@ -200,9 +198,7 @@
       final MyStatefulLocal bean = lookup(MyStatefulLocal.JNDI_NAME, MyStatefulLocal.class);
 
       // Get our bean's Session ID
-      StatefulLocalProxyInvocationHandler handler = (StatefulLocalProxyInvocationHandler) Proxy
-            .getInvocationHandler(bean);
-      Serializable sessionId = (Serializable) handler.getTarget();
+      Serializable sessionId = this.getSessionId(bean);
 
       // Invoke upon our bean
       int next = bean.getNextCounter();
@@ -282,9 +278,7 @@
       final MyStatefulLocal bean = lookup(MyStatefulLocal.JNDI_NAME, MyStatefulLocal.class);
 
       // Get our bean's Session ID
-      StatefulLocalProxyInvocationHandler handler = (StatefulLocalProxyInvocationHandler) Proxy
-            .getInvocationHandler(bean);
-      Serializable sessionId = (Serializable) handler.getTarget();
+      Serializable sessionId = this.getSessionId(bean);
 
       // Invoke upon our bean
       int next = bean.getNextCounter();
@@ -639,9 +633,8 @@
    private Serializable getSessionId(MyStatefulLocal bean)
    {
       // Get our bean's Session ID
-      StatefulLocalProxyInvocationHandler handler = (StatefulLocalProxyInvocationHandler) Proxy
-            .getInvocationHandler(bean);
-      Serializable sessionId = (Serializable) handler.getTarget();
+      SessionProxy sessionProxy = (SessionProxy) bean;
+      Serializable sessionId = (Serializable) sessionProxy.getTarget();
       return sessionId;
    }
 }

Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/service/ServiceLocalProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/service/ServiceLocalProxyFactory.java	2009-03-11 22:39:18 UTC (rev 85748)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/service/ServiceLocalProxyFactory.java	2009-03-11 23:06:42 UTC (rev 85749)
@@ -25,8 +25,7 @@
 
 import org.jboss.aop.Advisor;
 import org.jboss.aop.advice.Interceptor;
-import org.jboss.ejb3.proxy.handler.session.service.ServiceLocalProxyInvocationHandler;
-import org.jboss.ejb3.proxy.handler.session.service.ServiceProxyInvocationHandler;
+import org.jboss.ejb3.proxy.handler.session.SessionSpecLocalProxyInvocationHandler;
 import org.jboss.logging.Logger;
 import org.jboss.metadata.ejb.jboss.JBossServiceBeanMetaData;
 
@@ -85,7 +84,7 @@
    }
 
    @Override
-   protected ServiceProxyInvocationHandler createInvocationHandler()
+   protected SessionSpecLocalProxyInvocationHandler createInvocationHandler()
    {
       // Obtain container name
       String containerName = this.getContainerName();
@@ -95,8 +94,8 @@
       Interceptor[] interceptors = this.getInterceptors();
 
       // Create
-      ServiceProxyInvocationHandler handler = new ServiceLocalProxyInvocationHandler(containerName, containerGuid,
-            interceptors);
+      SessionSpecLocalProxyInvocationHandler handler = new SessionSpecLocalProxyInvocationHandler(containerName,
+            containerGuid, interceptors, null);
 
       // Return
       return handler;

Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/service/ServiceProxyFactoryBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/service/ServiceProxyFactoryBase.java	2009-03-11 22:39:18 UTC (rev 85748)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/service/ServiceProxyFactoryBase.java	2009-03-11 23:06:42 UTC (rev 85749)
@@ -27,7 +27,7 @@
 
 import org.jboss.aop.Advisor;
 import org.jboss.ejb3.proxy.factory.ProxyFactoryBase;
-import org.jboss.ejb3.proxy.handler.session.service.ServiceProxyInvocationHandler;
+import org.jboss.ejb3.proxy.handler.session.SessionProxyInvocationHandler;
 import org.jboss.ejb3.proxy.intf.ServiceProxy;
 import org.jboss.logging.Logger;
 import org.jboss.metadata.ejb.jboss.JBossServiceBeanMetaData;
@@ -107,7 +107,7 @@
             + ServiceProxyFactory.class.getSimpleName() + " was not properly started?";
 
       // Create a new InvocationHandler
-      ServiceProxyInvocationHandler handler = this.createInvocationHandler();
+      SessionProxyInvocationHandler handler = this.createInvocationHandler();
 
       try
       {
@@ -244,7 +244,7 @@
     * 
     * @return
     */
-   protected abstract ServiceProxyInvocationHandler createInvocationHandler();
+   protected abstract SessionProxyInvocationHandler createInvocationHandler();
 
    // --------------------------------------------------------------------------------||
    // Accessors / Mutators -----------------------------------------------------------||

Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/service/ServiceRemoteProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/service/ServiceRemoteProxyFactory.java	2009-03-11 22:39:18 UTC (rev 85748)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/service/ServiceRemoteProxyFactory.java	2009-03-11 23:06:42 UTC (rev 85749)
@@ -25,8 +25,7 @@
 
 import org.jboss.aop.Advisor;
 import org.jboss.aop.advice.Interceptor;
-import org.jboss.ejb3.proxy.handler.session.service.ServiceProxyInvocationHandler;
-import org.jboss.ejb3.proxy.handler.session.service.ServiceRemoteProxyInvocationHandler;
+import org.jboss.ejb3.proxy.handler.session.SessionSpecRemoteProxyInvocationHandler;
 import org.jboss.logging.Logger;
 import org.jboss.metadata.ejb.jboss.JBossServiceBeanMetaData;
 
@@ -136,7 +135,7 @@
    // --------------------------------------------------------------------------------||
 
    @Override
-   protected ServiceProxyInvocationHandler createInvocationHandler()
+   protected SessionSpecRemoteProxyInvocationHandler createInvocationHandler()
    {
       // Obtain properties
       String containerName = this.getContainerName();
@@ -147,8 +146,8 @@
       Interceptor[] interceptors = this.getInterceptors();
 
       // Create
-      ServiceProxyInvocationHandler handler = new ServiceRemoteProxyInvocationHandler(containerName, containerGuid,
-            interceptors, url);
+      SessionSpecRemoteProxyInvocationHandler handler = new SessionSpecRemoteProxyInvocationHandler(containerName,
+            containerGuid, interceptors, null, url);
 
       // Return
       return handler;

Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionLocalProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionLocalProxyFactory.java	2009-03-11 22:39:18 UTC (rev 85748)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionLocalProxyFactory.java	2009-03-11 23:06:42 UTC (rev 85749)
@@ -27,7 +27,7 @@
 import org.jboss.aop.advice.Interceptor;
 import org.jboss.ejb3.proxy.factory.session.SessionSpecProxyFactory;
 import org.jboss.ejb3.proxy.handler.session.SessionProxyInvocationHandler;
-import org.jboss.ejb3.proxy.handler.session.stateful.StatefulLocalProxyInvocationHandler;
+import org.jboss.ejb3.proxy.handler.session.SessionSpecLocalProxyInvocationHandler;
 import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
 
 /**
@@ -120,7 +120,7 @@
       Interceptor[] interceptors = this.getInterceptors();
 
       // Create
-      SessionProxyInvocationHandler handler = new StatefulLocalProxyInvocationHandler(containerName, containerGuid,
+      SessionProxyInvocationHandler handler = new SessionSpecLocalProxyInvocationHandler(containerName, containerGuid,
             interceptors, businessInterfaceName);
 
       // Return

Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionProxyFactoryBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionProxyFactoryBase.java	2009-03-11 22:39:18 UTC (rev 85748)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionProxyFactoryBase.java	2009-03-11 23:06:42 UTC (rev 85749)
@@ -32,7 +32,7 @@
 import org.jboss.ejb3.common.registrar.spi.NotBoundException;
 import org.jboss.ejb3.proxy.container.StatefulSessionFactory;
 import org.jboss.ejb3.proxy.factory.session.SessionProxyFactoryBase;
-import org.jboss.ejb3.proxy.handler.session.stateful.StatefulProxyInvocationHandlerBase;
+import org.jboss.ejb3.proxy.handler.session.SessionProxyInvocationHandler;
 import org.jboss.ejb3.proxy.intf.StatefulSessionProxy;
 import org.jboss.logging.Logger;
 import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
@@ -270,9 +270,9 @@
    {
       // Obtain the InvocationHandler
       InvocationHandler handler = Proxy.getInvocationHandler(proxy);
-      assert handler instanceof StatefulProxyInvocationHandlerBase : "SFSB Proxy must be of type "
-            + StatefulProxyInvocationHandlerBase.class.getName();
-      StatefulProxyInvocationHandlerBase sHandler = (StatefulProxyInvocationHandlerBase) handler;
+      assert handler instanceof SessionProxyInvocationHandler : "SFSB Proxy must be of type "
+            + SessionProxyInvocationHandler.class.getName();
+      SessionProxyInvocationHandler sHandler = (SessionProxyInvocationHandler) handler;
 
       // Set the Session ID on the Proxy
       sHandler.setTarget(sessionId);

Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionRemoteProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionRemoteProxyFactory.java	2009-03-11 22:39:18 UTC (rev 85748)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionRemoteProxyFactory.java	2009-03-11 23:06:42 UTC (rev 85749)
@@ -27,7 +27,7 @@
 import org.jboss.aop.advice.Interceptor;
 import org.jboss.ejb3.proxy.factory.session.SessionSpecProxyFactory;
 import org.jboss.ejb3.proxy.handler.session.SessionProxyInvocationHandler;
-import org.jboss.ejb3.proxy.handler.session.stateful.StatefulRemoteProxyInvocationHandler;
+import org.jboss.ejb3.proxy.handler.session.SessionSpecRemoteProxyInvocationHandler;
 import org.jboss.logging.Logger;
 import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
 
@@ -169,7 +169,7 @@
       Interceptor[] interceptors = this.getInterceptors();
 
       // Create
-      SessionProxyInvocationHandler handler = new StatefulRemoteProxyInvocationHandler(containerName, containerGuid,
+      SessionProxyInvocationHandler handler = new SessionSpecRemoteProxyInvocationHandler(containerName, containerGuid,
             interceptors, businessInterfaceName, url);
 
       // Return

Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionLocalProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionLocalProxyFactory.java	2009-03-11 22:39:18 UTC (rev 85748)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionLocalProxyFactory.java	2009-03-11 23:06:42 UTC (rev 85749)
@@ -27,7 +27,7 @@
 import org.jboss.aop.advice.Interceptor;
 import org.jboss.ejb3.proxy.factory.session.SessionSpecProxyFactory;
 import org.jboss.ejb3.proxy.handler.session.SessionProxyInvocationHandler;
-import org.jboss.ejb3.proxy.handler.session.stateless.StatelessLocalProxyInvocationHandler;
+import org.jboss.ejb3.proxy.handler.session.SessionSpecLocalProxyInvocationHandler;
 import org.jboss.logging.Logger;
 import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
 
@@ -123,7 +123,7 @@
       Interceptor[] interceptors = this.getInterceptors();
 
       // Create
-      SessionProxyInvocationHandler handler = new StatelessLocalProxyInvocationHandler(containerName, containerGuid,
+      SessionProxyInvocationHandler handler = new SessionSpecLocalProxyInvocationHandler(containerName, containerGuid,
             interceptors, businessInterfaceName);
 
       // Return

Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionRemoteProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionRemoteProxyFactory.java	2009-03-11 22:39:18 UTC (rev 85748)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionRemoteProxyFactory.java	2009-03-11 23:06:42 UTC (rev 85749)
@@ -27,7 +27,7 @@
 import org.jboss.aop.advice.Interceptor;
 import org.jboss.ejb3.proxy.factory.session.SessionSpecProxyFactory;
 import org.jboss.ejb3.proxy.handler.session.SessionProxyInvocationHandler;
-import org.jboss.ejb3.proxy.handler.session.stateless.StatelessRemoteProxyInvocationHandler;
+import org.jboss.ejb3.proxy.handler.session.SessionSpecRemoteProxyInvocationHandler;
 import org.jboss.logging.Logger;
 import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
 
@@ -171,7 +171,7 @@
       Interceptor[] interceptors = this.getInterceptors();
 
       // Create
-      SessionProxyInvocationHandler handler = new StatelessRemoteProxyInvocationHandler(containerName, containerGuid,
+      SessionProxyInvocationHandler handler = new SessionSpecRemoteProxyInvocationHandler(containerName, containerGuid,
             interceptors, businessInterfaceName, url);
 
       // Return

Deleted: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/NotEligibleForDirectInvocationException.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/NotEligibleForDirectInvocationException.java	2009-03-11 22:39:18 UTC (rev 85748)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/NotEligibleForDirectInvocationException.java	2009-03-11 23:06:42 UTC (rev 85749)
@@ -1,77 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.proxy.handler;
-
-/**
- * NotEligibleForDirectInvocationException
- * 
- * Thrown when attempting to handle an invocation
- * directly within the InvocationHandler when 
- * the invocation should instead be delegated 
- * back to the Container
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public class NotEligibleForDirectInvocationException extends Exception
-{
-   // ------------------------------------------------------------------------------||
-   // Class Members ----------------------------------------------------------------||
-   // ------------------------------------------------------------------------------||
-
-   private static final long serialVersionUID = 1L;
-
-   // ------------------------------------------------------------------------------||
-   // Constructors -----------------------------------------------------------------||
-   // ------------------------------------------------------------------------------||
-
-   public NotEligibleForDirectInvocationException()
-   {
-
-   }
-
-   /**
-    * @param message
-    */
-   public NotEligibleForDirectInvocationException(String message)
-   {
-      super(message);
-   }
-
-   /**
-    * @param cause
-    */
-   public NotEligibleForDirectInvocationException(Throwable cause)
-   {
-      super(cause);
-   }
-
-   /**
-    * @param message
-    * @param cause
-    */
-   public NotEligibleForDirectInvocationException(String message, Throwable cause)
-   {
-      super(message, cause);
-   }
-
-}

Deleted: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/ProxyInvocationHandler.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/ProxyInvocationHandler.java	2009-03-11 22:39:18 UTC (rev 85748)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/ProxyInvocationHandler.java	2009-03-11 23:06:42 UTC (rev 85749)
@@ -1,41 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, 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.proxy.handler;
-
-import java.io.Serializable;
-import java.lang.reflect.InvocationHandler;
-
-/**
- * ProxyInvocationHandler
- * 
- * Defines contract for a generic EJB3 Proxy
- * Invocation Handler
- * 
- * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision$
- */
-public interface ProxyInvocationHandler extends InvocationHandler, Serializable
-{
-   
-}
\ No newline at end of file

Deleted: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/ProxyInvocationHandlerBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/ProxyInvocationHandlerBase.java	2009-03-11 22:39:18 UTC (rev 85748)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/ProxyInvocationHandlerBase.java	2009-03-11 23:06:42 UTC (rev 85749)
@@ -1,330 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.proxy.handler;
-
-import java.io.Serializable;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.jboss.aop.advice.Interceptor;
-import org.jboss.ejb3.common.lang.SerializableMethod;
-import org.jboss.ejb3.common.registrar.spi.Ejb3Registrar;
-import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
-import org.jboss.ejb3.proxy.container.InvokableContext;
-import org.jboss.ejb3.proxy.intf.SessionProxy;
-import org.jboss.logging.Logger;
-
-/**
- * ProxyInvocationHandlerBase
- * 
- * Abstract base from which all Proxy InvocationHandlers
- * may extend
- * 
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public abstract class ProxyInvocationHandlerBase implements ProxyInvocationHandler, Serializable
-{
-   // ------------------------------------------------------------------------------||
-   // Instance Members -------------------------------------------------------------||
-   // ------------------------------------------------------------------------------||
-
-   /**
-    * The interceptors to apply to inovcations upon this handler
-    */
-   private Interceptor[] interceptors;
-
-   // ------------------------------------------------------------------------------||
-   // Class Members ----------------------------------------------------------------||
-   // ------------------------------------------------------------------------------||
-
-   private static final long serialVersionUID = 1L;
-
-   /**
-    * Logger
-    */
-   private static final Logger log = Logger.getLogger(ProxyInvocationHandlerBase.class);
-
-   /*
-    * Method Names
-    */
-   private static final String METHOD_NAME_TO_STRING = "toString";
-
-   private static final String METHOD_NAME_EQUALS = "equals";
-
-   private static final String METHOD_NAME_HASH_CODE = "hashCode";
-
-   /*
-    * Local Methods
-    */
-   private static final SerializableMethod METHOD_TO_STRING;
-
-   private static final SerializableMethod METHOD_EQUALS;
-
-   private static final SerializableMethod METHOD_HASH_CODE;
-
-   static
-   {
-      try
-      {
-         METHOD_TO_STRING = new SerializableMethod(Object.class
-               .getDeclaredMethod(ProxyInvocationHandlerBase.METHOD_NAME_TO_STRING), Object.class);
-         METHOD_EQUALS = new SerializableMethod(Object.class.getDeclaredMethod(
-               ProxyInvocationHandlerBase.METHOD_NAME_EQUALS, Object.class), Object.class);
-         METHOD_HASH_CODE = new SerializableMethod(Object.class
-               .getDeclaredMethod(ProxyInvocationHandlerBase.METHOD_NAME_HASH_CODE), Object.class);
-      }
-      catch (NoSuchMethodException nsme)
-      {
-         throw new RuntimeException(
-               "Methods for handling directly by the InvocationHandler were not initialized correctly", nsme);
-      }
-
-   }
-
-   // ------------------------------------------------------------------------------||
-   // Instance Members -------------------------------------------------------------||
-   // ------------------------------------------------------------------------------||
-
-   /**
-    * The name under which the target container is registered
-    */
-   private String containerName;
-
-   /**
-    * The Globally-unique Container ID
-    */
-   private String containerGuid;
-
-   // ------------------------------------------------------------------------------||
-   // Constructor ------------------------------------------------------------------||
-   // ------------------------------------------------------------------------------||
-
-   /**
-    * Constructor
-    * 
-    * @param containerName The name of the target container
-    * @param containerGuid The globally-unique name of the container
-    * @param interceptors The interceptors to apply to invocations upon this handler
-    */
-   protected ProxyInvocationHandlerBase(final String containerName, final String containerGuid,
-         final Interceptor[] interceptors)
-   {
-      this.setContainerName(containerName);
-      this.setContainerGuid(containerGuid);
-      this.setInterceptors(interceptors);
-   }
-
-   // ------------------------------------------------------------------------------||
-   // Functional Methods -----------------------------------------------------------||
-   // ------------------------------------------------------------------------------||
-
-   /**
-    * Handles the current invocation directly in this invocation handler.  Only 
-    * a subset of method invocations are eligible for this treatment, else 
-    * a NotEligibleForDirectInvocationException will be thrown
-    * 
-    * @param proxy
-    * @param args Arguments of the current invocation
-    * @param invokedMethod The method invoked
-    * @return
-    * @throws NotEligibleForDirectInvocationException
-    */
-   protected Object handleInvocationDirectly(Object proxy, Object[] args, Method invokedMethod)
-         throws NotEligibleForDirectInvocationException
-   {
-      // Obtain the invoked method
-      assert invokedMethod != null : "Invoked Method was not set upon invocation of " + this.getClass().getName();
-
-      // equals
-      if (invokedMethod.equals(ProxyInvocationHandlerBase.METHOD_EQUALS.toMethod()))
-      {
-         assert args.length == 1 : "Invocation for 'equals' should have exactly one argument, instead was: "
-               + invokedMethod;
-         Object argument = args[0];
-         return this.invokeEquals(proxy, argument);
-      }
-      // toString
-      if (invokedMethod.equals(ProxyInvocationHandlerBase.METHOD_TO_STRING.toMethod()))
-      {
-         // Perform assertions
-         assert Proxy.isProxyClass(proxy.getClass()) : "Specified proxy invoked is not of type "
-               + Proxy.class.getName();
-
-         // Obtain implemented interfaces
-         Class<?>[] implementedInterfaces = proxy.getClass().getInterfaces();
-         Set<Class<?>> interfacesSet = new HashSet<Class<?>>();
-         for (Class<?> interfaze : implementedInterfaces)
-         {
-            interfacesSet.add(interfaze);
-         }
-
-         // Construct a return value
-         StringBuffer sb = new StringBuffer();
-         sb.append("Proxy to ");
-         sb.append(this.getContainerName());
-         sb.append(" implementing ");
-         sb.append(interfacesSet);
-
-         // Return
-         return sb.toString();
-      }
-      // hashCode
-      if (invokedMethod.equals(ProxyInvocationHandlerBase.METHOD_HASH_CODE.toMethod()))
-      {
-         return this.invokeHashCode(proxy);
-      }
-
-      // If no eligible methods were invoked
-      throw new NotEligibleForDirectInvocationException("Current invocation \"" + invokedMethod
-            + "\" is not eligible for direct handling by " + this);
-   }
-
-   /**
-    * Returns the container housed locally
-    * 
-    * @return
-    */
-   protected InvokableContext getContainerLocally()
-   {
-      // Lookup
-      Object obj = Ejb3RegistrarLocator.locateRegistrar().lookup(this.getContainerName());
-
-      // Ensure of correct type
-      assert obj instanceof InvokableContext : "Container retrieved from " + Ejb3Registrar.class.getSimpleName()
-            + " was not of expected type " + InvokableContext.class.getName() + " but was instead " + obj;
-
-      // Return
-      return (InvokableContext) obj;
-   }
-
-   /**
-    * Overloaded "invoke" which takes into account a {@link SerializableMethod} 
-    * view
-    * 
-    * @param proxy
-    * @param method
-    * @param args
-    * @return
-    * @throws Throwable
-    */
-   public Object invoke(SessionProxy proxy, SerializableMethod method, Object[] args) throws Throwable
-   {
-      // Attempt to handle directly
-      try
-      {
-         return this.handleInvocationDirectly(proxy, args, method.toMethod());
-      }
-      // Ignore this, we just couldn't handle here
-      catch (NotEligibleForDirectInvocationException nefdie)
-      {
-         log.debug("Couldn't handle invocation directly within " + this + ": " + nefdie.getMessage());
-      }
-
-      /*
-       * Obtain the Container
-       */
-      InvokableContext container = this.getContainer();
-
-      /*
-       * Invoke
-       */
-
-      // Adjust args if null to empty array
-      if (args == null)
-      {
-         args = new Object[]
-         {};
-      }
-
-      // Invoke
-      Object result = container.invoke(proxy, method, args);
-
-      // Return
-      return result;
-   }
-
-   // ------------------------------------------------------------------------------||
-   // Contracts --------------------------------------------------------------------||
-   // ------------------------------------------------------------------------------||
-
-   /**
-    * Obtains the Container upon which this Proxy should invoke
-    * 
-    * @return
-    */
-   protected abstract InvokableContext getContainer();
-
-   /**
-    * Handles invocation of "equals(Object)" upon the Proxy 
-    * 
-    * @param proxy
-    * @param args
-    * @return
-    */
-   protected abstract boolean invokeEquals(Object proxy, Object argument);
-
-   /**
-    * Handles invocation of "hashCode()" upon the proxy
-    * 
-    * @param proxy
-    * @return
-    */
-   protected abstract int invokeHashCode(Object proxy);
-
-   // ------------------------------------------------------------------------------||
-   // Accessors / Mutators ---------------------------------------------------------||
-   // ------------------------------------------------------------------------------||
-
-   protected String getContainerName()
-   {
-      return containerName;
-   }
-
-   protected void setContainerName(final String containerName)
-   {
-      assert containerName != null && containerName.trim().length() > 0 : "Container Name must be specified";
-      this.containerName = containerName;
-   }
-
-   protected Interceptor[] getInterceptors()
-   {
-      return interceptors;
-   }
-
-   private void setInterceptors(final Interceptor[] interceptors)
-   {
-      this.interceptors = interceptors;
-   }
-
-   protected String getContainerGuid()
-   {
-      return containerGuid;
-   }
-
-   private void setContainerGuid(final String containerGuid)
-   {
-      this.containerGuid = containerGuid;
-   }
-}

Copied: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/NotEligibleForDirectInvocationException.java (from rev 85702, projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/NotEligibleForDirectInvocationException.java)
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/NotEligibleForDirectInvocationException.java	                        (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/NotEligibleForDirectInvocationException.java	2009-03-11 23:06:42 UTC (rev 85749)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.proxy.handler.session;
+
+/**
+ * NotEligibleForDirectInvocationException
+ * 
+ * Thrown when attempting to handle an invocation
+ * directly within the InvocationHandler when 
+ * the invocation should instead be delegated 
+ * back to the Container
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class NotEligibleForDirectInvocationException extends Exception
+{
+   // ------------------------------------------------------------------------------||
+   // Class Members ----------------------------------------------------------------||
+   // ------------------------------------------------------------------------------||
+
+   private static final long serialVersionUID = 1L;
+
+   // ------------------------------------------------------------------------------||
+   // Constructors -----------------------------------------------------------------||
+   // ------------------------------------------------------------------------------||
+
+   public NotEligibleForDirectInvocationException()
+   {
+
+   }
+
+   /**
+    * @param message
+    */
+   public NotEligibleForDirectInvocationException(String message)
+   {
+      super(message);
+   }
+
+   /**
+    * @param cause
+    */
+   public NotEligibleForDirectInvocationException(Throwable cause)
+   {
+      super(cause);
+   }
+
+   /**
+    * @param message
+    * @param cause
+    */
+   public NotEligibleForDirectInvocationException(String message, Throwable cause)
+   {
+      super(message, cause);
+   }
+
+}


Property changes on: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/NotEligibleForDirectInvocationException.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionProxyInvocationHandler.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionProxyInvocationHandler.java	2009-03-11 22:39:18 UTC (rev 85748)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionProxyInvocationHandler.java	2009-03-11 23:06:42 UTC (rev 85749)
@@ -25,7 +25,7 @@
 import java.io.Serializable;
 import java.lang.reflect.InvocationHandler;
 
-import org.jboss.ejb3.proxy.handler.ProxyInvocationHandler;
+import org.jboss.aop.advice.Interceptor;
 
 /**
  * SessionProxyInvocationHandler
@@ -36,7 +36,27 @@
  * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
  * @version $Revision: 72638 $
  */
-public interface SessionProxyInvocationHandler extends ProxyInvocationHandler, InvocationHandler, Serializable
+public interface SessionProxyInvocationHandler extends InvocationHandler, Serializable
 {
 
+   // ------------------------------------------------------------------------------||
+   // Contracts --------------------------------------------------------------------||
+   // ------------------------------------------------------------------------------||
+
+   public Object getTarget();
+
+   public void setTarget(final Object target);
+
+   public String getContainerName();
+
+   public void setContainerName(final String containerName);
+
+   public Interceptor[] getInterceptors();
+
+   public void setInterceptors(final Interceptor[] interceptors);
+
+   public String getContainerGuid();
+
+   public void setContainerGuid(final String containerGuid);
+
 }
\ No newline at end of file

Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionProxyInvocationHandlerBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionProxyInvocationHandlerBase.java	2009-03-11 22:39:18 UTC (rev 85748)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionProxyInvocationHandlerBase.java	2009-03-11 23:06:42 UTC (rev 85749)
@@ -22,13 +22,19 @@
 package org.jboss.ejb3.proxy.handler.session;
 
 import java.io.Serializable;
+import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.HashSet;
+import java.util.Set;
 
 import org.jboss.aop.advice.Interceptor;
 import org.jboss.ejb3.common.lang.SerializableMethod;
-import org.jboss.ejb3.proxy.handler.NotEligibleForDirectInvocationException;
-import org.jboss.ejb3.proxy.handler.ProxyInvocationHandlerBase;
+import org.jboss.ejb3.common.registrar.spi.Ejb3Registrar;
+import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
+import org.jboss.ejb3.proxy.container.InvokableContext;
 import org.jboss.ejb3.proxy.intf.SessionProxy;
+import org.jboss.ejb3.proxy.remoting.ProxyRemotingUtils;
 import org.jboss.logging.Logger;
 
 /**
@@ -40,11 +46,9 @@
  * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
  * @version $Revision: $
  */
-public abstract class SessionProxyInvocationHandlerBase extends ProxyInvocationHandlerBase
-      implements
-         SessionProxyInvocationHandler,
-         Serializable
+public abstract class SessionProxyInvocationHandlerBase implements SessionProxyInvocationHandler, Serializable
 {
+
    // ------------------------------------------------------------------------------||
    // Class Members ----------------------------------------------------------------||
    // ------------------------------------------------------------------------------||
@@ -53,10 +57,28 @@
 
    private static final Logger log = Logger.getLogger(SessionProxyInvocationHandlerBase.class);
 
+   /*
+    * Method Names
+    */
+   private static final String METHOD_NAME_TO_STRING = "toString";
+
+   private static final String METHOD_NAME_EQUALS = "equals";
+
+   private static final String METHOD_NAME_HASH_CODE = "hashCode";
+
    private static final String METHOD_NAME_GET_TARGET = "getTarget";
 
    private static final String METHOD_NAME_SET_TARGET = "setTarget";
 
+   /*
+    * Local Methods
+    */
+   private static final SerializableMethod METHOD_TO_STRING;
+
+   private static final SerializableMethod METHOD_EQUALS;
+
+   private static final SerializableMethod METHOD_HASH_CODE;
+
    private static final SerializableMethod METHOD_GET_TARGET;
 
    private static final SerializableMethod METHOD_SET_TARGET;
@@ -68,6 +90,10 @@
          METHOD_GET_TARGET = new SerializableMethod(SessionProxy.class.getDeclaredMethod(METHOD_NAME_GET_TARGET));
          METHOD_SET_TARGET = new SerializableMethod(SessionProxy.class.getDeclaredMethod(METHOD_NAME_SET_TARGET,
                Object.class));
+         METHOD_TO_STRING = new SerializableMethod(Object.class.getDeclaredMethod(METHOD_NAME_TO_STRING), Object.class);
+         METHOD_EQUALS = new SerializableMethod(Object.class.getDeclaredMethod(METHOD_NAME_EQUALS, Object.class),
+               Object.class);
+         METHOD_HASH_CODE = new SerializableMethod(Object.class.getDeclaredMethod(METHOD_NAME_HASH_CODE), Object.class);
       }
       catch (NoSuchMethodException nsme)
       {
@@ -86,6 +112,21 @@
     */
    private Object target;
 
+   /**
+    * The interceptors to apply to inovcations upon this handler
+    */
+   private Interceptor[] interceptors;
+
+   /**
+    * The name under which the target container is registered
+    */
+   private String containerName;
+
+   /**
+    * The Globally-unique Container ID
+    */
+   private String containerGuid;
+
    // ------------------------------------------------------------------------------||
    // Constructor ------------------------------------------------------------------||
    // ------------------------------------------------------------------------------||
@@ -100,15 +141,63 @@
    protected SessionProxyInvocationHandlerBase(final String containerName, final String containerGuid,
          final Interceptor[] interceptors, final Object target)
    {
-      super(containerName, containerGuid, interceptors);
+      this.setContainerName(containerName);
+      this.setContainerGuid(containerGuid);
+      this.setInterceptors(interceptors);
       this.setTarget(target);
    }
 
    // ------------------------------------------------------------------------------||
-   // Overridden Implementations ---------------------------------------------------||
+   // Functional Methods -----------------------------------------------------------||
    // ------------------------------------------------------------------------------||
 
    /**
+    * Overloaded "invoke" which takes into account a {@link SerializableMethod} 
+    * view
+    * 
+    * @param proxy
+    * @param method
+    * @param args
+    * @return
+    * @throws Throwable
+    */
+   public Object invoke(SessionProxy proxy, SerializableMethod method, Object[] args) throws Throwable
+   {
+      // Attempt to handle directly
+      try
+      {
+         return this.handleInvocationDirectly(proxy, args, method.toMethod());
+      }
+      // Ignore this, we just couldn't handle here
+      catch (NotEligibleForDirectInvocationException nefdie)
+      {
+         log.debug("Couldn't handle invocation directly within " + this + ": " + nefdie.getMessage());
+      }
+
+      /*
+       * Obtain the Container
+       */
+      InvokableContext container = this.getContainer();
+
+      /*
+       * Invoke
+       */
+
+      // Adjust args if null to empty array
+      if (args == null)
+      {
+         args = new Object[]
+         {};
+      }
+
+      // Invoke
+      Object result = container.invoke(proxy, method, args);
+
+      // Return
+      return result;
+   }
+
+   /**
     * Handles the current invocation directly in this invocation handler.  Only 
     * a subset of method invocations are eligible for this treatment, else 
     * a NotEligibleForDirectInvocationException will be thrown
@@ -119,8 +208,7 @@
     * @return
     * @throws NotEligibleForDirectInvocationException
     */
-   @Override
-   protected Object handleInvocationDirectly(Object proxy, Object[] args, Method invokedMethod)
+   protected Object handleInvocationDirectly(SessionProxy proxy, Object[] args, Method invokedMethod)
          throws NotEligibleForDirectInvocationException
    {
       // Obtain the invoked method
@@ -131,6 +219,7 @@
       {
          return this.getTarget();
       }
+
       // setTarget
       if (invokedMethod.equals(METHOD_SET_TARGET.toMethod()))
       {
@@ -142,11 +231,220 @@
          return null;
       }
 
-      // Call to super
-      return super.handleInvocationDirectly(proxy, args, invokedMethod);
+      // equals
+      if (invokedMethod.equals(METHOD_EQUALS.toMethod()))
+      {
+         assert args.length == 1 : "Invocation for 'equals' should have exactly one argument, instead was: "
+               + invokedMethod;
+         Object argument = args[0];
+         return this.invokeEquals(proxy, argument);
+      }
+
+      // toString
+      if (invokedMethod.equals(METHOD_TO_STRING.toMethod()))
+      {
+         // Perform assertions
+         assert Proxy.isProxyClass(proxy.getClass()) : "Specified proxy invoked is not of type "
+               + Proxy.class.getName();
+
+         // Obtain implemented interfaces
+         Class<?>[] implementedInterfaces = proxy.getClass().getInterfaces();
+         Set<Class<?>> interfacesSet = new HashSet<Class<?>>();
+         for (Class<?> interfaze : implementedInterfaces)
+         {
+            interfacesSet.add(interfaze);
+         }
+
+         // Construct a return value
+         StringBuffer sb = new StringBuffer();
+         sb.append("Proxy to ");
+         sb.append(this.getContainerName());
+         sb.append(" implementing ");
+         sb.append(interfacesSet);
+
+         // Return
+         return sb.toString();
+      }
+      // hashCode
+      if (invokedMethod.equals(METHOD_HASH_CODE.toMethod()))
+      {
+         return this.invokeHashCode(proxy);
+      }
+
+      // If no eligible methods were invoked
+      throw new NotEligibleForDirectInvocationException("Current invocation \"" + invokedMethod
+            + "\" is not eligible for direct handling by " + this);
    }
 
+   /**
+    * Handles invocation of "equals(Object)" upon a Session Proxy
+    * 
+    * EJB 3.0 Specification 3.4.5.1, 3.4.5.2
+    * 
+    * @param proxy
+    * @param args
+    * @return
+    */
+   protected boolean invokeEquals(SessionProxy proxy, Object argument)
+   {
+      /*
+       * EJB 3.0 Core Specification 3.4.5.1: 
+       * 
+       * A stateful session object has a unique identity that is assigned by the 
+       * container at the time the object is created. A client of the stateful 
+       * session bean business interface can determine if two business interface 
+       * references refer to the same session object by use of the equals method.
+       * 
+       * All stateful session bean references to the same business interface for 
+       * the same stateful session bean instance will be equal. Stateful session 
+       * bean references to different interface types or to different session bean 
+       * instances will not have the same identity.
+       */
+
+      /*
+       * EJB 3.0 Specification 3.4.5.2:
+       * 
+       * All business object references of the same interface type for the same 
+       * stateless session bean have the same object identity, which is 
+       * assigned by the container.
+       *
+       * The equals method always returns true when used to compare references 
+       * to the same business interface type of the same session bean.
+       * 
+       * Session bean references to either different business interface types
+       * or different session beans will not be equal."
+       */
+
+      // If the argument is not a proxy
+      if (!(argument instanceof SessionProxy))
+      {
+         return false;
+      }
+
+      // Cast the argument
+      SessionProxy sArgument = (SessionProxy) argument;
+
+      // Get the InvocationHandlers
+      InvocationHandler proxyHandler = Proxy.getInvocationHandler(proxy);
+      InvocationHandler argumentHandler = Proxy.getInvocationHandler(argument);
+
+      // If argument handler is not SLSB Handler
+      if (!(argumentHandler instanceof SessionProxyInvocationHandler))
+      {
+         return false;
+      }
+
+      // Cast
+      SessionProxyInvocationHandler proxySHandler = (SessionProxyInvocationHandler) proxyHandler;
+      SessionProxyInvocationHandler argumentSHandler = (SessionProxyInvocationHandler) argumentHandler;
+
+      // Ensure target containers are equal
+      String proxyContainerName = proxySHandler.getContainerName();
+      assert proxyContainerName != null : "Container Name for " + proxySHandler + " was not set and is required";
+      if (!proxyContainerName.equals(argumentSHandler.getContainerName()))
+      {
+         return false;
+      }
+
+      // If target (Session ID) is specified, ensure equal
+      Object proxyTarget = proxy.getTarget();
+      if (proxyTarget != null)
+      {
+         Object argumentTarget = sArgument.getTarget();
+         if (!proxyTarget.equals(argumentTarget))
+         {
+            return false;
+         }
+      }
+
+      // All conditions passed, so true
+      return true;
+
+   }
+
+   /**
+    * Handles invocation of "hashCode()" upon the proxy
+    * 
+    * @param proxy
+    * @return
+    */
+   protected int invokeHashCode(SessionProxy proxy)
+   {
+      // Get the InvocationHandler
+      InvocationHandler handler = Proxy.getInvocationHandler(proxy);
+      assert handler instanceof SessionProxyInvocationHandler;
+      SessionProxyInvocationHandler sHandler = (SessionProxyInvocationHandler) handler;
+
+      int hash = 0;
+
+      // Generate unique String by value according to rules in "invokeEquals"; 
+      // Destination Container
+      StringBuffer sb = new StringBuffer();
+      sb.append(sHandler.getContainerName());
+      sb.append(sHandler.getContainerGuid());
+      String compositionString = sb.toString();
+
+      // Make the hash
+      hash = compositionString.hashCode();
+
+      // If there's a target in play, take that into account
+      Object target = sHandler.getTarget();
+      if (target != null)
+      {
+         hash += target.hashCode();
+      }
+
+      // Return the hash
+      return hash;
+   }
+
+   /**
+    * Returns the container housed locally
+    * 
+    * @return
+    */
+   protected InvokableContext getContainerLocally()
+   {
+      // Lookup
+      Object obj = Ejb3RegistrarLocator.locateRegistrar().lookup(this.getContainerName());
+
+      // Ensure of correct type
+      assert obj instanceof InvokableContext : "Container retrieved from " + Ejb3Registrar.class.getSimpleName()
+            + " was not of expected type " + InvokableContext.class.getName() + " but was instead " + obj;
+
+      // Return
+      return (InvokableContext) obj;
+   }
+
+   /**
+    * Creates and returns a Remoting Proxy to invoke upon the container
+    * 
+    * This implementation is marked as FIXME as remoting should be an add-on
+    * capability atop ejb3-proxy
+    * 
+    * @param url The location of the remote host holding the Container
+    * @return
+    */
+   //FIXME
+   protected InvokableContext createRemoteProxyToContainer(String url)
+   {
+      InvokableContext container = ProxyRemotingUtils.createRemoteProxyToContainer(this.getContainerName(), this
+            .getContainerGuid(), url, this.getInterceptors(), this.getTarget());
+      return container;
+   }
+
    // ------------------------------------------------------------------------------||
+   // Contracts --------------------------------------------------------------------||
+   // ------------------------------------------------------------------------------||
+
+   /**
+    * Obtains the Container upon which this Proxy should invoke
+    * 
+    * @return
+    */
+   protected abstract InvokableContext getContainer();
+
+   // ------------------------------------------------------------------------------||
    // Accessors / Mutators ---------------------------------------------------------||
    // ------------------------------------------------------------------------------||
 
@@ -155,9 +453,40 @@
       return target;
    }
 
-   public void setTarget(Object target)
+   public void setTarget(final Object target)
    {
       this.target = target;
    }
 
+   public String getContainerName()
+   {
+      return containerName;
+   }
+
+   public void setContainerName(final String containerName)
+   {
+      assert containerName != null && containerName.trim().length() > 0 : "Container Name must be specified";
+      this.containerName = containerName;
+   }
+
+   public Interceptor[] getInterceptors()
+   {
+      return interceptors;
+   }
+
+   public void setInterceptors(final Interceptor[] interceptors)
+   {
+      this.interceptors = interceptors;
+   }
+
+   public String getContainerGuid()
+   {
+      return containerGuid;
+   }
+
+   public void setContainerGuid(final String containerGuid)
+   {
+      this.containerGuid = containerGuid;
+   }
+
 }

Copied: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionSpecLocalProxyInvocationHandler.java (from rev 85729, projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateful/StatefulLocalProxyInvocationHandler.java)
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionSpecLocalProxyInvocationHandler.java	                        (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionSpecLocalProxyInvocationHandler.java	2009-03-11 23:06:42 UTC (rev 85749)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.proxy.handler.session;
+
+import java.io.Serializable;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.ejb3.proxy.container.InvokableContext;
+
+/**
+ * SessionSpecLocalProxyInvocationHandler
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class SessionSpecLocalProxyInvocationHandler extends SessionSpecProxyInvocationHandlerBase implements Serializable
+{
+
+   // --------------------------------------------------------------------------------||
+   // Class Members ------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   private static final long serialVersionUID = 1L;
+
+   // --------------------------------------------------------------------------------||
+   // Constructor --------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Constructor
+    * 
+    * @param containerName The name of the target container
+    * @param containerGuid The globally-unique name of the container
+    * @param interceptors The interceptors to apply to invocations upon this handler
+    */
+   public SessionSpecLocalProxyInvocationHandler(final String containerName, final String containerGuid,
+         final Interceptor[] interceptors)
+   {
+      super(containerName, containerGuid, interceptors, null, null);
+   }
+
+   /**
+    * Constructor
+    * 
+    * @param containerName The name of the target container
+    * @param containerGuid The globally-unique name of the container
+    * @param businessInterfaceType The possibly null businessInterfaceType
+    *   marking this invocation hander as specific to a given
+    *   EJB3 Business Interface
+    * @param interceptors The interceptors to apply to invocations upon this handler
+    */
+   public SessionSpecLocalProxyInvocationHandler(final String containerName, final String containerGuid,
+         final Interceptor[] interceptors, final String businessInterfaceType)
+   {
+      super(containerName, containerGuid, interceptors, businessInterfaceType, null);
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Required Implementations -------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /* (non-Javadoc)
+    * @see org.jboss.ejb3.proxy.handler.session.SessionProxyInvocationHandlerBase#getContainer()
+    */
+   @Override
+   protected InvokableContext getContainer()
+   {
+      return this.getContainerLocally();
+   }
+
+}


Property changes on: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionSpecLocalProxyInvocationHandler.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionSpecRemoteProxyInvocationHandler.java (from rev 85729, projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateful/StatefulRemoteProxyInvocationHandler.java)
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionSpecRemoteProxyInvocationHandler.java	                        (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionSpecRemoteProxyInvocationHandler.java	2009-03-11 23:06:42 UTC (rev 85749)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.proxy.handler.session;
+
+import java.io.Serializable;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.ejb3.proxy.container.InvokableContext;
+
+/**
+ * SessionSpecRemoteProxyInvocationHandler
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class SessionSpecRemoteProxyInvocationHandler extends SessionSpecProxyInvocationHandlerBase
+      implements
+         Serializable
+{
+
+   // --------------------------------------------------------------------------------||
+   // Class Members ------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   private static final long serialVersionUID = 1L;
+
+   // --------------------------------------------------------------------------------||
+   // Instance Members ---------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   private String url;
+
+   // --------------------------------------------------------------------------------||
+   // Constructor --------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Constructor
+    * 
+    * @param containerName The name of the target container
+    * @param containerGuid The globally-unique name of the container
+    * @param businessInterfaceType The possibly null businessInterfaceType
+    *   marking this invocation hander as specific to a given
+    *   EJB3 Business Interface
+    * @param url The URL to the Remote Host
+    * @param interceptors The interceptors to apply to invocations upon this handler
+    */
+   public SessionSpecRemoteProxyInvocationHandler(final String containerName, final String containerGuid,
+         final Interceptor[] interceptors, final String businessInterfaceType, final String url)
+   {
+      super(containerName, containerGuid, interceptors, businessInterfaceType, null);
+
+      // Set properties
+      this.setUrl(url);
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Required Implementations -------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /* (non-Javadoc)
+    * @see org.jboss.ejb3.proxy.handler.session.SessionProxyInvocationHandlerBase#getContainer()
+    */
+   @Override
+   protected InvokableContext getContainer()
+   {
+      return this.createRemoteProxyToContainer(this.getUrl());
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Accessors / Mutators -----------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   public String getUrl()
+   {
+      return url;
+   }
+
+   public void setUrl(String url)
+   {
+      this.url = url;
+   }
+
+}


Property changes on: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionSpecRemoteProxyInvocationHandler.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Modified: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/ejbthree1529/unit/RemoteBindingInvokerNameTestCase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/ejbthree1529/unit/RemoteBindingInvokerNameTestCase.java	2009-03-11 22:39:18 UTC (rev 85748)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/ejbthree1529/unit/RemoteBindingInvokerNameTestCase.java	2009-03-11 23:06:42 UTC (rev 85749)
@@ -29,7 +29,7 @@
 import junit.framework.TestCase;
 
 import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
-import org.jboss.ejb3.proxy.handler.session.stateless.StatelessRemoteProxyInvocationHandler;
+import org.jboss.ejb3.proxy.handler.session.SessionSpecRemoteProxyInvocationHandler;
 import org.jboss.ejb3.proxy.remoting.ProxyRemotingUtils;
 import org.jboss.ejb3.test.proxy.common.SessionTestCaseBase;
 import org.jboss.ejb3.test.proxy.common.Utils;
@@ -86,7 +86,7 @@
       // Get the clientBindUrl from the Proxy itself
       Class<?> proxyClass = bean.getClass();
       assert Proxy.isProxyClass(proxyClass) : "Stub from JNDI was not a " + Proxy.class.getName();
-      StatelessRemoteProxyInvocationHandler handler = (StatelessRemoteProxyInvocationHandler) Proxy
+      SessionSpecRemoteProxyInvocationHandler handler = (SessionSpecRemoteProxyInvocationHandler) Proxy
             .getInvocationHandler(bean);
       String clientBindUrl = handler.getUrl();
 

Modified: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/unit/JNDIBindingTestCase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/unit/JNDIBindingTestCase.java	2009-03-11 22:39:18 UTC (rev 85748)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/unit/JNDIBindingTestCase.java	2009-03-11 23:06:42 UTC (rev 85749)
@@ -48,7 +48,7 @@
 import org.jboss.ejb3.common.registrar.plugin.mc.Ejb3McRegistrar;
 import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
 import org.jboss.ejb3.common.registrar.spi.NotBoundException;
-import org.jboss.ejb3.proxy.handler.session.stateless.StatelessRemoteProxyInvocationHandler;
+import org.jboss.ejb3.proxy.handler.session.SessionSpecRemoteProxyInvocationHandler;
 import org.jboss.ejb3.proxy.jndiregistrar.JndiSessionRegistrarBase;
 import org.jboss.ejb3.proxy.jndiregistrar.JndiStatelessSessionRegistrar;
 import org.jboss.ejb3.test.mc.bootstrap.EmbeddedTestMcBootstrap;
@@ -308,7 +308,8 @@
       Object obj1 = context.lookup(ClientBindUrlBindingTest.JNDI_BINDING_1);
       
       // Get the underlying URL
-      StatelessRemoteProxyInvocationHandler handler1 = (StatelessRemoteProxyInvocationHandler)Proxy.getInvocationHandler(obj1);
+      SessionSpecRemoteProxyInvocationHandler handler1 = (SessionSpecRemoteProxyInvocationHandler) Proxy
+            .getInvocationHandler(obj1);
       String url1 = handler1.getUrl();
       
       // Test
@@ -322,7 +323,8 @@
       Object obj2 = context.lookup(ClientBindUrlBindingTest.JNDI_BINDING_2);
       
       // Get the underlying URL
-      StatelessRemoteProxyInvocationHandler handler2 = (StatelessRemoteProxyInvocationHandler)Proxy.getInvocationHandler(obj2);
+      SessionSpecRemoteProxyInvocationHandler handler2 = (SessionSpecRemoteProxyInvocationHandler) Proxy
+            .getInvocationHandler(obj2);
       String url2 = handler2.getUrl();
       
       // Test




More information about the jboss-cvs-commits mailing list