Search in sources :

Example 66 with MuleRuntimeException

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;
}
Also used : RegistrationException(org.mule.runtime.core.privileged.registry.RegistrationException) SchedulerService(org.mule.runtime.api.scheduler.SchedulerService) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException)

Example 67 with MuleRuntimeException

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());
        }
    }
}
Also used : MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) SplashScreen(org.mule.runtime.core.internal.util.splash.SplashScreen) ServerStartupSplashScreen(org.mule.runtime.core.internal.util.splash.ServerStartupSplashScreen) ArtifactShutdownSplashScreen(org.mule.runtime.core.internal.util.splash.ArtifactShutdownSplashScreen) ServerShutdownSplashScreen(org.mule.runtime.core.internal.util.splash.ServerShutdownSplashScreen) ArtifactStartupSplashScreen(org.mule.runtime.core.internal.util.splash.ArtifactStartupSplashScreen) MuleContextNotification(org.mule.runtime.core.api.context.notification.MuleContextNotification)

Example 68 with MuleRuntimeException

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);
    }
}
Also used : CoreEvent(org.mule.runtime.core.api.event.CoreEvent) MessagingExceptionHandlerAcceptor(org.mule.runtime.core.privileged.exception.MessagingExceptionHandlerAcceptor) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) MessagingExceptionResolver(org.mule.runtime.core.internal.util.MessagingExceptionResolver) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException)

Example 69 with MuleRuntimeException

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));
    }
}
Also used : Message(org.mule.runtime.api.message.Message) I18nMessageFactory.createStaticMessage(org.mule.runtime.api.i18n.I18nMessageFactory.createStaticMessage) Error(org.mule.runtime.api.message.Error) Flow(org.mule.runtime.core.api.construct.Flow) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) ComponentExecutionException(org.mule.runtime.api.component.execution.ComponentExecutionException) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) Component(org.mule.runtime.api.component.Component) ExecutableComponent(org.mule.runtime.api.component.execution.ExecutableComponent) ExecutionException(java.util.concurrent.ExecutionException) ComponentExecutionException(org.mule.runtime.api.component.execution.ComponentExecutionException) Location(org.mule.runtime.api.component.location.Location)

Example 70 with MuleRuntimeException

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;
}
Also used : MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) TlsConfiguration(org.mule.runtime.core.privileged.security.tls.TlsConfiguration) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) IOException(java.io.IOException)

Aggregations

MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)123 IOException (java.io.IOException)22 List (java.util.List)22 MuleException (org.mule.runtime.api.exception.MuleException)22 InitialisationException (org.mule.runtime.api.lifecycle.InitialisationException)22 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)22 Map (java.util.Map)20 Optional (java.util.Optional)20 I18nMessageFactory.createStaticMessage (org.mule.runtime.api.i18n.I18nMessageFactory.createStaticMessage)18 ArrayList (java.util.ArrayList)17 String.format (java.lang.String.format)16 File (java.io.File)15 HashMap (java.util.HashMap)15 HashSet (java.util.HashSet)13 Set (java.util.Set)13 Collectors.toList (java.util.stream.Collectors.toList)12 ConfigurationException (org.mule.runtime.core.api.config.ConfigurationException)12 ComponentIdentifier (org.mule.runtime.api.component.ComponentIdentifier)10 Collections.emptyMap (java.util.Collections.emptyMap)9 Optional.empty (java.util.Optional.empty)9