Search in sources :

Example 11 with InitialisationException

use of org.mule.runtime.api.lifecycle.InitialisationException in project mule by mulesoft.

the class MuleObjectStoreManager method getMonitorablePartition.

@SuppressWarnings({ "rawtypes", "unchecked" })
private <T extends ObjectStore<? extends Serializable>> T getMonitorablePartition(String name, ObjectStore baseStore, T store, ObjectStoreSettings settings) {
    if (baseStore instanceof PartitionableExpirableObjectStore) {
        Scheduler scheduler = schedulerService.customScheduler(muleContext.getSchedulerBaseConfig().withName("ObjectStoreManager-Monitor-" + name).withMaxConcurrentTasks(1));
        scheduler.scheduleWithFixedDelay(new Monitor(name, (PartitionableExpirableObjectStore) baseStore, settings.getEntryTTL().orElse(0L), settings.getMaxEntries().orElse(UNBOUNDED)), 0, settings.getExpirationInterval(), MILLISECONDS);
        expirationSchedulers.put(name, scheduler);
        return store;
    } else {
        MonitoredObjectStoreWrapper monObjectStore;
        // or putting an uninitialised ObjectStore
        synchronized (this) {
            monObjectStore = new MonitoredObjectStoreWrapper(store, settings);
            monObjectStore.setMuleContext(muleContext);
            try {
                monObjectStore.initialise();
            } catch (InitialisationException e) {
                throw new MuleRuntimeException(e);
            }
        }
        return (T) monObjectStore;
    }
}
Also used : Scheduler(org.mule.runtime.api.scheduler.Scheduler) PartitionableExpirableObjectStore(org.mule.runtime.api.store.PartitionableExpirableObjectStore) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException)

Example 12 with InitialisationException

use of org.mule.runtime.api.lifecycle.InitialisationException in project mule by mulesoft.

the class ArtifactObjectSerializer method initialise.

@Override
public void initialise() throws InitialisationException {
    try {
        muleContext.getInjector().inject(javaInternalSerializerProtocol);
        muleContext.getInjector().inject(javaExternalSerializerProtocol);
    } catch (MuleException e) {
        throw new InitialisationException(e, this);
    }
}
Also used : InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException) MuleException(org.mule.runtime.api.exception.MuleException)

Example 13 with InitialisationException

use of org.mule.runtime.api.lifecycle.InitialisationException in project mule by mulesoft.

the class DefaultExtensionsClient method resolveParameters.

private Map<String, ValueResolver> resolveParameters(Map<String, Object> parameters, CoreEvent event) {
    LinkedHashMap<String, ValueResolver> values = new LinkedHashMap<>();
    parameters.forEach((name, value) -> {
        if (value instanceof ComplexParameter) {
            ComplexParameter complex = (ComplexParameter) value;
            DefaultObjectBuilder<?> builder = new DefaultObjectBuilder<>(complex.getType());
            resolveParameters(complex.getParameters(), event).forEach((propertyName, valueResolver) -> {
                try {
                    initialiseIfNeeded(valueResolver, true, muleContext);
                    builder.addPropertyResolver(propertyName, valueResolver);
                } catch (InitialisationException e) {
                    throw new MuleRuntimeException(e);
                }
            });
            try {
                values.put(name, new StaticValueResolver<>(builder.build(from(event))));
            } catch (MuleException e) {
                throw new MuleRuntimeException(createStaticMessage(format("Could not construct parameter [%s]", name)), e);
            }
        } else {
            if (value instanceof String && parser.isContainsTemplate((String) value)) {
                values.put(name, new ExpressionValueResolver((String) value));
            } else {
                values.put(name, new StaticValueResolver<>(value));
            }
        }
    });
    return values;
}
Also used : ComplexParameter(org.mule.runtime.extension.internal.client.ComplexParameter) StaticValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.StaticValueResolver) ValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ValueResolver) ExpressionValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ExpressionValueResolver) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException) DefaultObjectBuilder(org.mule.runtime.module.extension.internal.runtime.objectbuilder.DefaultObjectBuilder) MuleException(org.mule.runtime.api.exception.MuleException) LinkedHashMap(java.util.LinkedHashMap) ExpressionValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ExpressionValueResolver)

Example 14 with InitialisationException

use of org.mule.runtime.api.lifecycle.InitialisationException in project mule by mulesoft.

the class DynamicConfigurationProvider method doInitialise.

@Override
protected void doInitialise() {
    try {
        initialiseIfNeeded(resolverSet, muleContext);
        initialiseIfNeeded(connectionProviderResolver, muleContext);
    } catch (InitialisationException e) {
        throw new MuleRuntimeException(e);
    }
}
Also used : MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException)

Example 15 with InitialisationException

use of org.mule.runtime.api.lifecycle.InitialisationException in project mule by mulesoft.

the class LifecycleAwareConfigurationInstance method initialise.

/**
 * Initialises this instance by
 * <ul>
 * <li>Initialising the {@link #configurationStats}</li>
 * <li>Performs dependency injection on the {@link #value} and each item in {@link #getInterceptors()}</li>
 * <li>Propagates this lifecycle phase into the the {@link #value} and each item in {@link #getInterceptors()}</li>
 * </ul>
 *
 * @throws InitialisationException if an exception is found
 */
@Override
public synchronized void initialise() throws InitialisationException {
    if (!initialized) {
        initialized = true;
        testConnectivityLock = lockFactory.createLock(this.getClass().getName() + "-testConnectivity-" + getName());
        try {
            initStats();
            doInitialise();
            super.initialise();
        } catch (Exception e) {
            if (e instanceof InitialisationException) {
                throw (InitialisationException) e;
            } else {
                throw new InitialisationException(e, this);
            }
        }
    }
}
Also used : InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException) MuleException(org.mule.runtime.api.exception.MuleException) DefaultMuleException(org.mule.runtime.api.exception.DefaultMuleException) ConnectionException(org.mule.runtime.api.connection.ConnectionException)

Aggregations

InitialisationException (org.mule.runtime.api.lifecycle.InitialisationException)36 MuleException (org.mule.runtime.api.exception.MuleException)14 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)12 HashMap (java.util.HashMap)5 ArrayList (java.util.ArrayList)3 LinkedList (java.util.LinkedList)3 Map (java.util.Map)3 Properties (java.util.Properties)3 DefaultMuleException (org.mule.runtime.api.exception.DefaultMuleException)3 ConfigurationException (org.mule.runtime.core.api.config.ConfigurationException)3 RegistrationException (org.mule.runtime.core.privileged.registry.RegistrationException)3 Arrays.asList (java.util.Arrays.asList)2 List (java.util.List)2 Optional (java.util.Optional)2 Optional.empty (java.util.Optional.empty)2 ErrorTypeRepository (org.mule.runtime.api.exception.ErrorTypeRepository)2 ArtifactDeclaration (org.mule.runtime.app.declaration.api.ArtifactDeclaration)2 FlowConstruct (org.mule.runtime.core.api.construct.FlowConstruct)2 ComponentUtils.getFromAnnotatedObject (org.mule.runtime.core.internal.component.ComponentUtils.getFromAnnotatedObject)2 MuleRegistry (org.mule.runtime.core.internal.registry.MuleRegistry)2