*/
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) {
//throw new InvocationException();
//Go to the tm and get the transaction
//This is mimicking the current behavior of
//the SystemResourceManagerImpl registerResource method
//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());
}
//If transactional, remove the connection handle from the
//component's resource list as there has been exception attempting
//to enlist the resource
if(inv != null) {
if(_logger.isLoggable(Level.FINE)) {
_logger.fine("Attempting to unregister component resource");
}
tm.unregisterComponentResource(handle);
}
throw ex;
}
}
}