Search in sources :

Example 56 with MuleException

use of org.mule.runtime.api.exception.MuleException in project mule by mulesoft.

the class ConfigOverrideValueResolverWrapper method initialise.

@Override
public void initialise() throws InitialisationException {
    try {
        muleContext.getInjector().inject(delegate);
        initialiseIfNeeded(delegate, muleContext);
    } catch (MuleException e) {
        throw new InitialisationException(createStaticMessage("Failed to initialise the delegate ValueResolver for ConfigOverride wrapper"), e, this);
    }
}
Also used : InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException) DefaultMuleException(org.mule.runtime.api.exception.DefaultMuleException) MuleException(org.mule.runtime.api.exception.MuleException)

Example 57 with MuleException

use of org.mule.runtime.api.exception.MuleException in project mule by mulesoft.

the class OAuthConnectionProviderObjectBuilder method getCustomParameters.

private Map<String, String> getCustomParameters(CoreEvent event) {
    Map<String, String> oauthParams = new HashMap<>();
    withCustomParameters((parameter, property) -> {
        String alias = property.getRequestAlias();
        if (StringUtils.isBlank(alias)) {
            alias = parameter.getName();
        }
        ValueResolver resolver = resolverSet.getResolvers().get(alias);
        if (resolver != null) {
            try {
                oauthParams.put(alias, resolveString(event, resolver));
            } catch (MuleException e) {
                throw new MuleRuntimeException(e);
            }
        }
    });
    return oauthParams;
}
Also used : HashMap(java.util.HashMap) MapValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.MapValueResolver) ValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ValueResolver) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) MuleException(org.mule.runtime.api.exception.MuleException)

Example 58 with MuleException

use of org.mule.runtime.api.exception.MuleException in project mule by mulesoft.

the class MuleServiceManager method start.

@Override
public void start() throws MuleException {
    File servicesFolder = getServicesFolder();
    if (!servicesFolder.exists()) {
        servicesFolder.mkdir();
    }
    try {
        registeredServices = serviceDiscoverer.discoverServices();
        wrappedServices = wrapServices(registeredServices);
        startServices();
    } catch (Exception e) {
        throw new StartException(e, this);
    }
}
Also used : StartException(org.mule.runtime.core.api.lifecycle.StartException) File(java.io.File) StartException(org.mule.runtime.core.api.lifecycle.StartException) MuleException(org.mule.runtime.api.exception.MuleException)

Example 59 with MuleException

use of org.mule.runtime.api.exception.MuleException in project mule by mulesoft.

the class ProcessorChainBenchmark method stream.

@Benchmark
public CountDownLatch stream() throws MuleException, InterruptedException {
    CountDownLatch latch = new CountDownLatch(STREAM_SIZE);
    Reference<FluxSink<CoreEvent>> sinkReference = new Reference<>();
    FluxProcessor.create(sinkReference::set).transform(chain).doOnNext(event -> latch.countDown()).subscribe();
    for (int i = 0; i < STREAM_SIZE; i++) {
        sinkReference.get().next(event);
    }
    sinkReference.get().complete();
    latch.await();
    return latch;
}
Also used : FluxSink(reactor.core.publisher.FluxSink) Setup(org.openjdk.jmh.annotations.Setup) DefaultMessageProcessorChainBuilder(org.mule.runtime.core.privileged.processor.chain.DefaultMessageProcessorChainBuilder) Measurement(org.openjdk.jmh.annotations.Measurement) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) FluxSink(reactor.core.publisher.FluxSink) EventContextFactory.create(org.mule.runtime.core.api.event.EventContextFactory.create) NullExceptionHandler(org.mule.runtime.core.api.exception.NullExceptionHandler) FluxProcessor(reactor.core.publisher.FluxProcessor) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) Message.of(org.mule.runtime.api.message.Message.of) Warmup(org.openjdk.jmh.annotations.Warmup) CoreEvent.builder(org.mule.runtime.core.api.event.CoreEvent.builder) Benchmark(org.openjdk.jmh.annotations.Benchmark) MessageProcessorChain(org.mule.runtime.core.privileged.processor.chain.MessageProcessorChain) TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) MuleException(org.mule.runtime.api.exception.MuleException) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit) Reference(org.mule.runtime.api.util.Reference) Reference(org.mule.runtime.api.util.Reference) CountDownLatch(java.util.concurrent.CountDownLatch) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 60 with MuleException

use of org.mule.runtime.api.exception.MuleException in project mule by mulesoft.

the class SourceAdapter method getNonCallbackParameterValue.

private <T> Optional<T> getNonCallbackParameterValue(String fieldName, Class<T> type) {
    ValueResolver<T> valueResolver = (ValueResolver<T>) nonCallbackParameters.getResolvers().get(fieldName);
    if (valueResolver == null) {
        return empty();
    }
    T object;
    CoreEvent initialiserEvent = null;
    try {
        initialiserEvent = getInitialiserEvent(muleContext);
        object = valueResolver.resolve(from(initialiserEvent));
    } catch (MuleException e) {
        throw new MuleRuntimeException(createStaticMessage("Unable to get the " + type.getSimpleName() + " value for Message Source"), e);
    } finally {
        if (initialiserEvent != null) {
            ((BaseEventContext) initialiserEvent.getContext()).success();
        }
    }
    if (!(type.isInstance(object))) {
        throw new IllegalStateException("The resolved value is not a " + type.getSimpleName());
    }
    return of(object);
}
Also used : BaseEventContext(org.mule.runtime.core.privileged.event.BaseEventContext) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) ValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ValueResolver) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) MuleException(org.mule.runtime.api.exception.MuleException) DefaultMuleException(org.mule.runtime.api.exception.DefaultMuleException)

Aggregations

MuleException (org.mule.runtime.api.exception.MuleException)68 InitialisationException (org.mule.runtime.api.lifecycle.InitialisationException)21 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)19 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)19 Test (org.junit.Test)15 DefaultMuleException (org.mule.runtime.api.exception.DefaultMuleException)14 Processor (org.mule.runtime.core.api.processor.Processor)12 MessagingException (org.mule.runtime.core.internal.exception.MessagingException)9 Logger (org.slf4j.Logger)7 ArrayList (java.util.ArrayList)6 List (java.util.List)6 BaseEventContext (org.mule.runtime.core.privileged.event.BaseEventContext)6 RegistrationException (org.mule.runtime.core.privileged.registry.RegistrationException)6 Map (java.util.Map)5 ConnectionException (org.mule.runtime.api.connection.ConnectionException)5 MuleContext (org.mule.runtime.core.api.MuleContext)5 LifecycleUtils.stopIfNeeded (org.mule.runtime.core.api.lifecycle.LifecycleUtils.stopIfNeeded)5 Thread.currentThread (java.lang.Thread.currentThread)4 CountDownLatch (java.util.concurrent.CountDownLatch)4 Startable (org.mule.runtime.api.lifecycle.Startable)4