/* */ package org.jboss.ejb.plugins;
/* */
/* */ import java.lang.reflect.Method;
/* */ import java.rmi.RemoteException;
/* */ import javax.ejb.EJBException;
/* */ import javax.ejb.TimedObject;
/* */ import javax.ejb.Timer;
/* */ import org.jboss.ejb.AllowedOperationsAssociation;
/* */ import org.jboss.ejb.EntityContainer;
/* */ import org.jboss.ejb.EntityEnterpriseContext;
/* */ import org.jboss.ejb.EntityPersistenceManager;
/* */ import org.jboss.ejb.InstancePool;
/* */ import org.jboss.ejb.Interceptor;
/* */ import org.jboss.invocation.Invocation;
/* */ import org.jboss.invocation.InvocationType;
/* */ import org.jboss.logging.Logger;
/* */
/* */ /** @deprecated */
/* */ public class EntityMultiInstanceInterceptor extends AbstractInterceptor
/* */ {
/* */ protected static final Method ejbTimeout;
/* */
/* */ public Object invokeHome(Invocation mi)
/* */ throws Exception
/* */ {
/* 89 */ EntityContainer ec = (EntityContainer)getContainer();
/* 90 */ EntityEnterpriseContext ctx = (EntityEnterpriseContext)ec.getInstancePool().get();
/* */
/* 93 */ mi.setEnterpriseContext(ctx);
/* */
/* 96 */ ctx.setTransaction(mi.getTransaction());
/* */
/* 99 */ ctx.setPrincipal(mi.getPrincipal());
/* */
/* 101 */ AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_HOME);
/* */ Object result;
/* */ try
/* */ {
/* 107 */ result = getNext().invokeHome(mi);
/* */ }
/* */ finally
/* */ {
/* 111 */ AllowedOperationsAssociation.popInMethodFlag();
/* */ }
/* */
/* 115 */ if (ctx.getId() == null)
/* */ {
/* 117 */ ctx.setTransaction(null);
/* 118 */ ec.getInstancePool().free(ctx);
/* */ }
/* */
/* 122 */ return result;
/* */ }
/* */
/* */ public Object invoke(Invocation mi)
/* */ throws Exception
/* */ {
/* 130 */ Object key = mi.getId();
/* */
/* 132 */ EntityEnterpriseContext ctx = null;
/* 133 */ EntityContainer ec = (EntityContainer)this.container;
/* */ InvocationType type;
/* 134 */ if ((mi.getTransaction() == null) ||
/* 138 */ (ctx == null))
/* */ {
/* 140 */ InstancePool pool = ec.getInstancePool();
/* */ try
/* */ {
/* 143 */ ctx = (EntityEnterpriseContext)pool.get();
/* */ }
/* */ catch (EJBException e)
/* */ {
/* 147 */ throw e;
/* */ }
/* */ catch (RemoteException e)
/* */ {
/* 151 */ throw e;
/* */ }
/* */ catch (Exception e)
/* */ {
/* 155 */ type = mi.getType();
/* 156 */ boolean isLocal = (type == InvocationType.LOCAL) || (type == InvocationType.LOCALHOME);
/* 157 */ if (isLocal) {
/* 158 */ throw new EJBException("Unable to get an instance from the pool", e);
/* */ }
/* 160 */ throw new RemoteException("Unable to get an intance from the pool", e);
/* */ }
/* 162 */ ctx.setCacheKey(key);
/* 163 */ ctx.setId(key);
/* 164 */ EntityPersistenceManager pm = ec.getPersistenceManager();
/* 165 */ pm.activateEntity(ctx);
/* */ }
/* */
/* 168 */ boolean trace = this.log.isTraceEnabled();
/* 169 */ if (trace) this.log.trace("Begin invoke, key=" + key);
/* */
/* 173 */ ctx.setTransaction(mi.getTransaction());
/* */
/* 176 */ ctx.setPrincipal(mi.getPrincipal());
/* */
/* 178 */ EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance());
/* */
/* 181 */ mi.setEnterpriseContext(ctx);
/* */
/* 183 */ if (ejbTimeout.equals(mi.getMethod()))
/* 184 */ AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT);
/* */ else {
/* 186 */ AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD);
/* */ }
/* */ try
/* */ {
/* 190 */ Object ret = getNext().invoke(mi);
/* 191 */ type = ret;
/* */ }
/* */ finally
/* */ {
/* 195 */ AllowedOperationsAssociation.popInMethodFlag();
/* 196 */ EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null);
/* */ }
/* */ }
/* */
/* */ static
/* */ {
/* */ try
/* */ {
/* 71 */ ejbTimeout = TimedObject.class.getMethod("ejbTimeout", new Class[] { Timer.class });
/* */ }
/* */ catch (Exception e)
/* */ {
/* 75 */ throw new ExceptionInInitializerError(e);
/* */ }
/* */ }
/* */ }
/* Location: /home/mnovotny/projects/EMBEDDED_JBOSS_BETA3_COMMUNITY/embedded/output/lib/embedded-jboss/lib/jboss-embedded-all.jar
* Qualified Name: org.jboss.ejb.plugins.EntityMultiInstanceInterceptor
* JD-Core Version: 0.6.0
*/