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;
}
}
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);
}
}
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;
}
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);
}
}
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);
}
}
}
}
Aggregations