Search in sources :

Example 21 with ComponentInvocation

use of org.glassfish.api.invocation.ComponentInvocation in project Payara by payara.

the class UserTransactionImpl method setRollbackOnly.

public void setRollbackOnly() throws IllegalStateException, SystemException {
    if (!initialized)
        init();
    if (userTx != null) {
        userTx.setRollbackOnly();
        return;
    }
    ComponentInvocation inv = invocationManager.getCurrentInvocation();
    if (inv != null) {
        checkUserTransactionMethodAccess(inv);
    }
    transactionManager.setRollbackOnly();
}
Also used : ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation)

Example 22 with ComponentInvocation

use of org.glassfish.api.invocation.ComponentInvocation in project Payara by payara.

the class EJBSecurityManager method postInvoke.

/**
 * This method is used by Message Driven Bean Container to remove
 * the run-as identity information that was set up using the
 * preSetRunAsIdentity method
 */
public void postInvoke(ComponentInvocation inv) {
    if (runAs != null && inv.isPreInvokeDone()) {
        final ComponentInvocation finv = inv;
        AppservAccessController.doPrivileged(new PrivilegedAction() {

            public Object run() {
                SecurityContext.setCurrent((SecurityContext) finv.getOldSecurityContext());
                return null;
            }
        });
    }
}
Also used : ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) PrivilegedAction(java.security.PrivilegedAction) SecurityContext(com.sun.enterprise.security.SecurityContext)

Example 23 with ComponentInvocation

use of org.glassfish.api.invocation.ComponentInvocation in project Payara by payara.

the class EJBSecurityManager method getCallerPrincipal.

/**
 * This method returns the Client Principal who initiated the current
 * Invocation.
 *
 * @return A Principal object of the client who made this invocation.
 *         or null if the SecurityContext has not been established by the client.
 */
public Principal getCallerPrincipal() {
    SecurityContext sc = null;
    if (runAs != null) {
        // Run As
        // return the principal associated with the old security context
        ComponentInvocation ci = invMgr.getCurrentInvocation();
        if (ci == null) {
            // 4646060
            throw new InvocationException();
        }
        sc = (SecurityContext) ci.getOldSecurityContext();
    } else {
        // lets optimize a little. no need to look up oldsecctx
        // its the same as the new one
        sc = SecurityContext.getCurrent();
    }
    Principal prin;
    if (sc != null) {
        prin = sc.getCallerPrincipal();
    } else {
        prin = SecurityContext.getDefaultCallerPrincipal();
    }
    return prin;
}
Also used : ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) InvocationException(org.glassfish.api.invocation.InvocationException) SecurityContext(com.sun.enterprise.security.SecurityContext) Principal(java.security.Principal)

Example 24 with ComponentInvocation

use of org.glassfish.api.invocation.ComponentInvocation in project Payara by payara.

the class MessageBeanContainer method cleanupResources.

