[jboss-cvs] JBossAS SVN: r80729 - in projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy: factory/service and 12 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Nov 9 19:13:19 EST 2008
Author: ALRubinger
Date: 2008-11-09 19:13:19 -0500 (Sun, 09 Nov 2008)
New Revision: 80729
Added:
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/service/ServiceLocalProxyFactory.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/service/ServiceProxyFactoryBase.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/service/ServiceRemoteProxyFactory.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/service/
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/service/ServiceLocalProxyInvocationHandler.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/service/ServiceProxyInvocationHandler.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/service/ServiceProxyInvocationHandlerBase.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/service/ServiceRemoteProxyInvocationHandler.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/intf/ServiceProxy.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiServiceRegistrar.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/service/
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/service/ServiceProxyObjectFactory.java
Modified:
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactoryBase.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/ProxyInvocationHandlerBase.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionProxyInvocationHandlerBase.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionSpecProxyInvocationHandlerBase.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateful/StatefulProxyInvocationHandlerBase.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateful/StatefulRemoteProxyInvocationHandler.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateless/StatelessRemoteProxyInvocationHandler.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiSessionRegistrarBase.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiStatefulSessionRegistrar.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiStatelessSessionRegistrar.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyObjectFactory.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/session/SessionProxyObjectFactory.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectstore/ObjectStoreBindings.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/remoting/ProxyRemotingUtils.java
Log:
[EJBTHREE-1573] Added @Service support in jboss-ejb3-proxy
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactoryBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactoryBase.java 2008-11-10 00:11:30 UTC (rev 80728)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactoryBase.java 2008-11-10 00:13:19 UTC (rev 80729)
@@ -193,7 +193,7 @@
// --------------------------------------------------------------------------------||
/**
- * Lifecycle callback to be invoked by the ProxyFactoryDeployer
+ * Lifecycle callback to be invoked by
* before the ProxyFactory is able to service requests
*
* @throws Exception
Added: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/service/ServiceLocalProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/service/ServiceLocalProxyFactory.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/service/ServiceLocalProxyFactory.java 2008-11-10 00:13:19 UTC (rev 80729)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.proxy.factory.service;
+
+import java.util.Set;
+
+import org.jboss.aop.Advisor;
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.ejb3.proxy.handler.service.ServiceLocalProxyInvocationHandler;
+import org.jboss.ejb3.proxy.handler.service.ServiceProxyInvocationHandler;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossServiceBeanMetaData;
+
+/**
+ * ServiceLocalProxyFactory
+ *
+ * A @Service Proxy Factory for Local Views
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class ServiceLocalProxyFactory extends ServiceProxyFactoryBase implements ServiceProxyFactory
+{
+ // --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private static final Logger logger = Logger.getLogger(ServiceLocalProxyFactory.class);
+
+ // --------------------------------------------------------------------------------||
+ // Constructor --------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Constructor
+ *
+ * @param name The unique name for this ProxyFactory
+ * @param containerName The name of the InvokableContext (container)
+ * upon which Proxies will invoke
+ * @param containerGuid The globally-unique name of the container
+ * @param metadata The metadata representing this SLSB
+ * @param classloader The ClassLoader associated with the StatelessContainer
+ * for which this ProxyFactory is to generate Proxies
+ * @param advisor The Advisor for proxies created by this factory
+ */
+ public ServiceLocalProxyFactory(final String name, final String containerName, final String containerGuid,
+ final JBossServiceBeanMetaData metadata, final ClassLoader classloader, final Advisor advisor)
+ {
+ // Call Super
+ super(name, containerName, containerGuid, metadata, classloader, advisor);
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Required Implementations -------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Returns the a Set of String representations of the Business Interface Types
+ *
+ * @return
+ */
+ @Override
+ protected final Set<String> getBusinessInterfaceTypes()
+ {
+ return this.getMetadata().getBusinessLocals();
+ }
+
+ @Override
+ protected ServiceProxyInvocationHandler createInvocationHandler()
+ {
+ // Obtain container name
+ String containerName = this.getContainerName();
+ String containerGuid = this.getContainerGuid();
+
+ // Get Interceptors
+ Interceptor[] interceptors = this.getInterceptors();
+
+ // Create
+ ServiceProxyInvocationHandler handler = new ServiceLocalProxyInvocationHandler(containerName, containerGuid,
+ interceptors);
+
+ // Return
+ return handler;
+ }
+}
Added: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/service/ServiceProxyFactoryBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/service/ServiceProxyFactoryBase.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/service/ServiceProxyFactoryBase.java 2008-11-10 00:13:19 UTC (rev 80729)
@@ -0,0 +1,272 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.proxy.factory.service;
+
+import java.lang.reflect.Constructor;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.aop.Advisor;
+import org.jboss.ejb3.proxy.factory.ProxyFactoryBase;
+import org.jboss.ejb3.proxy.handler.service.ServiceProxyInvocationHandler;
+import org.jboss.ejb3.proxy.intf.ServiceProxy;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossServiceBeanMetaData;
+
+/**
+ * ServiceProxyFactoryBase
+ *
+ * Base upon which @Service Proxy Factory implementations
+ * may build
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public abstract class ServiceProxyFactoryBase extends ProxyFactoryBase implements ServiceProxyFactory
+{
+
+ // --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(ServiceProxyFactoryBase.class);
+
+ // --------------------------------------------------------------------------------||
+ // Instance Members ---------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private JBossServiceBeanMetaData metadata;
+
+ /**
+ * Proxy Constructor (All
+ * business interfaces)
+ */
+ private Constructor<?> proxyConstructor;
+
+ // --------------------------------------------------------------------------------||
+ // Constructor --------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Constructor
+ *
+ * @param name The unique name for this ProxyFactory
+ * @param containerName The name of the InvokableContext (container)
+ * upon which Proxies will invoke
+ * @param containerGuid The globally-unique name of the container
+ * @param metadata The metadata representing this @Service Bean
+ * @param classloader The ClassLoader associated with the Container's Bean Class
+ * for which this ProxyFactory is to generate Proxies
+ * @param advisor The Advisor for proxies created by this factory
+ */
+ public ServiceProxyFactoryBase(final String name, final String containerName, final String containerGuid,
+ final JBossServiceBeanMetaData metadata, final ClassLoader classloader, final Advisor advisor)
+ {
+ // Call Super
+ super(name, containerName, containerGuid, classloader, advisor);
+
+ // Set Metadata
+ this.setMetadata(metadata);
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Functional Methods -------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Create an EJB3 Business proxy. The
+ * returned proxy will implement all appropriate
+ * business interfaces.
+ *
+ * @return
+ */
+ public Object createProxy()
+ {
+ // Obtain Constructor to Default Proxy
+ Constructor<?> constructor = this.getProxyConstructor();
+ assert constructor != null : "Constructor for Default Proxy was null; perhaps the "
+ + ServiceProxyFactory.class.getSimpleName() + " was not properly started?";
+
+ // Create a new InvocationHandler
+ ServiceProxyInvocationHandler handler = this.createInvocationHandler();
+
+ try
+ {
+ // Create a new Proxy instance, and return
+ return constructor.newInstance(handler);
+ }
+ catch (Throwable t)
+ {
+ // Throw a descriptive error message along with the originating Throwable
+ throw new RuntimeException("Could not create the Default Proxy for " + this.getMetadata().getEjbName(), t);
+ }
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Lifecycle Methods --------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Lifecycle callback to be invoked
+ * before the ProxyFactory is able to service requests
+ *
+ * @throws Exception
+ */
+ @Override
+ public void start() throws Exception
+ {
+ // Call Super
+ super.start();
+
+ /*
+ * Make Default Proxy
+ */
+
+ // Create a Set to hold all relevant interfaces
+ Set<Class<?>> defaultProxyInterfaces = new HashSet<Class<?>>();
+
+ // Obtain Business Interface Types
+ Set<String> businessInterfaceTypes = this.getBusinessInterfaceTypes();
+
+ // Initialize
+ Set<Class<?>> businessInterfaceClasses = new HashSet<Class<?>>();
+
+ // Determine if business interfaces are defined
+ boolean hasBusinessInterfaces = businessInterfaceTypes != null && businessInterfaceTypes.size() > 0;
+
+ // If there are business interfaces
+ if (hasBusinessInterfaces)
+ {
+ // For all business interface types
+ for (String businessInterfaceType : businessInterfaceTypes)
+ {
+ Class<?> businessInterface = null;
+ try
+ {
+ // Load
+ businessInterface = this.getClassLoader().loadClass(businessInterfaceType);
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ throw new RuntimeException("Could not find specified @Service Bean Business Interface \""
+ + businessInterfaceType + "\" in " + ClassLoader.class.getSimpleName() + " for EJB "
+ + this.getMetadata().getEjbName(), cnfe);
+ }
+
+ // Add business interface to classes
+ businessInterfaceClasses.add(businessInterface);
+ }
+ }
+
+ // Add all business interfaces
+ defaultProxyInterfaces.addAll(businessInterfaceClasses);
+
+ // Make the Default Business Interfaces Proxy Constructor
+ Constructor<?> businessInterfacesConstructor = this.createProxyConstructor(defaultProxyInterfaces, this
+ .getClassLoader());
+ log.debug("Created @Service Bean Default EJB3 Business Proxy Constructor implementing " + defaultProxyInterfaces);
+
+ // Set
+ this.setProxyConstructor(businessInterfacesConstructor);
+
+ }
+
+ /**
+ * Lifecycle callback to be invoked
+ * before the ProxyFactory is taken out of service,
+ * possibly GC'd
+ *
+ * @throws Exception
+ */
+ @Override
+ 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(ServiceProxy.class);
+
+ // Return
+ return interfaces;
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Functional Methods -------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ // --------------------------------------------------------------------------------||
+ // Contracts ----------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Returns the a Set of String representations of the Business Interface Types
+ *
+ * @return
+ */
+ protected abstract Set<String> getBusinessInterfaceTypes();
+
+ /**
+ * Returns the ServiceProxyInvocationHandler to be used in
+ * Proxy Creation
+ *
+ * @return
+ */
+ protected abstract ServiceProxyInvocationHandler createInvocationHandler();
+
+ // --------------------------------------------------------------------------------||
+ // Accessors / Mutators -----------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ public JBossServiceBeanMetaData getMetadata()
+ {
+ return metadata;
+ }
+
+ protected void setMetadata(final JBossServiceBeanMetaData metadata)
+ {
+ this.metadata = metadata;
+ }
+
+ protected Constructor<?> getProxyConstructor()
+ {
+ return proxyConstructor;
+ }
+
+ protected void setProxyConstructor(Constructor<?> proxyConstructor)
+ {
+ this.proxyConstructor = proxyConstructor;
+ }
+}
Added: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/service/ServiceRemoteProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/service/ServiceRemoteProxyFactory.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/service/ServiceRemoteProxyFactory.java 2008-11-10 00:13:19 UTC (rev 80729)
@@ -0,0 +1,175 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.proxy.factory.service;
+
+import java.util.Set;
+
+import org.jboss.aop.Advisor;
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.ejb3.proxy.handler.service.ServiceProxyInvocationHandler;
+import org.jboss.ejb3.proxy.handler.service.ServiceRemoteProxyInvocationHandler;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossServiceBeanMetaData;
+
+/**
+ * ServiceRemoteProxyFactory
+ *
+ * A @Service Proxy Factory for Remote Views
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class ServiceRemoteProxyFactory extends ServiceProxyFactoryBase implements ServiceProxyFactory
+{
+ // --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private static final Logger logger = Logger.getLogger(ServiceRemoteProxyFactory.class);
+
+ private static final String DEFAULT_STACK_NAME_STATELESS_SESSION_CLIENT_INTERCEPTORS = "ServiceClientInterceptors";
+
+ // --------------------------------------------------------------------------------||
+ // Instance Members ---------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * URL to be used in Remoting
+ */
+ private String url;
+
+ /**
+ * Name of the interceptor stack to use (overrides the default)
+ */
+ private String interceptorStackName;
+
+ // --------------------------------------------------------------------------------||
+ // Constructor --------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Constructor
+ *
+ * @param name The unique name for this ProxyFactory
+ * @param containerName The name of the InvokableContext (container)
+ * upon which Proxies will invoke
+ * @param containerGuid The globally-unique name of the container
+ * @param metadata The metadata representing this SLSB
+ * @param classloader The ClassLoader associated with the StatelessContainer
+ * for which this ProxyFactory is to generate Proxies
+ * @param url The URL to use for remoting
+ * @param advisor The Advisor for proxies created by this factory
+ * @param interceptorStackName The name of the client-side interceptor stack to use.
+ * If null the default will apply.
+ */
+ public ServiceRemoteProxyFactory(final String name, final String containerName, final String containerGuid,
+ final JBossServiceBeanMetaData metadata, final ClassLoader classloader, final String url,
+ final Advisor advisor, final String interceptorStackName)
+ {
+ // Call Super
+ super(name, containerName, containerGuid, metadata, classloader, advisor);
+
+ // Set properties
+ this.setUrl(url);
+ this.setInterceptorStackName(interceptorStackName);
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Functional Methods -------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Returns the a Set of String representations of the Business Interface Types
+ *
+ * @return
+ */
+ @Override
+ protected final Set<String> getBusinessInterfaceTypes()
+ {
+ return this.getMetadata().getBusinessRemotes();
+ }
+
+ /**
+ * Return the name of the interceptor stack to apply to
+ * proxies created by this proxy factory
+ *
+ * @return
+ */
+ @Override
+ protected String getInterceptorStackName()
+ {
+ // Initialize to default
+ String stackName = ServiceRemoteProxyFactory.DEFAULT_STACK_NAME_STATELESS_SESSION_CLIENT_INTERCEPTORS;
+
+ // Override if specified
+ String overrideName = this.interceptorStackName;
+ if (overrideName != null && overrideName.trim().length() > 0)
+ {
+ stackName = overrideName;
+ }
+
+ // Return
+ return stackName;
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Required Implementations -------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ @Override
+ protected ServiceProxyInvocationHandler createInvocationHandler()
+ {
+ // Obtain properties
+ String containerName = this.getContainerName();
+ String containerGuid = this.getContainerGuid();
+ String url = this.getUrl();
+
+ // Get Interceptors
+ Interceptor[] interceptors = this.getInterceptors();
+
+ // Create
+ ServiceProxyInvocationHandler handler = new ServiceRemoteProxyInvocationHandler(containerName, containerGuid,
+ interceptors, url);
+
+ // Return
+ return handler;
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Accessors / Mutators -----------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ public String getUrl()
+ {
+ return url;
+ }
+
+ public void setUrl(final String url)
+ {
+ this.url = url;
+ }
+
+ protected void setInterceptorStackName(String interceptorStackName)
+ {
+ this.interceptorStackName = interceptorStackName;
+ }
+}
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/ProxyInvocationHandlerBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/ProxyInvocationHandlerBase.java 2008-11-10 00:11:30 UTC (rev 80728)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/ProxyInvocationHandlerBase.java 2008-11-10 00:13:19 UTC (rev 80729)
@@ -29,6 +29,10 @@
import org.jboss.aop.advice.Interceptor;
import org.jboss.ejb3.common.lang.SerializableMethod;
+import org.jboss.ejb3.common.registrar.spi.Ejb3Registrar;
+import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
+import org.jboss.ejb3.proxy.container.InvokableContext;
+import org.jboss.logging.Logger;
/**
* ProxyInvocationHandlerBase
@@ -54,6 +58,13 @@
// Class Members ----------------------------------------------------------------||
// ------------------------------------------------------------------------------||
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(ProxyInvocationHandlerBase.class);
+
/*
* Method Names
*/
@@ -189,11 +200,82 @@
+ "\" is not eligible for direct handling by " + this);
}
+ /**
+ * Returns the container housed locally
+ *
+ * @return
+ */
+ protected InvokableContext getContainerLocally()
+ {
+ // Lookup
+ Object obj = Ejb3RegistrarLocator.locateRegistrar().lookup(this.getContainerName());
+
+ // Ensure of correct type
+ assert obj instanceof InvokableContext : "Container retrieved from " + Ejb3Registrar.class.getSimpleName()
+ + " was not of expected type " + InvokableContext.class.getName() + " but was instead " + obj;
+
+ // Return
+ return (InvokableContext) obj;
+ }
+
+ /**
+ * Overloaded "invoke" which takes into account a {@link SerializableMethod}
+ * view
+ *
+ * @param proxy
+ * @param method
+ * @param args
+ * @return
+ * @throws Throwable
+ */
+ public Object invoke(Object proxy, SerializableMethod method, Object[] args) throws Throwable
+ {
+ // Attempt to handle directly
+ try
+ {
+ return this.handleInvocationDirectly(proxy, args, method.toMethod());
+ }
+ // Ignore this, we just couldn't handle here
+ catch (NotEligibleForDirectInvocationException nefdie)
+ {
+ log.debug("Couldn't handle invocation directly within " + this + ": " + nefdie.getMessage());
+ }
+
+ /*
+ * Obtain the Container
+ */
+ InvokableContext container = this.getContainer();
+
+ /*
+ * Invoke
+ */
+
+ // Adjust args if null to empty array
+ if (args == null)
+ {
+ args = new Object[]
+ {};
+ }
+
+ // Invoke
+ Object result = container.invoke(proxy, method, args);
+
+ // Return
+ return result;
+ }
+
// ------------------------------------------------------------------------------||
// Contracts --------------------------------------------------------------------||
// ------------------------------------------------------------------------------||
/**
+ * Obtains the Container upon which this Proxy should invoke
+ *
+ * @return
+ */
+ protected abstract InvokableContext getContainer();
+
+ /**
* Handles invocation of "equals(Object)" upon the Proxy
*
* @param proxy
Added: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/service/ServiceLocalProxyInvocationHandler.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/service/ServiceLocalProxyInvocationHandler.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/service/ServiceLocalProxyInvocationHandler.java 2008-11-10 00:13:19 UTC (rev 80729)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.proxy.handler.service;
+
+import java.io.Serializable;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.ejb3.proxy.container.InvokableContext;
+
+/**
+ * ServiceLocalProxyInvocationHandler
+ *
+ * Invocation Handler for local @Service Bean Proxies
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class ServiceLocalProxyInvocationHandler extends ServiceProxyInvocationHandlerBase
+ implements
+ Serializable,
+ ServiceProxyInvocationHandler
+{
+
+ // --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private static final long serialVersionUID = 1L;
+
+ // --------------------------------------------------------------------------------||
+ // Constructor --------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Constructor
+ *
+ * @param containerName The name of the target container
+ * @param containerGuid The globally-unique name of the container
+ * @param interceptors The interceptors to apply to invocations upon this handler
+ */
+ public ServiceLocalProxyInvocationHandler(final String containerName, final String containerGuid,
+ final Interceptor[] interceptors)
+ {
+ super(containerName, containerGuid, interceptors);
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Required Implementations -------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.proxy.handler.session.SessionProxyInvocationHandlerBase#getContainer()
+ */
+ @Override
+ protected InvokableContext getContainer()
+ {
+ return this.getContainerLocally();
+ }
+}
Added: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/service/ServiceProxyInvocationHandler.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/service/ServiceProxyInvocationHandler.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/service/ServiceProxyInvocationHandler.java 2008-11-10 00:13:19 UTC (rev 80729)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.proxy.handler.service;
+
+import java.io.Serializable;
+import java.lang.reflect.InvocationHandler;
+
+import org.jboss.ejb3.proxy.handler.ProxyInvocationHandler;
+
+/**
+ * ServiceProxyInvocationHandler
+ *
+ * Defines contract for operations required of
+ * a JBoss Service Bean Proxy Invocation Handler
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: 72638 $
+ */
+public interface ServiceProxyInvocationHandler extends ProxyInvocationHandler, InvocationHandler, Serializable
+{
+
+}
\ No newline at end of file
Added: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/service/ServiceProxyInvocationHandlerBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/service/ServiceProxyInvocationHandlerBase.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/service/ServiceProxyInvocationHandlerBase.java 2008-11-10 00:13:19 UTC (rev 80729)
@@ -0,0 +1,184 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.proxy.handler.service;
+
+import java.io.Serializable;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.ejb3.common.lang.SerializableMethod;
+import org.jboss.ejb3.proxy.handler.ProxyInvocationHandlerBase;
+import org.jboss.ejb3.proxy.handler.session.SessionProxyInvocationHandler;
+import org.jboss.logging.Logger;
+import org.jboss.util.NotImplementedException;
+
+/**
+ * ServiceProxyInvocationHandlerBase
+ *
+ * Abstract base from which all JBoss Service Proxy InvocationHandlers
+ * may extend.
+ *
+ * Implements the notion of equality based solely on the name
+ * of the target container
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public abstract class ServiceProxyInvocationHandlerBase extends ProxyInvocationHandlerBase
+ implements
+ SessionProxyInvocationHandler,
+ Serializable
+{
+ // ------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------||
+ // ------------------------------------------------------------------------------||
+
+ private static final long serialVersionUID = 1L;
+
+ private static final Logger log = Logger.getLogger(ServiceProxyInvocationHandlerBase.class);
+
+ // ------------------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------||
+ // ------------------------------------------------------------------------------||
+
+ /**
+ * Constructor
+ *
+ * @param containerName The name of the target Container
+ * @param containerGuid The globally-unique name of the container
+ * @param interceptors The interceptors to apply to invocations upon this handler
+ */
+ protected ServiceProxyInvocationHandlerBase(final String containerName, final String containerGuid,
+ final Interceptor[] interceptors)
+ {
+ super(containerName, containerGuid, interceptors);
+ }
+
+ // ------------------------------------------------------------------------------||
+ // Required Implementations -----------------------------------------------------||
+ // ------------------------------------------------------------------------------||
+
+ /**
+ * Required "invoke" as defined by InvocationHandler interface
+ */
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
+ {
+ // Set the invoked method as a SerializableMethod
+ SerializableMethod invokedMethod = new SerializableMethod(method);
+
+ // Use the overloaded implementation
+ return this.invoke(proxy, invokedMethod, args);
+ }
+
+ /**
+ * Handles invocation of "equals(Object)" upon a @Service Proxy
+ *
+ * Since this is a Singleton, if and only if the destination
+ * targets are to the same container, we'll consider
+ * the two Proxies equal
+ *
+ * @param proxy
+ * @param args
+ * @return
+ */
+ protected boolean invokeEquals(Object proxy, Object argument)
+ {
+
+ // If the argument is not a proxy
+ if (!Proxy.isProxyClass(argument.getClass()))
+ {
+ return false;
+ }
+
+ // Get the InvocationHandlers
+ InvocationHandler proxyHandler = this.getInvocationHandler(proxy);
+ InvocationHandler argumentHandler = Proxy.getInvocationHandler(argument);
+
+ // If argument handler is not @Service Handler
+ if (!(argumentHandler instanceof ServiceProxyInvocationHandlerBase))
+ {
+ return false;
+ }
+
+ // Cast
+ ServiceProxyInvocationHandlerBase proxySHandler = (ServiceProxyInvocationHandlerBase) proxyHandler;
+ ServiceProxyInvocationHandlerBase argumentSHandler = (ServiceProxyInvocationHandlerBase) argumentHandler;
+
+ // Ensure target containers are equal
+ String proxyContainerName = proxySHandler.getContainerName();
+ assert proxyContainerName != null : "Container Name for " + proxySHandler + " was not set and is required";
+ if (!proxyContainerName.equals(argumentSHandler.getContainerName()))
+ {
+ return false;
+ }
+
+ // Condition passed, so true
+ return true;
+
+ }
+
+ /**
+ * Handles invocation of "hashCode()" upon the proxy
+ *
+ * @param proxy
+ * @return
+ */
+ protected int invokeHashCode(Object proxy)
+ {
+ // Get the InvocationHandler
+ ServiceProxyInvocationHandlerBase handler = this.getInvocationHandler(proxy);
+
+ // Generate unique String by value according to rules in "invokeEquals";
+ // Destination Container and Business Interface
+ String unique = handler.getContainerName();
+
+ // Hash the String
+ return unique.hashCode();
+ }
+
+ // ------------------------------------------------------------------------------||
+ // Internal Helper Methods ------------------------------------------------------||
+ // ------------------------------------------------------------------------------||
+
+ protected ServiceProxyInvocationHandlerBase getInvocationHandler(Object proxy)
+ {
+ InvocationHandler handler = Proxy.getInvocationHandler(proxy);
+ assert handler instanceof ServiceProxyInvocationHandlerBase : "Expected "
+ + InvocationHandler.class.getSimpleName() + " of type " + ServiceProxyInvocationHandlerBase.class.getName()
+ + ", but instead was " + handler;
+ return (ServiceProxyInvocationHandlerBase) handler;
+ }
+
+ // ------------------------------------------------------------------------------||
+ // TO BE IMPLEMENTED ------------------------------------------------------------||
+ // ------------------------------------------------------------------------------||
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.proxy.handler.ProxyInvocationHandler#getAsynchronousProxy(java.lang.Object)
+ */
+ public Object getAsynchronousProxy(Object proxy)
+ {
+ throw new NotImplementedException("ALR");
+ }
+}
Added: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/service/ServiceRemoteProxyInvocationHandler.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/service/ServiceRemoteProxyInvocationHandler.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/service/ServiceRemoteProxyInvocationHandler.java 2008-11-10 00:13:19 UTC (rev 80729)
@@ -0,0 +1,130 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.proxy.handler.service;
+
+import java.io.Serializable;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.ejb3.proxy.container.InvokableContext;
+import org.jboss.ejb3.proxy.remoting.ProxyRemotingUtils;
+
+/**
+ * ServiceRemoteProxyInvocationHandler
+ *
+ * Invocation Handler for Remote view of
+ * a @Service proxy
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class ServiceRemoteProxyInvocationHandler extends ServiceProxyInvocationHandlerBase
+ implements
+ Serializable,
+ ServiceProxyInvocationHandler
+{
+
+ // --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private static final long serialVersionUID = 1L;
+
+ // --------------------------------------------------------------------------------||
+ // Instance Members ---------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private String url;
+
+ // --------------------------------------------------------------------------------||
+ // Constructor --------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Constructor
+ *
+ * @param containerName The name of the target container
+ * @param url The URL to the Remote Host
+ * @param interceptors The interceptors to apply to invocations upon this handler
+ */
+ public ServiceRemoteProxyInvocationHandler(final String containerName, final String containerGuid,
+ final Interceptor[] interceptors, final String url)
+ {
+ super(containerName, containerGuid, interceptors);
+
+ // Adjust URL if not specified to a default
+ String remotingUrl = url;
+ if (remotingUrl == null || remotingUrl.trim().length() == 0)
+ {
+ remotingUrl = ProxyRemotingUtils.getDefaultClientBinding();
+ }
+ this.setUrl(remotingUrl);
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Required Implementations -------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.proxy.handler.session.SessionProxyInvocationHandlerBase#getContainer()
+ */
+ @Override
+ protected InvokableContext getContainer()
+ {
+ return this.createRemoteProxyToContainer(this.getUrl());
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Functional Methods -------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Creates and returns a Remoting Proxy to invoke upon the container
+ *
+ * This implementation is marked as FIXME as remoting should be an add-on
+ * capability atop ejb3-proxy
+ *
+ * @param url The location of the remote host holding the Container
+ * @return
+ */
+ //FIXME
+ protected InvokableContext createRemoteProxyToContainer(String url)
+ {
+ InvokableContext container = ProxyRemotingUtils.createRemoteProxyToContainer(this.getContainerName(), this
+ .getContainerGuid(), url, this.getInterceptors(), null);
+ return container;
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Accessors / Mutators -----------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ public String getUrl()
+ {
+ return url;
+ }
+
+ public void setUrl(String url)
+ {
+ this.url = url;
+ }
+
+}
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionProxyInvocationHandlerBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionProxyInvocationHandlerBase.java 2008-11-10 00:11:30 UTC (rev 80728)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionProxyInvocationHandlerBase.java 2008-11-10 00:13:19 UTC (rev 80729)
@@ -24,9 +24,6 @@
import java.io.Serializable;
import org.jboss.aop.advice.Interceptor;
-import org.jboss.ejb3.common.registrar.spi.Ejb3Registrar;
-import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
-import org.jboss.ejb3.proxy.container.InvokableContext;
import org.jboss.ejb3.proxy.handler.ProxyInvocationHandlerBase;
import org.jboss.logging.Logger;
@@ -68,33 +65,4 @@
{
super(containerName, containerGuid, interceptors);
}
-
- /**
- * Returns the container housed locally
- *
- * @return
- */
- protected InvokableContext getContainerLocally()
- {
- // Lookup
- Object obj = Ejb3RegistrarLocator.locateRegistrar().lookup(this.getContainerName());
-
- // Ensure of correct type
- assert obj instanceof InvokableContext : "Container retrieved from " + Ejb3Registrar.class.getSimpleName()
- + " was not of expected type " + InvokableContext.class.getName() + " but was instead " + obj;
-
- // Return
- return (InvokableContext) obj;
- }
-
- // ------------------------------------------------------------------------------||
- // Contracts --------------------------------------------------------------------||
- // ------------------------------------------------------------------------------||
-
- /**
- * Obtains the Container upon which this Proxy should invoke
- *
- * @return
- */
- protected abstract InvokableContext getContainer();
}
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionSpecProxyInvocationHandlerBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionSpecProxyInvocationHandlerBase.java 2008-11-10 00:11:30 UTC (rev 80728)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionSpecProxyInvocationHandlerBase.java 2008-11-10 00:13:19 UTC (rev 80729)
@@ -26,8 +26,6 @@
import org.jboss.aop.advice.Interceptor;
import org.jboss.ejb3.common.lang.SerializableMethod;
-import org.jboss.ejb3.proxy.container.InvokableContext;
-import org.jboss.ejb3.proxy.handler.NotEligibleForDirectInvocationException;
import org.jboss.logging.Logger;
/**
@@ -47,6 +45,8 @@
// ------------------------------------------------------------------------------||
// Class Members ----------------------------------------------------------------||
// ------------------------------------------------------------------------------||
+
+ private static final long serialVersionUID = 1L;
private static final Logger log = Logger.getLogger(SessionSpecProxyInvocationHandlerBase.class);
@@ -86,46 +86,19 @@
// Required Implementations -----------------------------------------------------||
// ------------------------------------------------------------------------------||
+ /**
+ * Required "invoke" as defined by InvocationHandler interface
+ */
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
{
- // Attempt to handle directly
- try
- {
- return this.handleInvocationDirectly(proxy, args, method);
- }
- // Ignore this, we just couldn't handle here
- catch (NotEligibleForDirectInvocationException nefdie)
- {
- log.debug("Couldn't handle invocation directly within " + this + ": " + nefdie.getMessage());
- }
-
// Obtain an explicitly-specified actual class
String actualClass = this.getBusinessInterfaceType();
// Set the invoked method
SerializableMethod invokedMethod = new SerializableMethod(method, actualClass);
- /*
- * Obtain the Container
- */
- InvokableContext container = this.getContainer();
-
- /*
- * Invoke
- */
-
- // Adjust args if null to empty array
- if (args == null)
- {
- args = new Object[]
- {};
- }
-
- // Invoke
- Object result = container.invoke(proxy, invokedMethod, args);
-
- // Return
- return result;
+ // Use the overloaded implementation
+ return this.invoke(proxy, invokedMethod, args);
}
// ------------------------------------------------------------------------------||
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateful/StatefulProxyInvocationHandlerBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateful/StatefulProxyInvocationHandlerBase.java 2008-11-10 00:11:30 UTC (rev 80728)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateful/StatefulProxyInvocationHandlerBase.java 2008-11-10 00:13:19 UTC (rev 80729)
@@ -24,16 +24,13 @@
import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
-import java.net.MalformedURLException;
import org.jboss.aop.advice.Interceptor;
-import org.jboss.aspects.remoting.PojiProxy;
import org.jboss.ejb3.proxy.container.InvokableContext;
import org.jboss.ejb3.proxy.handler.session.SessionSpecProxyInvocationHandlerBase;
import org.jboss.ejb3.proxy.intf.StatefulSessionProxy;
-import org.jboss.ejb3.proxy.invocation.InvokableContextStatefulRemoteProxyInvocationHack;
+import org.jboss.ejb3.proxy.remoting.ProxyRemotingUtils;
import org.jboss.logging.Logger;
-import org.jboss.remoting.InvokerLocator;
import org.jboss.util.NotImplementedException;
/**
@@ -202,45 +199,17 @@
/**
* Creates and returns a Remoting Proxy to invoke upon the container
*
+ * This implementation is marked as FIXME as remoting should be an add-on
+ * capability atop ejb3-proxy
+ *
* @param url The location of the remote host holding the Container
* @return
*/
+ //FIXME
protected InvokableContext createRemoteProxyToContainer(String url)
{
- // Create an InvokerLocator
- InvokerLocator locator = null;
- try
- {
- locator = new InvokerLocator(url);
- }
- catch (MalformedURLException e)
- {
- throw new RuntimeException("Could not create " + InvokerLocator.class.getSimpleName() + " to url \"" + url
- + "\"", e);
- }
-
- /*
- * Define interceptors
- */
-
- // Get interceptors from the stack
- Interceptor[] interceptors = this.getInterceptors();
-
- /*
- * Create Proxy
- */
-
- // Create a POJI Proxy to the Container
- String containerName = this.getContainerName();
- assert containerName != null && containerName.trim().length() > 0 : "Container Name must be set";
- PojiProxy handler = new InvokableContextStatefulRemoteProxyInvocationHack(this.getContainerName(), this
- .getContainerGuid(), locator, interceptors, this.getSessionId());
- Class<?>[] interfaces = new Class<?>[]
- {InvokableContext.class};
- InvokableContext container = (InvokableContext) Proxy.newProxyInstance(InvokableContext.class.getClassLoader(),
- interfaces, handler);
-
- // Return
+ InvokableContext container = ProxyRemotingUtils.createRemoteProxyToContainer(this.getContainerName(), this
+ .getContainerGuid(), url, this.getInterceptors(), this.getSessionId());
return container;
}
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateful/StatefulRemoteProxyInvocationHandler.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateful/StatefulRemoteProxyInvocationHandler.java 2008-11-10 00:11:30 UTC (rev 80728)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateful/StatefulRemoteProxyInvocationHandler.java 2008-11-10 00:13:19 UTC (rev 80729)
@@ -25,7 +25,6 @@
import org.jboss.aop.advice.Interceptor;
import org.jboss.ejb3.proxy.container.InvokableContext;
-import org.jboss.ejb3.proxy.remoting.ProxyRemotingUtils;
/**
* StatefulRemoteProxyInvocationHandler
@@ -67,14 +66,9 @@
final Interceptor[] interceptors, final String businessInterfaceType, final String url)
{
super(containerName, containerGuid, interceptors, businessInterfaceType);
-
- // Adjust URL if not specified to a default
- String remotingUrl = url;
- if (remotingUrl == null || remotingUrl.trim().length() == 0)
- {
- remotingUrl = ProxyRemotingUtils.getDefaultClientBinding();
- }
- this.setUrl(remotingUrl);
+
+ // Set properties
+ this.setUrl(url);
}
// --------------------------------------------------------------------------------||
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateless/StatelessRemoteProxyInvocationHandler.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateless/StatelessRemoteProxyInvocationHandler.java 2008-11-10 00:11:30 UTC (rev 80728)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateless/StatelessRemoteProxyInvocationHandler.java 2008-11-10 00:13:19 UTC (rev 80729)
@@ -22,15 +22,10 @@
package org.jboss.ejb3.proxy.handler.session.stateless;
import java.io.Serializable;
-import java.lang.reflect.Proxy;
-import java.net.MalformedURLException;
import org.jboss.aop.advice.Interceptor;
-import org.jboss.aspects.remoting.PojiProxy;
import org.jboss.ejb3.proxy.container.InvokableContext;
-import org.jboss.ejb3.proxy.invocation.InvokableContextStatefulRemoteProxyInvocationHack;
import org.jboss.ejb3.proxy.remoting.ProxyRemotingUtils;
-import org.jboss.remoting.InvokerLocator;
/**
* StatelessRemoteProxyInvocationHandler
@@ -72,13 +67,8 @@
{
super(containerName, containerGuid, interceptors, businessInterfaceType);
- // Adjust URL if not specified to a default
- String remotingUrl = url;
- if (remotingUrl == null || remotingUrl.trim().length() == 0)
- {
- remotingUrl = ProxyRemotingUtils.getDefaultClientBinding();
- }
- this.setUrl(remotingUrl);
+ // Set properties
+ this.setUrl(url);
}
// --------------------------------------------------------------------------------||
@@ -101,47 +91,17 @@
/**
* Creates and returns a Remoting Proxy to invoke upon the container
*
+ * This implementation is marked as FIXME as remoting should be an add-on
+ * capability atop ejb3-proxy
+ *
* @param url The location of the remote host holding the Container
* @return
*/
- //FIXME Mostly a copy of the SFSB Remote Handler, but passing null
- // as a SessionID. Should be using more intelligent design, SLSB's have
- // no Sessions. To be reworked in InvokableContextStatefulRemoteProxyInvocationHack,
- // as this implementation is @deprecated
+ //FIXME
protected InvokableContext createRemoteProxyToContainer(String url)
{
- // Create an InvokerLocator
- InvokerLocator locator = null;
- try
- {
- locator = new InvokerLocator(url);
- }
- catch (MalformedURLException e)
- {
- throw new RuntimeException("Could not create " + InvokerLocator.class.getSimpleName() + " to url \"" + url
- + "\"", e);
- }
-
- /*
- * Define interceptors
- */
-
- // Get interceptors from the stack
- Interceptor[] interceptors = this.getInterceptors();
-
- /*
- * Create a Proxy
- */
-
- // Create a POJI Proxy to the Container
- PojiProxy handler = new InvokableContextStatefulRemoteProxyInvocationHack(this.getContainerName(), this
- .getContainerGuid(), locator, interceptors, null);
- Class<?>[] interfaces = new Class<?>[]
- {InvokableContext.class};
- InvokableContext container = (InvokableContext) Proxy.newProxyInstance(InvokableContext.class.getClassLoader(),
- interfaces, handler);
-
- // Return
+ InvokableContext container = ProxyRemotingUtils.createRemoteProxyToContainer(this.getContainerName(), this
+ .getContainerGuid(), this.getUrl(), this.getInterceptors(), null);
return container;
}
Added: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/intf/ServiceProxy.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/intf/ServiceProxy.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/intf/ServiceProxy.java 2008-11-10 00:13:19 UTC (rev 80729)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.proxy.intf;
+
+/**
+ * ServiceProxy
+ *
+ * Defines the contract for all methods required
+ * of JBoss EJB3 @Service Bean Proxies
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface ServiceProxy extends EjbProxy
+{
+
+}
Added: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiServiceRegistrar.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiServiceRegistrar.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiServiceRegistrar.java 2008-11-10 00:13:19 UTC (rev 80729)
@@ -0,0 +1,130 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.proxy.jndiregistrar;
+
+import org.jboss.aop.Advisor;
+import org.jboss.aop.Dispatcher;
+import org.jboss.ejb3.proxy.factory.ProxyFactory;
+import org.jboss.ejb3.proxy.factory.service.ServiceLocalProxyFactory;
+import org.jboss.ejb3.proxy.factory.service.ServiceRemoteProxyFactory;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossServiceBeanMetaData;
+
+/**
+ * JndiServiceRegistrar
+ *
+ * Responsible for binding of ObjectFactories and
+ * creation/registration of associated ProxyFactories,
+ * centralizing operations for @Service Implementations
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class JndiServiceRegistrar extends JndiSessionRegistrarBase
+{
+
+ // --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(JndiServiceRegistrar.class);
+
+ // --------------------------------------------------------------------------------||
+ // Constructor --------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Creates a JNDI Registrar from the specified configuration properties, none of
+ * which may be null.
+ *
+ * @param serviceProxyObjectFactoryType String representation of the JNDI Object Factory to use for @Service
+ */
+ public JndiServiceRegistrar(String serviceProxyObjectFactoryType)
+ {
+ super(serviceProxyObjectFactoryType);
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Required Implementations -------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Creates and returns a new local proxy factory for this @Service
+ *
+ * @param name The unique name for the ProxyFactory
+ * @param containerName The name of the Container upon which Proxies
+ * from the returned ProxyFactory will invoke
+ * @param containerGuid The globally-unique name of the container
+ * @param smd The metadata representing this SFSB
+ * @param cl The ClassLoader for this EJB Container
+ * @param advisor The Advisor for proxies created by this factory
+ */
+ @Override
+ protected ProxyFactory createLocalProxyFactory(final String name, final String containerName,
+ final String containerGuid, final JBossEnterpriseBeanMetaData smd, final ClassLoader cl, final Advisor advisor)
+ {
+ assert (smd instanceof JBossServiceBeanMetaData) : "Specified metadata was not of expected type "
+ + JBossServiceBeanMetaData.class.getSimpleName();
+ JBossServiceBeanMetaData serviceMd = (JBossServiceBeanMetaData) smd;
+ return new ServiceLocalProxyFactory(name, containerName, containerGuid, serviceMd, cl, advisor);
+ }
+
+ /**
+ * Creates and returns a new remote proxy factory for this SFSB
+ *
+ * @param name The unique name for the ProxyFactory
+ * @param containerName The name of the Container upon which Proxies
+ * from the returned ProxyFactory will invoke
+ * @param containerGuid The globally-unique name of the container
+ * @param smd The metadata representing this SFSB
+ * @param cl The ClassLoader for this EJB Container
+ * @param url The URL to use for Remoting
+ * @param advisor The Advisor for proxies created by this factory
+ * @param interceptorStackName The name of the client-side interceptor stack to use.
+ * If null the default will apply.
+ */
+ @Override
+ protected ProxyFactory createRemoteProxyFactory(final String name, final String containerName,
+ final String containerGuid, final JBossEnterpriseBeanMetaData smd, final ClassLoader cl, final String url,
+ final Advisor advisor, final String interceptorStackName)
+ {
+ // Ensure metadata is of expected type
+ assert (smd instanceof JBossServiceBeanMetaData) : "Specified metadata was not of expected type "
+ + JBossServiceBeanMetaData.class.getSimpleName();
+
+ // Cast
+ JBossServiceBeanMetaData serviceMd = (JBossServiceBeanMetaData) smd;
+
+ // Create
+ ProxyFactory factory = new ServiceRemoteProxyFactory(name, containerName, containerGuid, serviceMd, cl, url,
+ advisor, interceptorStackName);
+
+ // Register with Remoting
+ log.debug("Registering with Remoting Dispatcher under name \"" + factory.getName() + "\": " + factory);
+ Dispatcher.singleton.registerTarget(factory.getName(), factory);
+
+ // Return
+ return factory;
+ }
+
+}
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiSessionRegistrarBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiSessionRegistrarBase.java 2008-11-10 00:11:30 UTC (rev 80728)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiSessionRegistrarBase.java 2008-11-10 00:13:19 UTC (rev 80729)
@@ -41,7 +41,6 @@
import org.jboss.ejb3.common.registrar.spi.NotBoundException;
import org.jboss.ejb3.common.string.StringUtils;
import org.jboss.ejb3.proxy.factory.ProxyFactory;
-import org.jboss.ejb3.proxy.factory.session.SessionProxyFactory;
import org.jboss.ejb3.proxy.objectfactory.ProxyFactoryReferenceAddressTypes;
import org.jboss.ejb3.proxy.remoting.ProxyRemotingUtils;
import org.jboss.logging.Logger;
@@ -232,7 +231,7 @@
// Create and register a remote proxy factory
String defaultRemoteProxyFactoryKey = this.getProxyFactoryRegistryKey(defaultRemoteJndiName, smd, false);
- SessionProxyFactory factory = this.createRemoteProxyFactory(defaultRemoteProxyFactoryKey, containerName,
+ ProxyFactory factory = this.createRemoteProxyFactory(defaultRemoteProxyFactoryKey, containerName,
containerGuid, smd, cl, defaultClientBindUrl, advisor, null);
try
{
@@ -361,13 +360,13 @@
// Create and register a remote proxy factory specific to this binding
String remoteBindingProxyFactoryKey = this.getProxyFactoryRegistryKey(remoteBindingJndiName, smd, false);
- SessionProxyFactory remoteBindingProxyFactory = null;
+ ProxyFactory remoteBindingProxyFactory = null;
boolean reregister = true;
try
{
// Check if it's already available
remoteBindingProxyFactory = Ejb3RegistrarLocator.locateRegistrar().lookup(
- remoteBindingProxyFactoryKey, SessionProxyFactory.class);
+ remoteBindingProxyFactoryKey, ProxyFactory.class);
}
catch (NotBoundException nbe)
{
@@ -453,8 +452,8 @@
// Create and register a local proxy factory
String localProxyFactoryKey = this.getProxyFactoryRegistryKey(defaultLocalJndiName, smd, true);
- SessionProxyFactory factory = this.createLocalProxyFactory(localProxyFactoryKey, containerName, containerGuid,
- smd, cl, advisor);
+ ProxyFactory factory = this.createLocalProxyFactory(localProxyFactoryKey, containerName, containerGuid, smd,
+ cl, advisor);
try
{
this.registerProxyFactory(localProxyFactoryKey, factory, smd);
@@ -715,8 +714,8 @@
* @param cl The ClassLoader for this EJB Container
* @param advisor The Advisor for proxies created by this factory
*/
- protected abstract SessionProxyFactory createLocalProxyFactory(final String name, final String containerName,
- final String containerGuid, final JBossSessionBeanMetaData smd, final ClassLoader cl, final Advisor advisor);
+ protected abstract ProxyFactory createLocalProxyFactory(final String name, final String containerName,
+ final String containerGuid, final JBossEnterpriseBeanMetaData smd, final ClassLoader cl, final Advisor advisor);
/**
* Creates and returns a new remote proxy factory for this Session Bean
@@ -732,8 +731,8 @@
* @param interceptorStackName The name of the client-side interceptor stack to use.
* If null the default will apply.
*/
- protected abstract SessionProxyFactory createRemoteProxyFactory(final String name, final String containerName,
- final String containerGuid, final JBossSessionBeanMetaData smd, final ClassLoader cl, final String url,
+ protected abstract ProxyFactory createRemoteProxyFactory(final String name, final String containerName,
+ final String containerGuid, final JBossEnterpriseBeanMetaData smd, final ClassLoader cl, final String url,
final Advisor advisor, final String interceptorStackName);
// --------------------------------------------------------------------------------||
@@ -784,7 +783,7 @@
Collection<JndiReferenceBinding> addressesToBind = new ArrayList<JndiReferenceBinding>();
StringBuffer sb = new StringBuffer();
sb.append("Binding the following Entries in Global JNDI:\n\n");
-
+
for (JndiReferenceBinding binding : bindings.getDefaultRemoteBindings())
{
sb.append("\t");
@@ -841,12 +840,12 @@
}
}
}
-
+
// Log
log.info(sb.toString());
-
+
// Bind all addresses
- for(JndiReferenceBinding binding : addressesToBind)
+ for (JndiReferenceBinding binding : addressesToBind)
{
bind(context, binding, useRebind);
}
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiStatefulSessionRegistrar.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiStatefulSessionRegistrar.java 2008-11-10 00:11:30 UTC (rev 80728)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiStatefulSessionRegistrar.java 2008-11-10 00:13:19 UTC (rev 80729)
@@ -23,10 +23,11 @@
import org.jboss.aop.Advisor;
import org.jboss.aop.Dispatcher;
-import org.jboss.ejb3.proxy.factory.session.SessionProxyFactory;
+import org.jboss.ejb3.proxy.factory.ProxyFactory;
import org.jboss.ejb3.proxy.factory.session.stateful.StatefulSessionLocalProxyFactory;
import org.jboss.ejb3.proxy.factory.session.stateful.StatefulSessionRemoteProxyFactory;
import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
/**
@@ -79,10 +80,13 @@
* @param advisor The Advisor for proxies created by this factory
*/
@Override
- protected SessionProxyFactory createLocalProxyFactory(final String name, final String containerName,
- final String containerGuid, final JBossSessionBeanMetaData smd, final ClassLoader cl, final Advisor advisor)
+ protected ProxyFactory createLocalProxyFactory(final String name, final String containerName,
+ final String containerGuid, final JBossEnterpriseBeanMetaData smd, final ClassLoader cl, final Advisor advisor)
{
- return new StatefulSessionLocalProxyFactory(name, containerName, containerGuid, smd, cl, advisor);
+ assert (smd instanceof JBossSessionBeanMetaData) : "Specified metadata was not of expected type "
+ + JBossSessionBeanMetaData.class.getSimpleName() + " but was instead " + smd;
+ JBossSessionBeanMetaData sessionMd = (JBossSessionBeanMetaData) smd;
+ return new StatefulSessionLocalProxyFactory(name, containerName, containerGuid, sessionMd, cl, advisor);
}
/**
@@ -100,12 +104,19 @@
* If null the default will apply.
*/
@Override
- protected SessionProxyFactory createRemoteProxyFactory(final String name, final String containerName,
- final String containerGuid, final JBossSessionBeanMetaData smd, final ClassLoader cl, final String url,
+ protected ProxyFactory createRemoteProxyFactory(final String name, final String containerName,
+ final String containerGuid, final JBossEnterpriseBeanMetaData smd, final ClassLoader cl, final String url,
final Advisor advisor, final String interceptorStackName)
{
+ // Ensure metadata is of expected type
+ assert (smd instanceof JBossSessionBeanMetaData) : "Specified metadata was not of expected type "
+ + JBossSessionBeanMetaData.class.getSimpleName() + " but was instead " + smd;
+
+ // Cast
+ JBossSessionBeanMetaData sessionMd = (JBossSessionBeanMetaData) smd;
+
// Create
- SessionProxyFactory factory = new StatefulSessionRemoteProxyFactory(name, containerName, containerGuid, smd, cl,
+ ProxyFactory factory = new StatefulSessionRemoteProxyFactory(name, containerName, containerGuid, sessionMd, cl,
url, advisor, interceptorStackName);
// Register with Remoting
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiStatelessSessionRegistrar.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiStatelessSessionRegistrar.java 2008-11-10 00:11:30 UTC (rev 80728)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiStatelessSessionRegistrar.java 2008-11-10 00:13:19 UTC (rev 80729)
@@ -23,10 +23,11 @@
import org.jboss.aop.Advisor;
import org.jboss.aop.Dispatcher;
-import org.jboss.ejb3.proxy.factory.session.SessionProxyFactory;
+import org.jboss.ejb3.proxy.factory.ProxyFactory;
import org.jboss.ejb3.proxy.factory.session.stateless.StatelessSessionLocalProxyFactory;
import org.jboss.ejb3.proxy.factory.session.stateless.StatelessSessionRemoteProxyFactory;
import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
/**
@@ -79,10 +80,13 @@
* @param advisor The Advisor for proxies created by this factory
*/
@Override
- protected SessionProxyFactory createLocalProxyFactory(final String name, final String containerName,
- final String containerGuid, final JBossSessionBeanMetaData smd, final ClassLoader cl, final Advisor advisor)
+ protected ProxyFactory createLocalProxyFactory(final String name, final String containerName,
+ final String containerGuid, final JBossEnterpriseBeanMetaData smd, final ClassLoader cl, final Advisor advisor)
{
- return new StatelessSessionLocalProxyFactory(name, containerName, containerGuid, smd, cl, advisor);
+ assert (smd instanceof JBossSessionBeanMetaData) : "Specified metadata was not of expected type "
+ + JBossSessionBeanMetaData.class.getSimpleName();
+ JBossSessionBeanMetaData sessionMd = (JBossSessionBeanMetaData) smd;
+ return new StatelessSessionLocalProxyFactory(name, containerName, containerGuid, sessionMd, cl, advisor);
}
/**
@@ -100,12 +104,19 @@
* If null the default will apply.
*/
@Override
- protected SessionProxyFactory createRemoteProxyFactory(final String name, final String containerName,
- final String containerGuid, final JBossSessionBeanMetaData smd, final ClassLoader cl, final String url,
+ protected ProxyFactory createRemoteProxyFactory(final String name, final String containerName,
+ final String containerGuid, final JBossEnterpriseBeanMetaData smd, final ClassLoader cl, final String url,
final Advisor advisor, final String interceptorStackName)
{
+ // Ensure metadata is of expected type
+ assert (smd instanceof JBossSessionBeanMetaData) : "Specified metadata was not of expected type "
+ + JBossSessionBeanMetaData.class.getSimpleName();
+
+ // Cast
+ JBossSessionBeanMetaData sessionMd = (JBossSessionBeanMetaData) smd;
+
// Create
- SessionProxyFactory factory = new StatelessSessionRemoteProxyFactory(name, containerName, containerGuid, smd, cl,
+ ProxyFactory factory = new StatelessSessionRemoteProxyFactory(name, containerName, containerGuid, sessionMd, cl,
url, advisor, interceptorStackName);
// Register with Remoting
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyObjectFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyObjectFactory.java 2008-11-10 00:11:30 UTC (rev 80728)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyObjectFactory.java 2008-11-10 00:13:19 UTC (rev 80729)
@@ -22,13 +22,16 @@
package org.jboss.ejb3.proxy.objectfactory;
import java.io.Serializable;
+import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import javax.naming.Context;
import javax.naming.Name;
@@ -243,6 +246,135 @@
return value;
}
+ /**
+ * Looks to the metadata specified by the reference addresses to determine if
+ * an EJB3 Business View is defined here. Additionally checks that both local
+ * and remote business interfaces are not bound to the same JNDI Address
+ *
+ * @param name
+ * @param referenceAddresses
+ * @return
+ */
+ protected boolean hasBusiness(Name name, Map<String, List<String>> referenceAddresses)
+ {
+ // Initialize
+ boolean hasBusiness = false;
+
+ // Obtain metadata
+ boolean hasLocalBusiness = this.hasLocalBusiness(referenceAddresses);
+ boolean hasRemoteBusiness = this.hasRemoteBusiness(referenceAddresses);
+
+ // Ensure both local and remote home are not specified here
+ String errorMessage = "ObjectFactory at JNDI \"" + name.toString()
+ + "\" contains references to both local and remote business interfaces";
+ assert !(hasLocalBusiness && hasRemoteBusiness) : errorMessage;
+ if (hasLocalBusiness && hasRemoteBusiness)
+ {
+ throw new RuntimeException(errorMessage);
+ }
+
+ // Set
+ hasBusiness = hasLocalBusiness || hasRemoteBusiness;
+
+ // Return
+ return hasBusiness;
+
+ }
+
+ /**
+ * If the specified proxy has been defined outside of
+ * this naming Context's ClassLoader, it must be reconstructed
+ * using the TCL so we avoid CCE. This is especially vital using
+ * a scope ClassLoader (ie. has defined by Servlet spec during Web Injection)
+ *
+ * @param proxy
+ */
+ protected void ensureProxyVisibleToTcl(Object proxy)
+ {
+ /*
+ * We've got to ensure that the Proxy will be assignable to the target
+ * within this CL
+ */
+
+ // Get the TCL
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+
+ // Get the Proxy's CL
+ ClassLoader proxyCl = proxy.getClass().getClassLoader();
+
+ // If the classloaders are not equal
+ if (tcl != proxyCl)
+ {
+ /*
+ * Reconstruct/redefine the Proxy in our CL
+ */
+
+ // Get the Proxy Class
+ Class<?> proxyClass = proxy.getClass();
+
+ // Ensure we've got a Proxy
+ assert Proxy.isProxyClass(proxyClass) : "Assumed Proxy is not an instance of " + Proxy.class.getName();
+
+ // Get the InvocationHandler
+ InvocationHandler handler = Proxy.getInvocationHandler(proxy);
+
+ // Get the Interfaces
+ Class<?>[] proxyInterfaces = proxyClass.getInterfaces();
+
+ // Make a Set to hold the redefined classes
+ Set<Class<?>> ourClInterfaces = new HashSet<Class<?>>();
+
+ // For each interface defined by the Proxy
+ for (Class<?> proxyInterface : proxyInterfaces)
+ {
+ // Get the FQN
+ String proxyInterfaceName = proxyInterface.getName();
+
+ // Redefine the class in our CL
+ Class<?> ourDefinedProxyInterface = null;
+ try
+ {
+ ourDefinedProxyInterface = Class.forName(proxyInterfaceName, false, tcl);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new RuntimeException("Can not find interface declared by Proxy in our CL + " + tcl, e);
+ }
+
+ // Add the Class to the Set
+ ourClInterfaces.add(ourDefinedProxyInterface);
+ }
+
+ // Redefine the Proxy in our CL
+ proxy = Proxy.newProxyInstance(tcl, ourClInterfaces.toArray(new Class<?>[]
+ {}), handler);
+ }
+ }
+
+ /**
+ * Determines if the specified metadata contains a type of local business
+ *
+ * @param referenceAddresses
+ * @return
+ */
+ protected boolean hasLocalBusiness(Map<String, List<String>> referenceAddresses)
+ {
+ return referenceAddresses
+ .containsKey(ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_BUSINESS_INTERFACE_LOCAL);
+ }
+
+ /**
+ * Determines if the specified metadata contains a type of remote business
+ *
+ * @param referenceAddresses
+ * @return
+ */
+ protected boolean hasRemoteBusiness(Map<String, List<String>> referenceAddresses)
+ {
+ return referenceAddresses
+ .containsKey(ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_BUSINESS_INTERFACE_REMOTE);
+ }
+
// --------------------------------------------------------------------------------||
// Specifications -----------------------------------------------------------------||
// --------------------------------------------------------------------------------||
Added: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/service/ServiceProxyObjectFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/service/ServiceProxyObjectFactory.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/service/ServiceProxyObjectFactory.java 2008-11-10 00:13:19 UTC (rev 80729)
@@ -0,0 +1,134 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.proxy.objectfactory.service;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.Name;
+
+import org.jboss.ejb3.proxy.factory.ProxyFactory;
+import org.jboss.ejb3.proxy.factory.service.ServiceProxyFactory;
+import org.jboss.ejb3.proxy.objectfactory.ProxyFactoryReferenceAddressTypes;
+import org.jboss.ejb3.proxy.objectfactory.ProxyObjectFactory;
+import org.jboss.logging.Logger;
+
+/**
+ * ServiceProxyObjectFactory
+ *
+ * A JNDI ObjectFactory responsible for returning the
+ * appropriate @Service Proxy upon lookup
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class ServiceProxyObjectFactory extends ProxyObjectFactory
+{
+ // --------------------------------------------------------------------------------||
+ // Class Members -----------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private static final long serialVersionUID = 1L;
+
+ private static final Logger log = Logger.getLogger(ServiceProxyObjectFactory.class);
+
+ // --------------------------------------------------------------------------------||
+ // Required Implementations -------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /*
+ * TODO
+ *
+ * This implementation simply creates a new proxy upon each lookup. We should
+ * improve performance by providing a caching mechanism to cache:
+ *
+ * Proxy per JNDI Address
+ *
+ * Can be done via a static Map? Not in an instance variable because
+ * ObjectFactories are made upon each lookup
+ */
+ /**
+ * @Service Object Factories must always create a new @Service Proxy if one is not
+ * available in the internal cache, otherwise use the cached one and return
+ *
+ * @param proxyFactory The ProxyFactory to use
+ * @param name The JNDI name looked up
+ * @param referenceAddresses
+ */
+ @Override
+ protected Object getProxy(ProxyFactory proxyFactory, Name name, Map<String, List<String>> referenceAddresses)
+ {
+ // Initialize
+ Object proxy = null;
+
+ // Determine if a business interface is defined here
+ boolean hasBusiness = this.hasBusiness(name, referenceAddresses);
+
+ // Cast
+ ServiceProxyFactory sFactory = null;
+ try
+ {
+ sFactory = this.getProxyFactoryClass().cast(proxyFactory);
+ }
+ catch (ClassCastException cce)
+ {
+ throw new RuntimeException(ProxyFactory.class.getSimpleName() + " used in "
+ + ServiceProxyFactory.class.getSimpleName() + " must be of type " + ServiceProxyFactory.class.getName()
+ + " but was instead " + proxyFactory, cce);
+ }
+
+ // If bound to business
+ if (hasBusiness)
+ {
+ // Use a general-purpose proxy for all business interfaces
+ proxy = sFactory.createProxy();
+ log.debug("Created Proxy of type " + proxy.getClass().getSimpleName() + ".");
+
+ }
+ // No valid type is bound here
+ else
+ {
+ throw new RuntimeException(proxyFactory + " found associated with JNDI Binding " + name.toString()
+ + " is not bound to create/return any valid @Service Business Interfaces");
+ }
+
+ // Obtain the target container name
+ String containerName = this.getSingleRequiredReferenceAddressValue(name, referenceAddresses,
+ ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_EJBCONTAINER_NAME);
+ assert containerName != null && containerName.trim().length() > 0 : "Container Name must be specified via reference address + \""
+ + ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_EJBCONTAINER_NAME + "\"";
+
+ // Return
+ return proxy;
+ }
+
+ /**
+ * Obtains the type or supertype used by proxy factories for this Object Factory
+ * @return
+ */
+ @Override
+ protected Class<ServiceProxyFactory> getProxyFactoryClass()
+ {
+ return ServiceProxyFactory.class;
+ }
+
+}
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/session/SessionProxyObjectFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/session/SessionProxyObjectFactory.java 2008-11-10 00:11:30 UTC (rev 80728)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/session/SessionProxyObjectFactory.java 2008-11-10 00:13:19 UTC (rev 80729)
@@ -21,12 +21,8 @@
*/
package org.jboss.ejb3.proxy.objectfactory.session;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import javax.naming.Name;
@@ -84,7 +80,7 @@
SessionProxyFactory sFactory = null;
try
{
- sFactory = SessionProxyFactory.class.cast(factory);
+ sFactory = this.getProxyFactoryClass().cast(factory);
}
catch (ClassCastException cce)
{
@@ -134,64 +130,8 @@
log.debug("Created Proxy of type " + proxy.getClass().getSimpleName() + " for EJB3 Business Interface: "
+ businessInterface);
- /*
- * We've got to ensure that the Proxy will be assignable to the target
- * within this CL
- */
-
- // Get the TCL
- ClassLoader tcl = Thread.currentThread().getContextClassLoader();
-
- // Get the Proxy's CL
- ClassLoader proxyCl = proxy.getClass().getClassLoader();
-
- // If the classloaders are not equal
- if (tcl != proxyCl)
- {
- /*
- * Reconstruct/redefine the Proxy in our CL
- */
-
- // Get the Proxy Class
- Class<?> proxyClass = proxy.getClass();
-
- // Ensure we've got a Proxy
- assert Proxy.isProxyClass(proxyClass) : "Assumed Proxy is not an instance of " + Proxy.class.getName();
-
- // Get the InvocationHandler
- InvocationHandler handler = Proxy.getInvocationHandler(proxy);
-
- // Get the Interfaces
- Class<?>[] proxyInterfaces = proxyClass.getInterfaces();
-
- // Make a Set to hold the redefined classes
- Set<Class<?>> ourClInterfaces = new HashSet<Class<?>>();
-
- // For each interface defined by the Proxy
- for (Class<?> proxyInterface : proxyInterfaces)
- {
- // Get the FQN
- String proxyInterfaceName = proxyInterface.getName();
-
- // Redefine the class in our CL
- Class<?> ourDefinedProxyInterface = null;
- try
- {
- ourDefinedProxyInterface = Class.forName(proxyInterfaceName, false, tcl);
- }
- catch (ClassNotFoundException e)
- {
- throw new RuntimeException("Can not find interface declared by Proxy in our CL + " + tcl, e);
- }
-
- // Add the Class to the Set
- ourClInterfaces.add(ourDefinedProxyInterface);
- }
-
- // Redefine the Proxy in our CL
- proxy = Proxy.newProxyInstance(tcl, ourClInterfaces.toArray(new Class<?>[]
- {}), handler);
- }
+ // Ensure the proxy is visible to the TCL
+ this.ensureProxyVisibleToTcl(proxy);
}
else
{
@@ -222,7 +162,8 @@
* Obtains the type or supertype used by proxy factories for this Object Factory
* @return
*/
- protected Class<?> getProxyFactoryClass()
+ @Override
+ protected Class<SessionProxyFactory> getProxyFactoryClass()
{
return SessionProxyFactory.class;
}
@@ -267,63 +208,4 @@
return hasHome;
}
- /**
- * Looks to the metadata specified by the reference addresses to determine if
- * an EJB3 Business View is defined here. Additionally checks that both local
- * and remote business interfaces are not bound to the same JNDI Address
- *
- * @param name
- * @param referenceAddresses
- * @return
- */
- protected boolean hasBusiness(Name name, Map<String, List<String>> referenceAddresses)
- {
- // Initialize
- boolean hasBusiness = false;
-
- // Obtain metadata
- boolean hasLocalBusiness = this.hasLocalBusiness(referenceAddresses);
- boolean hasRemoteBusiness = this.hasRemoteBusiness(referenceAddresses);
-
- // Ensure both local and remote home are not specified here
- String errorMessage = "ObjectFactory at JNDI \"" + name.toString()
- + "\" contains references to both local and remote business interfaces";
- assert !(hasLocalBusiness && hasRemoteBusiness) : errorMessage;
- if (hasLocalBusiness && hasRemoteBusiness)
- {
- throw new RuntimeException(errorMessage);
- }
-
- // Set
- hasBusiness = hasLocalBusiness || hasRemoteBusiness;
-
- // Return
- return hasBusiness;
-
- }
-
- /**
- * Determines if the specified metadata contains a type of local business
- *
- * @param referenceAddresses
- * @return
- */
- protected boolean hasLocalBusiness(Map<String, List<String>> referenceAddresses)
- {
- return referenceAddresses
- .containsKey(ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_BUSINESS_INTERFACE_LOCAL);
- }
-
- /**
- * Determines if the specified metadata contains a type of remote business
- *
- * @param referenceAddresses
- * @return
- */
- protected boolean hasRemoteBusiness(Map<String, List<String>> referenceAddresses)
- {
- return referenceAddresses
- .containsKey(ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_BUSINESS_INTERFACE_REMOTE);
- }
-
}
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectstore/ObjectStoreBindings.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectstore/ObjectStoreBindings.java 2008-11-10 00:11:30 UTC (rev 80728)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectstore/ObjectStoreBindings.java 2008-11-10 00:13:19 UTC (rev 80729)
@@ -105,4 +105,10 @@
String OBJECTSTORE_BEAN_NAME_JNDI_REGISTRAR_SFSB = ObjectStoreBindings.OBJECTSTORE_NAMESPACE_JNDI_REGISTRAR_SESSION
+ "SFSBJndiRegistrar";
+ /**
+ * Bind name for @Service JNDI Registrar
+ */
+ String OBJECTSTORE_BEAN_NAME_JNDI_REGISTRAR_SERVICE = ObjectStoreBindings.OBJECTSTORE_NAMESPACE_JNDI_REGISTRAR
+ + "ServiceJndiRegistrar";
+
}
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/remoting/ProxyRemotingUtils.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/remoting/ProxyRemotingUtils.java 2008-11-10 00:11:30 UTC (rev 80728)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/remoting/ProxyRemotingUtils.java 2008-11-10 00:13:19 UTC (rev 80729)
@@ -21,8 +21,16 @@
*/
package org.jboss.ejb3.proxy.remoting;
+import java.io.Serializable;
+import java.lang.reflect.Proxy;
+import java.net.MalformedURLException;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aspects.remoting.PojiProxy;
import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
import org.jboss.ejb3.common.registrar.spi.NotBoundException;
+import org.jboss.ejb3.proxy.container.InvokableContext;
+import org.jboss.ejb3.proxy.invocation.InvokableContextStatefulRemoteProxyInvocationHack;
import org.jboss.logging.Logger;
import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.transport.Connector;
@@ -113,4 +121,57 @@
return DEFAULT_CLIENT_BINDING;
}
+ /**
+ * Creates a remote proxy to the container using the specified
+ * arguments.
+ *
+ * This is here to centralize the hackiness of this approach. Ideally
+ * remoting should be an add-on capability, not built-in to the core
+ * logic of having a proxy to a container. Thus marked as FIXME.
+ *
+ * @param containerName
+ * @param containerGuid
+ * @param url
+ * @param interceptors
+ * @param sessionId
+ * @return
+ */
+ //FIXME
+ public static InvokableContext createRemoteProxyToContainer(String containerName, String containerGuid, String url,
+ Interceptor[] interceptors, Serializable sessionId)
+ {
+ // Default the remoting URL if necessary
+ if (url == null || url.trim().length() == 0)
+ {
+ url = ProxyRemotingUtils.getDefaultClientBinding();
+ }
+
+ // Create an InvokerLocator
+ InvokerLocator locator = null;
+ try
+ {
+ locator = new InvokerLocator(url);
+ }
+ catch (MalformedURLException e)
+ {
+ throw new RuntimeException("Could not create " + InvokerLocator.class.getSimpleName() + " to url \"" + url
+ + "\"", e);
+ }
+
+ /*
+ * Create a Proxy
+ */
+
+ // Create a POJI Proxy to the Container
+ PojiProxy handler = new InvokableContextStatefulRemoteProxyInvocationHack(containerName, containerGuid, locator,
+ interceptors, sessionId);
+ Class<?>[] interfaces = new Class<?>[]
+ {InvokableContext.class};
+ InvokableContext container = (InvokableContext) Proxy.newProxyInstance(InvokableContext.class.getClassLoader(),
+ interfaces, handler);
+
+ // Return
+ return container;
+ }
+
}
More information about the jboss-cvs-commits
mailing list