org.jboss.ejb.plugins
public class: MessageDrivenInstanceInterceptor [javadoc |
source]
java.lang.Object
org.jboss.ejb.plugins.AbstractInterceptor
org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor
All Implemented Interfaces:
Interceptor
This container acquires the given instance. This must be used after
the EnvironmentInterceptor, since acquiring instances requires a proper
JNDI environment to be set.
- author:
< - a href="mailto:peter.antman@tim.se">Peter Antman.
- author:
< - a href="mailto:rickard.oberg@telkel.com">Rickard Oberg
- author:
< - a href="mailto:jason@planet57.com">Jason Dillon
- version:
$ - Revision: 66439 $
| Field Summary |
|---|
| protected static final Method | ejbTimeout | A reference to javax.ejb.TimedObject#ejbTimeout . |
| Method from org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor Summary: |
|---|
|
invoke, invokeHome |
| Methods from org.jboss.ejb.plugins.AbstractInterceptor: |
|---|
|
create, destroy, getContainer, getNext, invoke, invokeHome, isAppException, setContainer, setNext, start, stop |
| Method from org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor Detail: |
public Object invoke(Invocation mi) throws Exception {
// Get context
MessageDrivenContainer mdc = (MessageDrivenContainer) container;
InstancePool pool = mdc.getInstancePool();
EnterpriseContext ctx = null;
try
{
ctx = pool.get();
}
catch (EJBException e)
{
throw e;
}
catch (Exception e)
{
throw new EJBException("Unable to get an instance from the pool", e);
}
// Set the current security information
ctx.setPrincipal(mi.getPrincipal());
// Use this context
mi.setEnterpriseContext(ctx);
// Set the JACC EnterpriseBean PolicyContextHandler data
EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance());
if (ejbTimeout.equals(mi.getMethod()))
AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT);
else
AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD);
// There is no need for synchronization since the instance is always
// fresh also there should never be a tx associated with the instance.
try
{
// Invoke through interceptors
Object obj = getNext().invoke(mi);
return obj;
}
catch (RuntimeException e) // Instance will be GC'ed at MI return
{
mi.setEnterpriseContext(null);
throw e;
}
catch (RemoteException e) // Instance will be GC'ed at MI return
{
mi.setEnterpriseContext(null);
throw e;
}
catch (Error e) // Instance will be GC'ed at MI return
{
mi.setEnterpriseContext(null);
throw e;
}
finally
{
AllowedOperationsAssociation.popInMethodFlag();
EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null);
// Return context
if (mi.getEnterpriseContext() != null)
{
pool.free((EnterpriseContext) mi.getEnterpriseContext());
}
else
{
pool.discard(ctx);
}
}
}
|
public Object invokeHome(Invocation mi) throws Exception {
try
{
ejbTimeout = TimedObject.class.getMethod("ejbTimeout", new Class[]{Timer.class});
}
catch (Exception e)
{
throw new ExceptionInInitializerError(e);
}
throw new Error("Not valid for MessageDriven beans");
}
Message driven beans do not have homes. |