Search in sources :

Example 1 with TransactionBindingDelegate

use of org.mule.runtime.module.extension.internal.runtime.transaction.TransactionBindingDelegate in project mule by mulesoft.

the class ExtensionConnectionSupplier method getTransactedConnectionHandler.

private <T extends TransactionalConnection> ConnectionHandler<T> getTransactedConnectionHandler(ExecutionContextAdapter<? extends ComponentModel> executionContext, TransactionConfig transactionConfig) throws ConnectionException, TransactionException {
    if (!transactionConfig.isTransacted()) {
        return getTransactionlessConnectionHandler(executionContext);
    }
    ExtensionModel extensionModel = executionContext.getExtensionModel();
    ComponentModel componentModel = executionContext.getComponentModel();
    ConfigurationInstance configuration = executionContext.getConfiguration().orElseThrow(() -> new IllegalStateException(format("%s '%s' of extension '%s' cannot participate in a transaction because it doesn't have a config", getComponentModelTypeName(componentModel), componentModel.getName(), extensionModel.getName())));
    final ExtensionTransactionKey txKey = new ExtensionTransactionKey(configuration);
    TransactionBindingDelegate transactionBindingDelegate = new TransactionBindingDelegate(extensionModel, componentModel);
    return transactionBindingDelegate.getBoundResource(transactionConfig, txKey, () -> getTransactionlessConnectionHandler(executionContext));
}
Also used : ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) ComponentModel(org.mule.runtime.api.meta.model.ComponentModel) TransactionBindingDelegate(org.mule.runtime.module.extension.internal.runtime.transaction.TransactionBindingDelegate) ExtensionTransactionKey(org.mule.runtime.module.extension.internal.runtime.transaction.ExtensionTransactionKey) ConfigurationInstance(org.mule.runtime.extension.api.runtime.config.ConfigurationInstance)

Aggregations

ComponentModel (org.mule.runtime.api.meta.model.ComponentModel)1 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)1 ConfigurationInstance (org.mule.runtime.extension.api.runtime.config.ConfigurationInstance)1 ExtensionTransactionKey (org.mule.runtime.module.extension.internal.runtime.transaction.ExtensionTransactionKey)1 TransactionBindingDelegate (org.mule.runtime.module.extension.internal.runtime.transaction.TransactionBindingDelegate)1