use of com.sun.ejb.InvocationInfo in project Payara by payara.
the class AsynchronousTask method releaseContext.
/**
* Called from preInvoke which is called from the EJBObject for local and
* remote invocations.
*/
@Override
public void releaseContext(EjbInvocation inv) {
SessionContextImpl sc = (SessionContextImpl) inv.context;
// any instance lock is released in the finally block.
try {
// check if the bean was destroyed
if (sc.getState() == BeanState.DESTROYED) {
return;
}
// we're sure that no concurrent thread can be using this
// context, so no need to synchronize.
Transaction tx = sc.getTransaction();
// If this was an invocation of a remove-method
if (inv.invocationInfo.removalInfo != null) {
InvocationInfo invInfo = inv.invocationInfo;
EjbRemovalInfo removeInfo = invInfo.removalInfo;
if (retainAfterRemoveMethod(inv, removeInfo)) {
_logger.log(Level.FINE, () -> //
"Skipping destruction of SFSB " + invInfo.ejbName + " after @Remove method " + //
invInfo.method + " due to (retainIfException == true) and exception " + inv.exception);
} else {
try {
destroyBean(inv, sc);
} catch (Throwable t) {
_logger.log(Level.FINE, "@Remove.preDestroy exception", t);
}
// Explicitly null out transaction association in bean's context.
// Otherwise, forceDestroyBean() will mark that tx for rollback,
// which could incorrectly rollback a client-propagated transaction.
sc.setTransaction(null);
forceDestroyBean(sc);
// The bean has been detroyed so just skip any remaining processing.
return;
}
}
if (tx == null || tx.getStatus() == Status.STATUS_NO_TRANSACTION) {
// container.afterCompletion() was already called.
if (sc.getState() != BeanState.READY) {
if (sc.isAfterCompletionDelayed()) {
// ejb.afterCompletion was not called yet
// because of container.afterCompletion may have
// been called concurrently with this invocation.
logTraceInfo(inv, sc, "Calling delayed afterCompletion");
callEjbAfterCompletion(sc, sc.getCompletedTxStatus());
}
if (sc.getState() != BeanState.DESTROYED) {
// callEjbAfterCompletion could make state as DESTROYED
sc.setState(BeanState.READY);
handleEndOfMethodCheckpoint(sc, inv);
}
}
if ((sc.getState() != BeanState.DESTROYED) && isHAEnabled) {
syncClientVersion(inv, sc);
}
} else {
if ((sc.getState() != BeanState.DESTROYED) && isHAEnabled) {
syncClientVersion(inv, sc);
}
sc.setState(BeanState.INCOMPLETE_TX);
logTraceInfo(inv, sc, "Marking state == INCOMPLETE_TX");
}
} catch (SystemException ex) {
throw new EJBException(ex);
} finally {
releaseSFSBSerializedLock(inv, sc);
}
}
use of com.sun.ejb.InvocationInfo in project Payara by payara.
the class AsynchronousTask method loadCheckpointInfo.
protected void loadCheckpointInfo() {
try {
if (!isHAEnabled) {
return;
}
for (InvocationInfo info : invocationInfoMap.values()) {
info.checkpointEnabled = false;
MethodDescriptor md = new MethodDescriptor(info.method, info.methodIntf);
IASEjbExtraDescriptors extraDesc = ejbDescriptor.getIASEjbExtraDescriptors();
if (extraDesc != null) {
CheckpointAtEndOfMethodDescriptor cpDesc = extraDesc.getCheckpointAtEndOfMethodDescriptor();
if (cpDesc != null) {
info.checkpointEnabled = cpDesc.isCheckpointEnabledFor(md);
}
}
if (info.checkpointEnabled) {
_logger.log(Level.FINE, () -> "[SFSBContainer] " + info.method + " MARKED for end-of-method-checkpoint");
}
}
} catch (Exception ex) {
_logger.log(Level.WARNING, EXCEPTION_WHILE_LOADING_CHECKPOINT, ex);
}
}
use of com.sun.ejb.InvocationInfo in project Payara by payara.
the class AsynchronousTask method postInvokeTx.
@Override
protected void postInvokeTx(EjbInvocation inv) throws Exception {
// If this was an invocation of a remove-method
if (inv.invocationInfo.removalInfo != null) {
InvocationInfo invInfo = inv.invocationInfo;
EjbRemovalInfo removeInfo = invInfo.removalInfo;
if (retainAfterRemoveMethod(inv, removeInfo)) {
// Do nothing
} else {
// If there is a tx, remove bean from ContainerSynch so it
// won't receive any SessionSynchronization callbacks.
// We delay the PreDestroy callback and instance destruction
// until releaseContext so that PreDestroy won't run within
// the business method's tx.
SessionContextImpl sc = (SessionContextImpl) inv.context;
Transaction tx = sc.getTransaction();
if (tx != null) {
ejbContainerUtilImpl.getContainerSync(tx).removeBean(sc);
}
}
}
super.postInvokeTx(inv);
}
use of com.sun.ejb.InvocationInfo in project Payara by payara.
the class AsynchronousTask method getLifecycleCallbackInvInfo.
private InvocationInfo getLifecycleCallbackInvInfo(Set<LifecycleCallbackDescriptor> lifecycleCallbackDescriptors) throws Exception {
InvocationInfo inv = new InvocationInfo();
inv.ejbName = ejbDescriptor.getName();
inv.methodIntf = MethodDescriptor.LIFECYCLE_CALLBACK;
inv.txAttr = getTxAttrForLifecycleCallback(lifecycleCallbackDescriptors, -1, Container.TX_NOT_SUPPORTED, Container.TX_REQUIRES_NEW);
return inv;
}
use of com.sun.ejb.InvocationInfo in project Payara by payara.
the class SafeProperties method preInvoke.
/**
* Called from EJBObject/EJBHome before invoking on EJB.
* Set the EJB instance in the EjbInvocation.
*
* It must be ensured that the following general pattern
* is followed by various parts of the EJBContainer code:
*
* try {
* container.preInvoke(inv);
* returnValue = container.intercept(inv);
* } catch (Exception1 e1) {
* ...
* } catch (Exception2 e2) {
* ...
* } finally {
* container.postInvoke();
* }
*/
@Override
public void preInvoke(EjbInvocation inv) {
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Entering BaseContainer::preInvoke : " + inv);
}
try {
if (containerState != CONTAINER_STARTED) {
throw new EJBException(localStrings.getLocalString("ejb.container_not_started", "Attempt to invoke when container is in {0}", containerStateToString(containerState)));
}
if (inv.method == null) {
throw new EJBException(localStrings.getLocalString("ejb.null_invocation_method", "Attempt to invoke container with null invocation method"));
}
if (inv.invocationInfo == null) {
inv.invocationInfo = getInvocationInfo(inv);
if (inv.invocationInfo == null) {
throw new EJBException(localStrings.getLocalString("ejb.null_invocation_info", "EjbInvocation Info lookup failed for method {0}", inv.method));
}
}
inv.transactionAttribute = inv.invocationInfo.txAttr;
inv.container = this;
if (inv.mustInvokeAsynchronously()) {
return;
}
if (doPreInvokeAuthorization(inv)) {
if (!authorize(inv)) {
throw new AccessLocalException(localStrings.getLocalString("ejb.client_not_authorized", "Client not authorized for this invocation"));
}
}
// Cache value of txManager.getStatus() in invocation to avoid
// multiple thread-local accesses of that value during pre-invoke
// stage.
inv.setPreInvokeTxStatus(transactionManager.getStatus());
ComponentContext ctx = getContext(inv);
inv.context = ctx;
inv.instance = inv.ejb = ctx.getEJB();
InvocationInfo info = inv.invocationInfo;
inv.useFastPath = (info.isTxRequiredLocalCMPField) && (inv.foundInTxCache);
if (!inv.useFastPath) {
// Sets thread-specific state for Transaction, Naming, Security,
// etc
invocationManager.preInvoke(inv);
// Do Tx machinery
preInvokeTx(inv);
// null out invocation preInovkeTxStatus since the cache value
// is obsolete
inv.setPreInvokeTxStatus(null);
enlistExtendedEntityManagers(ctx);
}
} catch (Exception ex) {
_logger.log(Level.FINE, "Exception while running pre-invoke : ejbName = [{0}]", logParams);
_logger.log(Level.FINE, "", ex);
EJBException ejbEx;
if (ex instanceof EJBException) {
ejbEx = (EJBException) ex;
} else {
ejbEx = new EJBException(ex);
}
throw new PreInvokeException(ejbEx);
}
}
Aggregations