Search in sources :

Example 11 with ComponentInvocation

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

the class ComponentEnvManagerImpl method getCurrentJndiNameEnvironment.

public JndiNameEnvironment getCurrentJndiNameEnvironment() {
    JndiNameEnvironment desc = null;
    ComponentInvocation inv = invMgr.getCurrentInvocation();
    if (inv != null) {
        if (inv.componentId != null) {
            desc = getJndiNameEnvironment(inv.componentId);
            if (_logger.isLoggable(Level.FINEST)) {
                _logger.finest("ComponentEnvManagerImpl: " + "getCurrentJndiNameEnvironment " + inv.componentId + " is " + desc.getClass());
            }
        }
    }
    return desc;
}
Also used : ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation)

Example 12 with ComponentInvocation

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

the class InjectionManagerImpl method injectInstance.

public void injectInstance(Object instance, boolean invokePostConstruct) throws InjectionException {
    ComponentInvocation invocation = invocationMgr.getCurrentInvocation();
    if (invocation == null) {
        throw new InjectionException(localStrings.getLocalString("injection-manager.null-invocation-context", "Null invocation context"));
    }
    JndiNameEnvironment componentEnvironment = compEnvManager.getJndiNameEnvironment(invocation.getComponentId());
    if (componentEnvironment == null) {
        throw new InjectionException(localStrings.getLocalString("injection-manager.no-descriptor-registered-for-invocation", "No descriptor registered for current invocation: {0}", invocation));
    }
    inject(instance.getClass(), instance, componentEnvironment, null, invokePostConstruct);
}
Also used : InjectionException(com.sun.enterprise.container.common.spi.util.InjectionException) JndiNameEnvironment(com.sun.enterprise.deployment.JndiNameEnvironment) ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation)

Example 13 with ComponentInvocation

use of org.glassfish.api.invocation.ComponentInvocation 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;
}
Also used : EjbInvocation(com.sun.ejb.EjbInvocation) ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) Method(java.lang.reflect.Method)

Example 14 with ComponentInvocation

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

the class ResourceManagerImpl method getTransaction.

/**
 * Returns the transaction component is participating.
 *
 * @return Handle to the <code>Transaction</code> object.
 * @exception <code>PoolingException<code>
 */
public Transaction getTransaction() throws PoolingException {
    InvocationManager invmgr = ConnectorRuntime.getRuntime().getInvocationManager();
    ComponentInvocation inv = invmgr.getCurrentInvocation();
    if (inv == null) {
        try {
            return ConnectorRuntime.getRuntime().getTransaction();
        } catch (Exception ex) {
            return null;
        }
    }
    return (Transaction) inv.getTransaction();
}
Also used : ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) InvocationManager(org.glassfish.api.invocation.InvocationManager) InvocationException(org.glassfish.api.invocation.InvocationException) PoolingException(com.sun.appserv.connectors.internal.api.PoolingException)

Example 15 with ComponentInvocation

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

the class ResourceManagerImpl method unregisterResource.

/**
 * Unregister the <code>ResourceHandle</code> from the transaction
 *
 * @param resource	<code>ResourceHandle</code> object
 * @param xaresFlag flag indicating transaction success. This can
 *        be XAResource.TMSUCCESS or XAResource.TMFAIL
 * @exception <code>PoolingException</code>
 */
public void unregisterResource(ResourceHandle resource, int xaresFlag) {
    JavaEETransactionManager tm = ConnectorRuntime.getRuntime().getTransactionManager();
    Transaction tran = null;
    try {
        // delist with TMSUCCESS if necessary
        if (resource.isTransactional()) {
            InvocationManager invmgr = ConnectorRuntime.getRuntime().getInvocationManager();
            ComponentInvocation inv = invmgr.getCurrentInvocation();
            if (inv == null) {
                // in that, you return the transaction from the TxManager
                try {
                    tran = tm.getTransaction();
                } catch (Exception e) {
                    tran = null;
                    _logger.log(Level.INFO, e.getMessage());
                }
            } else {
                tran = (Transaction) inv.getTransaction();
                tm.unregisterComponentResource(resource);
            }
            if (tran != null && resource.isEnlisted()) {
                tm.delistResource(tran, resource, xaresFlag);
            }
        }
    } catch (SystemException ex) {
        _logger.log(Level.WARNING, "poolmgr.system_exception", ex);
    } catch (IllegalStateException ex) {
    // transaction aborted. Do nothing
    } catch (InvocationException ex) {
    // unregisterResource is called outside of component context
    // likely to be container-forced destroy. Do nothing
    }
}
Also used : ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) InvocationException(org.glassfish.api.invocation.InvocationException) InvocationManager(org.glassfish.api.invocation.InvocationManager) JavaEETransactionManager(com.sun.enterprise.transaction.api.JavaEETransactionManager) InvocationException(org.glassfish.api.invocation.InvocationException) PoolingException(com.sun.appserv.connectors.internal.api.PoolingException)

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