Search in sources :

Example 6 with InvocationInfo

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);
    }
}
Also used : InvocationInfo(com.sun.ejb.InvocationInfo) JavaEETransaction(com.sun.enterprise.transaction.api.JavaEETransaction) Transaction(javax.transaction.Transaction) SystemException(javax.transaction.SystemException) EjbRemovalInfo(org.glassfish.ejb.deployment.descriptor.EjbRemovalInfo) EJBException(javax.ejb.EJBException)

Example 7 with InvocationInfo

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);
    }
}
Also used : InvocationInfo(com.sun.ejb.InvocationInfo) IASEjbExtraDescriptors(org.glassfish.ejb.deployment.descriptor.runtime.IASEjbExtraDescriptors) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor) CheckpointAtEndOfMethodDescriptor(org.glassfish.ejb.deployment.descriptor.runtime.CheckpointAtEndOfMethodDescriptor) IllegalLoopbackException(javax.ejb.IllegalLoopbackException) ConcurrentAccessException(javax.ejb.ConcurrentAccessException) RemoveException(javax.ejb.RemoveException) ConcurrentAccessTimeoutException(javax.ejb.ConcurrentAccessTimeoutException) InvocationTargetException(java.lang.reflect.InvocationTargetException) RemoteException(java.rmi.RemoteException) EJBException(javax.ejb.EJBException) BackingStoreException(org.glassfish.ha.store.api.BackingStoreException) IOException(java.io.IOException) NotSerializableException(java.io.NotSerializableException) SystemException(javax.transaction.SystemException) CreateException(javax.ejb.CreateException) NoSuchObjectLocalException(javax.ejb.NoSuchObjectLocalException) CheckpointAtEndOfMethodDescriptor(org.glassfish.ejb.deployment.descriptor.runtime.CheckpointAtEndOfMethodDescriptor)

Example 8 with InvocationInfo

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);
}
Also used : InvocationInfo(com.sun.ejb.InvocationInfo) JavaEETransaction(com.sun.enterprise.transaction.api.JavaEETransaction) Transaction(javax.transaction.Transaction) EjbRemovalInfo(org.glassfish.ejb.deployment.descriptor.EjbRemovalInfo)

Example 9 with InvocationInfo

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;
}
Also used : InvocationInfo(com.sun.ejb.InvocationInfo)

Example 10 with InvocationInfo

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);
    }
}
Also used : InvocationInfo(com.sun.ejb.InvocationInfo) ComponentContext(com.sun.ejb.ComponentContext) InvocationTargetException(java.lang.reflect.InvocationTargetException) DeploymentException(org.glassfish.deployment.common.DeploymentException) AccessException(java.rmi.AccessException) SystemException(javax.transaction.SystemException) NamingException(javax.naming.NamingException) RemoteException(java.rmi.RemoteException) RollbackException(javax.transaction.RollbackException)

Aggregations

InvocationInfo (com.sun.ejb.InvocationInfo)15 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 EjbInvocation (com.sun.ejb.EjbInvocation)4 RemoteException (java.rmi.RemoteException)4 EJBException (javax.ejb.EJBException)4 JavaEETransaction (com.sun.enterprise.transaction.api.JavaEETransaction)3 SystemException (javax.transaction.SystemException)3 Transaction (javax.transaction.Transaction)3 ComponentContext (com.sun.ejb.ComponentContext)2 IndirectlySerializable (com.sun.enterprise.container.common.spi.util.IndirectlySerializable)2 MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)2 Method (java.lang.reflect.Method)2 ConcurrentAccessException (javax.ejb.ConcurrentAccessException)2 ConcurrentAccessTimeoutException (javax.ejb.ConcurrentAccessTimeoutException)2 IllegalLoopbackException (javax.ejb.IllegalLoopbackException)2 EjbRemovalInfo (org.glassfish.ejb.deployment.descriptor.EjbRemovalInfo)2 FencedLock (com.hazelcast.cp.lock.FencedLock)1 MethodLockInfo (com.sun.ejb.MethodLockInfo)1 BeanStateSynchronization (com.sun.ejb.spi.container.BeanStateSynchronization)1 WebServiceEndpoint (com.sun.enterprise.deployment.WebServiceEndpoint)1