use of org.mule.runtime.extension.api.connectivity.TransactionalConnection in project mule by mulesoft.
the class DefaultSourceCallbackContext method bindConnection.
/**
* {@inheritDoc}
*/
@Override
public TransactionHandle bindConnection(Object connection) throws ConnectionException, TransactionException {
checkArgument(connection != null, "Cannot bind a null connection");
if (this.connection != null) {
throw new IllegalArgumentException("Connection can only be set once per " + SourceCallbackContext.class.getSimpleName());
}
this.connection = connection;
if (sourceCallback.getTransactionConfig().isTransacted() && connection instanceof TransactionalConnection) {
ConnectionHandler<Object> connectionHandler = sourceCallback.getSourceConnectionManager().getConnectionHandler(connection).orElseThrow(() -> new TransactionException(createWrongConnectionMessage(connection)));
sourceCallback.getTransactionSourceBinder().bindToTransaction(sourceCallback.getTransactionConfig(), sourceCallback.getConfigurationInstance(), connectionHandler);
transactionHandle = DEFAULT_TRANSACTION_HANDLE;
}
return transactionHandle;
}
Aggregations