[jboss-cvs] JBossAS SVN: r86124 - in projects/ejb3/trunk: core/src/main/java/org/jboss/ejb3/session and 10 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Mar 19 15:40:55 EDT 2009
Author: ALRubinger
Date: 2009-03-19 15:40:55 -0400 (Thu, 19 Mar 2009)
New Revision: 86124
Removed:
projects/ejb3/trunk/proxy-spi/src/main/java/org/jboss/ejb3/proxy/spi/intf/
Modified:
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/unit/PassivationDoesNotPreventNewActivityUnitTestCase.java
projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/ProxyFactoryBase.java
projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/SessionProxyFactoryBase.java
projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/service/ServiceProxyFactoryBase.java
projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/handler/session/SessionProxyInvocationHandlerBase.java
projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/invocation/InvokableContextStatefulRemoteProxyInvocationHack.java
projects/ejb3/trunk/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/common/container/SessionContainer.java
projects/ejb3/trunk/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/spec_3_4_5/unit/SfsbProxyEqualityTestCase.java
projects/ejb3/trunk/proxy-spi/src/main/java/org/jboss/ejb3/proxy/spi/container/InvokableContext.java
projects/ejb3/trunk/proxy-spi/src/main/java/org/jboss/ejb3/proxy/spi/container/StatefulSessionFactory.java
Log:
[EJBTHREE-1777] Do not allow proxies to support operations except EJB business methods and equals, hashCode, toString
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java 2009-03-19 19:21:49 UTC (rev 86123)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java 2009-03-19 19:40:55 UTC (rev 86124)
@@ -65,7 +65,6 @@
import org.jboss.ejb3.proxy.clustered.objectstore.ClusteredObjectStoreBindings;
import org.jboss.ejb3.proxy.impl.objectstore.ObjectStoreBindings;
import org.jboss.ejb3.proxy.spi.container.InvokableContext;
-import org.jboss.ejb3.proxy.spi.intf.SessionProxy;
import org.jboss.ejb3.session.SessionContainer;
import org.jboss.ejb3.stateful.StatefulContainerInvocation;
import org.jboss.ejb3.timerservice.spi.TimedObjectInvoker;
@@ -77,7 +76,6 @@
import org.jboss.metadata.ejb.spec.NamedMethodMetaData;
import org.jboss.util.NotImplementedException;
-
/**
* @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
* @version $Revision$
@@ -104,14 +102,17 @@
@SuppressWarnings("unused")
private static final Logger log = Logger.getLogger(ServiceContainer.class);
-
+
/*
* Define lifecycle callback method names
*/
-
+
private static final String METHOD_NAME_LIFECYCLE_CALLBACK_CREATE = "create";
+
private static final String METHOD_NAME_LIFECYCLE_CALLBACK_START = "start";
+
private static final String METHOD_NAME_LIFECYCLE_CALLBACK_STOP = "stop";
+
private static final String METHOD_NAME_LIFECYCLE_CALLBACK_DESTROY = "destroy";
public ServiceContainer(MBeanServer server, ClassLoader cl, String beanClassName, String ejbName, Domain domain,
@@ -170,7 +171,7 @@
// throw new IllegalArgumentException("service bean create method must take no arguments");
throw new UnsupportedOperationException("Service Containers have no Sessions");
}
-
+
/**
* Returns the name under which the JNDI Registrar for this container is bound
*
@@ -178,8 +179,9 @@
*/
protected String getJndiRegistrarBindName()
{
- return isClustered() ? ClusteredObjectStoreBindings.CLUSTERED_OBJECTSTORE_BEAN_NAME_JNDI_REGISTRAR_SERVICE
- : ObjectStoreBindings.OBJECTSTORE_BEAN_NAME_JNDI_REGISTRAR_SERVICE;
+ return isClustered()
+ ? ClusteredObjectStoreBindings.CLUSTERED_OBJECTSTORE_BEAN_NAME_JNDI_REGISTRAR_SERVICE
+ : ObjectStoreBindings.OBJECTSTORE_BEAN_NAME_JNDI_REGISTRAR_SERVICE;
}
public Object getMBean()
@@ -198,9 +200,9 @@
// EJBTHREE-655: fire up an instance for use as MBean delegate
singleton = super.construct();
-
+
registerManagementInterface();
-
+
invokeOptionalMethod(METHOD_NAME_LIFECYCLE_CALLBACK_CREATE);
}
@@ -268,7 +270,7 @@
{
lockedStop();
}
- catch(Exception stopEx)
+ catch (Exception stopEx)
{
log.error("Error during forced container stop", stopEx);
}
@@ -299,7 +301,7 @@
// Unregister w/ MBean Server
unregisterManagementInterface();
-
+
// Null out
singleton = null;
beanContext = null;
@@ -323,7 +325,7 @@
assert timerService != null : "Timer Service not yet initialized";
return timerService;
}
-
+
private void setTcl(final ClassLoader cl)
{
AccessController.doPrivileged(new PrivilegedAction<Object>()
@@ -356,7 +358,8 @@
Class<?> parameterTypes[] =
{};
Method method = this.singleton.getClass().getMethod(methodName, parameterTypes);
- Object[] args = new Object[]{};
+ Object[] args = new Object[]
+ {};
// Invoke
if (log.isTraceEnabled())
@@ -461,7 +464,7 @@
Thread.currentThread().setContextClassLoader(oldLoader);
}
}
-
+
public InvocationResponse dynamicInvoke(Invocation invocation) throws Throwable
{
long start = System.currentTimeMillis();
@@ -598,11 +601,11 @@
/**
* @see InvokableContext
*/
- public Object invoke(SessionProxy proxy, SerializableMethod method, Object[] args) throws Throwable
+ public Object invoke(Object proxy, SerializableMethod method, Object[] args) throws Throwable
{
return this.localInvoke(method.toMethod(), args);
}
-
+
public Object invoke(String actionName, Object params[], String signature[]) throws MBeanException,
ReflectionException
{
@@ -633,7 +636,7 @@
{
return getDeploymentQualifiedName();
}
-
+
private void registerManagementInterface()
{
try
@@ -656,7 +659,7 @@
++interfaceIndex;
}
}
-
+
/*
* Construct a DependencyPolicy for the MBean which will also
* define a demand upon this container
@@ -665,7 +668,7 @@
DependencyPolicy newPolicy = containerPolicy.clone();
String cName = this.getObjectName().getCanonicalName();
newPolicy.addDependency(cName);
-
+
// Find MBean Server if not specified
if (mbeanServer == null)
{
@@ -679,7 +682,7 @@
log.warn(ise);
}
}
-
+
/*
* Construct the ObjectName
*/
@@ -697,7 +700,7 @@
+ " but the MBeanServer has not been initialized for it");
delegate = new ServiceMBeanDelegate(mbeanServer, this, intf, delegateObjectName);
-
+
/*
*
* This section is in place to replace the KernelAbstraction.installMBean
@@ -708,15 +711,15 @@
* http://www.jboss.com/index.html?module=bb&op=viewtopic&t=148497
*
*/
-
+
// The old/deprecated access
//getDeployment().getKernelAbstraction().installMBean(delegateObjectName, newPolicy, delegate);
-
// Register w/ MBean Server
mbeanServer.registerMBean(delegate, delegateObjectName);
-
+
// Install into MC
- getDeployment().getKernelAbstraction().install(delegateObjectName.getCanonicalName(), newPolicy, null, delegate);
+ getDeployment().getKernelAbstraction().install(delegateObjectName.getCanonicalName(), newPolicy, null,
+ delegate);
/*
*
@@ -735,7 +738,6 @@
throw new RuntimeException(ejbName
+ "is defined as an XMBean, but the MBeanServer has not been initialized for it");
-
delegate = new ServiceMBeanDelegate(mbeanServer, this, service.xmbean(), delegateObjectName);
getDeployment().getKernelAbstraction().installMBean(delegateObjectName, newPolicy, delegate);
@@ -763,12 +765,10 @@
* http://www.jboss.com/index.html?module=bb&op=viewtopic&t=148497
*
*/
-
+
//getDeployment().getKernelAbstraction().uninstallMBean(delegateObjectName);
-
mbeanServer.unregisterMBean(delegateObjectName);
-
-
+
/*
*
* End backwards-compatible replacement for:
@@ -782,7 +782,7 @@
{
throw new RuntimeException("Don't do this");
}
-
+
@Inject
public void setTimerServiceFactory(TimerServiceFactory factory)
{
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java 2009-03-19 19:21:49 UTC (rev 86123)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java 2009-03-19 19:40:55 UTC (rev 86124)
@@ -1,7 +1,9 @@
package org.jboss.ejb3.session;
import java.io.Serializable;
+import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
import java.util.Hashtable;
import javax.ejb.EJB;
@@ -20,9 +22,9 @@
import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
import org.jboss.ejb3.proxy.impl.factory.session.SessionProxyFactory;
import org.jboss.ejb3.proxy.impl.factory.session.SessionSpecProxyFactory;
+import org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandler;
import org.jboss.ejb3.proxy.impl.remoting.SessionSpecRemotingMetadata;
import org.jboss.ejb3.proxy.spi.container.InvokableContext;
-import org.jboss.ejb3.proxy.spi.intf.SessionProxy;
import org.jboss.ejb3.stateful.StatefulContainer;
import org.jboss.ejb3.stateful.StatefulContainerInvocation;
import org.jboss.logging.Logger;
@@ -47,12 +49,12 @@
// ------------------------------------------------------------------------------||
private static final Logger log = Logger.getLogger(SessionSpecContainer.class);
-
+
/**
* The method invoked upon by the client
*/
//TODO: Remove when CurrentInvocation is completely sorted out
- @Deprecated
+ @Deprecated
protected static ThreadLocalStack<SerializableMethod> invokedMethod = new ThreadLocalStack<SerializableMethod>();
// ------------------------------------------------------------------------------||
@@ -76,20 +78,20 @@
* @throws Throwable A possible exception thrown by the invocation
* @return
*/
- public Object invoke(SessionProxy proxy, SerializableMethod method, Object[] args) throws Throwable
+ public Object invoke(Object proxy, SerializableMethod method, Object[] args) throws Throwable
{
/*
* Replace the TCL with the CL for this Container
*/
ClassLoader oldLoader = SecurityActions.getContextClassLoader();
-
+
SecurityActions.setContextClassLoader(this.getClassloader());
-
+
try
{
-
+
invokedMethod.push(method);
-
+
/*
* Obtain the target method (advised)
*/
@@ -105,9 +107,23 @@
Method unadvisedMethod = info.getUnadvisedMethod();
SerializableMethod unadvisedSerializableMethod = new SerializableMethod(unadvisedMethod);
- // Obtain Session ID
- Serializable sessionId = (Serializable) proxy.getTarget();
+ /*
+ * Obtain Session ID
+ */
+ Serializable sessionId = null;
+
+ // If coming from ejb3-proxy-impl
+ if (Proxy.isProxyClass(proxy.getClass()))
+ {
+ InvocationHandler handler = Proxy.getInvocationHandler(proxy);
+ assert handler instanceof SessionProxyInvocationHandler : "Requires "
+ + SessionProxyInvocationHandler.class.getName();
+ SessionProxyInvocationHandler sHandler = (SessionProxyInvocationHandler) handler;
+ sessionId = (Serializable) sHandler.getTarget();
+ }
+ //TODO Session ID if nointerface
+
/*
* Invoke directly if this is an EJB2.x Method
*/
@@ -125,12 +141,12 @@
/*
* Build an invocation
*/
-
- StatefulContainerInvocation nextInvocation = new StatefulContainerInvocation(info,sessionId);
+
+ StatefulContainerInvocation nextInvocation = new StatefulContainerInvocation(info, sessionId);
nextInvocation.getMetaData().addMetaData(SessionSpecRemotingMetadata.TAG_SESSION_INVOCATION,
SessionSpecRemotingMetadata.KEY_INVOKED_METHOD, method);
nextInvocation.setArguments(args);
-
+
/*
* Invoke
*/
@@ -158,36 +174,34 @@
{
//TODO Should be getting from current invocation
SerializableMethod invokedMethod = SessionSpecContainer.invokedMethod.get();
- assert invokedMethod!=null : "Invoked Method has not been set";
-
+ assert invokedMethod != null : "Invoked Method has not been set";
+
// Obtain the name of the invoking interface
String interfaceName = null;
if (invokedMethod != null)
{
interfaceName = invokedMethod.getActualClassName();
}
-
+
// Test for no invoked business interface
- if(interfaceName==null)
+ if (interfaceName == null)
{
- throw new IllegalStateException(
- "Call to "
- + SessionContext.class.getName()
+ throw new IllegalStateException("Call to " + SessionContext.class.getName()
+ ".getInvokedBusinessInterface() was made from outside an EJB3 Business Interface "
+ "(possibly an EJB2.x Remote/Local?). " + "EJB 3.0 Specification 4.5.2.");
}
-
+
/*
* Determine if the specified class is not a valid business
* interface
*/
-
+
// Initialize a check flag
boolean isValidBusinessInterface = false;
-
+
// Get Metadata
JBossSessionBeanMetaData smd = this.getMetaData();
-
+
// Check in business remotes
BusinessRemotesMetaData businessRemotes = smd.getBusinessRemotes();
if (businessRemotes != null)
@@ -215,19 +229,19 @@
}
}
}
-
+
// If not found as a business interface, we haven't invoked through EJB3 View
- if(!isValidBusinessInterface)
+ if (!isValidBusinessInterface)
{
throw new IllegalStateException("Cannot invoke " + SessionContext.class.getName()
+ ".getInvokedBusinessInterface() from outside of an EJB3 Business View - "
+ "EJB 3.0 Core Specification 4.5.2; Used: " + interfaceName);
}
-
+
/*
* Get Invoked Interface
*/
-
+
// Attempt to load the invoked interface
Class<?> invokedInterface = null;
try
@@ -239,25 +253,25 @@
throw new RuntimeException("Invoked Business Interface on Proxy was set to " + interfaceName
+ ", but this could not be loaded by the " + ClassLoader.class.getSimpleName() + " for " + this);
}
-// if (method == null) throw new IllegalStateException("getInvokedBusinessInterface() being invoked outside of a business invocation");
-// if (method.getName() == null || method.getName().equals("")) throw new IllegalStateException("getInvokedBusinessInterface() being invoked outside of a business invocation");
-
-// String invokedBusinessInterfaceClassName = method.getActualClassName();
-// Class<?> invokedBusinessInterface = null;
-// try
-// {
-// invokedBusinessInterface = this.getClassloader().loadClass(invokedBusinessInterfaceClassName);
-// }
-// catch (ClassNotFoundException e)
-// {
-// throw new RuntimeException("Invoked Business Interface on Proxy was set to "
-// + invokedBusinessInterfaceClassName + ", but this could not be loaded by the "
-// + ClassLoader.class.getSimpleName() + " for " + this);
-// }
-
+ // if (method == null) throw new IllegalStateException("getInvokedBusinessInterface() being invoked outside of a business invocation");
+ // if (method.getName() == null || method.getName().equals("")) throw new IllegalStateException("getInvokedBusinessInterface() being invoked outside of a business invocation");
+
+ // String invokedBusinessInterfaceClassName = method.getActualClassName();
+ // Class<?> invokedBusinessInterface = null;
+ // try
+ // {
+ // invokedBusinessInterface = this.getClassloader().loadClass(invokedBusinessInterfaceClassName);
+ // }
+ // catch (ClassNotFoundException e)
+ // {
+ // throw new RuntimeException("Invoked Business Interface on Proxy was set to "
+ // + invokedBusinessInterfaceClassName + ", but this could not be loaded by the "
+ // + ClassLoader.class.getSimpleName() + " for " + this);
+ // }
+
return invokedInterface;
}
-
+
/**
* Provides implementation for this bean's EJB 2.1 Home.create() method
*
@@ -406,14 +420,14 @@
/*
* Initialize
*/
-
+
// Get the declaring class
Class<?> declaringClass = method.getDeclaringClass();
-
+
/*
* Test if declared by EJBObject/EJBLocalObject
*/
-
+
if (declaringClass.getName().equals(EJBObject.class.getName()))
return true;
@@ -432,11 +446,11 @@
*/
protected boolean isEjbObjectMethod(SerializableMethod method)
{
-
+
/*
* Initialize
*/
-
+
// Get the declaring class
Class<?> declaringClass = null;
String declaringClassName = method.getDeclaringClassName();
@@ -449,11 +463,11 @@
throw new RuntimeException("Invoked Method specifies a declaring class that could not be loaded by the "
+ ClassLoader.class.getSimpleName() + " for EJB " + this.getEjbName());
}
-
+
/*
* Test if declared by EJBObject/EJBLocalObject
*/
-
+
if (declaringClass.getName().equals(EJBObject.class.getName()))
return true;
@@ -496,7 +510,7 @@
// ------------------------------------------------------------------------------||
// Lifecycle Methods ------------------------------------------------------------||
// ------------------------------------------------------------------------------||
-
+
/**
* Lifecycle Start
*/
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-19 19:21:49 UTC (rev 86123)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/unit/PassivationDoesNotPreventNewActivityUnitTestCase.java 2009-03-19 19:40:55 UTC (rev 86124)
@@ -25,6 +25,8 @@
import static org.junit.Assert.assertFalse;
import java.io.Serializable;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
@@ -44,7 +46,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.spi.intf.SessionProxy;
+import org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandler;
import org.jboss.ejb3.stateful.StatefulContainer;
import org.jboss.logging.Logger;
import org.junit.After;
@@ -633,8 +635,9 @@
private Serializable getSessionId(MyStatefulLocal bean)
{
// Get our bean's Session ID
- SessionProxy sessionProxy = (SessionProxy) bean;
- Serializable sessionId = (Serializable) sessionProxy.getTarget();
+ InvocationHandler handler = Proxy.getInvocationHandler(bean);
+ SessionProxyInvocationHandler sHandler = (SessionProxyInvocationHandler) handler;
+ Serializable sessionId = (Serializable) sHandler.getTarget();
return sessionId;
}
}
Modified: projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/ProxyFactoryBase.java
===================================================================
--- projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/ProxyFactoryBase.java 2009-03-19 19:21:49 UTC (rev 86123)
+++ projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/ProxyFactoryBase.java 2009-03-19 19:40:55 UTC (rev 86124)
@@ -31,7 +31,6 @@
import org.jboss.aop.AspectManager;
import org.jboss.aop.advice.AdviceStack;
import org.jboss.aop.advice.Interceptor;
-import org.jboss.ejb3.proxy.spi.intf.EjbProxy;
import org.jboss.logging.Logger;
/**
@@ -141,9 +140,6 @@
// Initialize
Set<Class<?>> interfaces = new HashSet<Class<?>>();
- // Add all Proxy Interfaces
- interfaces.add(EjbProxy.class);
-
// Return
return interfaces;
}
Modified: projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/SessionProxyFactoryBase.java
===================================================================
--- projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/SessionProxyFactoryBase.java 2009-03-19 19:21:49 UTC (rev 86123)
+++ projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/SessionProxyFactoryBase.java 2009-03-19 19:40:55 UTC (rev 86124)
@@ -38,7 +38,6 @@
import org.jboss.ejb3.common.string.StringUtils;
import org.jboss.ejb3.proxy.impl.factory.ProxyFactoryBase;
import org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandler;
-import org.jboss.ejb3.proxy.spi.intf.SessionProxy;
import org.jboss.logging.Logger;
import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
@@ -449,28 +448,8 @@
public void stop() throws Exception
{
super.stop();
- //TODO
}
- /**
- * Returns Proxy interfaces common to all Proxies generated
- * by this ProxyFactory
- *
- * @return
- */
- @Override
- protected Set<Class<?>> getCommonProxyInterfaces()
- {
- // Initialize
- Set<Class<?>> interfaces = super.getCommonProxyInterfaces();
-
- // Add
- interfaces.add(SessionProxy.class);
-
- // Return
- return interfaces;
- }
-
// --------------------------------------------------------------------------------||
// Functional Methods -------------------------------------------------------------||
// --------------------------------------------------------------------------------||
Modified: projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/service/ServiceProxyFactoryBase.java
===================================================================
--- projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/service/ServiceProxyFactoryBase.java 2009-03-19 19:21:49 UTC (rev 86123)
+++ projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/service/ServiceProxyFactoryBase.java 2009-03-19 19:40:55 UTC (rev 86124)
@@ -28,7 +28,6 @@
import org.jboss.aop.Advisor;
import org.jboss.ejb3.proxy.impl.factory.ProxyFactoryBase;
import org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandler;
-import org.jboss.ejb3.proxy.spi.intf.ServiceProxy;
import org.jboss.logging.Logger;
import org.jboss.metadata.ejb.jboss.JBossServiceBeanMetaData;
@@ -204,25 +203,6 @@
//TODO
}
- /**
- * Returns Proxy interfaces common to all Proxies generated
- * by this ProxyFactory
- *
- * @return
- */
- @Override
- protected Set<Class<?>> getCommonProxyInterfaces()
- {
- // Initialize
- Set<Class<?>> interfaces = super.getCommonProxyInterfaces();
-
- // Add
- interfaces.add(ServiceProxy.class);
-
- // Return
- return interfaces;
- }
-
// --------------------------------------------------------------------------------||
// Functional Methods -------------------------------------------------------------||
// --------------------------------------------------------------------------------||
Modified: projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/handler/session/SessionProxyInvocationHandlerBase.java
===================================================================
--- projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/handler/session/SessionProxyInvocationHandlerBase.java 2009-03-19 19:21:49 UTC (rev 86123)
+++ projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/handler/session/SessionProxyInvocationHandlerBase.java 2009-03-19 19:40:55 UTC (rev 86124)
@@ -34,7 +34,6 @@
import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
import org.jboss.ejb3.proxy.impl.remoting.ProxyRemotingUtils;
import org.jboss.ejb3.proxy.spi.container.InvokableContext;
-import org.jboss.ejb3.proxy.spi.intf.SessionProxy;
import org.jboss.logging.Logger;
/**
@@ -66,10 +65,6 @@
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
*/
@@ -79,17 +74,10 @@
private static final SerializableMethod METHOD_HASH_CODE;
- private static final SerializableMethod METHOD_GET_TARGET;
-
- private static final SerializableMethod METHOD_SET_TARGET;
-
static
{
try
{
- 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);
@@ -166,11 +154,6 @@
*/
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
{
- // Precondition check
- assert proxy instanceof SessionProxy : this + " is eligible for handling " + SessionProxy.class.getName()
- + " invocations only";
- SessionProxy sessionProxy = (SessionProxy) proxy;
-
// Obtain an explicitly-specified actual class
String actualClass = this.getBusinessInterfaceType();
@@ -178,7 +161,7 @@
SerializableMethod invokedMethod = new SerializableMethod(method, actualClass);
// Use the overloaded implementation
- return this.invoke(sessionProxy, invokedMethod, args);
+ return this.invoke(proxy, invokedMethod, args);
}
/**
@@ -191,7 +174,7 @@
* @return
* @throws Throwable
*/
- public Object invoke(SessionProxy proxy, SerializableMethod method, Object[] args) throws Throwable
+ public Object invoke(Object proxy, SerializableMethod method, Object[] args) throws Throwable
{
// Attempt to handle directly
try
@@ -238,29 +221,12 @@
* @return
* @throws NotEligibleForDirectInvocationException
*/
- protected Object handleInvocationDirectly(SessionProxy proxy, Object[] args, Method invokedMethod)
+ 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();
- // getTarget
- if (invokedMethod.equals(METHOD_GET_TARGET.toMethod()))
- {
- return this.getTarget();
- }
-
- // setTarget
- if (invokedMethod.equals(METHOD_SET_TARGET.toMethod()))
- {
- assert args.length == 1 : "Expecting exactly one argument for invocation of " + METHOD_SET_TARGET;
- Object arg = args[0];
- assert arg instanceof Serializable : "Argument must be instance of " + Serializable.class.getName();
- Serializable id = (Serializable) arg;
- this.setTarget(id);
- return null;
- }
-
// equals
if (invokedMethod.equals(METHOD_EQUALS.toMethod()))
{
@@ -315,7 +281,7 @@
* @param args
* @return
*/
- protected boolean invokeEquals(SessionProxy proxy, Object argument)
+ protected boolean invokeEquals(Object proxy, Object argument)
{
/*
* EJB 3.0 Core Specification 3.4.5.1:
@@ -345,22 +311,22 @@
* or different session beans will not be equal."
*/
- // If the argument is not a proxy
- if (!(argument instanceof SessionProxy))
- {
- return false;
- }
+ // Ensure we've got j.l.r.Proxies
+ assert Proxy.isProxyClass(proxy.getClass()) && Proxy.isProxyClass(argument.getClass()) : "invokeEquals handles only "
+ + Proxy.class.getName();
- // 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 argument handler is not a SessionProxyInvocationHandler
if (!(argumentHandler instanceof SessionProxyInvocationHandler))
{
+ if (log.isTraceEnabled())
+ {
+ log.trace(argument + " and " + this + " are not equal; handler of argument is not a "
+ + SessionProxyInvocationHandler.class.getName());
+ }
return false;
}
@@ -377,12 +343,16 @@
}
// If target (Session ID) is specified, ensure equal
- Object proxyTarget = proxy.getTarget();
+ Object proxyTarget = proxySHandler.getTarget();
if (proxyTarget != null)
{
- Object argumentTarget = sArgument.getTarget();
+ Object argumentTarget = argumentSHandler.getTarget();
if (!proxyTarget.equals(argumentTarget))
{
+ if (log.isTraceEnabled())
+ {
+ log.trace("Not equal; different Session IDs - proxy== " + proxyTarget + ", argument==" + argumentTarget);
+ }
return false;
}
}
@@ -398,9 +368,10 @@
* @param proxy
* @return
*/
- protected int invokeHashCode(SessionProxy proxy)
+ protected int invokeHashCode(Object proxy)
{
// Get the InvocationHandler
+ assert Proxy.isProxyClass(proxy.getClass()) : "Unexpected proxy implementation";
InvocationHandler handler = Proxy.getInvocationHandler(proxy);
assert handler instanceof SessionProxyInvocationHandler;
SessionProxyInvocationHandler sHandler = (SessionProxyInvocationHandler) handler;
Modified: projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/invocation/InvokableContextStatefulRemoteProxyInvocationHack.java
===================================================================
--- projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/invocation/InvokableContextStatefulRemoteProxyInvocationHack.java 2009-03-19 19:21:49 UTC (rev 86123)
+++ projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/invocation/InvokableContextStatefulRemoteProxyInvocationHack.java 2009-03-19 19:40:55 UTC (rev 86124)
@@ -32,7 +32,6 @@
import org.jboss.ejb3.proxy.impl.remoting.SessionSpecRemotingMetadata;
import org.jboss.ejb3.proxy.impl.remoting.StatefulSessionRemotingMetadata;
import org.jboss.ejb3.proxy.spi.container.InvokableContext;
-import org.jboss.ejb3.proxy.spi.intf.SessionProxy;
import org.jboss.logging.Logger;
import org.jboss.remoting.InvokerLocator;
@@ -125,7 +124,7 @@
try
{
expectedInvokeMethod = InvokableContext.class.getDeclaredMethod("invoke", new Class<?>[]
- {SessionProxy.class, SerializableMethod.class, Object[].class});
+ {Object.class, SerializableMethod.class, Object[].class});
}
catch (NoSuchMethodException e)
{
Modified: projects/ejb3/trunk/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/common/container/SessionContainer.java
===================================================================
--- projects/ejb3/trunk/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/common/container/SessionContainer.java 2009-03-19 19:21:49 UTC (rev 86123)
+++ projects/ejb3/trunk/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/common/container/SessionContainer.java 2009-03-19 19:40:55 UTC (rev 86124)
@@ -22,7 +22,9 @@
package org.jboss.ejb3.test.proxy.impl.common.container;
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.Map;
import java.util.Set;
@@ -45,10 +47,10 @@
import org.jboss.ejb3.common.registrar.spi.Ejb3Registrar;
import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
import org.jboss.ejb3.common.registrar.spi.NotBoundException;
+import org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandler;
import org.jboss.ejb3.proxy.impl.jndiregistrar.JndiSessionRegistrarBase;
import org.jboss.ejb3.proxy.impl.remoting.StatefulSessionRemotingMetadata;
import org.jboss.ejb3.proxy.spi.container.InvokableContext;
-import org.jboss.ejb3.proxy.spi.intf.SessionProxy;
import org.jboss.logging.Logger;
import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
import org.jboss.metadata.ejb.spec.BusinessLocalsMetaData;
@@ -162,7 +164,7 @@
* @throws Throwable A possible exception thrown by the invocation
* @return
*/
- public Object invoke(SessionProxy proxy, SerializableMethod method, Object[] args) throws Throwable
+ public Object invoke(Object proxy, SerializableMethod method, Object[] args) throws Throwable
{
Method m = method.toMethod(this.getClassLoader());
@@ -270,10 +272,17 @@
}
//FIXME: Should be agnostic to Session IDs, SLSBs have none
- public Object invokeBean(SessionProxy proxy, Method method, Object args[]) throws Throwable
+ public Object invokeBean(Object proxy, Method method, Object args[]) throws Throwable
{
+ // Precondition checks
+ assert Proxy.isProxyClass(proxy.getClass()) : "Unexpected proxy, was expecting type " + Proxy.class.getName();
+ InvocationHandler handler = Proxy.getInvocationHandler(proxy);
+ assert handler instanceof SessionProxyInvocationHandler : InvocationHandler.class.getSimpleName()
+ + " must be of type " + SessionProxyInvocationHandler.class.getName();
+ SessionProxyInvocationHandler sHandler = (SessionProxyInvocationHandler) handler;
+
// Get the Target (Session ID)
- Object sessionId = proxy.getTarget();
+ Object sessionId = sHandler.getTarget();
// Get the appropriate instance
Object obj = this.getBeanInstance((Serializable) sessionId);
Modified: projects/ejb3/trunk/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/spec_3_4_5/unit/SfsbProxyEqualityTestCase.java
===================================================================
--- projects/ejb3/trunk/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/spec_3_4_5/unit/SfsbProxyEqualityTestCase.java 2009-03-19 19:21:49 UTC (rev 86123)
+++ projects/ejb3/trunk/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/spec_3_4_5/unit/SfsbProxyEqualityTestCase.java 2009-03-19 19:40:55 UTC (rev 86124)
@@ -22,6 +22,8 @@
package org.jboss.ejb3.test.proxy.impl.spec_3_4_5.unit;
import java.io.Serializable;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
import java.util.UUID;
import junit.framework.TestCase;
@@ -30,7 +32,7 @@
import org.jboss.ejb3.proxy.impl.factory.session.SessionProxyFactory;
import org.jboss.ejb3.proxy.impl.factory.session.stateful.StatefulSessionLocalProxyFactory;
import org.jboss.ejb3.proxy.impl.factory.session.stateful.StatefulSessionRemoteProxyFactory;
-import org.jboss.ejb3.proxy.spi.intf.SessionProxy;
+import org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandler;
import org.jboss.ejb3.test.proxy.impl.common.Utils;
import org.jboss.ejb3.test.proxy.impl.common.container.StatefulContainer;
import org.jboss.ejb3.test.proxy.impl.common.ejb.sfsb.MyStatefulBean;
@@ -129,9 +131,15 @@
*/
private void setSessionIdOnProxy(Object proxy, Serializable id)
{
+ // Precondition checks
+ assert Proxy.isProxyClass(proxy.getClass()) : "Unexpected proxy, was expecting type " + Proxy.class.getName();
+ InvocationHandler handler = Proxy.getInvocationHandler(proxy);
+ assert handler instanceof SessionProxyInvocationHandler : InvocationHandler.class.getSimpleName()
+ + " must be of type " + SessionProxyInvocationHandler.class.getName();
+ SessionProxyInvocationHandler sHandler = (SessionProxyInvocationHandler) handler;
+
// Get the InvocationHander for the Proxy
- SessionProxy handler = (SessionProxy) proxy;
- handler.setTarget(id);
+ sHandler.setTarget(id);
}
/**
Modified: projects/ejb3/trunk/proxy-spi/src/main/java/org/jboss/ejb3/proxy/spi/container/InvokableContext.java
===================================================================
--- projects/ejb3/trunk/proxy-spi/src/main/java/org/jboss/ejb3/proxy/spi/container/InvokableContext.java 2009-03-19 19:21:49 UTC (rev 86123)
+++ projects/ejb3/trunk/proxy-spi/src/main/java/org/jboss/ejb3/proxy/spi/container/InvokableContext.java 2009-03-19 19:40:55 UTC (rev 86124)
@@ -24,7 +24,6 @@
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.aop.joinpoint.InvocationResponse;
import org.jboss.ejb3.common.lang.SerializableMethod;
-import org.jboss.ejb3.proxy.spi.intf.SessionProxy;
/**
* InvokableContext
@@ -35,7 +34,9 @@
*
* @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
* @version $Revision: $
+ * @deprecated In favor of ejb3-endpoint
*/
+ at Deprecated
public interface InvokableContext
{
/**
@@ -48,7 +49,7 @@
* @throws Throwable A possible exception thrown by the invocation
* @return
*/
- Object invoke(SessionProxy proxy, SerializableMethod method, Object[] args) throws Throwable;
+ Object invoke(Object proxy, SerializableMethod method, Object[] args) throws Throwable;
/**
* Invocation point of entry for Remoting
Modified: projects/ejb3/trunk/proxy-spi/src/main/java/org/jboss/ejb3/proxy/spi/container/StatefulSessionFactory.java
===================================================================
--- projects/ejb3/trunk/proxy-spi/src/main/java/org/jboss/ejb3/proxy/spi/container/StatefulSessionFactory.java 2009-03-19 19:21:49 UTC (rev 86123)
+++ projects/ejb3/trunk/proxy-spi/src/main/java/org/jboss/ejb3/proxy/spi/container/StatefulSessionFactory.java 2009-03-19 19:40:55 UTC (rev 86124)
@@ -30,7 +30,9 @@
*
* @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
* @version $Revision: $
+ * @deprecated In favor of ejb3-endpoint
*/
+ at Deprecated
public interface StatefulSessionFactory
{
/**
More information about the jboss-cvs-commits
mailing list