Known Direct Subclasses
|
Class Overview
Basic invoker for a remote Stateless Session Bean.
Designed for EJB 2.x, but works for EJB 3 Session Beans as well.
"Creates" a new EJB instance for each invocation, or caches the session
bean instance for all invocations (see setCacheSessionBean(boolean)
).
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 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.
Summary
Public Methods |
void
|
destroy()
Remove the cached session bean instance, if necessary.
|
void
|
setCacheSessionBean(boolean cacheSessionBean)
Set whether to cache the actual session bean object.
|
[Expand]
Inherited Methods |
From class
org.springframework.ejb.access.AbstractRemoteSlsbInvokerInterceptor
abstract
Object
|
doInvoke(MethodInvocation invocation)
Perform the given invocation on the current EJB home.
|
Method
|
getCreateMethod(Object home)
Check for EJB3-style home object that serves as EJB component directly.
|
Object
|
invokeInContext(MethodInvocation invocation)
Fetches an EJB home object and delegates to doInvoke .
|
boolean
|
isConnectFailure(RemoteException ex)
Determine whether the given RMI exception indicates a connect failure.
|
boolean
|
isHomeRefreshable()
Return whether the cached EJB home object is potentially
subject to on-demand refreshing.
|
Object
|
lookup()
This overridden lookup implementation performs a narrow operation
after the JNDI lookup, provided that a home interface is specified.
|
Object
|
newSessionBeanInstance()
Return a new instance of the stateless session bean.
|
Object
|
refreshAndRetry(MethodInvocation invocation)
Refresh the EJB home object and retry the given invocation.
|
void
|
removeSessionBeanInstance(EJBObject ejb)
Remove the given EJB instance.
|
void
|
setHomeInterface(Class homeInterface)
Set a home interface that this invoker will narrow to before performing
the parameterless SLSB create() call that returns the actual
SLSB proxy.
|
void
|
setRefreshHomeOnConnectFailure(boolean refreshHomeOnConnectFailure)
Set whether to refresh the EJB home on connect failure.
|
|
From class
org.springframework.ejb.access.AbstractSlsbInvokerInterceptor
void
|
afterPropertiesSet()
Fetches EJB home on startup, if necessary.
|
Object
|
create()
Invokes the create() method on the cached EJB home object.
|
Method
|
getCreateMethod(Object home)
Determine the create method of the given EJB home object.
|
Object
|
getHome()
Return the EJB home object to use.
|
Object
|
invoke(MethodInvocation invocation)
|
abstract
Object
|
invokeInContext(MethodInvocation invocation)
Perform the given invocation on the current EJB home,
within the thread context being prepared accordingly.
|
boolean
|
isHomeRefreshable()
Return whether the cached EJB home object is potentially
subject to on-demand refreshing.
|
void
|
refreshHome()
Refresh the cached home object, if applicable.
|
void
|
setCacheHome(boolean cacheHome)
Set whether to cache the EJB home object once it has been located.
|
void
|
setExposeAccessContext(boolean exposeAccessContext)
Set whether to expose the JNDI environment context for all access to the target
EJB, i.e.
|
void
|
setLookupHomeOnStartup(boolean lookupHomeOnStartup)
Set whether to look up the EJB home object on startup.
|
|
From class
org.springframework.jndi.JndiObjectLocator
void
|
afterPropertiesSet()
Invoked by a BeanFactory after it has set all bean properties supplied
(and satisfied BeanFactoryAware and ApplicationContextAware).
|
Class<?>
|
getExpectedType()
Return the type that the located JNDI object is supposed
to be assignable to, if any.
|
String
|
getJndiName()
Return the JNDI name to look up.
|
Object
|
lookup()
Perform the actual JNDI lookup for this locator's target resource.
|
void
|
setExpectedType(Class<?> expectedType)
Specify the type that the located JNDI object is supposed
to be assignable to, if any.
|
void
|
setJndiName(String jndiName)
Specify the JNDI name to look up.
|
|
From class
org.springframework.jndi.JndiLocatorSupport
String
|
convertJndiName(String jndiName)
Convert the given JNDI name into the actual JNDI name to use.
|
boolean
|
isResourceRef()
Return whether the lookup occurs in a J2EE container.
|
<T>
T
|
lookup(String jndiName, Class<T> requiredType)
Perform an actual JNDI lookup for the given name via the JndiTemplate.
|
Object
|
lookup(String jndiName)
Perform an actual JNDI lookup for the given name via the JndiTemplate.
|
void
|
setResourceRef(boolean resourceRef)
Set whether the lookup occurs in a J2EE container, i.e.
|
|
From class
org.springframework.jndi.JndiAccessor
|
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
|
From interface
org.springframework.beans.factory.DisposableBean
abstract
void
|
destroy()
Invoked by a BeanFactory on destruction of a singleton.
|
|
From interface
org.springframework.beans.factory.InitializingBean
abstract
void
|
afterPropertiesSet()
Invoked by a BeanFactory after it has set all bean properties supplied
(and satisfied BeanFactoryAware and ApplicationContextAware).
|
|
Public Constructors
public
SimpleRemoteSlsbInvokerInterceptor
()
Public Methods
public
void
destroy
()
Remove the cached session bean instance, if necessary.
public
void
setCacheSessionBean
(boolean cacheSessionBean)
Set whether to cache the actual session bean object.
Off by default for standard EJB compliance. Turn this flag
on to optimize session bean access for servers that are
known to allow for caching the actual session bean object.
Protected Methods
protected
Object
doInvoke
(MethodInvocation invocation)
This implementation "creates" a new EJB instance for each invocation.
Can be overridden for custom invocation strategies.
Alternatively, override getSessionBeanInstance()
and
releaseSessionBeanInstance(EJBObject)
to change EJB instance creation,
for example to hold a single shared EJB component instance.
Parameters
invocation
| the AOP method invocation |
Returns
- the invocation result, if any
protected
Object
getSessionBeanInstance
()
Return an EJB component instance to delegate the call to.
The default implementation delegates to newSessionBeanInstance()
.
Returns
- the EJB component instance
protected
void
refreshHome
()
Reset the cached session bean instance, if necessary.
protected
void
releaseSessionBeanInstance
(EJBObject ejb)
Parameters
ejb
| the EJB component instance to release |