/**
* {@inheritDoc}
*/
public TransactionManager findTransactionManager() throws Exception
{
Current current = Current.getCurrent();
if (current == null)
{
try
{
current = SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<Current>()
{
public Current run() throws Exception
{
TransactionFactory tm = new TransactionFactoryImpl();
return new Current(tm);
}
});
}
catch (PrivilegedActionException pae)
{
Throwable cause = pae.getCause();
if (cause instanceof RemoteException)
{
throw (RemoteException)cause;
}
else if (cause instanceof RuntimeException)
{
throw (RuntimeException)cause;
}
else
{
throw new RuntimeException(cause);
}
}
// Change the timeout only if JOTM is not initialized yet
if (defaultTimeout > 0)
{
current.setDefaultTimeout(defaultTimeout);
}
}
else
{
LOG.info("Use externally initialized JOTM: " + current);