-
1. Re: Container managed transactions on WebSphere 8.0
hchiorean Sep 5, 2013 7:07 AM (in response to andrey.samuleev)1 of 1 people found this helpfulYes, ModeShape will use whatever transaction manager it gets out of ISPN. That being said, if the existing GenericTransactionManagerLookup doesn't retrieve the tx manager from WebSphere 8, you can always implement your own TransactionManagerLookup and "plug" that into ISPN (it's a 1 method interface).
-
2. Re: Container managed transactions on WebSphere 8.0
andrey.samuleev Sep 5, 2013 9:20 AM (in response to hchiorean)Thank you for the quick response!
I've implemented custom TransactionManagerLookup, and now container managed transactions work fine in Embedded WebSphere 8 container.
Here is the code:
public class EmbeddableWebSphereTransactionManagerLookup implements TransactionManagerLookup {
private final String WS8_TM_Factory = "com.ibm.tx.jta.impl.EmbeddableTranManagerSet";
private TransactionManager tm = null;
private void useDummyTM() {
tm = DummyTransactionManager.getInstance();
}
@Override
public synchronized TransactionManager getTransactionManager() throws Exception {
if (tm != null) {
return tm;
}
lookup();
return tm;
}
private void lookup() {
ClassLoader cl = this.getClass().getClassLoader();
Class<?> clazz;
try {
clazz = Util.loadClassStrict(WS8_TM_Factory, cl);
}
catch (ClassNotFoundException ex) {
System.out.println("TransactionManagerLookup : Error loading class");
useDummyTM();
return;
}
try {
Class<?>[] signature = null;
Object[] args = null;
Method method = clazz.getMethod("instance", signature);
tm = (TransactionManager) method.invoke(null, args);
}
catch (Exception ex) {
System.out.println("TransactionManagerLookup : Error invoking method");
useDummyTM();
return;
}
}
}
-
3. Re: Container managed transactions on WebSphere 8.0
rhauch Sep 5, 2013 9:43 AM (in response to andrey.samuleev)Thank you for sharing your solution!