Skip to content

Instantly share code, notes, and snippets.

@milenkovicm
Created May 14, 2012 08:30
Show Gist options
  • Save milenkovicm/2692708 to your computer and use it in GitHub Desktop.
Save milenkovicm/2692708 to your computer and use it in GitHub Desktop.
TransactionManager locateTM
/** The Resource adapter can't depend on any provider's specific library. Because of that we use reflection to locate the
* transaction manager during startup.
*
*
* TODO: https://jira.jboss.org/browse/HORNETQ-417
* We should use a proper SPI instead of reflection
* We would need to define a proper SPI package for this.
* */
public static TransactionManager locateTM(final String locatorClass, final String locatorMethod)
{
try
{
ClassLoader loader = Thread.currentThread().getContextClassLoader();
Class<?> aClass = loader.loadClass(locatorClass);
Object o = aClass.newInstance();
Method m = aClass.getMethod(locatorMethod);
return (TransactionManager)m.invoke(o);
}
catch (Throwable e)
{
HornetQRALogger.LOGGER.debug(e.getMessage(), e);
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment