use of org.mule.runtime.api.lifecycle.InitialisationException in project mule by mulesoft.
the class ResolverUtils method getExpressionBasedValueResolver.
private static ValueResolver<?> getExpressionBasedValueResolver(String expression, BooleanSupplier isTypedValue, BooleanSupplier isParameterResolver, Optional<StackedTypesModelProperty> stackedTypesModelProperty, MetadataType type, MuleContext muleContext) {
try {
ValueResolver resolver;
if (stackedTypesModelProperty.isPresent()) {
resolver = stackedTypesModelProperty.get().getValueResolverFactory().getExpressionBasedValueResolver(expression, getType(type));
// TODO MULE-13518: Add support for stacked value resolvers for @Parameter inside pojos // The following "IFs" should be removed once implemented
} else if (isTypedValue.getAsBoolean()) {
ExpressionTypedValueValueResolver<Object> valueResolver = new ExpressionTypedValueValueResolver<>(expression, getType(type));
valueResolver.setTransformationService(muleContext.getTransformationService());
valueResolver.setExtendedExpressionManager(muleContext.getExpressionManager());
resolver = valueResolver;
} else if (isParameterResolver.getAsBoolean()) {
ExpressionBasedParameterResolverValueResolver<Object> valueResolver = new ExpressionBasedParameterResolverValueResolver<>(expression, getType(type), type);
valueResolver.setTransformationService(muleContext.getTransformationService());
valueResolver.setExtendedExpressionManager(muleContext.getExpressionManager());
resolver = valueResolver;
} else if (muleContext.getExpressionManager().isExpression(expression)) {
TypeSafeExpressionValueResolver<Object> valueResolver = new TypeSafeExpressionValueResolver<>(expression, getType(type), type);
valueResolver.setTransformationService(muleContext.getTransformationService());
valueResolver.setExtendedExpressionManager(muleContext.getExpressionManager());
resolver = valueResolver;
} else {
TypeSafeValueResolverWrapper typeSafeValueResolverWrapper = new TypeSafeValueResolverWrapper<>(new StaticValueResolver<>(expression), getType(type));
typeSafeValueResolverWrapper.setTransformationService(muleContext.getTransformationService());
resolver = typeSafeValueResolverWrapper;
}
initialiseIfNeeded(resolver, muleContext);
return resolver;
} catch (InitialisationException e) {
throw new MuleRuntimeException(e);
}
}
use of org.mule.runtime.api.lifecycle.InitialisationException in project mule by mulesoft.
the class AbstractFlowConstruct method initialise.
@Override
public final void initialise() throws InitialisationException {
try {
lifecycleManager.fireInitialisePhase((phaseName, object) -> {
initialiseIfNeeded(exceptionListener, muleContext);
validateConstruct();
doInitialise();
});
} catch (InitialisationException e) {
safely(() -> dispose());
throw e;
} catch (MuleException e) {
safely(() -> dispose());
throw new InitialisationException(e, this);
}
}
use of org.mule.runtime.api.lifecycle.InitialisationException in project mule by mulesoft.
the class AbstractRegistryBootstrap method createTransactionFactoryBootstrapProperty.
private TransactionFactoryBootstrapProperty createTransactionFactoryBootstrapProperty(BootstrapService bootstrapService, Properties bootstrapProperties, String propertyKey, String propertyValue) throws InitialisationException {
String transactionResourceKey = propertyKey.replace(".transaction.factory", TRANSACTION_RESOURCE_SUFFIX);
String transactionResource = bootstrapProperties.getProperty(transactionResourceKey);
if (transactionResource == null) {
throw new InitialisationException(createStaticMessage(format("There is no transaction resource specified for transaction factory %s", propertyKey)), this);
}
String transactionResourceClassNameProperties = transactionResource;
boolean optional = false;
int index = transactionResourceClassNameProperties.indexOf(",");
if (index > -1) {
Properties p = PropertiesUtils.getPropertiesFromString(transactionResourceClassNameProperties.substring(index + 1), ',');
optional = p.containsKey(OPTIONAL_ATTRIBUTE);
}
final String transactionResourceClassName = (index == -1 ? transactionResourceClassNameProperties : transactionResourceClassNameProperties.substring(0, index));
return new TransactionFactoryBootstrapProperty(bootstrapService, singleton(APP), optional, propertyValue, transactionResourceClassName);
}
use of org.mule.runtime.api.lifecycle.InitialisationException in project mule by mulesoft.
the class OnErrorContinueHandler method doInitialise.
@Override
protected void doInitialise(MuleContext muleContext) throws InitialisationException {
super.doInitialise(muleContext);
ErrorTypeRepository errorTypeRepository = muleContext.getErrorTypeRepository();
sourceErrorMatcher = new SingleErrorTypeMatcher(errorTypeRepository.getSourceResponseErrorType());
if (errorType != null) {
String[] errors = errorType.split(",");
for (String error : errors) {
// Since the partial initialisation was successful, we know this error ids are safe
String sanitizedError = error.trim();
ErrorType errorType = errorTypeRepository.lookupErrorType(buildFromStringRepresentation(sanitizedError)).get();
if (sourceErrorMatcher.match(errorType)) {
throw new InitialisationException(getInitialisationError(sanitizedError), this);
}
}
} else if (when == null) {
// No error type and no expression, force ANY matcher
errorTypeMatcher = new SingleErrorTypeMatcher(errorTypeRepository.getAnyErrorType());
}
}
use of org.mule.runtime.api.lifecycle.InitialisationException in project mule by mulesoft.
the class AsyncDelegateMessageProcessor method initialise.
@Override
public void initialise() throws InitialisationException {
Object rootContainer = getFromAnnotatedObject(componentLocator, this).orElse(null);
if (rootContainer instanceof FlowConstruct) {
if (maxConcurrency != null && rootContainer instanceof Pipeline) {
ProcessingStrategyFactory flowPsFactory = ((Pipeline) rootContainer).getProcessingStrategyFactory();
if (flowPsFactory instanceof AsyncProcessingStrategyFactory) {
((AsyncProcessingStrategyFactory) flowPsFactory).setMaxConcurrency(maxConcurrency);
} else {
logger.warn("{} does not support 'maxConcurrency'. Ignoring the value.", flowPsFactory.getClass().getSimpleName());
}
processingStrategy = flowPsFactory.create(muleContext, getLocation().getLocation());
ownProcessingStrategy = true;
} else {
processingStrategy = ((FlowConstruct) rootContainer).getProcessingStrategy();
}
} else {
processingStrategy = DIRECT_PROCESSING_STRATEGY_INSTANCE;
}
if (delegateBuilder == null) {
throw new InitialisationException(objectIsNull("delegate message processor"), this);
}
delegateBuilder.setProcessingStrategy(processingStrategy);
delegate = delegateBuilder.build();
initialiseIfNeeded(delegate, muleContext);
super.initialise();
}
Aggregations