use of com.sun.enterprise.transaction.api.JavaEETransactionManager 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 com.sun.enterprise.transaction.api.JavaEETransactionManager in project Payara by payara.
the class SystemResourceManagerImpl method rollBackTransaction.
public void rollBackTransaction() {
try {
JavaEETransactionManager tm = ConnectorRuntime.getRuntime().getTransactionManager();
Transaction tran = tm.getTransaction();
if (tran != null) {
tran.setRollbackOnly();
}
} catch (SystemException ex) {
_logger.log(Level.WARNING, "poolmgr.system_exception", ex);
} catch (IllegalStateException ex) {
// ignore
}
}
use of com.sun.enterprise.transaction.api.JavaEETransactionManager in project Payara by payara.
the class SystemResourceManagerImpl method enlistResource.
/**
* Register the <code>ResourceHandle</code> in the transaction
*
* @param handle <code>ResourceHandle</code> object
* @exception <code>PoolingException</code> If there is any error while
* enlisting.
*/
public void enlistResource(ResourceHandle handle) throws PoolingException {
try {
JavaEETransactionManager tm = ConnectorRuntime.getRuntime().getTransactionManager();
Transaction tran = tm.getTransaction();
if (tran != null) {
tm.enlistResource(tran, handle);
}
} catch (Exception ex) {
_logger.log(Level.SEVERE, "poolmgr.unexpected_exception", ex);
throw new PoolingException(ex.toString(), ex);
}
}
use of com.sun.enterprise.transaction.api.JavaEETransactionManager in project Payara by payara.
the class SystemResourceManagerImpl method delistResource.
/**
* delist the <code>ResourceHandle</code> from the transaction
*
* @param h <code>ResourceHandle</code> object
* @param xaresFlag flag indicating transaction success. This can
* be XAResource.TMSUCCESS or XAResource.TMFAIL
* @exception <code>PoolingException</code>
*/
public void delistResource(ResourceHandle h, int xaresFlag) {
try {
JavaEETransactionManager tm = ConnectorRuntime.getRuntime().getTransactionManager();
Transaction tran = tm.getTransaction();
if (tran != null) {
tm.delistResource(tran, h, xaresFlag);
}
} catch (SystemException ex) {
_logger.log(Level.WARNING, "poolmgr.system_exception", ex);
} catch (IllegalStateException ex) {
// ignore
}
}
use of com.sun.enterprise.transaction.api.JavaEETransactionManager in project Payara by payara.
the class MessageEndpointInvocationHandler method invoke.
/**
* Invokes the method
*
* @param proxy Object
* @param method <code>Method</code> to be executed.
* @param args Arguments
* @throws Throwable.
*/
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
// NOTE : be careful with "args" parameter. It is null
// if method signature has 0 arguments.
String methodClassName = method.getDeclaringClass().getName();
String methodName = method.getName();
Object returnValue = null;
if (logger.isLoggable(Level.FINEST)) {
String msg = "Invoking method [" + methodName + "] from class [" + methodClassName + "]";
logger.log(Level.FINEST, msg);
}
// to the MDB container
if (MESSAGE_ENDPOINT.equals(methodClassName)) {
if ("beforeDelivery".equals(methodName)) {
Method onMessageMethod = (Method) args[0];
beforeDeliveryCalled = true;
listener_.beforeMessageDelivery(onMessageMethod, false);
} else if ("afterDelivery".equals(methodName)) {
// reset
beforeDeliveryCalled = false;
listener_.afterMessageDelivery();
} else if ("release".equals(methodName)) {
messageBeanPM_.destroyMessageBeanListener(listener_);
} else {
logger.log(Level.SEVERE, "endpointfactory.method_not_defined", new Object[] { methodName, MESSAGE_ENDPOINT });
throw new RuntimeException(methodName);
}
} else if ("java.lang.Object".equals(methodClassName)) {
returnValue = invokeJavaObjectMethod(this, method, args);
} else {
// RA did not call beforeDelivery, handle it here
if (!beforeDeliveryCalled) {
JavaEETransactionManager txManager = ConnectorRuntime.getRuntime().getTransactionManager();
boolean txImported = (txManager.getTransaction() != null);
listener_.beforeMessageDelivery(method, txImported);
}
try {
// returnValue = listener_.deliverMessage(method, args);
// TODO startCallFlowAgent();
returnValue = listener_.deliverMessage(args);
} catch (Throwable ex) {
if (messageBeanPM_.isDeliveryTransacted(method)) {
if (throwTransactedExceptions_) {
throw ex;
} else {
logger.log(Level.INFO, "Resource adapter eating " + " transacted exception", ex);
}
} else {
throw ex;
}
} finally {
// to determine when to pair the afterDelivery call.
if (!beforeDeliveryCalled) {
listener_.afterMessageDelivery();
}
beforeDeliveryCalled = false;
}
}
return returnValue;
}
Aggregations