org.springframework.ejb.access

Class SimpleRemoteStatelessSessionProxyFactoryBean

Implemented Interfaces:
FactoryBean, MethodInterceptor, InitializingBean

public class SimpleRemoteStatelessSessionProxyFactoryBean
extends SimpleRemoteSlsbInvokerInterceptor
implements FactoryBean

Convenient factory for remote SLSB proxies. If you want control over interceptor chaining, use an AOP ProxyFactoryBean with SimpleRemoteSlsbInvokerInterceptor rather than rely on this class.

See JndiObjectLocator for info on how to specify the JNDI location of the target EJB.

In a bean container, this class is normally best used as a singleton. However, if that bean container pre-instantiates singletons (as do the XML ApplicationContext variants) you may have a problem if the bean container is loaded before the EJB container loads the target EJB. That is because by default the JNDI lookup will be performed in the init method of this class and cached, but the EJB will not have been bound at the target location yet. The best solution is to set the lookupHomeOnStartup property to false, in which case the home will be fetched on first access to the EJB. (This flag is only true by default for backwards compatibility reasons).

This proxy factory is typically used with an RMI business interface, which serves as super-interface of the EJB component interface. Alternatively, this factory can also proxy a remote SLSB with a matching non-RMI business interface, i.e. an interface that mirrors the EJB business methods but does not declare RemoteExceptions. In the latter case, RemoteExceptions thrown by the EJB stub will automatically get converted to Spring's unchecked RemoteAccessException.

Since:
09.05.2003
See Also:
RemoteAccessException, AbstractSlsbInvokerInterceptor.setLookupHomeOnStartup(boolean), AbstractSlsbInvokerInterceptor.setCacheHome(boolean), AbstractRemoteSlsbInvokerInterceptor.setRefreshHomeOnConnectFailure(boolean)

Field Summary

Fields inherited from class org.springframework.jndi.JndiLocatorSupport

CONTAINER_PREFIX

Fields inherited from class org.springframework.jndi.JndiAccessor

logger

Method Summary

void
afterPropertiesSet()
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).
Class<T>
getBusinessInterface()
Return the business interface of the EJB we're proxying.
Object
getObject()
Class<T>
getObjectType()
boolean
isSingleton()
void
setBusinessInterface(Class<T> businessInterface)
Set the business interface of the EJB we're proxying.

Methods inherited from class org.springframework.ejb.access.SimpleRemoteSlsbInvokerInterceptor

doInvoke, getSessionBeanInstance, releaseSessionBeanInstance

Methods inherited from class org.springframework.ejb.access.AbstractRemoteSlsbInvokerInterceptor

doInvoke, invoke, isConnectFailure, isHomeRefreshable, lookup, newSessionBeanInstance, refreshAndRetry, removeSessionBeanInstance, setHomeInterface, setRefreshHomeOnConnectFailure

Methods inherited from class org.springframework.ejb.access.AbstractSlsbInvokerInterceptor

afterPropertiesSet, create, getCreateMethod, getHome, isHomeRefreshable, refreshHome, setCacheHome, setLookupHomeOnStartup

Methods inherited from class org.springframework.jndi.JndiObjectLocator

afterPropertiesSet, getExpectedType, getJndiName, lookup, setExpectedType, setJndiName

Methods inherited from class org.springframework.jndi.JndiLocatorSupport

convertJndiName, isResourceRef, lookup, lookup, setResourceRef

Methods inherited from class org.springframework.jndi.JndiAccessor

getJndiEnvironment, getJndiTemplate, setJndiEnvironment, setJndiTemplate

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Details

afterPropertiesSet

public void afterPropertiesSet()
            throws NamingException
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).

This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.

Specified by:
afterPropertiesSet in interface InitializingBean
Overrides:
afterPropertiesSet in interface AbstractSlsbInvokerInterceptor

getBusinessInterface

public Class<T> getBusinessInterface()
Return the business interface of the EJB we're proxying.

getObject

public Object getObject()
Specified by:
getObject in interface FactoryBean

getObjectType

public Class<T> getObjectType()
Specified by:
getObjectType in interface FactoryBean

isSingleton

public boolean isSingleton()
Specified by:
isSingleton in interface FactoryBean

setBusinessInterface

public void setBusinessInterface(Class<T> businessInterface)
Set the business interface of the EJB we're proxying. This will normally be a super-interface of the EJB remote component interface. Using a business methods interface is a best practice when implementing EJBs.

You can also specify a matching non-RMI business interface, i.e. an interface that mirrors the EJB business methods but does not declare RemoteExceptions. In this case, RemoteExceptions thrown by the EJB stub will automatically get converted to Spring's generic RemoteAccessException.

Parameters:
businessInterface - the business interface of the EJB