use of org.mule.runtime.api.exception.MuleException in project mule by mulesoft.
the class AbstractFlowConstruct method initialise.
@Override
public final void initialise() throws InitialisationException {
try {
lifecycleManager.fireInitialisePhase((phaseName, object) -> {
initialiseIfNeeded(exceptionListener, muleContext);
validateConstruct();
doInitialise();
});
} catch (InitialisationException e) {
safely(() -> dispose());
throw e;
} catch (MuleException e) {
safely(() -> dispose());
throw new InitialisationException(e, this);
}
}
use of org.mule.runtime.api.exception.MuleException in project mule by mulesoft.
the class AbstractPipeline method doInitialise.
@Override
protected void doInitialise() throws MuleException {
super.doInitialise();
pipeline = createPipeline();
if (source != null) {
source.setListener(new Processor() {
@Override
public CoreEvent process(CoreEvent event) throws MuleException {
return processToApply(event, this);
}
@Override
public Publisher<CoreEvent> apply(Publisher<CoreEvent> publisher) {
return from(publisher).transform(dispatchToFlow());
}
});
}
initialiseIfNeeded(source, muleContext);
initialiseIfNeeded(pipeline, muleContext);
}
use of org.mule.runtime.api.exception.MuleException in project mule by mulesoft.
the class DefaultMuleContext method dispose.
@Override
public void dispose() {
synchronized (lifecycleStateLock) {
if (isStarted() || (lifecycleManager.getLastPhaseExecuted() != null && (lifecycleManager.getLastPhaseExecuted().equals(Startable.PHASE_NAME) && lifecycleManager.isLastPhaseExecutionFailed()))) {
try {
stop();
} catch (MuleException e) {
logger.error("Failed to stop Mule context", e);
}
}
getLifecycleManager().checkPhase(Disposable.PHASE_NAME);
fireNotification(new MuleContextNotification(this, CONTEXT_DISPOSING));
disposeIfNeeded(getExceptionListener(), logger);
try {
getLifecycleManager().fireLifecycle(Disposable.PHASE_NAME);
// abstraction?
if (muleRegistryHelper != null) {
safely(() -> muleRegistryHelper.dispose());
}
} catch (Exception e) {
logger.debug("Failed to cleanly dispose Mule: " + e.getMessage(), e);
}
notificationManager.fireNotification(new MuleContextNotification(this, CONTEXT_DISPOSED));
disposeManagers();
if ((getStartDate() > 0) && logger.isInfoEnabled()) {
SplashScreen shutdownScreen = buildShutdownSplash();
logger.info(shutdownScreen.toString());
}
// registryBroker.dispose();
setExecutionClassLoader(null);
}
}
use of org.mule.runtime.api.exception.MuleException in project mule by mulesoft.
the class InvokerMessageProcessor method process.
@Override
public CoreEvent process(CoreEvent event) throws MuleException {
CoreEvent resultEvent = event;
Object[] args = evaluateArguments(event, arguments);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(format("Invoking '%s' of '%s' with arguments: '%s'", method.getName(), object, args));
}
try {
Object result = method.invoke(object, args);
if (!method.getReturnType().equals(void.class)) {
resultEvent = createResultEvent(event, result);
}
} catch (Exception e) {
throw new MessagingException(failedToInvoke(object.toString()), event, e, this);
}
return resultEvent;
}
use of org.mule.runtime.api.exception.MuleException in project mule by mulesoft.
the class TryScope method process.
@Override
public CoreEvent process(final CoreEvent event) throws MuleException {
if (nestedChain == null) {
return event;
} else {
ExecutionTemplate<CoreEvent> executionTemplate = createScopeTransactionalExecutionTemplate(muleContext, transactionConfig);
ExecutionCallback<CoreEvent> processingCallback = () -> {
try {
CoreEvent e = processToApply(event, p -> from(p).flatMap(request -> processWithChildContext(request, nestedChain, ofNullable(getLocation()), messagingExceptionHandler)));
return e;
} catch (Exception e) {
throw e;
}
};
try {
return executionTemplate.execute(processingCallback);
} catch (MuleException e) {
throw e;
} catch (Exception e) {
throw new DefaultMuleException(errorInvokingMessageProcessorWithinTransaction(nestedChain, transactionConfig), e);
}
}
}
Aggregations