Search in sources :

Example 11 with ConstructDeclarer

use of org.mule.runtime.api.meta.model.declaration.fluent.ConstructDeclarer in project mule by mulesoft.

the class MuleExtensionModelDeclarer method declareErrorHandler.

private void declareErrorHandler(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) {
    ConstructDeclarer errorHandler = extensionDeclarer.withConstruct("errorHandler").withStereotype(ERROR_HANDLER).allowingTopLevelDefinition().describedAs("Allows the definition of internal selective handlers. It will route the error to the first handler that matches it." + " If there's no match, then a default error handler will be executed.");
    errorHandler.onDefaultParameterGroup().withOptionalParameter("ref").withAllowedStereotypes(singletonList(ERROR_HANDLER)).ofType(typeLoader.load(String.class)).withExpressionSupport(NOT_SUPPORTED).describedAs("The name of the error handler to reuse.");
    NestedRouteDeclarer onErrorContinue = errorHandler.withRoute("onErrorContinue").describedAs("Error handler used to handle exceptions. It will commit any transaction as if the message was consumed successfully.");
    declareOnErrorRoute(typeLoader, onErrorContinue);
    NestedRouteDeclarer onErrorPropagate = errorHandler.withRoute("onErrorPropagate").describedAs("Error handler used to propagate errors. It will rollback any transaction and not consume messages.");
    declareOnErrorRoute(typeLoader, onErrorPropagate);
    errorHandler.withOptionalComponent("onError").withAllowedStereotypes(ON_ERROR).describedAs("Error handler used to reference other ones.");
    ConstructDeclarer onError = extensionDeclarer.withConstruct("onError").withStereotype(ON_ERROR).describedAs("Error handler used to reference other ones.");
    onError.onDefaultParameterGroup().withRequiredParameter("ref").ofType(typeLoader.load(String.class)).withExpressionSupport(NOT_SUPPORTED).describedAs("The name of the error handler to reuse.");
// TODO MULE-13277 errorHandler.isOneRouteRequired(true);
}
Also used : ConstructDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.ConstructDeclarer) NestedRouteDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.NestedRouteDeclarer)

Example 12 with ConstructDeclarer

use of org.mule.runtime.api.meta.model.declaration.fluent.ConstructDeclarer in project mule by mulesoft.

the class MuleExtensionModelDeclarer method declareFlow.

private void declareFlow(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) {
    ConstructDeclarer flow = extensionDeclarer.withConstruct(FLOW_ELEMENT_IDENTIFIER).allowingTopLevelDefinition().withStereotype(FLOW);
    flow.onDefaultParameterGroup().withOptionalParameter("initialState").defaultingTo("started").ofType(BaseTypeBuilder.create(JAVA).stringType().enumOf("started", "stopped").build());
    flow.onDefaultParameterGroup().withOptionalParameter("maxConcurrency").describedAs("The maximum concurrency. This value determines the maximum level of parallelism that the Flow can use to optimize for performance when processing messages.").ofType(typeLoader.load(Integer.class));
    flow.withComponent("source").withAllowedStereotypes(MuleStereotypes.SOURCE);
    flow.withChain().setRequired(true);
    flow.withComponent("errorHandler").withAllowedStereotypes(ERROR_HANDLER);
}
Also used : ConstructDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.ConstructDeclarer)

Example 13 with ConstructDeclarer

use of org.mule.runtime.api.meta.model.declaration.fluent.ConstructDeclarer in project mule by mulesoft.

the class MuleExtensionModelDeclarer method declareFirstSuccessful.

private void declareFirstSuccessful(ExtensionDeclarer extensionDeclarer) {
    ConstructDeclarer firstSuccessful = extensionDeclarer.withConstruct("firstSuccessful").describedAs("Sends a message to a list of message processors until one processes it successfully.");
    firstSuccessful.withRoute("route").withChain();
}
Also used : ConstructDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.ConstructDeclarer)

Example 14 with ConstructDeclarer

use of org.mule.runtime.api.meta.model.declaration.fluent.ConstructDeclarer in project mule by mulesoft.

the class MuleExtensionModelDeclarer method declareConfigurationProperties.

