org.jboss.ejb.plugins
public class: EntityMultiInstanceInterceptor [javadoc |
source]
java.lang.Object
org.jboss.ejb.plugins.AbstractInterceptor
org.jboss.ejb.plugins.EntityMultiInstanceInterceptor
All Implemented Interfaces:
Interceptor
Deprecated! this - interceptor was used with Instance Per Transaction containers which do not use a global cache
but cache instances per transaction and always passivate instances at commit time (commit option C).
This interceptor used org.jboss.ejb.TxEntityMap to compensate the absence of a real per transaction cache implementation.
Now, the differences between IPT and standard container are:
- org.jboss.ejb.plugins.PerTxEntityInstanceCache as the cache implementation;
- NoLock as the locking policy;
- empty container-cache-conf element.
(alex@jboss.org)
The instance interceptors role is to acquire a context representing
the target object from the cache.
- author:
< - a href="mailto:bill@burkecentral.com">Bill Burke
- version:
$ - Revision: 59510 $
| Field Summary |
|---|
| protected static final Method | ejbTimeout | A reference to javax.ejb.TimedObject#ejbTimeout . |
| Method from org.jboss.ejb.plugins.EntityMultiInstanceInterceptor 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.EntityMultiInstanceInterceptor Detail: |
public Object invoke(Invocation mi) throws Exception {
// The key
Object key = mi.getId();
EntityEnterpriseContext ctx = null;
EntityContainer ec = (EntityContainer) container;
if (mi.getTransaction() != null)
{
//ctx = ec.getTxEntityMap().getCtx(mi.getTransaction(), key);
}
if (ctx == null)
{
InstancePool pool = ec.getInstancePool();
try
{
ctx = (EntityEnterpriseContext) pool.get();
}
catch (EJBException e)
{
throw e;
}
catch (RemoteException e)
{
throw e;
}
catch (Exception e)
{
InvocationType type = mi.getType();
boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME);
if (isLocal)
throw new EJBException("Unable to get an instance from the pool", e);
else
throw new RemoteException("Unable to get an intance from the pool", e);
}
ctx.setCacheKey(key);
ctx.setId(key);
EntityPersistenceManager pm = ec.getPersistenceManager();
pm.activateEntity(ctx);
}
boolean trace = log.isTraceEnabled();
if( trace ) log.trace("Begin invoke, key="+key);
// Associate transaction, in the new design the lock already has the transaction from the
// previous interceptor
ctx.setTransaction(mi.getTransaction());
// Set the current security information
ctx.setPrincipal(mi.getPrincipal());
// Set the JACC EnterpriseBean PolicyContextHandler data
EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance());
// Set context on the method invocation
mi.setEnterpriseContext(ctx);
if (ejbTimeout.equals(mi.getMethod()))
AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT);
else
AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD);
try
{
Object ret = getNext().invoke(mi);
return ret;
}
finally
{
AllowedOperationsAssociation.popInMethodFlag();
EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null);
}
} Deprecated! |
public Object invokeHome(Invocation mi) throws Exception {
try
{
ejbTimeout = TimedObject.class.getMethod("ejbTimeout", new Class[]{Timer.class});
}
catch (Exception e)
{
throw new ExceptionInInitializerError(e);
}
// Get context
EntityContainer ec = (EntityContainer) getContainer();
EntityEnterpriseContext ctx = (EntityEnterpriseContext) ec.getInstancePool().get();
// Pass it to the method invocation
mi.setEnterpriseContext(ctx);
// Give it the transaction
ctx.setTransaction(mi.getTransaction());
// Set the current security information
ctx.setPrincipal(mi.getPrincipal());
AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_HOME);
Object result;
try
{
// Invoke through interceptors
result = getNext().invokeHome(mi);
}
finally
{
AllowedOperationsAssociation.popInMethodFlag();
}
// No id, means we can put the context back in the pool
if (ctx.getId() == null)
{
ctx.setTransaction(null);
ec.getInstancePool().free(ctx);
}
// We are done
return result;
} Deprecated! |