org.springframework.ejb.access
Class SimpleRemoteSlsbInvokerInterceptor

java.lang.Object
  extended byorg.springframework.jndi.AbstractJndiLocator
      extended byorg.springframework.ejb.access.AbstractSlsbInvokerInterceptor
          extended byorg.springframework.ejb.access.AbstractRemoteSlsbInvokerInterceptor
              extended byorg.springframework.ejb.access.SimpleRemoteSlsbInvokerInterceptor
All Implemented Interfaces:
org.aopalliance.aop.Advice, InitializingBean, org.aopalliance.intercept.Interceptor, org.aopalliance.intercept.MethodInterceptor
Direct Known Subclasses:
SimpleRemoteStatelessSessionProxyFactoryBean

public class SimpleRemoteSlsbInvokerInterceptor
extends AbstractRemoteSlsbInvokerInterceptor

Basic invoker for a remote Stateless Session Bean. "Creates" a new EJB instance for each invocation.

See AbstractJndiLocator 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 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 solution is to not pre-instantiate this factory object, but allow it to be created on first use. In the XML containers, this is controlled via the "lazy-init" attribute.

This invoker is typically used with an RMI business interface, which serves as super-interface of the EJB component interface. Alternatively, this invoker 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-May-2003
Version:
$Id: SimpleRemoteSlsbInvokerInterceptor.java,v 1.10 2004/03/19 21:35:54 johnsonr Exp $
Author:
Rod Johnson, Juergen Hoeller
See Also:
RemoteAccessException

Field Summary
 
Fields inherited from class org.springframework.jndi.AbstractJndiLocator
CONTAINER_PREFIX, logger
 
Constructor Summary
SimpleRemoteSlsbInvokerInterceptor()
          Constructor for use as JavaBean.
SimpleRemoteSlsbInvokerInterceptor(java.lang.String jndiName, boolean resourceRef)
          Convenient constructor for programmatic use.
 
Method Summary
 java.lang.Object invoke(org.aopalliance.intercept.MethodInvocation invocation)
          This is the last invoker in the chain.
 
Methods inherited from class org.springframework.ejb.access.AbstractRemoteSlsbInvokerInterceptor
newSessionBeanInstance
 
Methods inherited from class org.springframework.ejb.access.AbstractSlsbInvokerInterceptor
afterLocated, create, getCachedEjbHome, located
 
Methods inherited from class org.springframework.jndi.AbstractJndiLocator
afterPropertiesSet, getJndiEnvironment, getJndiName, getJndiTemplate, isResourceRef, setJndiEnvironment, setJndiName, setJndiTemplate, setResourceRef
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleRemoteSlsbInvokerInterceptor

public SimpleRemoteSlsbInvokerInterceptor()
Constructor for use as JavaBean. Sets "resourceRef" to false by default.

See Also:
AbstractJndiLocator.setResourceRef(boolean)

SimpleRemoteSlsbInvokerInterceptor

public SimpleRemoteSlsbInvokerInterceptor(java.lang.String jndiName,
                                          boolean resourceRef)
                                   throws org.aopalliance.aop.AspectException
Convenient constructor for programmatic use.

See Also:
AbstractJndiLocator.setJndiName(java.lang.String), AbstractJndiLocator.setResourceRef(boolean)
Method Detail

invoke

public java.lang.Object invoke(org.aopalliance.intercept.MethodInvocation invocation)
                        throws java.lang.Throwable
This is the last invoker in the chain. "Creates" a new EJB instance for each invocation. Can be overridden for custom invocation strategies.

Throws:
java.lang.Throwable


Copyright (C) 2003-2004 The Spring Framework Project.