- assigned_to: nobody --> whoover
Hibernate Transaction needs to do lookup for JTA user transaction bound by JNDI; Use Service Locator for lookups instead.
Currently there is code like this:
try { return (UserTransaction) new InitialContext().lookup(DEFAULT_JNDI_BOUND_NAME); } catch (NamingException e) { throw new RuntimeException("Unable to find the transaction using: " + DEFAULT_JNDI_BOUND_NAME, e); }
in HibernateTransaction to do lookups for user transactions.
Proposed solution:
*********************
Use a service locator injected by annotations instead. Attaching relevant fix / patch / solution files needed to be merged for the same.
Some words on Attached files for solution.
A use case of above service locator would look like:
@ServiceLocator(name="SomeLookUpTypeInfluxCommonServiceLocator")
public final class ClassThatWantsOrNeedsLookUpService {
// Perform lookup.
public final void someMethodThatNeedsToDoLookup( ) { // Use Third Party util to infer annotation of the class. // feed the class type to factory // get the service locator from registry (if one doesn't exist in registry an exception is thrown) // use service locator to do lookups. }
}
Distinct advantage of using an annotation to infer what we want keeps the service locator highly decoupled from any kind of code. The registry has an added advantage of keeping track of all locators plus gives chance to cache some stuff. All in all a great solution.
Regards
Vyas, Anirudh