use of org.mule.runtime.api.exception.MuleRuntimeException in project mule by mulesoft.
the class DefaultMuleContext method getSchedulerService.
@Override
public SchedulerService getSchedulerService() {
if (this.schedulerService == null) {
try {
this.schedulerService = this.getRegistry().lookupObject(SchedulerService.class);
requireNonNull(schedulerService);
} catch (RegistrationException e) {
throw new MuleRuntimeException(e);
}
}
return this.schedulerService;
}
use of org.mule.runtime.api.exception.MuleRuntimeException in project mule by mulesoft.
the class DefaultMuleContext method start.
@Override
public void start() throws MuleException {
synchronized (lifecycleStateLock) {
getLifecycleManager().checkPhase(Startable.PHASE_NAME);
if (getQueueManager() == null) {
throw new MuleRuntimeException(objectIsNull("queueManager"));
}
componentInitialStateManager = muleRegistryHelper.get(OBJECT_COMPONENT_INITIAL_STATE_MANAGER);
startDate = System.currentTimeMillis();
startIfNeeded(extensionManager);
fireNotification(new MuleContextNotification(this, CONTEXT_STARTING));
getLifecycleManager().fireLifecycle(Startable.PHASE_NAME);
overridePollingController();
overrideClusterConfiguration();
startMessageSources();
fireNotification(new MuleContextNotification(this, CONTEXT_STARTED));
listeners.forEach(l -> l.onStart(this, getApiRegistry()));
startLatch.release();
if (logger.isInfoEnabled()) {
SplashScreen startupScreen = buildStartupSplash();
logger.info(startupScreen.toString());
}
}
}
use of org.mule.runtime.api.exception.MuleRuntimeException in project mule by mulesoft.
the class ErrorHandler method apply.
@Override
public Publisher<CoreEvent> apply(Exception exception) {
if (exception instanceof MessagingException) {
CoreEvent event = addExceptionPayload(exception, ((MessagingException) exception).getEvent());
((MessagingException) exception).setProcessedEvent(event);
try {
for (MessagingExceptionHandlerAcceptor exceptionListener : exceptionListeners) {
if (exceptionListener.accept(event)) {
return exceptionListener.apply(exception);
}
}
throw new MuleRuntimeException(createStaticMessage(MUST_ACCEPT_ANY_EVENT_MESSAGE));
} catch (Exception e) {
return error(new MessagingExceptionResolver(this).resolve(new MessagingException(event, e, this), muleContext));
}
} else {
// This should never occur since all exceptions at this point are ME
return error(exception);
}
}
use of org.mule.runtime.api.exception.MuleRuntimeException in project mule by mulesoft.
the class LookupFunction method call.
@Override
public Object call(Object[] parameters, BindingContext context) {
String flowName = (String) parameters[0];
Object payload = parameters[1];
Location componentLocation = Location.builder().globalName(flowName).build();
Component component = componentLocator.find(componentLocation).orElseThrow(() -> new IllegalArgumentException(format("There is no component named '%s'.", flowName)));
if (component instanceof Flow) {
try {
Message incomingMessage = lookupValue(context, MESSAGE, Message.builder().nullValue().build());
Map<String, ?> incomingVariables = lookupValue(context, VARS, EMPTY_MAP);
Error incomingError = lookupValue(context, ERROR, null);
Message message = Message.builder(incomingMessage).value(payload).mediaType(APPLICATION_JAVA).build();
CoreEvent event = CoreEvent.builder(PrivilegedEvent.getCurrentEvent().getContext()).variables(incomingVariables).error(incomingError).message(message).build();
return ((ExecutableComponent) component).execute(event).get().getMessage().getPayload();
} catch (ExecutionException e) {
ComponentExecutionException componentExecutionException = (ComponentExecutionException) e.getCause();
Error error = componentExecutionException.getEvent().getError().get();
throw new MuleRuntimeException(createStaticMessage(format("Flow '%s' has failed with error '%s' (%s)", flowName, error.getErrorType(), error.getDescription())), error.getCause());
} catch (InterruptedException e) {
throw new MuleRuntimeException(e);
}
} else {
throw new IllegalArgumentException(format("Component '%s' is not a flow.", flowName));
}
}
use of org.mule.runtime.api.exception.MuleRuntimeException in project mule by mulesoft.
the class RestrictedSSLSocketFactory method getDefault.
public static synchronized SocketFactory getDefault() {
if (defaultSocketFactory == null) {
try {
TlsConfiguration configuration = new TlsConfiguration(null);
configuration.initialise(true, null);
defaultSocketFactory = new RestrictedSSLSocketFactory(configuration.getSslContext(), configuration.getEnabledCipherSuites(), configuration.getEnabledProtocols());
} catch (Exception e) {
throw new MuleRuntimeException(createStaticMessage("Could not create the default RestrictedSSLSocketFactory"), e);
}
}
return defaultSocketFactory;
}
Aggregations