public void bindResource(Object key, Object resource) throws TransactionException { if (!(key instanceof QueueManager) || !(resource instanceof QueueSession)) { throw new IllegalTransactionStateException( CoreMessages.transactionCanOnlyBindToResources("QueueManager/QueueSession")); } super.bindResource(key, resource); try { ((QueueSession) resource).begin(); } catch (ResourceManagerException e) { throw new TransactionException(CoreMessages.cannotStartTransaction("VMTransaction"), e); } }
/* * (non-Javadoc) * * @see org.mule.umo.UMOTransaction#bindResource(java.lang.Object, * java.lang.Object) */ public void bindResource(Object key, Object resource) throws TransactionException { if (!(key instanceof DataSource) || !(resource instanceof Connection)) { throw new IllegalTransactionStateException( new Message( Messages.TX_CAN_ONLY_BIND_TO_X_TYPE_RESOURCES, "javax.sql.DataSource/java.sql.Connection")); } Connection con = (Connection) resource; try { if (con.getAutoCommit()) { con.setAutoCommit(false); } } catch (SQLException e) { throw new TransactionException(new Message(Messages.TX_SET_AUTO_COMMIT_FAILED), e); } super.bindResource(key, resource); }
@Override public void bindResource(Object key, Object resource) throws TransactionException { logger.info(String.format("bindResource( '%s', '%s')", key, resource)); super.bindResource(key, resource); }