use of com.sun.ejb.EjbInvocation in project Payara by payara.
the class TimerServiceNamingProxy method getTimerServiceWrapper.
private Object getTimerServiceWrapper() {
// Cannot store EjbContainerUtilImpl.getInstance() in an instance
// variable because it shouldn't be accessed before EJB container
// is initialized.
// NamedNamingObjectProxy is initialized on the first lookup.
ComponentInvocation currentInv = EjbContainerUtilImpl.getInstance().getCurrentInvocation();
if (currentInv == null) {
throw new IllegalStateException("no current invocation");
} else if (currentInv.getInvocationType() != ComponentInvocation.ComponentInvocationType.EJB_INVOCATION) {
throw new IllegalStateException("Illegal invocation type for EJB Context : " + currentInv.getInvocationType());
}
EJBTimerService ejbTimerService = EJBTimerService.getEJBTimerService();
if (ejbTimerService == null) {
throw new IllegalStateException("EJB Timer Service not " + "available");
}
return new EJBTimerServiceWrapper(ejbTimerService, (EJBContextImpl) ((EjbInvocation) currentInv).context);
}
use of com.sun.ejb.EjbInvocation in project Payara by payara.
the class TimerWrapper method checkCallPermission.
/**
* Verify that Timer method access is allowed from this context.
* This method is static so that TimerHandle can call it even
* before it has created a TimerWrapper instance.
*/
private static void checkCallPermission() throws IllegalStateException {
// Can't store a static ref because in embedded container it can be
// changed by server restart
EjbContainerUtil ejbContainerUtil = EjbContainerUtilImpl.getInstance();
EJBTimerService timerService = EJBTimerService.getEJBTimerService();
if (timerService == null) {
throw new IllegalStateException("EJBTimerService is not available");
}
ComponentInvocation inv = ejbContainerUtil.getCurrentInvocation();
if (inv == null) {
throw new IllegalStateException("Invocation cannot be null");
}
ComponentInvocation.ComponentInvocationType invType = inv.getInvocationType();
if (invType == ComponentInvocation.ComponentInvocationType.EJB_INVOCATION) {
if (inv instanceof EjbInvocation) {
ComponentContext context = ((EjbInvocation) inv).context;
// Delegate check to EJB context. Let any
// IllegalStateException bubble up.
context.checkTimerServiceMethodAccess();
}
}
}
use of com.sun.ejb.EjbInvocation in project Payara by payara.
the class ActiveTxCache method passivateEJB.
// Called from AbstractCache
protected boolean passivateEJB(ComponentContext ctx) {
if (containerState != CONTAINER_STARTED) {
return false;
}
EntityContextImpl context = (EntityContextImpl) ctx;
if (!context.isInState(BeanState.READY)) {
return false;
}
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST, "EntityContainer.passivateEJB(): context = (" + ctx + ")");
}
EntityBean ejb = (EntityBean) context.getEJB();
EjbInvocation inv = super.createEjbInvocation(ejb, context);
inv.method = ejbPassivateMethod;
Object pkey = context.getPrimaryKey();
boolean wasPassivated = false;
// check state after locking ctx
if (!context.isInState(BeanState.READY))
return false;
try {
invocationManager.preInvoke(inv);
// remove EJB from readyStore
removeContextFromReadyStore(pkey, context);
// no Tx needed for ejbPassivate
ejb.ejbPassivate();
wasPassivated = true;
} catch (Exception ex) {
_logger.log(Level.FINE, "Exception in passivateEJB()", ex);
// Error during ejbStore/Passivate, discard bean: EJB2.0 18.3.3
forceDestroyBean(context);
return false;
} finally {
invocationManager.postInvoke(inv);
}
// If a future EjbInvocation arrives for them, they'll get recreated.
if (isRemote) {
removeEJBObjectFromStore(pkey);
}
if (isLocal) {
ejbLocalObjectStore.remove(pkey);
}
// after calling ejbStore and ejbPassivate.
synchronized (context) {
addPooledEJB(context);
}
return wasPassivated;
}
use of com.sun.ejb.EjbInvocation in project Payara by payara.
the class ActiveTxCache method activateEJBFromPool.
/**
* Called from getContext and getEJBWithIncompleteTx
* Get an EJB in the ready state (i.e. which is not doing any
* invocations and doesnt have any incomplete Tx), for the
* ejbObject provided in the EjbInvocation.
* Concurrent invocations should get *different* instances.
*/
protected EntityContextImpl activateEJBFromPool(Object primaryKey, EjbInvocation inv) {
EntityContextImpl context = null;
// get a pooled EJB and activate it.
context = getPooledEJB();
// set EJBObject/LocalObject for the context
if (inv.isLocal) {
EJBLocalObjectImpl localObjImpl = internalGetEJBLocalObjectImpl(primaryKey, true);
containerStateManager.attachObject(inv, context, null, localObjImpl);
// No need to create/set EJBObject if this EJB isRemote too.
// This saves remote object creation overhead.
// The EJBObject and stub will get created lazily if needed
// when EntityContext.getEJBObjectImpl is called.
} else {
// remote EjbInvocation
EJBObjectImpl ejbObjImpl = internalGetEJBObjectImpl(primaryKey, null, true);
containerStateManager.attachObject(inv, context, ejbObjImpl, null);
if (isLocal) {
// Create EJBLocalObject so EntityContext methods work
containerStateManager.attachObject(inv, context, null, internalGetEJBLocalObjectImpl(primaryKey, true));
}
}
context.setState(BeanState.READY);
EntityBean ejb = (EntityBean) context.getEJB();
EjbInvocation inv2 = super.createEjbInvocation(ejb, context);
inv2.method = ejbActivateMethod;
invocationManager.preInvoke(inv2);
try {
ejb.ejbActivate();
// Note: ejbLoad will be called during preInvokeTx
// since this EJB instance is being associated with
// a Tx for the first time.
} catch (Exception ex) {
// Error during ejbActivate, discard bean: EJB2.0 18.3.3
forceDestroyBean(context);
throw new EJBException(ex);
} finally {
invocationManager.postInvoke(inv2);
}
context.setNewlyActivated(true);
// recycler.initSoftRef(context);
afterNewlyActivated(context);
return context;
}
use of com.sun.ejb.EjbInvocation in project Payara by payara.
the class EntityContextImpl method inFinder.
private boolean inFinder() {
boolean inFinder = false;
ComponentInvocation ci = _container.getCurrentInvocation();
if (ci instanceof EjbInvocation) {
EjbInvocation inv = (EjbInvocation) ci;
Method currentMethod = inv.method;
inFinder = ((currentMethod != null) && inv.isHome && currentMethod.getName().startsWith("find"));
}
return inFinder;
}
Aggregations