[jboss-cvs] JBossAS SVN: r109346 - in projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3: core/businessobject and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Nov 16 07:28:41 EST 2010
Author: wolfc
Date: 2010-11-16 07:28:40 -0500 (Tue, 16 Nov 2010)
New Revision: 109346
Added:
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/businessobject/
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/businessobject/BusinessObjectFactory.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/businessobject/LegacyStatefulBusinessObjectFactory.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/businessobject/LegacyStatelessBusinessObjectFactory.java
Modified:
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java
Log:
EJBTHREE-2126: create a BusinessObjectFactory plug point
Added: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/businessobject/BusinessObjectFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/businessobject/BusinessObjectFactory.java (rev 0)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/businessobject/BusinessObjectFactory.java 2010-11-16 12:28:40 UTC (rev 109346)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.core.businessobject;
+
+import org.jboss.ejb3.session.SessionContainer;
+
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @deprecated should not expose SessionContainer
+ */
+public interface BusinessObjectFactory
+{
+ <B> B createBusinessObject(SessionContainer container, Serializable sessionId, Class<B> businessInterface);
+}
Added: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/businessobject/LegacyStatefulBusinessObjectFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/businessobject/LegacyStatefulBusinessObjectFactory.java (rev 0)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/businessobject/LegacyStatefulBusinessObjectFactory.java 2010-11-16 12:28:40 UTC (rev 109346)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.core.businessobject;
+
+import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
+import org.jboss.ejb3.proxy.factory.ProxyFactoryHelper;
+import org.jboss.ejb3.proxy.impl.factory.session.stateful.StatefulSessionProxyFactory;
+import org.jboss.ejb3.proxy.impl.jndiregistrar.JndiStatefulSessionRegistrar;
+import org.jboss.ejb3.session.SessionContainer;
+import org.jboss.ejb3.stateful.StatefulContainer;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public class LegacyStatefulBusinessObjectFactory implements BusinessObjectFactory
+{
+ public <B> B createBusinessObject(SessionContainer container, Serializable sessionId, Class<B> businessInterface)
+ {
+ assert businessInterface != null : "businessInterface is null";
+
+ boolean isRemote = false;
+ boolean found = false;
+ Class<?>[] remoteInterfaces = ProxyFactoryHelper.getRemoteAndBusinessRemoteInterfaces(container);
+ for (Class<?> intf : remoteInterfaces)
+ {
+ if (intf.getName().equals(businessInterface.getName()))
+ {
+ isRemote = true;
+ found = true;
+ break;
+ }
+ }
+ if (found == false)
+ {
+ Class<?>[] localInterfaces = ProxyFactoryHelper.getLocalAndBusinessLocalInterfaces(container);
+ for (Class<?> intf : localInterfaces)
+ {
+ if (intf.getName().equals(businessInterface.getName()))
+ {
+ found = true;
+ break;
+ }
+ }
+ }
+ if (found == false)
+ throw new IllegalStateException(businessInterface.getName() + " is not a business interface for container "
+ + this);
+
+ // Obtain SFSB JNDI Registrar
+ String sfsbJndiRegistrarObjectStoreBindName = ((StatefulContainer) container).getJndiRegistrarBindName();
+ JndiStatefulSessionRegistrar sfsbJndiRegistrar = Ejb3RegistrarLocator.locateRegistrar().lookup(
+ sfsbJndiRegistrarObjectStoreBindName, JndiStatefulSessionRegistrar.class);
+
+ // Get the metadata
+ JBossSessionBeanMetaData smd = container.getMetaData();
+
+ // Get the appropriate JNDI Name
+ String jndiName = !isRemote ? smd.getLocalJndiName() : smd.getJndiName();
+
+ // Find the Proxy Factory Key for this SFSB
+ String proxyFactoryKey = sfsbJndiRegistrar.getProxyFactoryRegistryKey(jndiName, smd, !isRemote);
+
+ // Lookup the Proxy Factory in the Object Store
+ StatefulSessionProxyFactory proxyFactory = Ejb3RegistrarLocator.locateRegistrar().lookup(proxyFactoryKey,
+ StatefulSessionProxyFactory.class);
+
+ // Create a new business proxy
+ Object proxy = proxyFactory.createProxyBusiness(sessionId, businessInterface.getName());
+
+ // Return the Proxy
+ return businessInterface.cast(proxy);
+
+ // Collection<ProxyFactory> proxyFactories = this.proxyDeployer.getProxyFactories().values();
+ // for (ProxyFactory factory : proxyFactories)
+ // {
+ // if (isRemote && factory instanceof StatefulRemoteProxyFactory)
+ // {
+ // return ((StatefulRemoteProxyFactory) factory).createProxyBusiness(ctx.getId(),null);
+ // }
+ // else if (!isRemote && factory instanceof StatefulLocalProxyFactory)
+ // {
+ // return ((StatefulLocalProxyFactory) factory).createProxyBusiness(ctx.getId(),null);
+ // }
+ // }
+ // throw new IllegalStateException("Unable to create proxy for getBusinessObject as a proxy factory was not found");
+ }
+}
Added: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/businessobject/LegacyStatelessBusinessObjectFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/businessobject/LegacyStatelessBusinessObjectFactory.java (rev 0)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/businessobject/LegacyStatelessBusinessObjectFactory.java 2010-11-16 12:28:40 UTC (rev 109346)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.core.businessobject;
+
+import org.jboss.ejb3.session.SessionContainer;
+import org.jboss.ejb3.util.CollectionHelper;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+
+import javax.naming.NamingException;
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public class LegacyStatelessBusinessObjectFactory implements BusinessObjectFactory
+{
+ public <B> B createBusinessObject(SessionContainer container, Serializable sessionId, Class<B> intf)
+ {
+ assert sessionId == null : "sessionId is must be null for Stateless";
+ assert intf != null : "intf is null";
+
+ try
+ {
+
+ /*
+ * Get all business interfaces
+ */
+ Set<String> businessInterfaceNames = new HashSet<String>();
+ JBossSessionBeanMetaData smd= (JBossSessionBeanMetaData) container.getXml();
+ CollectionHelper.addAllIfSet(businessInterfaceNames, smd.getBusinessRemotes());
+ CollectionHelper.addAllIfSet(businessInterfaceNames, smd.getBusinessLocals());
+
+ String interfaceName = intf.getName();
+
+ if (!businessInterfaceNames.contains(interfaceName))
+ throw new IllegalStateException("Cannot find BusinessObject for interface: " + interfaceName);
+
+ String jndiName = container.getXml().determineResolvedJndiName(interfaceName);
+ return intf.cast(container.getInitialContext().lookup(jndiName));
+ }
+ catch (NamingException e)
+ {
+ throw new RuntimeException("failed to invoke getBusinessObject", e);
+ }
+ }
+}
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java 2010-11-16 11:19:56 UTC (rev 109345)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java 2010-11-16 12:28:40 UTC (rev 109346)
@@ -21,27 +21,13 @@
*/
package org.jboss.ejb3.session;
-import java.io.Serializable;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Set;
-import java.util.concurrent.ExecutorService;
-
-import javax.ejb.EJBLocalObject;
-import javax.ejb.EJBObject;
-import javax.ejb.Handle;
-import javax.ejb.RemoveException;
-
import org.jboss.aop.Domain;
import org.jboss.aop.MethodInfo;
import org.jboss.aop.util.MethodHashing;
import org.jboss.ejb3.Ejb3Deployment;
import org.jboss.ejb3.common.lang.SerializableMethod;
import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
+import org.jboss.ejb3.core.businessobject.BusinessObjectFactory;
import org.jboss.ejb3.core.proxy.spi.CurrentRemoteProxyFactory;
import org.jboss.ejb3.core.proxy.spi.RemoteProxyFactory;
import org.jboss.ejb3.endpoint.Endpoint;
@@ -55,6 +41,20 @@
import org.jboss.logging.Logger;
import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import javax.ejb.EJBLocalObject;
+import javax.ejb.EJBObject;
+import javax.ejb.Handle;
+import javax.ejb.RemoveException;
+import java.io.Serializable;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+
/**
* SessionSpecContainer
*
@@ -83,6 +83,8 @@
*/
private final ExecutorService asynchronousExecutor;
+ private BusinessObjectFactory businessObjectFactory;
+
// ------------------------------------------------------------------------------||
// Constructor ------------------------------------------------------------------||
// ------------------------------------------------------------------------------||
@@ -110,7 +112,7 @@
}
this.asynchronousExecutor = asynchronousExecutor;
}
-
+
/**
* Invokes the specified method upon the specified session, passing the specified
* arguments.
@@ -539,7 +541,12 @@
}
return businessInterfaces;
}
-
+
+ protected BusinessObjectFactory getBusinessObjectFactory()
+ {
+ return businessObjectFactory;
+ }
+
/**
* Returns true if the passed fully qualified class name, represents a
* EJB 2.x view of the EJB, corresponding to this container. Else
@@ -601,6 +608,8 @@
}
businessInterfaces = Collections.unmodifiableSet(set);
+ verifyBusinessObjectFactory();
+
super.lockedStart();
}
@@ -622,4 +631,14 @@
{
return this.asynchronousExecutor;
}
+
+ public void setBusinessObjectFactory(BusinessObjectFactory factory)
+ {
+ this.businessObjectFactory = factory;
+ }
+
+ protected void verifyBusinessObjectFactory()
+ {
+ log.warn("EJBTHREE-2126: container " + this + " does not verify the businessObjectFactory");
+ }
}
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java 2010-11-16 11:19:56 UTC (rev 109345)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java 2010-11-16 12:28:40 UTC (rev 109346)
@@ -45,6 +45,7 @@
import org.jboss.ejb3.cache.StatefulObjectFactory;
import org.jboss.ejb3.common.lang.SerializableMethod;
import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
+import org.jboss.ejb3.core.businessobject.LegacyStatefulBusinessObjectFactory;
import org.jboss.ejb3.core.proxy.spi.CurrentRemoteProxyFactory;
import org.jboss.ejb3.core.proxy.spi.EJB2RemoteProxyFactory;
import org.jboss.ejb3.core.proxy.spi.RemoteProxyFactory;
@@ -58,7 +59,6 @@
import org.jboss.ejb3.proxy.impl.factory.session.stateful.StatefulSessionProxyFactory;
import org.jboss.ejb3.proxy.impl.invocation.StatefulRemoteInvocation;
import org.jboss.ejb3.proxy.impl.jndiregistrar.JndiSessionRegistrarBase;
-import org.jboss.ejb3.proxy.impl.jndiregistrar.JndiStatefulSessionRegistrar;
import org.jboss.ejb3.proxy.impl.objectstore.ObjectStoreBindings;
import org.jboss.ejb3.proxy.impl.remoting.SessionSpecRemotingMetadata;
import org.jboss.ejb3.proxy.impl.remoting.StatefulSessionRemotingMetadata;
@@ -299,7 +299,7 @@
*
* @return
*/
- protected String getJndiRegistrarBindName()
+ public String getJndiRegistrarBindName()
{
return isClustered()
? ClusteredObjectStoreBindings.CLUSTERED_OBJECTSTORE_BEAN_NAME_JNDI_REGISTRAR_SFSB
@@ -1234,79 +1234,8 @@
@Override
public Object getBusinessObject(BeanContext beanContext, Class businessInterface) throws IllegalStateException
{
- assert beanContext != null : "beanContext is null";
- assert businessInterface != null : "businessInterface is null";
-
- StatefulBeanContext ctx = (StatefulBeanContext) beanContext;
-
- SessionContainer container = ctx.getContainer();
- assert container == this : "beanContext not of this container (" + container + " != " + this + ")";
-
- boolean isRemote = false;
- boolean found = false;
- Class<?>[] remoteInterfaces = ProxyFactoryHelper.getRemoteAndBusinessRemoteInterfaces(this);
- for (Class<?> intf : remoteInterfaces)
- {
- if (intf.getName().equals(businessInterface.getName()))
- {
- isRemote = true;
- found = true;
- break;
- }
- }
- if (found == false)
- {
- Class<?>[] localInterfaces = ProxyFactoryHelper.getLocalAndBusinessLocalInterfaces(this);
- for (Class<?> intf : localInterfaces)
- {
- if (intf.getName().equals(businessInterface.getName()))
- {
- found = true;
- break;
- }
- }
- }
- if (found == false)
- throw new IllegalStateException(businessInterface.getName() + " is not a business interface for container "
- + this);
-
- // Obtain SFSB JNDI Registrar
- String sfsbJndiRegistrarObjectStoreBindName = this.getJndiRegistrarBindName();
- JndiStatefulSessionRegistrar sfsbJndiRegistrar = Ejb3RegistrarLocator.locateRegistrar().lookup(
- sfsbJndiRegistrarObjectStoreBindName, JndiStatefulSessionRegistrar.class);
-
- // Get the metadata
- JBossSessionBeanMetaData smd = this.getMetaData();
-
- // Get the appropriate JNDI Name
- String jndiName = !isRemote ? smd.getLocalJndiName() : smd.getJndiName();
-
- // Find the Proxy Factory Key for this SFSB
- String proxyFactoryKey = sfsbJndiRegistrar.getProxyFactoryRegistryKey(jndiName, smd, !isRemote);
-
- // Lookup the Proxy Factory in the Object Store
- StatefulSessionProxyFactory proxyFactory = Ejb3RegistrarLocator.locateRegistrar().lookup(proxyFactoryKey,
- StatefulSessionProxyFactory.class);
-
- // Create a new business proxy
- Object proxy = proxyFactory.createProxyBusiness((Serializable) ctx.getId(), businessInterface.getName());
-
- // Return the Proxy
- return proxy;
-
- // Collection<ProxyFactory> proxyFactories = this.proxyDeployer.getProxyFactories().values();
- // for (ProxyFactory factory : proxyFactories)
- // {
- // if (isRemote && factory instanceof StatefulRemoteProxyFactory)
- // {
- // return ((StatefulRemoteProxyFactory) factory).createProxyBusiness(ctx.getId(),null);
- // }
- // else if (!isRemote && factory instanceof StatefulLocalProxyFactory)
- // {
- // return ((StatefulLocalProxyFactory) factory).createProxyBusiness(ctx.getId(),null);
- // }
- // }
- // throw new IllegalStateException("Unable to create proxy for getBusinessObject as a proxy factory was not found");
+ Serializable id = (Serializable) ((StatefulBeanContext) beanContext).getId();
+ return getBusinessObjectFactory().createBusinessObject(this, id, businessInterface);
}
protected void popEnc()
@@ -1403,4 +1332,14 @@
// stateful beans don't support timers
return null;
}
+
+ @Override
+ protected void verifyBusinessObjectFactory()
+ {
+ if(getBusinessObjectFactory() == null)
+ {
+ log.warn("EJBTHREE-2126: businessObjectFactory not set, using legacy on " + this);
+ setBusinessObjectFactory(new LegacyStatefulBusinessObjectFactory());
+ }
+ }
}
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java 2010-11-16 11:19:56 UTC (rev 109345)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java 2010-11-16 12:28:40 UTC (rev 109346)
@@ -22,23 +22,6 @@
package org.jboss.ejb3.stateless;
-import java.io.Serializable;
-import java.lang.reflect.Method;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ExecutorService;
-
-import javax.ejb.EJBContext;
-import javax.ejb.EJBException;
-import javax.ejb.EJBLocalObject;
-import javax.ejb.EJBObject;
-import javax.ejb.Handle;
-import javax.ejb.RemoteHome;
-import javax.ejb.Timer;
-import javax.naming.NamingException;
-
import org.jboss.aop.Advisor;
import org.jboss.aop.Domain;
import org.jboss.aop.MethodInfo;
@@ -58,6 +41,7 @@
import org.jboss.ejb3.annotation.RemoteHomeBinding;
import org.jboss.ejb3.common.lang.SerializableMethod;
import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
+import org.jboss.ejb3.core.businessobject.LegacyStatelessBusinessObjectFactory;
import org.jboss.ejb3.core.proxy.spi.CurrentRemoteProxyFactory;
import org.jboss.ejb3.core.proxy.spi.EJB2RemoteProxyFactory;
import org.jboss.ejb3.proxy.clustered.objectstore.ClusteredObjectStoreBindings;
@@ -74,7 +58,6 @@
import org.jboss.ejb3.session.SessionSpecContainer;
import org.jboss.ejb3.timerservice.spi.MultiTimeoutMethodTimedObjectInvoker;
import org.jboss.ejb3.timerservice.spi.TimedObjectInvoker;
-import org.jboss.ejb3.util.CollectionHelper;
import org.jboss.injection.WebServiceContextProxy;
import org.jboss.injection.lang.reflect.BeanProperty;
import org.jboss.logging.Logger;
@@ -91,7 +74,20 @@
import org.jboss.wsf.spi.invocation.integration.InvocationContextCallback;
import org.jboss.wsf.spi.invocation.integration.ServiceEndpointContainer;
+import javax.ejb.EJBContext;
+import javax.ejb.EJBException;
+import javax.ejb.EJBLocalObject;
+import javax.ejb.EJBObject;
+import javax.ejb.Handle;
+import javax.ejb.RemoteHome;
+import javax.ejb.Timer;
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+
/**
* Comment
*
@@ -546,31 +542,7 @@
@Override
public <T> T getBusinessObject(BeanContext<?> ctx, Class<T> intf)
{
- assert intf != null : "intf is null";
-
- try
- {
-
- /*
- * Get all business interfaces
- */
- Set<String> businessInterfaceNames = new HashSet<String>();
- JBossSessionBeanMetaData smd= (JBossSessionBeanMetaData)this.getXml();
- CollectionHelper.addAllIfSet(businessInterfaceNames, smd.getBusinessRemotes());
- CollectionHelper.addAllIfSet(businessInterfaceNames, smd.getBusinessLocals());
-
- String interfaceName = intf.getName();
-
- if (!businessInterfaceNames.contains(interfaceName))
- throw new IllegalStateException("Cannot find BusinessObject for interface: " + interfaceName);
-
- String jndiName = this.getXml().determineResolvedJndiName(interfaceName);
- return intf.cast(getInitialContext().lookup(jndiName));
- }
- catch (NamingException e)
- {
- throw new RuntimeException("failed to invoke getBusinessObject", e);
- }
+ return getBusinessObjectFactory().createBusinessObject(this, null, intf);
}
protected void removeHandle(Handle handle)
@@ -747,4 +719,14 @@
beanProp.set(beanCtx.getInstance(), null);
}
}
+
+ @Override
+ protected void verifyBusinessObjectFactory()
+ {
+ if(getBusinessObjectFactory() == null)
+ {
+ log.warn("EJBTHREE-2126: businessObjectFactory not set, using legacy on " + this);
+ setBusinessObjectFactory(new LegacyStatelessBusinessObjectFactory());
+ }
+ }
}
More information about the jboss-cvs-commits
mailing list