use of org.mule.runtime.extension.api.runtime.source.SourceCallbackContext in project mule by mulesoft.
the class SourceResultArgumentResolver method resolve.
@Override
public LazyValue<SourceResult> resolve(ExecutionContext executionContext) {
return new LazyValue<>(() -> {
Error error = errorArgumentResolver.resolve(executionContext).get();
SourceCallbackContext callbackContext = callbackContextArgumentResolver.resolve(executionContext).get();
if (error == null) {
return success(callbackContext);
} else {
String errorIdentifier = error.getErrorType().getIdentifier();
return isErrorGeneratingErrorResponse(errorIdentifier) ? invocationError(error, callbackContext) : responseError(error, callbackContext);
}
});
}
use of org.mule.runtime.extension.api.runtime.source.SourceCallbackContext in project mule by mulesoft.
the class PetStoreSource method onStart.
@Override
public void onStart(SourceCallback<String, Object> sourceCallback) throws MuleException {
SourceCallbackContext context = sourceCallback.createContext();
context.setCorrelationId(breeder.getBirds());
sourceCallback.handle(Result.<String, Object>builder().output(encoding).build(), context);
}
use of org.mule.runtime.extension.api.runtime.source.SourceCallbackContext in project mule by mulesoft.
the class TransactionalSource method onStart.
@Override
public void onStart(SourceCallback<TestTransactionalConnection, Object> sourceCallback) throws MuleException {
connectExecutor = newFixedThreadPool(1);
connectExecutor.execute(() -> {
SourceCallbackContext ctx = sourceCallback.createContext();
try {
TestTransactionalConnection connection = connectionProvider.connect();
boolean isXa = false;
if (connection instanceof XATransactionalConnection) {
isXa = true;
xaResource = (DummyXaResource) ((XATransactionalConnection) connection).getXAResource();
}
ctx.addVariable(IS_XA, isXa);
ctx.bindConnection(connection);
sourceCallback.handle(Result.<TestTransactionalConnection, Object>builder().output(connection).build(), ctx);
} catch (ConnectionException e) {
sourceCallback.onConnectionException(e);
} catch (Exception e) {
throw new RuntimeException(e);
}
});
}
Aggregations