瞅瞅Infinispan事务管理源码是啥样的
/**
* Uses JNDI to look-up the {@link TransactionManager} instance from "java:/TransactionManager".
*
* @author Bela Ban, Aug 26 2003
* @since 4.0
*/
public class JBossTransactionManagerLookup implements TransactionManagerLookup {
public TransactionManager getTransactionManager() throws Exception {
String as7Location = "java:jboss/TransactionManager";
InitialContext initialContext = new InitialContext();
try {
// Check for JBoss AS 7
return (TransactionManager) initialContext.lookup(as7Location);
} catch (NamingException ne) {
// Fall back and try for AS 4 ~ 6
String legacyAsLocation = "java:/TransactionManager";
try {
// Check for JBoss AS 4 ~ 6
return (TransactionManager) initialContext.lookup(legacyAsLocation);
} catch (NamingException neAgain) {
throw new ConfigurationException("Unable to locate a transaction manager in JNDI, either in " + as7Location + " or " + legacyAsLocation);
}
} finally {
Util.close(initialContext);
}
}
}
相关文章