From: Scott M S. <st...@us...> - 2005-01-31 23:47:40
|
User: starksm Date: 05/01/31 15:47:25 Modified: src/main/org/jboss/proxy/ejb ProxyFactory.java Log: Only add the IClientContainer interface added to the ejb proxies if the client-interceptors exposeContainer attribute exists so that legacy clients are not broken due to a missing IClientContainer. Revision Changes Path 1.41 +54 -17 jboss/src/main/org/jboss/proxy/ejb/ProxyFactory.java Index: ProxyFactory.java =================================================================== RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/proxy/ejb/ProxyFactory.java,v retrieving revision 1.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- ProxyFactory.java 4 Dec 2004 07:25:57 -0000 1.40 +++ ProxyFactory.java 31 Jan 2005 23:47:25 -0000 1.41 @@ -40,6 +40,7 @@ import org.jboss.naming.Util; import org.jboss.proxy.Interceptor; import org.jboss.proxy.ClientContainer; +import org.jboss.proxy.ClientContainerEx; import org.jboss.proxy.IClientContainer; import org.jboss.proxy.ejb.handle.HomeHandleImpl; import org.jboss.system.Registry; @@ -68,7 +69,7 @@ * @author <a href="mailto:mar...@jb...">Marc Fleury</a> * @author <a href="mailto:sco...@jb...">Scott Stark/a> * @author <a href="mailto:tho...@jb...">Thomas Diesler/a> - * @version $Revision: 1.40 $ + * @version $Revision: 1.41 $ */ public class ProxyFactory implements EJBProxyFactory @@ -115,7 +116,8 @@ * The proxy-config/client-interceptors/entity-list stack */ protected ArrayList listEntityInterceptorClasses = new ArrayList(); - + /** A flag indicating if the IClientContainer interface should be added */ + protected boolean includeIClientIface; // A pointer to the container this proxy factory is dedicated to protected Container container; @@ -260,6 +262,8 @@ ); if(clientInterceptors != null) { + String value = MetaData.getElementAttribute(clientInterceptors, "exposeContainer"); + this.includeIClientIface = Boolean.valueOf(value).booleanValue(); NodeList children = clientInterceptors.getChildNodes(); for(int i = 0; i < children.getLength(); i++) { @@ -376,13 +380,22 @@ context.setValue(InvocationKey.EJB_METADATA, ejbMetaData); context.setInvokerProxyBinding(invokerMetaData.getName()); - ClientContainer client = new ClientContainer(context); + ClientContainer client = null; + EJBProxyFactoryContainer pfc = (EJBProxyFactoryContainer) container; + Class[] ifaces = {pfc.getHomeClass(), Class.forName("javax.ejb.Handle")}; + if( includeIClientIface ) + { + ifaces = new Class[] {IClientContainer.class, pfc.getHomeClass(), + Class.forName("javax.ejb.Handle")}; + client = new ClientContainerEx(context); + } + else + { + client = new ClientContainer(context); + } loadInterceptorChain(homeInterceptorClasses, client); - EJBProxyFactoryContainer pfc = (EJBProxyFactoryContainer) container; // Create the EJBHome - Class[] ifaces = {IClientContainer.class, pfc.getHomeClass(), - Class.forName("javax.ejb.Handle")}; this.home = (EJBHome) Proxy.newProxyInstance( // Class loader pointing to the right classes from deployment pfc.getHomeClass().getClassLoader(), @@ -405,12 +418,18 @@ context.setInvokerProxyBinding(invokerMetaData.getName()); context.setValue(InvocationKey.EJB_HOME, home); - client = new ClientContainer(context); - + Class[] ssifaces = {pfc.getRemoteClass()}; + if( includeIClientIface ) + { + ssifaces = new Class[] {IClientContainer.class, pfc.getRemoteClass()}; + client = new ClientContainerEx(context); + } + else + { + client = new ClientContainer(context); + } loadInterceptorChain(beanInterceptorClasses, client); - Class[] ssifaces = {IClientContainer.class, pfc.getRemoteClass()}; - this.statelessObject = (EJBObject)Proxy.newProxyInstance( // Correct CL @@ -424,13 +443,14 @@ else { // this is faster than newProxyInstance - Class[] intfs = {IClientContainer.class, pfc.getRemoteClass()}; + Class[] intfs = {pfc.getRemoteClass()}; + if( this.includeIClientIface ) + { + intfs = new Class[]{IClientContainer.class, pfc.getRemoteClass()}; + } Class proxyClass = Proxy.getProxyClass(pfc.getRemoteClass().getClassLoader(), intfs); - final Class[] constructorParams = - {InvocationHandler.class}; - + final Class[] constructorParams = {InvocationHandler.class}; proxyClassConstructor = proxyClass.getConstructor(constructorParams); - } @@ -533,7 +553,16 @@ context.setValue(InvocationKey.EJB_HOME, home); context.setValue("InvokerID", Invoker.ID); - ClientContainer client = new ClientContainer(context); + ClientContainer client; + if( includeIClientIface ) + { + client = new ClientContainerEx(context); + } + else + { + client = new ClientContainer(context); + } + try { loadInterceptorChain(beanInterceptorClasses, client); @@ -576,7 +605,15 @@ context.setInvokerProxyBinding(invokerMetaData.getName()); context.setValue(InvocationKey.EJB_HOME, home); - ClientContainer client = new ClientContainer(context); + ClientContainer client; + if( includeIClientIface ) + { + client = new ClientContainerEx(context); + } + else + { + client = new ClientContainer(context); + } try { |