use of com.arjuna.ats.jdbc.TransactionalDriver in project narayana by jbosstm.
the class TransactionServiceFactory method start.
/**
* Makes the transaction service available by bind various transaction related object into the default
* JNDI tree.
* @param startRecoveryService set to true to start the recovery service.
* @throws InitializationException if no usable InitialContext is available
*/
public static synchronized void start(boolean startRecoveryService) throws InitializationException {
if (initialized)
return;
try {
initialContext = new InitialContext();
replacedJndiProperties = jdbcPropertyManager.getJDBCEnvironmentBean().getJndiProperties().size() == 0;
if (replacedJndiProperties)
jdbcPropertyManager.getJDBCEnvironmentBean().setJndiProperties(initialContext.getEnvironment());
DriverManager.registerDriver(new TransactionalDriver());
} catch (NamingException e) {
if (tsLogger.logger.isInfoEnabled())
tsLogger.logger.info("TransactionServiceFactory error:", e);
throw new InitializationException("No suitable JNDI provider available", e);
} catch (SQLException e) {
if (tsLogger.logger.isInfoEnabled())
tsLogger.logger.info("TransactionServiceFactory error:", e);
throw new InitializationException("Cannot initialize TransactionalDriver", e);
}
registerJndiBindings(initialContext);
initialized = true;
if (startRecoveryService)
startRecoveryService();
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
TransactionServiceFactory.stop();
}
});
}
Aggregations