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) {
}
}
}
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();
}
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
}
}
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;
}
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;
}
Aggregations