private void cleanupResources() {
    ComponentInvocation componentInvocation = createComponentInvocation();
    ASyncClientShutdownTask task = new ASyncClientShutdownTask(appEJBName_, messageBeanClient_, loader, messageBeanPool_, componentInvocation);
    long timeout = 0;
    try {
        timeout = ejbContainerUtilImpl.getServices().getService(ConnectorRuntime.class).getShutdownTimeout();
    } catch (Throwable th) {
        _logger.log(Level.WARNING, "[MDBContainer] Got exception while trying " + " to get shutdown timeout", th);
    }
    try {
        boolean addedAsyncTask = false;
        if (timeout > 0) {
            try {
                ejbContainerUtilImpl.addWork(task);
                addedAsyncTask = true;
            } catch (Throwable th) {
                // Since we got an exception while trying to add the async
                // task
                // we will have to do the cleanup in the current thread
                // itself.
                addedAsyncTask = false;
                _logger.log(WARNING, "[MDBContainer] Got exception while trying " + "to add task to ContainerWorkPool. Will execute " + "cleanupResources on current thread", th);
            }
        }
        if (addedAsyncTask) {
            synchronized (task) {
                if (!task.isDone()) {
                    _logger.log(Level.FINE, "[MDBContainer] " + "Going to wait for a maximum of " + timeout + " mili-seconds.");
                    long maxWaitTime = System.currentTimeMillis() + timeout;
                    // wait in loop to guard against spurious wake-up
                    do {
                        long timeTillTimeout = maxWaitTime - System.currentTimeMillis();
                        if (timeTillTimeout <= 0)
                            break;
                        task.wait(timeTillTimeout);
                    } while (!task.isDone());
                }
                if (!task.isDone()) {
                    _logger.log(Level.WARNING, "[MDBContainer] ASync task has not finished. " + "Giving up after " + timeout + " mili-seconds.");
                } else {
                    _logger.log(Level.FINE, "[MDBContainer] ASync task has completed");
                }
            }
        } else {
            // Execute in the same thread
            _logger.log(Level.FINE, "[MDBContainer] Attempting to do cleanup()in current thread...");
            task.run();
            _logger.log(Level.FINE, "[MDBContainer] Current thread done cleanup()... ");
        }
    } catch (InterruptedException inEx) {
        _logger.log(Level.SEVERE, "containers.mdb.cleanup_exception", new Object[] { appEJBName_, inEx.toString() });
    } catch (Exception ex) {
        _logger.log(Level.SEVERE, "containers.mdb.cleanup_exception", new Object[] { appEJBName_, ex.toString() });
    }
}
Also used : ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) EJBLocalRemoteObject(com.sun.ejb.containers.EJBLocalRemoteObject) RemoveException(javax.ejb.RemoveException) InvocationTargetException(java.lang.reflect.InvocationTargetException) EJBException(javax.ejb.EJBException) ResourcesExceededException(org.glassfish.ejb.api.ResourcesExceededException) CreateException(javax.ejb.CreateException)

Example 25 with ComponentInvocation

use of org.glassfish.api.invocation.ComponentInvocation in project Payara by payara.

the class TransactionalInterceptorBase method setTransactionalTransactionOperationsManger.

void setTransactionalTransactionOperationsManger(boolean userTransactionMethodsAllowed) {
    if (testTransactionManager != null) {
        // test
        return;
    }
    ComponentInvocation currentInvocation = getCurrentInvocation();
    if (currentInvocation == null) {
        _logger.log(WARNING, CDI_JTA_NOCOMPONENT);
        return;
    }
    preexistingTransactionOperationsManager = (TransactionOperationsManager) currentInvocation.getTransactionOperationsManager();
    currentInvocation.setTransactionOperationsManager(userTransactionMethodsAllowed ? transactionalTransactionOperationsManagerTransactionMethodsAllowed : transactionalTransactionOperationsManagerTransactionMethodsNotAllowed);
}
Also used : ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation)

Aggregations

ComponentInvocation (org.glassfish.api.invocation.ComponentInvocation)67 InvocationManager (org.glassfish.api.invocation.InvocationManager)13 JndiNameEnvironment (com.sun.enterprise.deployment.JndiNameEnvironment)8 EjbInvocation (com.sun.ejb.EjbInvocation)7 InvocationException (org.glassfish.api.invocation.InvocationException)7 SecurityContext (com.sun.enterprise.security.SecurityContext)6 WebModule (com.sun.enterprise.web.WebModule)6 PoolingException (com.sun.appserv.connectors.internal.api.PoolingException)5 InjectionException (com.sun.enterprise.container.common.spi.util.InjectionException)5 WebComponentInvocation (com.sun.enterprise.web.WebComponentInvocation)5 BundleDescriptor (com.sun.enterprise.deployment.BundleDescriptor)4 EjbDescriptor (com.sun.enterprise.deployment.EjbDescriptor)4 WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)4 JavaEETransactionManager (com.sun.enterprise.transaction.api.JavaEETransactionManager)4 RemoteException (java.rmi.RemoteException)4 EJBInvocation (org.glassfish.ejb.api.EJBInvocation)4 ArrayList (java.util.ArrayList)3 NamingException (javax.naming.NamingException)3 WeldBootstrap (org.jboss.weld.bootstrap.WeldBootstrap)3 BeanDeploymentArchive (org.jboss.weld.bootstrap.spi.BeanDeploymentArchive)3