WebSphereUowTransactionManager falls back to UOWManagerFactory lookup by default

This commit is contained in:
Juergen Hoeller 2009-07-21 14:18:53 +00:00
parent ea8f628c9c
commit 3f6e4282d6
1 changed files with 22 additions and 4 deletions

View File

@ -24,6 +24,7 @@ import com.ibm.wsspi.uow.UOWAction;
import com.ibm.wsspi.uow.UOWActionException;
import com.ibm.wsspi.uow.UOWException;
import com.ibm.wsspi.uow.UOWManager;
import com.ibm.wsspi.uow.UOWManagerFactory;
import org.springframework.transaction.IllegalTransactionStateException;
import org.springframework.transaction.InvalidTimeoutException;
@ -88,7 +89,7 @@ public class WebSphereUowTransactionManager extends JtaTransactionManager
private UOWManager uowManager;
private String uowManagerName = DEFAULT_UOW_MANAGER_NAME;
private String uowManagerName;
/**
@ -139,15 +140,13 @@ public class WebSphereUowTransactionManager extends JtaTransactionManager
this.uowManager = lookupUowManager(this.uowManagerName);
}
else {
throw new IllegalStateException("'uowManager' or 'uowManagerName' is required");
this.uowManager = lookupDefaultUowManager();
}
}
}
/**
* Look up the WebSphere UOWManager in JNDI via the configured name.
* Called by <code>afterPropertiesSet</code> if no direct UOWManager reference was set.
* Can be overridden in subclasses to provide a different UOWManager object.
* @param uowManagerName the JNDI name of the UOWManager
* @return the UOWManager object
* @throws TransactionSystemException if the JNDI lookup failed
@ -167,6 +166,25 @@ public class WebSphereUowTransactionManager extends JtaTransactionManager
}
}
/**
* Obtain the WebSphere UOWManager from the default JNDI location
* "java:comp/websphere/UOWManager".
* @return the UOWManager object
* @throws TransactionSystemException if the JNDI lookup failed
* @see #setJndiTemplate
*/
protected UOWManager lookupDefaultUowManager() throws TransactionSystemException {
try {
logger.debug("Retrieving WebSphere UOWManager from default JNDI location [" + DEFAULT_UOW_MANAGER_NAME + "]");
return getJndiTemplate().lookup(DEFAULT_UOW_MANAGER_NAME, UOWManager.class);
}
catch (NamingException ex) {
logger.debug("WebSphere UOWManager is not available at default JNDI location [" +
DEFAULT_UOW_MANAGER_NAME + "] - falling back to UOWManagerFactory lookup");
return UOWManagerFactory.getUOWManager();
}
}
/**
* Registers the synchronizations as interposed JTA Synchronization on the UOWManager.
*/