private void declareConfigurationProperties(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) {
    ConstructDeclarer configuration = extensionDeclarer.withConstruct("configurationProperties").allowingTopLevelDefinition().withStereotype(APP_CONFIG).describedAs("Configuration properties are key/value pairs that can be stored in configuration files or set as system environment variables. " + "\nEach property%2Cs value can be referenced inside the attributes of a mule configuration file by wrapping the property%2Cs key name in the syntax: \n${key_name}. " + "\n At runtime, each property placeholder expression is substituted with the property's value. " + "\nThis allows you to externalize configuration of properties outside" + " the Mule application's deployable archive, and to allow others to change these properties based on the environment the application is being deployed to. " + "Note that a system environment variable with a matching key name will override the same key%2Cs value from a properties file. Each property has a key and a value. \n" + "The key can be referenced from the mule configuration files using the following semantics: \n" + "${key_name}. This allows to externalize configuration and change it based\n" + "on the environment the application is being deployed to.");
    configuration.onDefaultParameterGroup().withRequiredParameter("file").ofType(typeLoader.load(String.class)).withExpressionSupport(NOT_SUPPORTED).withDisplayModel(DisplayModel.builder().path(new PathModel(FILE, false, EMBEDDED, new String[] { "properties" })).build()).describedAs(" The location of the file with the configuration properties to use. " + "It may be a location in the classpath or an absolute location. \nThe file location" + " value may also contains references to properties that will only be resolved based on " + "system properties or properties set at deployment time.");
}
Also used : ConstructDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.ConstructDeclarer) PathModel(org.mule.runtime.api.meta.model.display.PathModel)

Example 15 with ConstructDeclarer

use of org.mule.runtime.api.meta.model.declaration.fluent.ConstructDeclarer in project mule by mulesoft.

the class MuleExtensionModelDeclarer method declareUntilSuccessful.

private void declareUntilSuccessful(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) {
    ConstructDeclarer untilSuccessful = extensionDeclarer.withConstruct("untilSuccessful").describedAs("Attempts to route a message to the message processor it contains in an asynchronous manner. " + "Routing is considered successful if no exception has been raised and, optionally, if the response matches an expression");
    untilSuccessful.withChain();
    untilSuccessful.onDefaultParameterGroup().withOptionalParameter("maxRetries").ofType(typeLoader.load(Integer.class)).defaultingTo(5).withExpressionSupport(NOT_SUPPORTED).describedAs("Specifies the maximum number of processing retries that will be performed.");
    untilSuccessful.onDefaultParameterGroup().withOptionalParameter("millisBetweenRetries").ofType(typeLoader.load(Integer.class)).defaultingTo(60000).withExpressionSupport(NOT_SUPPORTED).describedAs("Specifies the minimum time interval between two process retries in milliseconds.\n" + " The actual time interval depends on the previous execution but should not exceed twice this number.\n" + " Default value is 60000 (one minute)");
}
Also used : ConstructDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.ConstructDeclarer)

Aggregations

ConstructDeclarer (org.mule.runtime.api.meta.model.declaration.fluent.ConstructDeclarer)15 NestedRouteDeclarer (org.mule.runtime.api.meta.model.declaration.fluent.NestedRouteDeclarer)3 TargetModelProperty (org.mule.runtime.extension.internal.property.TargetModelProperty)2 TypeToken (com.google.gson.reflect.TypeToken)1 String.format (java.lang.String.format)1 Method (java.lang.reflect.Method)1 Arrays.asList (java.util.Arrays.asList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Collectors.toList (java.util.stream.Collectors.toList)1 Declarer (org.mule.runtime.api.meta.model.declaration.fluent.Declarer)1 ExtensionDeclarer (org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclarer)1 HasConstructDeclarer (org.mule.runtime.api.meta.model.declaration.fluent.HasConstructDeclarer)1 HasOperationDeclarer (org.mule.runtime.api.meta.model.declaration.fluent.HasOperationDeclarer)1 PathModel (org.mule.runtime.api.meta.model.display.PathModel)1 Parameter (org.mule.runtime.extension.api.annotation.param.Parameter)1 DynamicConfigExpirationTypeBuilder (org.mule.runtime.extension.api.declaration.type.DynamicConfigExpirationTypeBuilder)1 RouterCompletionCallback (org.mule.runtime.extension.api.runtime.process.RouterCompletionCallback)1