public abstract class AbstractSlsbInvokerInterceptor extends JndiObjectLocator implements MethodInterceptor
Such an interceptor must be the last interceptor in the advice chain. In this case, there is no direct target object: The call is handled in a special way, getting executed on an EJB instance retrieved via an EJB home.
CONTAINER_PREFIX
logger
Constructor and Description |
---|
AbstractSlsbInvokerInterceptor() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Fetches EJB home on startup, if necessary.
|
protected java.lang.Object |
create()
Invokes the
create() method on the cached EJB home object. |
protected java.lang.reflect.Method |
getCreateMethod(java.lang.Object home)
Determine the create method of the given EJB home object.
|
protected java.lang.Object |
getHome()
Return the EJB home object to use.
|
java.lang.Object |
invoke(MethodInvocation invocation)
Prepares the thread context if necessar, and delegates to
invokeInContext(org.aopalliance.intercept.MethodInvocation) . |
protected abstract java.lang.Object |
invokeInContext(MethodInvocation invocation)
Perform the given invocation on the current EJB home,
within the thread context being prepared accordingly.
|
protected boolean |
isHomeRefreshable()
Return whether the cached EJB home object is potentially
subject to on-demand refreshing.
|
protected 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.
|
getExpectedType, getJndiName, lookup, setExpectedType, setJndiName
convertJndiName, isResourceRef, lookup, lookup, setResourceRef
getJndiEnvironment, getJndiTemplate, setJndiEnvironment, setJndiTemplate
public void setLookupHomeOnStartup(boolean lookupHomeOnStartup)
Can be turned off to allow for late start of the EJB server. In this case, the EJB home object will be fetched on first access.
setCacheHome(boolean)
public void setCacheHome(boolean cacheHome)
Can be turned off to allow for hot restart of the EJB server. In this case, the EJB home object will be fetched for each invocation.
setLookupHomeOnStartup(boolean)
public void setExposeAccessContext(boolean exposeAccessContext)
Default is "false", i.e. to only expose the JNDI context for object lookup. Switch this flag to "true" in order to expose the JNDI environment (including the authorization context) for each EJB invocation, as needed by WebLogic for EJBs with authorization requirements.
public void afterPropertiesSet() throws javax.naming.NamingException
afterPropertiesSet
in interface InitializingBean
afterPropertiesSet
in class JndiObjectLocator
javax.naming.NamingException
setLookupHomeOnStartup(boolean)
,
refreshHome()
protected void refreshHome() throws javax.naming.NamingException
javax.naming.NamingException
- if thrown by the JNDI lookupJndiObjectLocator.lookup()
,
getCreateMethod(java.lang.Object)
@Nullable protected java.lang.reflect.Method getCreateMethod(java.lang.Object home) throws EjbAccessException
home
- the EJB home objectEjbAccessException
- if the method couldn't be retrievedprotected java.lang.Object getHome() throws javax.naming.NamingException
Default implementation returns the home created on initialization, if any; else, it invokes lookup to get a new proxy for each invocation.
Can be overridden in subclasses, for example to cache a home object for a given amount of time before recreating it, or to test the home object whether it is still alive.
javax.naming.NamingException
- if proxy creation failedJndiObjectLocator.lookup()
,
getCreateMethod(java.lang.Object)
protected boolean isHomeRefreshable()
@Nullable public java.lang.Object invoke(MethodInvocation invocation) throws java.lang.Throwable
invokeInContext(org.aopalliance.intercept.MethodInvocation)
.invoke
in interface MethodInterceptor
invocation
- the method invocation joinpointJoinpoint.proceed()
;
might be intercepted by the interceptorjava.lang.Throwable
- if the interceptors or the target object
throws an exception@Nullable protected abstract java.lang.Object invokeInContext(MethodInvocation invocation) throws java.lang.Throwable
invocation
- the AOP method invocationjava.lang.Throwable
- in case of invocation failureprotected java.lang.Object create() throws javax.naming.NamingException, java.lang.reflect.InvocationTargetException
create()
method on the cached EJB home object.javax.naming.NamingException
- if thrown by JNDIjava.lang.reflect.InvocationTargetException
- if thrown by the create method