[jboss-cvs] JBossAS SVN: r71286 - in projects/ejb3/trunk/core/src: main/java/org/jboss/ejb3/iiop and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Mar 26 00:46:40 EDT 2008
Author: ALRubinger
Date: 2008-03-26 00:46:40 -0400 (Wed, 26 Mar 2008)
New Revision: 71286
Added:
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/SpecificationInterfaceType.java
Modified:
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/ProxyFactoryHelper.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/iiop/IORFactory.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/BaseSessionProxyFactory.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/ProxyDeployer.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionContainer.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/BaseStatefulProxyFactory.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulHomeRemoteProxy.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulLocalProxyFactory.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/BaseStatelessProxyFactory.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessClusterProxyFactory.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessLocalProxyFactory.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/stateful/StatefulRemoteProxyFactory.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/statefulproxyfactoryoverride/StatefulRemoteProxyFactory.java
Log:
[EJBTHREE-1222] Make SFSB use different Proxies for business/EJBObject to avoid overlap of method signatures with different declared exceptions. Some unrelated code cleanup along the way.
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java 2008-03-26 04:21:36 UTC (rev 71285)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java 2008-03-26 04:46:40 UTC (rev 71286)
@@ -502,12 +502,12 @@
*/
private static boolean isCallable(Method method, Method other)
{
- if ((method.getDeclaringClass().isAssignableFrom(other.getDeclaringClass())) && (method.getName() == other.getName()))
+ if ((method.getDeclaringClass().isAssignableFrom(other.getDeclaringClass())) && (method.getName().equals(other.getName())))
{
if (!method.getReturnType().equals(other.getReturnType()))
return false;
- Class[] params1 = method.getParameterTypes();
- Class[] params2 = other.getParameterTypes();
+ Class<?>[] params1 = method.getParameterTypes();
+ Class<?>[] params2 = other.getParameterTypes();
if (params1.length == params2.length)
{
for (int i = 0; i < params1.length; i++)
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/ProxyFactoryHelper.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/ProxyFactoryHelper.java 2008-03-26 04:21:36 UTC (rev 71285)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/ProxyFactoryHelper.java 2008-03-26 04:46:40 UTC (rev 71286)
@@ -401,7 +401,7 @@
* @param businessInterface
* @return
*/
- public static String getJndiName(Container container, Class<?> businessInterface)
+ public static String getJndiName(EJBContainer container, Class<?> businessInterface)
{
assert container != null : "container is null";
assert businessInterface != null : "businessInterface is null";
@@ -836,10 +836,8 @@
public static String getHomeJndiName(EJBContainer container)
{
- // Initialize
-
// Use explicitly-specified binding, if defined
- RemoteHomeBinding binding = (RemoteHomeBinding) container.resolveAnnotation(RemoteHomeBinding.class);
+ RemoteHomeBinding binding = container.getAnnotation(RemoteHomeBinding.class);
if (binding != null)
return binding.jndiBinding();
@@ -850,10 +848,8 @@
public static String getLocalHomeJndiName(EJBContainer container)
{
- // Initialize
-
// Use explicitly-specified binding, if defined
- LocalHomeBinding binding = (LocalHomeBinding) container.resolveAnnotation(LocalHomeBinding.class);
+ LocalHomeBinding binding = container.getAnnotation(LocalHomeBinding.class);
if (binding != null)
return binding.jndiBinding();
@@ -864,15 +860,13 @@
public static String getLocalJndiName(EJBContainer container)
{
- return getLocalJndiName(container, true);
+ return ProxyFactoryHelper.getLocalJndiName(container, true);
}
private static String getLocalJndiName(EJBContainer container, boolean conflictCheck)
{
- // Initialize
-
// See if local binding is explicitly-defined
- LocalBinding localBinding = (LocalBinding) container.resolveAnnotation(LocalBinding.class);
+ LocalBinding localBinding = container.getAnnotation(LocalBinding.class);
// If none specified
if (localBinding == null)
@@ -881,9 +875,13 @@
String name = ProxyFactoryHelper.getJndiBindingPolicy(container).getDefaultLocalJndiName(
ProxyFactoryHelper.getDeploymentSummaryFromContainer(container));
- if (conflictCheck)
- checkForJndiNamingConflict(container);
+ // If we should check for naming conflict
+ if (conflictCheck){
+ // Check
+ ProxyFactoryHelper.checkForJndiNamingConflict(container);
+ }
+ // Return
return name;
}
// Local Binding was explicitly-specified, use it
@@ -893,21 +891,21 @@
}
}
- public static String getRemoteJndiName(EJBContainer container)
+ public static String getRemoteBusinessJndiName(EJBContainer container)
{
- return getRemoteJndiName(container, true);
+ return ProxyFactoryHelper.getRemoteBusinessJndiName(container, true);
}
- public static String getRemoteJndiName(EJBContainer container, boolean check)
+ public static String getRemoteBusinessJndiName(EJBContainer container, boolean check)
{
- RemoteBinding binding = (RemoteBinding) container.resolveAnnotation(RemoteBinding.class);
+ RemoteBinding binding = container.getAnnotation(RemoteBinding.class);
- return getRemoteJndiName(container, binding);
+ return ProxyFactoryHelper.getRemoteBusinessJndiName(container, binding);
}
private static void checkForJndiNamingConflict(EJBContainer container)
{
- if (container.resolveAnnotation(Local.class) != null)
+ if (container.getAnnotation(Local.class) != null)
{
Ejb3DeploymentSummary summary = ProxyFactoryHelper.getDeploymentSummaryFromContainer(container);
String localJndiName = ProxyFactoryHelper.getJndiBindingPolicy(container).getDefaultLocalJndiName(summary);
@@ -922,33 +920,51 @@
}
}
- private static String getRemoteJndiName(EJBContainer container, RemoteBinding binding)
+ private static String getRemoteBusinessJndiName(EJBContainer container, RemoteBinding binding)
{
- return getRemoteJndiName(container, binding, true);
+ return ProxyFactoryHelper.getRemoteBusinessJndiName(container, binding, true);
}
- public static String getRemoteJndiName(EJBContainer container, RemoteBinding binding, boolean conflictCheck)
+ public static String getRemoteBusinessJndiName(EJBContainer container, RemoteBinding binding, boolean conflictCheck)
{
+ // Initialize
String jndiName = null;
- if (binding == null || binding.jndiBinding() == null || binding.jndiBinding().equals(""))
+
+ // If binding is not defined
+ if (binding == null || binding.jndiBinding() == null || binding.jndiBinding().trim().equals(""))
{
- jndiName = getDefaultRemoteJndiName(container);
+ // Use the default
+ jndiName = getDefaultRemoteBusinessJndiName(container);
+ // If we should check for a naming conflict
if (conflictCheck)
- checkForJndiNamingConflict(container);
+ {
+ // Check
+ ProxyFactoryHelper.checkForJndiNamingConflict(container);
+ }
+
}
+ // Binding is explicitly-defined
else
{
+ // use it
jndiName = binding.jndiBinding();
}
+ // Return
return jndiName;
}
- public static String getDefaultRemoteJndiName(EJBContainer container)
+ public static String getDefaultRemoteBusinessJndiName(EJBContainer container)
{
- return ProxyFactoryHelper.getJndiBindingPolicy(container).getDefaultRemoteJndiName(
- ProxyFactoryHelper.getDeploymentSummaryFromContainer(container));
+ // Obtain JNDI Binding Policy
+ DefaultJndiBindingPolicy policy = ProxyFactoryHelper.getJndiBindingPolicy(container);
+
+ // Obtain Deployment Summary
+ Ejb3DeploymentSummary summary = ProxyFactoryHelper.getDeploymentSummaryFromContainer(container);
+
+ // Return the policy's default remote name for this summary
+ return policy.getDefaultRemoteJndiName(summary);
}
/**
@@ -958,23 +974,36 @@
* @author ALR
* @return
*/
- private static DefaultJndiBindingPolicy getJndiBindingPolicy(Container container)
+ private static DefaultJndiBindingPolicy getJndiBindingPolicy(EJBContainer container)
{
- EJBContainer ejbContainer = (EJBContainer) container;
- JndiBindingPolicy bindingPolicy = ejbContainer.getAnnotation(JndiBindingPolicy.class);
+ // Attempt to obtain the binding policy from annotation repo
+ JndiBindingPolicy bindingPolicy = container.getAnnotation(JndiBindingPolicy.class);
+
+ // Initialize
Class<? extends DefaultJndiBindingPolicy> policy = null;
- if (bindingPolicy != null)
+
+ // If policy is defined
+ if (bindingPolicy != null){
+ // Use it
policy = bindingPolicy.policy();
+ }
+ // No policy defined
else
{
+ // Use default policy
Class<? extends DefaultJndiBindingPolicy> policyClass = PackagingBasedJndiBindingPolicy.class;
+ // Log warning
log.warn("No default JNDI Binding Policy Defined (see ejb3-interceptors-aop.xml for example); defaulting to "
+ policyClass.getName());
policy = policyClass;
}
+
+ // Log
log.debug("Obtaining JNDI name from policy " + policy.getName());
+
try
{
+ // Instanciate the policy and return
return policy.newInstance();
}
catch (InstantiationException e)
@@ -987,23 +1016,22 @@
}
}
- private static Ejb3DeploymentSummary getDeploymentSummaryFromContainer(Container container)
+ private static Ejb3DeploymentSummary getDeploymentSummaryFromContainer(EJBContainer container)
{
// Construct Deployment Summary
Ejb3DeploymentSummary summary = new Ejb3DeploymentSummary();
summary.setEjbName(container.getEjbName());
summary.setService(container instanceof ServiceContainer);
summary.setStateful(container instanceof StatefulContainer);
- summary.setDeploymentName(((EJBContainer) container).getDeployment().getName());
+ summary.setDeploymentName(container.getDeployment().getName());
summary.setBeanClass(container.getBeanClass());
- if (container instanceof EJBContainer)
+ DeploymentScope scope = container.getDeployment().getEar();
+ if (scope != null)
{
- DeploymentScope scope = ((EJBContainer) container).getDeployment().getEar();
- if (scope != null)
- {
- summary.setDeploymentScopeBaseName(scope.getBaseName());
- }
+ summary.setDeploymentScopeBaseName(scope.getBaseName());
}
+
+ // Return
return summary;
}
}
\ No newline at end of file
Added: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/SpecificationInterfaceType.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/SpecificationInterfaceType.java (rev 0)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/SpecificationInterfaceType.java 2008-03-26 04:46:40 UTC (rev 71286)
@@ -0,0 +1,34 @@
+/*
+ * 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;
+
+/**
+ * SpecificationInterfaceType
+ *
+ * Represents a Specification interface type supported by EJB3
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public enum SpecificationInterfaceType {
+ EJB30_BUSINESS,EJB21
+}
Property changes on: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/SpecificationInterfaceType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/iiop/IORFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/iiop/IORFactory.java 2008-03-26 04:21:36 UTC (rev 71285)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/iiop/IORFactory.java 2008-03-26 04:46:40 UTC (rev 71286)
@@ -190,7 +190,7 @@
private String getJndiName()
{
- return ProxyFactoryHelper.getDefaultRemoteJndiName(container);
+ return ProxyFactoryHelper.getDefaultRemoteBusinessJndiName(container);
}
private String getServantName()
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/BaseSessionProxyFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/BaseSessionProxyFactory.java 2008-03-26 04:21:36 UTC (rev 71285)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/BaseSessionProxyFactory.java 2008-03-26 04:46:40 UTC (rev 71286)
@@ -114,7 +114,7 @@
HomeHandleImpl homeHandle = null;
- RemoteBinding remoteBindingAnnotation = (RemoteBinding)ejbContainer.resolveAnnotation(RemoteBinding.class);
+ RemoteBinding remoteBindingAnnotation = ejbContainer.getAnnotation(RemoteBinding.class);
if (remoteBindingAnnotation != null)
homeHandle = new HomeHandleImpl(ProxyFactoryHelper.getHomeJndiName(container));
@@ -123,20 +123,20 @@
protected EJBMetaData getEjbMetaData()
{
- Class remote = null;
- Class home = null;
- Class pkClass = Object.class;
+ Class<?> remote = null;
+ Class<?> home = null;
+ Class<?> pkClass = Object.class;
HomeHandleImpl homeHandle = null;
EJBContainer ejbContainer = (EJBContainer)container;
- Remote remoteAnnotation = (Remote)ejbContainer.resolveAnnotation(Remote.class);
+ Remote remoteAnnotation = ejbContainer.getAnnotation(Remote.class);
if (remoteAnnotation != null)
remote = remoteAnnotation.value()[0];
- RemoteHome homeAnnotation = (RemoteHome)ejbContainer.resolveAnnotation(RemoteHome.class);
+ RemoteHome homeAnnotation = ejbContainer.getAnnotation(RemoteHome.class);
if (homeAnnotation != null)
home = homeAnnotation.value();
- RemoteBinding remoteBindingAnnotation = (RemoteBinding)ejbContainer.resolveAnnotation(RemoteBinding.class);
+ RemoteBinding remoteBindingAnnotation = ejbContainer.getAnnotation(RemoteBinding.class);
if (remoteBindingAnnotation != null)
homeHandle = new HomeHandleImpl(remoteBindingAnnotation.jndiBinding());
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/ProxyDeployer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/ProxyDeployer.java 2008-03-26 04:21:36 UTC (rev 71285)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/ProxyDeployer.java 2008-03-26 04:46:40 UTC (rev 71286)
@@ -133,7 +133,8 @@
{
if(binding.jndiBinding().length() == 0)
{
- return new RemoteBindingImpl(ProxyFactoryHelper.getDefaultRemoteJndiName(container), binding.interceptorStack(), binding.clientBindUrl(), binding.factory());
+ return new RemoteBindingImpl(ProxyFactoryHelper.getDefaultRemoteBusinessJndiName(container), binding
+ .interceptorStack(), binding.clientBindUrl(), binding.factory());
}
return binding;
}
@@ -150,7 +151,7 @@
if (ProxyFactoryHelper.getRemoteAndBusinessRemoteInterfaces(container).length > 0)
{
log.debug("there is remote interfaces for " + container.getEjbName());
- String jndiName = ProxyFactoryHelper.getDefaultRemoteJndiName(container);
+ String jndiName = ProxyFactoryHelper.getDefaultRemoteBusinessJndiName(container);
log.debug("default remote binding has jndiName of " + jndiName);
String uri = ""; // use the default
RemoteBinding[] list = {new RemoteBindingImpl(jndiName, "", uri, RemoteBindingDefaults.PROXY_FACTORY_DEFAULT)};
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionContainer.java 2008-03-26 04:21:36 UTC (rev 71285)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionContainer.java 2008-03-26 04:46:40 UTC (rev 71286)
@@ -29,6 +29,7 @@
import java.util.List;
import java.util.Map;
+import javax.ejb.EJBLocalObject;
import javax.ejb.EJBObject;
import javax.ejb.Handle;
import javax.ejb.LocalHome;
@@ -355,10 +356,10 @@
protected boolean isEJBObjectMethod(Method method)
{
- if (method.getDeclaringClass().getName().equals("javax.ejb.EJBObject"))
+ if (method.getDeclaringClass().getName().equals(EJBObject.class.getName()))
return true;
- if (method.getDeclaringClass().getName().equals("javax.ejb.EJBLocalObject"))
+ if (method.getDeclaringClass().getName().equals(EJBLocalObject.class.getName()))
return true;
return false;
@@ -366,7 +367,7 @@
protected boolean isHandleMethod(Method method)
{
- if (method.getDeclaringClass().getName().equals("javax.ejb.Handle"))
+ if (method.getDeclaringClass().getName().equals(Handle.class.getName()))
return true;
return false;
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/BaseStatefulProxyFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/BaseStatefulProxyFactory.java 2008-03-26 04:21:36 UTC (rev 71285)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/BaseStatefulProxyFactory.java 2008-03-26 04:46:40 UTC (rev 71286)
@@ -27,6 +27,8 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
+import java.util.HashSet;
+import java.util.Set;
import javax.naming.Context;
import javax.naming.Name;
@@ -34,8 +36,12 @@
import javax.naming.RefAddr;
import javax.naming.Reference;
import javax.naming.StringRefAddr;
+
+import org.jboss.ejb3.JBossProxy;
import org.jboss.ejb3.JndiProxyFactory;
import org.jboss.ejb3.ProxyFactory;
+import org.jboss.ejb3.ProxyFactoryHelper;
+import org.jboss.ejb3.SpecificationInterfaceType;
import org.jboss.ejb3.session.SessionContainer;
import org.jboss.logging.Logger;
import org.jboss.util.naming.Util;
@@ -48,11 +54,27 @@
*/
public abstract class BaseStatefulProxyFactory extends org.jboss.ejb3.session.BaseSessionProxyFactory implements ProxyFactory
{
+ // Class Members
+
@SuppressWarnings("unused")
private static final Logger log = Logger.getLogger(BaseStatefulProxyFactory.class);
+
+ protected static enum ProxyAccessType{
+ REMOTE,LOCAL;
+ }
// protected Class proxyClass;
- private Constructor proxyConstructor;
+
+ /**
+ * Proxy Constructor for the Business Interfaces' Proxy
+ */
+ private Constructor<?> businessProxyConstructor;
+
+ /**
+ * Proxy Constructor for the EJBObject/EJBLocalObject Proxy
+ */
+ private Constructor<?> ejb21ProxyConstructor;
+
// protected Context proxyFactoryContext;
protected String jndiName;
@@ -75,11 +97,43 @@
this.jndiName = jndiName;
}
- protected Object constructProxy(InvocationHandler handler)
+ protected Object constructBusinessProxy(InvocationHandler handler)
{
+ // Return
+ return this.constructProxy(handler, SpecificationInterfaceType.EJB30_BUSINESS);
+ }
+
+ protected Object constructEjb21Proxy(InvocationHandler handler)
+ {
+ // Return
+ return this.constructProxy(handler, SpecificationInterfaceType.EJB21);
+ }
+
+ /**
+ * Construct a new Proxy of the specified type using the
+ * specified handler as argument to the Constructor
+ *
+ * @param handler
+ * @param specType
+ * @return
+ */
+ private Object constructProxy(InvocationHandler handler, SpecificationInterfaceType specType)
+ {
+ // Initialize
+ Object obj = null;
+
try
{
- return proxyConstructor.newInstance(handler);
+ // Business Proxy
+ if (specType.equals(SpecificationInterfaceType.EJB30_BUSINESS))
+ {
+ obj = this.businessProxyConstructor.newInstance(handler);
+ }
+ // EJBObject/EJBLocalObject
+ else if (specType.equals(SpecificationInterfaceType.EJB21))
+ {
+ obj = this.ejb21ProxyConstructor.newInstance(handler);
+ }
}
catch (InstantiationException e)
{
@@ -92,18 +146,48 @@
catch (InvocationTargetException e)
{
Throwable t = e.getTargetException();
- if(t instanceof RuntimeException)
+ if (t instanceof RuntimeException)
throw (RuntimeException) t;
throw new RuntimeException(t);
}
+
+ // Ensure Proxy object was created
+ assert obj != null : "Proxy Object must not be null";
+
+ // Return
+ return obj;
}
+
public void init() throws Exception
{
- Class[] interfaces = getInterfaces();
- Class proxyClass = java.lang.reflect.Proxy.getProxyClass(getContainer().getBeanClass().getClassLoader(), interfaces);
- proxyConstructor = proxyClass.getConstructor(InvocationHandler.class);
+ // Ensure EJB2.1 View is Complete
+ this.ensureEjb21ViewComplete();
+
+ // Create the Proxy Constructors
+ this.createProxyConstructors();
}
+
+ /**
+ * Creates the Proxy constructors
+ */
+ protected void createProxyConstructors() throws Exception
+ {
+ // Obtain interfaces to be used in the proxies
+ Class<?>[] businessInterfaces = this.getInterfacesForBusinessProxy();
+ Class<?>[] ejb21Interfaces = this.getInterfacesForEjb21Proxy();
+
+ // Obtain this bean class' CL
+ ClassLoader cl = this.getContainer().getBeanClass().getClassLoader();
+
+ // Create proxy classes
+ Class<?> businessProxyClass = java.lang.reflect.Proxy.getProxyClass(cl, businessInterfaces);
+ Class<?> ejb21ProxyClass = java.lang.reflect.Proxy.getProxyClass(cl, ejb21Interfaces);
+
+ // Obtain and set the proxy constructors
+ this.businessProxyConstructor = businessProxyClass.getConstructor(InvocationHandler.class);
+ this.ejb21ProxyConstructor = ejb21ProxyClass.getConstructor(InvocationHandler.class);
+ }
public void start() throws Exception
{
@@ -121,19 +205,108 @@
Util.rebind(ctx, atom, ref);
} catch (NamingException e)
{
- NamingException namingException = new NamingException("Could not bind stateful proxy with ejb name " + getContainer().getEjbName() + " into JNDI under jndiName: " + ctx.getNameInNamespace() + "/" + atom);
+ NamingException namingException = new NamingException("Could not bind stateful proxy with ejb name "
+ + getContainer().getEjbName() + " into JNDI under jndiName: " + ctx.getNameInNamespace() + "/" + atom);
namingException.setRootCause(e);
throw namingException;
}
}
+
+ /**
+ * Obtains interfaces to be used in the business proxy
+ *
+ * @return
+ */
+ protected Class<?>[] getInterfacesForBusinessProxy()
+ {
+ return this.getInterfacesForProxy(this.getProxyAccessType(), SpecificationInterfaceType.EJB30_BUSINESS);
+ }
+
+ /**
+ * Obtains interfaces to be used in the EJB21 proxy
+ *
+ * @return
+ */
+ protected Class<?>[] getInterfacesForEjb21Proxy()
+ {
+ return this.getInterfacesForProxy(this.getProxyAccessType(), SpecificationInterfaceType.EJB21);
+ }
+
+ /**
+ * Returns an array of interfaces to be used for the proxy;
+ * the proxy type will be dependent on
+ *
+ * @param business
+ * @return
+ */
+ private Class<?>[] getInterfacesForProxy(ProxyAccessType accessType, SpecificationInterfaceType specType)
+ {
+ // Initialize
+ Set<Class<?>> interfaces = new HashSet<Class<?>>();
+ SessionContainer container = this.getContainer();
+
+ // Initialize array of interfaces
+ Class<?>[] intfs = null;
+
+ // If Local
+ if (accessType.equals(ProxyAccessType.LOCAL))
+ {
+
+ // If business
+ if (specType.equals(SpecificationInterfaceType.EJB30_BUSINESS))
+ {
+ intfs = ProxyFactoryHelper.getLocalBusinessInterfaces(container);
+ }
+ // If EJBLocalObject
+ else
+ {
+ intfs = ProxyFactoryHelper.getLocalInterfaces(container);
+ }
+ }
+ // If remote
+ else
+ {
+ // If business
+ if (specType.equals(SpecificationInterfaceType.EJB30_BUSINESS))
+ {
+ intfs = ProxyFactoryHelper.getRemoteBusinessInterfaces(container);
+ }
+ // If EJBObject
+ else
+ {
+ intfs = ProxyFactoryHelper.getRemoteInterfaces(container);
+ }
+ }
+
+ // Add all interfaces
+ for (Class<?> interfaze : intfs)
+ {
+ interfaces.add(interfaze);
+ }
+
+ // Add JBossProxy
+ interfaces.add(JBossProxy.class);
+
+ // Return
+ return interfaces.toArray(new Class[]
+ {});
+ }
+
public void stop() throws Exception
{
Util.unbind(getContainer().getInitialContext(), jndiName);
}
+
+ /**
+ * Defines the access type for this Proxies created by this Factory
+ *
+ * @return
+ */
+ protected abstract ProxyAccessType getProxyAccessType();
+
+ protected abstract void ensureEjb21ViewComplete();
- protected abstract Class<?>[] getInterfaces();
-
protected final void initializeJndiName() {};
@Override
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java 2008-03-26 04:21:36 UTC (rev 71285)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java 2008-03-26 04:46:40 UTC (rev 71286)
@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.List;
+import javax.ejb.RemoteHome;
import javax.naming.NamingException;
import org.jboss.aop.AspectManager;
@@ -31,7 +32,6 @@
import org.jboss.aop.advice.AdviceStack;
import org.jboss.aspects.remoting.FamilyWrapper;
import org.jboss.aspects.remoting.Remoting;
-import org.jboss.ejb3.JBossProxy;
import org.jboss.ejb3.ProxyFactory;
import org.jboss.ejb3.ProxyFactoryHelper;
import org.jboss.ejb3.annotation.Clustered;
@@ -48,8 +48,8 @@
import org.jboss.ha.framework.interfaces.HAPartition;
import org.jboss.ha.framework.server.HATarget;
import org.jboss.logging.Logger;
+import org.jboss.remoting.InvokerLocator;
import org.jboss.util.naming.Util;
-import org.jboss.remoting.InvokerLocator;
/**
@@ -85,14 +85,29 @@
this.binding = binding;
this.clustered = clustered;
}
+
+ /**
+ * Defines the access type for this Proxies created by this Factory
+ *
+ * @return
+ */
+ @Override
+ protected ProxyAccessType getProxyAccessType(){
+ return ProxyAccessType.REMOTE;
+ }
+
+ protected void ensureEjb21ViewComplete()
+ {
+ // Obtain Container
+ SessionContainer container = this.getContainer();
+
+ // Obtain @RemoteHome
+ RemoteHome remoteHome = container.getAnnotation(RemoteHome.class);
- protected Class[] getInterfaces()
- {
- Class[] remoteInterfaces = ProxyFactoryHelper.getRemoteAndBusinessRemoteInterfaces(getContainer());
- Class[] interfaces = new Class[remoteInterfaces.length + 1];
- System.arraycopy(remoteInterfaces, 0, interfaces, 0, remoteInterfaces.length);
- interfaces[remoteInterfaces.length] = JBossProxy.class;
- return interfaces;
+ // Ensure that if EJB 2.1 Components are defined, they're complete
+ this.ensureEjb21ViewComplete(remoteHome == null ? null : remoteHome.value(), ProxyFactoryHelper
+ .getRemoteInterfaces(container));
+
}
public void start() throws Exception
@@ -132,7 +147,7 @@
super.start();
- Class[] interfaces = {ProxyFactory.class};
+ Class<?>[] interfaces = {ProxyFactory.class};
String targetId = getTargetId();
Object factoryProxy = Remoting.createPojiProxy(targetId, interfaces, ProxyFactoryHelper.getClientBindUrl(binding));
try
@@ -158,8 +173,8 @@
}
AdviceStack stack = AspectManager.instance().getAdviceStack(stackName);
String partitionName = ((SessionContainer) getContainer()).getPartitionName();
- return constructProxy(new StatefulClusteredProxy(getContainer(), stack.createInterceptors(getContainer().getAdvisor(), null),
- wrapper, lbPolicy, partitionName));
+ return constructBusinessProxy(new StatefulClusteredProxy(getContainer(), stack.createInterceptors(this.getContainer()
+ .getAdvisor(), null), wrapper, lbPolicy, partitionName));
}
public Object createProxy(Object id)
@@ -180,7 +195,7 @@
protected StatefulHandleImpl getHandle()
{
StatefulHandleImpl handle = new StatefulHandleImpl();
- RemoteBinding remoteBinding = (RemoteBinding) getContainer().resolveAnnotation(RemoteBinding.class);
+ RemoteBinding remoteBinding = this.getContainer().getAnnotation(RemoteBinding.class);
if (remoteBinding != null)
handle.jndiName = remoteBinding.jndiBinding();
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java 2008-03-26 04:21:36 UTC (rev 71285)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java 2008-03-26 04:46:40 UTC (rev 71286)
@@ -689,12 +689,12 @@
initParameterValues = args;
}
- LocalBinding binding = (LocalBinding) resolveAnnotation(LocalBinding.class);
+ LocalBinding binding = this.getAnnotation(LocalBinding.class);
StatefulLocalProxyFactory factory = new StatefulLocalProxyFactory(this, binding);
factory.init();
- Object proxy = factory.createProxy(initParameterTypes,
+ Object proxy = factory.createEjb21Proxy(initParameterTypes,
initParameterValues);
return proxy;
@@ -748,7 +748,7 @@
Method unadvisedMethod = info.getUnadvisedMethod();
if (unadvisedMethod.getName().startsWith("create"))
{
- Class[] initParameterTypes =
+ Class<?>[] initParameterTypes =
{};
Object[] initParameterValues =
{};
@@ -759,11 +759,11 @@
}
RemoteBinding binding = null;
- RemoteBindings bindings = (RemoteBindings) resolveAnnotation(RemoteBindings.class);
+ RemoteBindings bindings = this.getAnnotation(RemoteBindings.class);
if (bindings != null)
binding = bindings.value()[0];
else
- binding = (RemoteBinding) resolveAnnotation(RemoteBinding.class);
+ binding = this.getAnnotation(RemoteBinding.class);
StatefulContainerInvocation newStatefulInvocation = buildNewInvocation(
info, statefulInvocation, initParameterTypes,
@@ -774,9 +774,9 @@
Object proxy = null;
if (newStatefulInvocation.getId() != null)
- proxy = factory.createProxy(newStatefulInvocation.getId());
+ proxy = factory.createEjb21Proxy(newStatefulInvocation.getId());
else
- proxy = factory.createProxy();
+ proxy = factory.createEjb21Proxy();
InvocationResponse response = marshallResponse(statefulInvocation, proxy, newStatefulInvocation.getResponseContextInfo());
if (newStatefulInvocation.getId() != null)
@@ -794,18 +794,18 @@
}
else if (unadvisedMethod.getName().equals("getEJBMetaData"))
{
- Class remote = null;
- Class home = null;
- Class pkClass = Object.class;
+ Class<?> remote = null;
+ Class<?> home = null;
+ Class<?> pkClass = Object.class;
HomeHandleImpl homeHandle = null;
- Remote remoteAnnotation = (Remote) resolveAnnotation(Remote.class);
+ Remote remoteAnnotation = this.getAnnotation(Remote.class);
if (remoteAnnotation != null)
remote = remoteAnnotation.value()[0];
- RemoteHome homeAnnotation = (RemoteHome) resolveAnnotation(RemoteHome.class);
+ RemoteHome homeAnnotation = this.getAnnotation(RemoteHome.class);
if (homeAnnotation != null)
home = homeAnnotation.value();
- RemoteBinding remoteBindingAnnotation = (RemoteBinding) resolveAnnotation(RemoteBinding.class);
+ RemoteBinding remoteBindingAnnotation = this.getAnnotation(RemoteBinding.class);
if (remoteBindingAnnotation != null)
homeHandle = new HomeHandleImpl(remoteBindingAnnotation
.jndiBinding());
@@ -820,7 +820,7 @@
{
HomeHandleImpl homeHandle = null;
- RemoteBinding remoteBindingAnnotation = (RemoteBinding) resolveAnnotation(RemoteBinding.class);
+ RemoteBinding remoteBindingAnnotation = this.getAnnotation(RemoteBinding.class);
if (remoteBindingAnnotation != null)
homeHandle = new HomeHandleImpl(remoteBindingAnnotation
.jndiBinding());
@@ -846,7 +846,7 @@
StatefulHandleImpl handle = new StatefulHandleImpl();
handle.id = newStatefulInvocation.getId();
- RemoteBinding remoteBinding = (RemoteBinding) resolveAnnotation(RemoteBinding.class);
+ RemoteBinding remoteBinding = this.getAnnotation(RemoteBinding.class);
if (remoteBinding != null)
handle.jndiName = remoteBinding.jndiBinding();
InvocationResponse response = marshallResponse(statefulInvocation, handle, null);
@@ -861,7 +861,7 @@
catch(NoSuchEJBException e)
{
if(log.isTraceEnabled())
- log.trace("Throwing NoSuchObjectException", e);
+ log.trace("Throwing " + e.getClass().getName(), e);
throw new NoSuchObjectException(e.getMessage());
}
@@ -872,7 +872,7 @@
{
HomeHandleImpl homeHandle = null;
- RemoteBinding remoteBindingAnnotation = (RemoteBinding) resolveAnnotation(RemoteBinding.class);
+ RemoteBinding remoteBindingAnnotation = this.getAnnotation(RemoteBinding.class);
if (remoteBindingAnnotation != null)
homeHandle = new HomeHandleImpl(ProxyFactoryHelper.getHomeJndiName(this));
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulHomeRemoteProxy.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulHomeRemoteProxy.java 2008-03-26 04:21:36 UTC (rev 71285)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulHomeRemoteProxy.java 2008-03-26 04:46:40 UTC (rev 71286)
@@ -22,8 +22,10 @@
package org.jboss.ejb3.stateful;
import java.lang.reflect.Method;
+
import javax.ejb.EJBMetaData;
import javax.ejb.HomeHandle;
+
import org.jboss.aop.Dispatcher;
import org.jboss.aop.advice.Interceptor;
import org.jboss.aop.util.MethodHashing;
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulLocalProxyFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulLocalProxyFactory.java 2008-03-26 04:21:36 UTC (rev 71285)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulLocalProxyFactory.java 2008-03-26 04:46:40 UTC (rev 71286)
@@ -32,12 +32,13 @@
import javax.ejb.LocalHome;
import javax.naming.NamingException;
-import org.jboss.ejb3.EJBContainer;
import org.jboss.ejb3.Ejb3Registry;
import org.jboss.ejb3.JBossProxy;
import org.jboss.ejb3.ProxyFactoryHelper;
+import org.jboss.ejb3.SpecificationInterfaceType;
import org.jboss.ejb3.annotation.LocalBinding;
import org.jboss.ejb3.session.SessionContainer;
+import org.jboss.ejb3.stateful.BaseStatefulProxyFactory.ProxyAccessType;
import org.jboss.util.naming.Util;
@@ -64,37 +65,28 @@
super(container, binding.jndiBinding());
}
- protected Class<?>[] getInterfaces()
- {
- SessionContainer statefulContainer = (SessionContainer) getContainer();
- LocalHome localHome = (LocalHome) statefulContainer.resolveAnnotation(LocalHome.class);
+ /**
+ * Defines the access type for this Proxies created by this Factory
+ *
+ * @return
+ */
+ @Override
+ protected ProxyAccessType getProxyAccessType(){
+ return ProxyAccessType.LOCAL;
+ }
+
+ protected void ensureEjb21ViewComplete()
+ {
+ // Obtain Container
+ SessionContainer container = this.getContainer();
+
+ // Obtain @LocalHome
+ LocalHome localHome = container.getAnnotation(LocalHome.class);
- boolean bindTogether = false;
-
- if (localHome != null && bindHomeAndBusinessTogether(statefulContainer))
- bindTogether = true;
-
- // Obtain all local interfaces
- Set<Class<?>> localInterfaces = new HashSet<Class<?>>();
- localInterfaces.addAll(Arrays.asList(ProxyFactoryHelper.getLocalAndBusinessLocalInterfaces(getContainer())));
-
// Ensure that if EJB 2.1 Components are defined, they're complete
this.ensureEjb21ViewComplete(localHome == null ? null : localHome.value(), ProxyFactoryHelper
- .getLocalInterfaces(getContainer()));
+ .getLocalInterfaces(container));
- // Add JBossProxy
- localInterfaces.add(JBossProxy.class);
-
- // If binding along w/ home, add home
- if (bindTogether)
- {
- localInterfaces.add(localHome.value());
- }
-
- // Return
- return localInterfaces.toArray(new Class<?>[]
- {});
-
}
protected boolean bindHomeAndBusinessTogether(SessionContainer container)
@@ -112,19 +104,23 @@
}
catch (NamingException e)
{
- NamingException namingException = new NamingException("Could not bind stateful local proxy with ejb name " + getContainer().getEjbName() + " into JNDI under jndiName: " + getContainer().getInitialContext().getNameInNamespace() + "/" + jndiName + PROXY_FACTORY_NAME);
+ NamingException namingException = new NamingException("Could not bind stateful local proxy with ejb name "
+ + getContainer().getEjbName() + " into JNDI under jndiName: "
+ + getContainer().getInitialContext().getNameInNamespace() + "/" + jndiName + PROXY_FACTORY_NAME);
namingException.setRootCause(e);
throw namingException;
}
SessionContainer statefulContainer = (SessionContainer) getContainer();
- LocalHome localHome = (LocalHome) ((EJBContainer) getContainer()).resolveAnnotation(LocalHome.class);
+ LocalHome localHome = this.getContainer().getAnnotation(LocalHome.class);
if (localHome != null && !bindHomeAndBusinessTogether(statefulContainer))
{
- Class[] interfaces = {localHome.value()};
+ Class<?>[] interfaces =
+ {localHome.value()};
Object homeProxy = java.lang.reflect.Proxy.newProxyInstance(getContainer().getBeanClass().getClassLoader(),
- interfaces, new StatefulLocalHomeProxy(getContainer()));
- Util.rebind(getContainer().getInitialContext(), ProxyFactoryHelper.getLocalHomeJndiName(getContainer()), homeProxy);
+ interfaces, new StatefulLocalHomeProxy(getContainer()));
+ Util.rebind(getContainer().getInitialContext(), ProxyFactoryHelper.getLocalHomeJndiName(getContainer()),
+ homeProxy);
}
}
@@ -133,7 +129,7 @@
super.stop();
Util.unbind(getContainer().getInitialContext(), jndiName + PROXY_FACTORY_NAME);
SessionContainer statefulContainer = (SessionContainer) getContainer();
- LocalHome localHome = (LocalHome) ((EJBContainer) getContainer()).resolveAnnotation(LocalHome.class);
+ LocalHome localHome = this.getContainer().getAnnotation(LocalHome.class);
if (localHome != null && !bindHomeAndBusinessTogether(statefulContainer))
{
Util.unbind(getContainer().getInitialContext(), ProxyFactoryHelper.getLocalHomeJndiName(getContainer()));
@@ -144,25 +140,49 @@
{
SessionContainer sfsb = (SessionContainer) getContainer();
Object id = sfsb.createSession();
- return constructProxy(new StatefulLocalProxy(getContainer(), id, vmid));
+ return this.createProxy(id);
}
+ public Object createEjb21Proxy()
+ {
+ Object id = getContainer().createSession();
+ return this.createEjb21Proxy(id);
+ }
+
public Object createProxy(Object id)
{
- return constructProxy(new StatefulLocalProxy(getContainer(), id, vmid));
+ return this.createProxy(id, SpecificationInterfaceType.EJB30_BUSINESS);
}
+
+ public Object createEjb21Proxy(Object id)
+ {
+ return this.createProxy(id, SpecificationInterfaceType.EJB21);
+ }
+
+ private Object createProxy(Object id, SpecificationInterfaceType type)
+ {
+ StatefulLocalProxy proxy = new StatefulLocalProxy(this.getContainer(), id, vmid);
+ return type.equals(SpecificationInterfaceType.EJB30_BUSINESS) ? this.constructBusinessProxy(proxy) : this
+ .constructEjb21Proxy(proxy);
+ }
- public Object createProxy(Class[] initTypes, Object[] initValues)
+ public Object createProxy(Class<?>[] initTypes, Object[] initValues)
{
SessionContainer sfsb = (SessionContainer) getContainer();
Object id = sfsb.createSession(initTypes, initValues);
- return constructProxy(new StatefulLocalProxy(getContainer(), id, vmid));
+ return this.createProxy(id, SpecificationInterfaceType.EJB30_BUSINESS);
}
+
+ public Object createEjb21Proxy(Class<?>[] initTypes, Object[] initValues){
+ SessionContainer sfsb = (SessionContainer) getContainer();
+ Object id = sfsb.createSession(initTypes, initValues);
+ return this.createProxy(id, SpecificationInterfaceType.EJB21);
+ }
protected StatefulHandleImpl getHandle()
{
StatefulHandleImpl handle = new StatefulHandleImpl();
- LocalBinding remoteBinding = (LocalBinding) getContainer().resolveAnnotation(LocalBinding.class);
+ LocalBinding remoteBinding = this.getContainer().getAnnotation(LocalBinding.class);
if (remoteBinding != null)
handle.jndiName = remoteBinding.jndiBinding();
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java 2008-03-26 04:21:36 UTC (rev 71285)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java 2008-03-26 04:46:40 UTC (rev 71286)
@@ -22,9 +22,6 @@
package org.jboss.ejb3.stateful;
import java.lang.reflect.Proxy;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
import javax.ejb.RemoteHome;
import javax.naming.NamingException;
@@ -35,16 +32,16 @@
import org.jboss.aop.advice.Interceptor;
import org.jboss.aspects.remoting.InvokeRemoteInterceptor;
import org.jboss.aspects.remoting.PojiProxy;
-import org.jboss.ejb3.JBossProxy;
import org.jboss.ejb3.ProxyFactory;
import org.jboss.ejb3.ProxyFactoryHelper;
+import org.jboss.ejb3.SpecificationInterfaceType;
import org.jboss.ejb3.annotation.RemoteBinding;
import org.jboss.ejb3.remoting.IsLocalProxyFactoryInterceptor;
import org.jboss.ejb3.remoting.RemoteProxyFactory;
import org.jboss.ejb3.session.SessionContainer;
import org.jboss.logging.Logger;
+import org.jboss.remoting.InvokerLocator;
import org.jboss.util.naming.Util;
-import org.jboss.remoting.InvokerLocator;
/**
* Comment
@@ -60,6 +57,8 @@
// public static final String FACTORY_ATTRIBUTE = ",element=ProxyFactory";
+ private static final String STACK_NAME_STATEFUL_SESSION_CLIENT_INTERCEPTORS = "StatefulSessionClientInterceptors";
+
private RemoteBinding binding;
private InvokerLocator locator;
@@ -69,42 +68,34 @@
this.binding = binding;
}
+
+ /**
+ * Defines the access type for this Proxies created by this Factory
+ *
+ * @return
+ */
+ @Override
+ protected ProxyAccessType getProxyAccessType(){
+ return ProxyAccessType.REMOTE;
+ }
+
+ protected void ensureEjb21ViewComplete()
+ {
+ // Obtain Container
+ SessionContainer container = this.getContainer();
+
+ // Obtain @RemoteHome
+ RemoteHome remoteHome = container.getAnnotation(RemoteHome.class);
- protected Class<?>[] getInterfaces()
- {
- SessionContainer statefulContainer = (SessionContainer) getContainer();
- RemoteHome remoteHome = (RemoteHome) statefulContainer.resolveAnnotation(RemoteHome.class);
-
- boolean bindTogether = false;
-
- if (remoteHome != null && bindHomeAndBusinessTogether(statefulContainer))
- bindTogether = true;
-
- // Obtain all remote interfaces
- Set<Class<?>> remoteInterfaces = new HashSet<Class<?>>();
- remoteInterfaces.addAll(Arrays.asList(ProxyFactoryHelper.getRemoteAndBusinessRemoteInterfaces(getContainer())));
-
// Ensure that if EJB 2.1 Components are defined, they're complete
this.ensureEjb21ViewComplete(remoteHome == null ? null : remoteHome.value(), ProxyFactoryHelper
- .getRemoteInterfaces(getContainer()));
+ .getRemoteInterfaces(container));
- // Add JBossProxy
- remoteInterfaces.add(JBossProxy.class);
-
- // If binding along w/ home, add home
- if (bindTogether)
- {
- remoteInterfaces.add(remoteHome.value());
- }
-
- // Return
- return remoteInterfaces.toArray(new Class<?>[]
- {});
}
protected boolean bindHomeAndBusinessTogether(SessionContainer container)
{
- return ProxyFactoryHelper.getHomeJndiName(container).equals(ProxyFactoryHelper.getRemoteJndiName(container));
+ return ProxyFactoryHelper.getHomeJndiName(container).equals(ProxyFactoryHelper.getRemoteBusinessJndiName(container));
}
public void init() throws Exception
@@ -119,7 +110,7 @@
init();
super.start();
- Class[] interfaces = {ProxyFactory.class};
+ Class<?>[] interfaces = {ProxyFactory.class};
String targetId = getTargetId();
String clientBindUrl = ProxyFactoryHelper.getClientBindUrl(binding);
Object factoryProxy = createPojiProxy(targetId, interfaces, clientBindUrl);
@@ -153,23 +144,23 @@
Util.unbind(getContainer().getInitialContext(), jndiName + PROXY_FACTORY_NAME);
Dispatcher.singleton.unregisterTarget(getTargetId());
- SessionContainer statefulContainer = (SessionContainer) getContainer();
- RemoteHome remoteHome = (RemoteHome) statefulContainer.resolveAnnotation(RemoteHome.class);
+ SessionContainer statefulContainer = this.getContainer();
+ RemoteHome remoteHome = statefulContainer.getAnnotation(RemoteHome.class);
if (remoteHome != null && !bindHomeAndBusinessTogether(statefulContainer))
{
- Util.unbind(getContainer().getInitialContext(), ProxyFactoryHelper.getHomeJndiName(getContainer()));
+ Util.unbind(this.getContainer().getInitialContext(), ProxyFactoryHelper.getHomeJndiName(getContainer()));
}
super.stop();
}
- public Object createHomeProxy(Class homeInterface)
+ public Object createHomeProxy(Class<?> homeInterface)
{
try
{
Object containerId = getContainer().getObjectName().getCanonicalName();
- String stackName = "StatefulSessionClientInterceptors";
- if (binding.interceptorStack() != null && !binding.interceptorStack().equals(""))
+ String stackName = StatefulRemoteProxyFactory.STACK_NAME_STATEFUL_SESSION_CLIENT_INTERCEPTORS;
+ if (binding.interceptorStack() != null && !binding.interceptorStack().trim().equals(""))
{
stackName = binding.interceptorStack();
}
@@ -178,20 +169,25 @@
StatefulHomeRemoteProxy proxy = new StatefulHomeRemoteProxy(getContainer(), stack.createInterceptors(getContainer().getAdvisor(), null), locator);
setEjb21Objects(proxy);
- Class[] intfs = {homeInterface};
+ Class<?>[] intfs = {homeInterface};
return java.lang.reflect.Proxy.newProxyInstance(getContainer().getBeanClass().getClassLoader(), intfs, proxy);
}
catch (IllegalArgumentException e)
{
- throw new RuntimeException(e); //To change body of catch statement use Options | File Templates.
+ throw new RuntimeException(e);
}
}
public Object createProxy()
{
Object id = getContainer().createSession();
- return createProxy(id);
+ return this.createProxy(id);
}
+ public Object createEjb21Proxy()
+ {
+ Object id = getContainer().createSession();
+ return this.createEjb21Proxy(id);
+ }
protected StatefulHandleImpl getHandle()
{
@@ -203,17 +199,27 @@
public Object createProxy(Object id)
{
- String stackName = "StatefulSessionClientInterceptors";
- if (binding.interceptorStack() != null && !binding.interceptorStack().equals(""))
+ return this.createProxy(id,SpecificationInterfaceType.EJB30_BUSINESS);
+ }
+
+ public Object createEjb21Proxy(Object id)
+ {
+ return this.createProxy(id,SpecificationInterfaceType.EJB21);
+ }
+
+ private Object createProxy(Object id,SpecificationInterfaceType type)
+ {
+ String stackName = StatefulRemoteProxyFactory.STACK_NAME_STATEFUL_SESSION_CLIENT_INTERCEPTORS;
+ if (binding.interceptorStack() != null && !binding.interceptorStack().trim().equals(""))
{
stackName = binding.interceptorStack();
}
AdviceStack stack = AspectManager.instance().getAdviceStack(stackName);
if (stack == null) throw new RuntimeException("unable to find interceptor stack: " + stackName);
StatefulRemoteProxy proxy = new StatefulRemoteProxy(getContainer(), stack.createInterceptors(getContainer().getAdvisor(), null), locator, id);
-
- setEjb21Objects(proxy);
- return constructProxy(proxy);
+ this.setEjb21Objects(proxy);
+ return type.equals(SpecificationInterfaceType.EJB21) ? this.constructEjb21Proxy(proxy) : this
+ .constructBusinessProxy(proxy);
}
/**
@@ -225,7 +231,7 @@
return jndiName + PROXY_FACTORY_NAME;
}
- protected Object createPojiProxy(Object oid, Class[] interfaces, String uri) throws Exception
+ protected Object createPojiProxy(Object oid, Class<?>[] interfaces, String uri) throws Exception
{
InvokerLocator locator = new InvokerLocator(uri);
Interceptor[] interceptors = {IsLocalProxyFactoryInterceptor.singleton, InvokeRemoteInterceptor.singleton};
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/BaseStatelessProxyFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/BaseStatelessProxyFactory.java 2008-03-26 04:21:36 UTC (rev 71285)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/BaseStatelessProxyFactory.java 2008-03-26 04:46:40 UTC (rev 71286)
@@ -240,6 +240,8 @@
}
protected abstract Class<?>[] getInterfaces();
+
+ protected abstract void ensureEjb21ViewComplete();
protected final void initializeJndiName() {};
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessClusterProxyFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessClusterProxyFactory.java 2008-03-26 04:21:36 UTC (rev 71285)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessClusterProxyFactory.java 2008-03-26 04:46:40 UTC (rev 71286)
@@ -22,8 +22,12 @@
package org.jboss.ejb3.stateless;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
+import javax.ejb.RemoteHome;
+
import org.jboss.aop.AspectManager;
import org.jboss.aop.advice.AdviceStack;
import org.jboss.aspects.remoting.FamilyWrapper;
@@ -77,15 +81,42 @@
this.clustered = clustered;
}
- protected Class[] getInterfaces()
+ protected Class<?>[] getInterfaces()
{
- Class[] remoteInterfaces = ProxyFactoryHelper.getRemoteAndBusinessRemoteInterfaces(getContainer());
- Class[] interfaces = new Class[remoteInterfaces.length + 1];
- System.arraycopy(remoteInterfaces, 0, interfaces, 0, remoteInterfaces.length);
- interfaces[remoteInterfaces.length] = JBossProxy.class;
- return interfaces;
+ // Initialize
+ Set<Class<?>> interfaces = new HashSet<Class<?>>();
+
+ // Obtain remote and business remote interfaces
+ Class<?>[] remoteAndBusinessRemoteInterfaces = ProxyFactoryHelper
+ .getRemoteAndBusinessRemoteInterfaces(getContainer());
+
+ // Add all remote and business remotes
+ for(Class<?> interfaze : remoteAndBusinessRemoteInterfaces)
+ {
+ interfaces.add(interfaze);
+ }
+
+ // Add JBossProxy
+ interfaces.add( JBossProxy.class);
+
+ // Return
+ return interfaces.toArray(new Class[]{});
}
+
+ protected void ensureEjb21ViewComplete()
+ {
+ // Obtain Container
+ SessionContainer container = this.getContainer();
+
+ // Obtain @RemoteHome
+ RemoteHome remoteHome = container.getAnnotation(RemoteHome.class);
+ // Ensure that if EJB 2.1 Components are defined, they're complete
+ this.ensureEjb21ViewComplete(remoteHome == null ? null : remoteHome.value(), ProxyFactoryHelper
+ .getRemoteInterfaces(container));
+
+ }
+
public void start() throws Exception
{
String clientBindUrl = ProxyFactoryHelper.getClientBindUrl(binding);
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessLocalProxyFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessLocalProxyFactory.java 2008-03-26 04:21:36 UTC (rev 71285)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessLocalProxyFactory.java 2008-03-26 04:46:40 UTC (rev 71286)
@@ -53,8 +53,8 @@
protected Class<?>[] getInterfaces()
{
- EJBContainer statelessContainer = (EJBContainer)getContainer();
- LocalHome localHome = (LocalHome)statelessContainer.resolveAnnotation(LocalHome.class);
+ EJBContainer statelessContainer = this.getContainer();
+ LocalHome localHome = statelessContainer.getAnnotation(LocalHome.class);
boolean bindTogether = false;
@@ -64,10 +64,6 @@
// Obtain all local interfaces
Set<Class<?>> localInterfaces = new HashSet<Class<?>>();
localInterfaces.addAll(Arrays.asList(ProxyFactoryHelper.getLocalAndBusinessLocalInterfaces(getContainer())));
-
- // Ensure that if EJB 2.1 Components are defined, they're complete
- this.ensureEjb21ViewComplete(localHome == null ? null : localHome.value(), ProxyFactoryHelper
- .getLocalInterfaces(getContainer()));
// Ensure local interfaces defined
if (localInterfaces.size() > 0)
@@ -92,6 +88,17 @@
{});
}
+ protected void ensureEjb21ViewComplete(){
+
+ EJBContainer container = this.getContainer();
+
+ LocalHome localHome = container.getAnnotation(LocalHome.class);
+
+ // Ensure that if EJB 2.1 Components are defined, they're complete
+ this.ensureEjb21ViewComplete(localHome == null ? null : localHome.value(), ProxyFactoryHelper
+ .getLocalInterfaces(container));
+ }
+
protected boolean bindHomeAndBusinessTogether(EJBContainer container)
{
return ProxyFactoryHelper.getLocalHomeJndiName(container).equals(jndiName);
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java 2008-03-26 04:21:36 UTC (rev 71285)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java 2008-03-26 04:46:40 UTC (rev 71286)
@@ -63,21 +63,17 @@
protected Class<?>[] getInterfaces()
{
- StatelessContainer statelessContainer = (StatelessContainer) getContainer();
- RemoteHome remoteHome = (RemoteHome) statelessContainer.resolveAnnotation(RemoteHome.class);
+ SessionContainer container = this.getContainer();
+ RemoteHome remoteHome = container.getAnnotation(RemoteHome.class);
boolean bindTogether = false;
- if (remoteHome != null && bindHomeAndBusinessTogether(statelessContainer))
+ if (remoteHome != null && bindHomeAndBusinessTogether(container))
bindTogether = true;
// Obtain all remote interfaces
Set<Class<?>> remoteInterfaces = new HashSet<Class<?>>();
remoteInterfaces.addAll(Arrays.asList(ProxyFactoryHelper.getRemoteAndBusinessRemoteInterfaces(getContainer())));
-
- // Ensure that if EJB 2.1 Components are defined, they're complete
- this.ensureEjb21ViewComplete(remoteHome == null ? null : remoteHome.value(), ProxyFactoryHelper
- .getRemoteInterfaces(getContainer()));
// Ensure remote interfaces defined
if (remoteInterfaces.size() > 0)
@@ -102,9 +98,22 @@
{});
}
+ protected void ensureEjb21ViewComplete()
+ {
+ // Obtain Container
+ EJBContainer container = this.getContainer();
+
+ // Obtaine @RemoteHome
+ RemoteHome remoteHome = container.getAnnotation(RemoteHome.class);
+
+ // Ensure that if EJB 2.1 Components are defined, they're complete
+ this.ensureEjb21ViewComplete(remoteHome == null ? null : remoteHome.value(), ProxyFactoryHelper
+ .getRemoteInterfaces(container));
+ }
+
protected boolean bindHomeAndBusinessTogether(EJBContainer container)
{
- return ProxyFactoryHelper.getHomeJndiName(container).equals(ProxyFactoryHelper.getRemoteJndiName(container));
+ return ProxyFactoryHelper.getHomeJndiName(container).equals(ProxyFactoryHelper.getRemoteBusinessJndiName(container));
}
public void init() throws Exception
Modified: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/stateful/StatefulRemoteProxyFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/stateful/StatefulRemoteProxyFactory.java 2008-03-26 04:21:36 UTC (rev 71285)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/stateful/StatefulRemoteProxyFactory.java 2008-03-26 04:46:40 UTC (rev 71286)
@@ -41,11 +41,12 @@
super(container, binding);
}
- protected Class[] getInterfaces()
+ @Override
+ protected Class<?>[] getInterfacesForBusinessProxy()
{
- Class[] remoteInterfaces = super.getInterfaces();
+ Class<?>[] remoteInterfaces = super.getInterfacesForBusinessProxy();
- Class[] interfaces = new Class[remoteInterfaces.length + 1];
+ Class<?>[] interfaces = new Class[remoteInterfaces.length + 1];
System.arraycopy(remoteInterfaces, 0, interfaces, 0, remoteInterfaces.length);
interfaces[remoteInterfaces.length] = org.jboss.ejb3.test.stateful.ProxyFactoryInterface.class;
Modified: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/statefulproxyfactoryoverride/StatefulRemoteProxyFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/statefulproxyfactoryoverride/StatefulRemoteProxyFactory.java 2008-03-26 04:21:36 UTC (rev 71285)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/statefulproxyfactoryoverride/StatefulRemoteProxyFactory.java 2008-03-26 04:46:40 UTC (rev 71286)
@@ -41,11 +41,12 @@
super(container, binding);
}
- protected Class<?>[] getInterfaces()
+ @Override
+ protected Class<?>[] getInterfacesForBusinessProxy()
{
- Class[] remoteInterfaces = super.getInterfaces();
+ Class<?>[] remoteInterfaces = super.getInterfacesForBusinessProxy();
- Class[] interfaces = new Class[remoteInterfaces.length + 1];
+ Class<?>[] interfaces = new Class[remoteInterfaces.length + 1];
System.arraycopy(remoteInterfaces, 0, interfaces, 0, remoteInterfaces.length);
interfaces[remoteInterfaces.length] = org.jboss.ejb3.test.statefulproxyfactoryoverride.ProxyFactoryInterface.class;
More information about the jboss-cvs-commits
mailing list