Search in sources :

Example 11 with InvocationManager

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

the class AppTest method testBind.

@Test
public void testBind() {
    GlassfishNamingManager nm = null;
    try {
        InvocationManager im = new InvocationManagerImpl();
        InitialContext ic = newInitialContext();
        nm = new GlassfishNamingManagerImpl(ic);
        nm.publishObject("foo", "Hello: foo", false);
        System.out.println("**lookup() ==> " + ic.lookup("foo"));
        assert (true);
    } catch (Exception ex) {
        ex.printStackTrace();
        assert (false);
    } finally {
        try {
            nm.unpublishObject("foo");
        } catch (Exception ex) {
        }
    }
}
Also used : InvocationManagerImpl(org.glassfish.api.invocation.InvocationManagerImpl) InvocationManager(org.glassfish.api.invocation.InvocationManager) GlassfishNamingManager(org.glassfish.api.naming.GlassfishNamingManager) InitialContext(javax.naming.InitialContext) NamingException(javax.naming.NamingException) InvocationException(org.glassfish.api.invocation.InvocationException)

Example 12 with InvocationManager

use of org.glassfish.api.invocation.InvocationManager 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 13 with InvocationManager

use of org.glassfish.api.invocation.InvocationManager 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)

Example 14 with InvocationManager

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

the class AppTest method createUtx.

private UserTransaction createUtx() throws javax.naming.NamingException {
    UserTransaction utx = new UserTransactionImpl();
    InvocationManager im = new org.glassfish.api.invocation.InvocationManagerImpl();
    ((UserTransactionImpl) utx).setForTesting(t, im);
    return utx;
}
Also used : InvocationManager(org.glassfish.api.invocation.InvocationManager) UserTransactionImpl(com.sun.enterprise.transaction.UserTransactionImpl)

Example 15 with InvocationManager

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

the class AppTest method createUtx.

private UserTransaction createUtx() throws javax.naming.NamingException {
    UserTransaction utx = new UserTransactionImpl();
    InvocationManager im = new org.glassfish.api.invocation.InvocationManagerImpl();
    ((UserTransactionImpl) utx).setForTesting(t, im);
    return utx;
}
Also used : InvocationManager(org.glassfish.api.invocation.InvocationManager) UserTransactionImpl(com.sun.enterprise.transaction.UserTransactionImpl)

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