/* */ throws Exception
/* */ {
/* 208 */ boolean trace = this.log.isTraceEnabled();
/* */
/* 211 */ Object key = mi.getId();
/* */ EntityEnterpriseContext ctx;
/* */ try
/* */ {
/* 217 */ ctx = (EntityEnterpriseContext)this.container.getInstanceCache().get(key);
/* */ }
/* */ catch (NoSuchObjectException e)
/* */ {
/* 221 */ if (mi.isLocal()) {
/* 222 */ throw new NoSuchObjectLocalException(e.getMessage());
/* */ }
/* 224 */ throw e;
/* */ }
/* */ catch (EJBException e)
/* */ {
/* 228 */ throw e;
/* */ }
/* */ catch (RemoteException e)
/* */ {
/* 232 */ throw e;
/* */ }
/* */ catch (Exception e)
/* */ {
/* 236 */ InvocationType type = mi.getType();
/* 237 */ boolean isLocal = (type == InvocationType.LOCAL) || (type == InvocationType.LOCALHOME);
/* 238 */ if (isLocal) {
/* 239 */ throw new EJBException("Unable to get an instance from the pool/cache", e);
/* */ }
/* 241 */ throw new RemoteException("Unable to get an intance from the pool/cache", e);
/* */ }
/* */
/* 244 */ if (trace) this.log.trace("Begin invoke, key=" + key);
/* */
/* 251 */ Transaction tx = mi.getTransaction();
/* 252 */ if (!this.container.isReadOnly())
/* */ {
/* 254 */ Method method = mi.getMethod();
/* 255 */ if ((method == null) || (!this.container.getBeanMetaData().isMethodReadOnly(method.getName())))
/* */ {
/* 258 */ ctx.setTransaction(tx);
/* */ }
/* */ }
/* */
/* 262 */ ctx.setSecurityContext(mi.getSecurityContext());
/* */
/* 264 */ ctx.setPrincipal(mi.getPrincipal());
/* */
/* 266 */ EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance());
/* */
/* 269 */ mi.setEnterpriseContext(ctx);
/* */
/* 271 */ if (ejbTimeout.equals(mi.getMethod()))
/* 272 */ AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT);
/* */ else {
/* 274 */ AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD);
/* */ }
/* 276 */ Throwable exceptionThrown = null;
/* 277 */ boolean discardContext = false;
/* */ try
/* */ {
/* 280 */ Object obj = getNext().invoke(mi);
/* 281 */ localObject1 = obj;
/* */ }
/* */ catch (RemoteException e)
/* */ {
/* */ Object localObject1;
/* 285 */ exceptionThrown = e;
/* 286 */ discardContext = true;
/* 287 */ throw e;
/* */ }
/* */ catch (RuntimeException e)
/* */ {
/* 291 */ exceptionThrown = e;
/* 292 */ discardContext = true;
/* 293 */ throw e;
/* */ }
/* */ catch (Error e)
/* */ {
/* 297 */ exceptionThrown = e;
/* 298 */ discardContext = true;
/* 299 */ throw e;
/* */ }
/* */ catch (Exception e)
/* */ {
/* 303 */ exceptionThrown = e;
/* 304 */ throw e;
/* */ }
/* */ catch (Throwable e)
/* */ {
/* 308 */ exceptionThrown = e;
/* 309 */ discardContext = true;
/* 310 */ throw new NestedRuntimeException(e);
/* */ }
/* */ finally
/* */ {
/* 314 */ AllowedOperationsAssociation.popInMethodFlag();
/* */
/* 319 */ if ((exceptionThrown != null) && (tx != null))
/* */ {
/* 321 */ Transaction ctxTx = ctx.getTransaction();
/* 322 */ if ((tx.equals(ctxTx)) && (!ctx.hasTxSynchronization())) {
/* 323 */ ctx.setTransaction(null);
/* */ }
/* */ }
/* */
/* 327 */ if ((exceptionThrown != null) && (!ctx.hasTxSynchronization()) && (discardContext))
/* */ {
/* 336 */ this.container.getInstanceCache().remove(key);
/* */
/* 338 */ if (trace) this.log.trace("Ending invoke, exceptionThrown, ctx=" + ctx, exceptionThrown);
/* */ }
/* 340 */ else if (ctx.getId() == null)
/* */ {
/* 343 */ this.container.getInstanceCache().remove(key);
/* */
/* 345 */ if (trace) this.log.trace("Ending invoke, cache removal, ctx=" + ctx);
/* */