Search in sources :

Example 21 with InvocationManager

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

the class ImplementorCacheDelegateImpl method getImplementorFor.

public Implementor getImplementorFor(RuntimeEndpointInfo targetEndpoint) {
    Implementor implementor = null;
    try {
        synchronized (targetEndpoint) {
            implementor = (Implementor) implementorCache_.get(targetEndpoint);
            if (implementor == null) {
                implementor = createImplementor(targetEndpoint);
                implementorCache_.put(targetEndpoint, implementor);
            }
        }
        WebServiceContractImpl wscImpl = WebServiceContractImpl.getInstance();
        InvocationManager invManager = wscImpl.getInvocationManager();
        ComponentInvocation inv = invManager.getCurrentInvocation();
        if (inv instanceof EJBInvocation)
            ((EJBInvocation) inv).setWebServiceTie(implementor.getTie());
    } catch (Throwable t) {
        RuntimeException re = new RuntimeException();
        re.initCause(t);
        throw re;
    }
    return implementor;
}
Also used : Implementor(com.sun.xml.rpc.spi.runtime.Implementor) ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) InvocationManager(org.glassfish.api.invocation.InvocationManager) EJBInvocation(org.glassfish.ejb.api.EJBInvocation)

Example 22 with InvocationManager

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

the class ResourceManagerImpl method rollBackTransaction.

/**
 * Get's the component's transaction and marks it for rolling back.
 */
public void rollBackTransaction() {
    InvocationManager invmgr = ConnectorRuntime.getRuntime().getInvocationManager();
    JavaEETransactionManager tm = ConnectorRuntime.getRuntime().getTransactionManager();
    Transaction tran = null;
    try {
        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();
        }
        if (tran != null) {
            tran.setRollbackOnly();
        }
    } catch (SystemException ex) {
        _logger.log(Level.WARNING, "poolmgr.system_exception", ex);
    } catch (IllegalStateException ex) {
    // ignore
    }
}
Also used : ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) 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)

Example 23 with InvocationManager

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

the class ResourceManagerImpl method registerResource.

/**
 * Register the <code>ResourceHandle</code> in the transaction
 *
 * @param handle	<code>ResourceHandle</code> object
 * @exception <code>PoolingException</code>
 */
public void registerResource(ResourceHandle handle) throws PoolingException {
    try {
        Transaction tran = null;
        JavaEETransactionManager tm = ConnectorRuntime.getRuntime().getTransactionManager();
        // enlist if necessary
        if (handle.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.registerComponentResource(handle);
            }
            if (tran != null) {
                try {
                    tm.enlistResource(tran, handle);
                } catch (Exception ex) {
                    if (_logger.isLoggable(Level.FINE)) {
                        _logger.fine("Exception whle trying to enlist resource " + ex.getMessage());
                    }
                    // to enlist the resource
                    if (inv != null) {
                        if (_logger.isLoggable(Level.FINE)) {
                            _logger.fine("Attempting to unregister component resource");
                        }
                        tm.unregisterComponentResource(handle);
                    }
                    throw ex;
                }
            }
        }
    } catch (Exception ex) {
        _logger.log(Level.SEVERE, "poolmgr.component_register_exception", ex);
        throw new PoolingException(ex.toString(), ex);
    }
}
Also used : PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) 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)

Example 24 with InvocationManager

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

the class ResourceManagerImpl method getComponent.

/**
 * Returns the component invoking resource request.
 *
 * @return Handle to the component.
 */
public Object getComponent() {
    InvocationManager invmgr = ConnectorRuntime.getRuntime().getInvocationManager();
    ComponentInvocation inv = invmgr.getCurrentInvocation();
    if (inv == null) {
        return null;
    }
    return inv.getInstance();
}
Also used : ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) InvocationManager(org.glassfish.api.invocation.InvocationManager)

Example 25 with InvocationManager

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

the class GlassfishNamingManagerImpl method getComponentId.

/**
 * Get the component id from the Invocation Manager.
 *
 * @return the component id as a string.
 */
private String getComponentId() throws NamingException {
    String id;
    ComponentInvocation ci;
    if (invMgr == null) {
        ci = habitat.<InvocationManager>getService(InvocationManager.class).getCurrentInvocation();
    } else {
        ci = invMgr.getCurrentInvocation();
    }
    if (ci == null) {
        throw new NamingException("Invocation exception: Got null ComponentInvocation ");
    }
    try {
        id = ci.getComponentId();
        if (id == null) {
            throw new NamingException("Invocation exception: ComponentId is null");
        }
    } catch (Throwable th) {
        NamingException ine = new NamingException("Invocation exception: " + th);
        ine.initCause(th);
        throw ine;
    }
    return id;
}
Also used : ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) InvocationManager(org.glassfish.api.invocation.InvocationManager) NamingException(javax.naming.NamingException)

Aggregations

InvocationManager (org.glassfish.api.invocation.InvocationManager)40 ComponentInvocation (org.glassfish.api.invocation.ComponentInvocation)13 FaultToleranceService (fish.payara.microprofile.faulttolerance.FaultToleranceService)9 NamingException (javax.naming.NamingException)9 Config (org.eclipse.microprofile.config.Config)8 InvocationException (org.glassfish.api.invocation.InvocationException)7 FallbackPolicy (fish.payara.microprofile.faulttolerance.interceptors.fallback.FallbackPolicy)5 AroundInvoke (javax.interceptor.AroundInvoke)5 Fallback (org.eclipse.microprofile.faulttolerance.Fallback)5 Retry (org.eclipse.microprofile.faulttolerance.Retry)5 ServiceLocator (org.glassfish.hk2.api.ServiceLocator)5 PoolingException (com.sun.appserv.connectors.internal.api.PoolingException)4 ArrayList (java.util.ArrayList)4 NoSuchElementException (java.util.NoSuchElementException)4 EJBInvocation (org.glassfish.ejb.api.EJBInvocation)4 JavaEETransactionManager (com.sun.enterprise.transaction.api.JavaEETransactionManager)3 RequestTraceSpan (fish.payara.notification.requesttracing.RequestTraceSpan)3 Method (java.lang.reflect.Method)3 Context (javax.naming.Context)3 InitialContext (javax.naming.InitialContext)3