: parameterizedDeclarer.onDefaultParameterGroup().withOptionalParameter(parameterName) .defaultingTo(parameterDefaultValue);
parameter = groupDeclarer.withRequiredParameter(extensionParameter.getAlias()); } else { parameter = groupDeclarer.withOptionalParameter(extensionParameter.getAlias()) .defaultingTo(extensionParameter.defaultValue().isPresent() ? extensionParameter.defaultValue().get() : null);
.build(); message.withOptionalParameter(BODY_PARAM).ofDynamicType(binaryType) .withRole(PRIMARY_CONTENT) .defaultingTo(PAYLOAD) .build()); message.withOptionalParameter(HEADERS_PARAM).ofDynamicType(binaryType) .withRole(CONTENT) .withLayout(getLayout(4)) .build()); message.withOptionalParameter(ATTACHMENTS_PARAM).ofDynamicType(attachments) .withRole(CONTENT) .withLayout(getLayout(5)) .withOptionalParameter(TRANSPORT_HEADERS_PARAM) .ofType(TYPE_BUILDER.objectType() .openWith(loader.load(String.class))
private void declareAsync(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) { ConstructDeclarer async = extensionDeclarer.withConstruct("async") .describedAs("Processes the nested list of message processors asynchronously using a thread pool"); async.withChain(); async.onDefaultParameterGroup() .withOptionalParameter("name") .withExpressionSupport(NOT_SUPPORTED) .ofType(typeLoader.load(String.class)) .describedAs("Name that will be used to name the async scheduler"); }
private void declareOnErrorRoute(ClassTypeLoader typeLoader, NestedRouteDeclarer onError) { onError.withChain(); onError.onDefaultParameterGroup() .withOptionalParameter("when") .ofType(typeLoader.load(String.class)) .describedAs("The expression that will be evaluated to determine if this exception strategy should be executed. " + "This should always be a boolean expression."); onError.onDefaultParameterGroup() .withOptionalParameter("type") .ofType(BaseTypeBuilder.create(JAVA).stringType() .enumOf("ANY", "REDELIVERY_EXHAUSTED", "TRANSFORMATION", "EXPRESSION", "SECURITY", "CLIENT_SECURITY", "SERVER_SECURITY", "ROUTING", "CONNECTIVITY", "RETRY_EXHAUSTED", "TIMEOUT") .build()) .withExpressionSupport(NOT_SUPPORTED) .describedAs("The full name of the error type to match against or a comma separated list of full names, " + "to match against any of them."); onError.onDefaultParameterGroup() .withOptionalParameter("logException") .ofType(typeLoader.load(boolean.class)) .defaultingTo(true) .describedAs("Determines whether the handled exception will be logged to its standard logger in the ERROR " + "level before being handled. Default is true."); onError.onDefaultParameterGroup() .withOptionalParameter("enableNotifications") .ofType(typeLoader.load(boolean.class)) .defaultingTo(true) .withExpressionSupport(NOT_SUPPORTED) .describedAs("Determines whether ExceptionNotifications will be fired from this strategy when an exception occurs." + " Default is true."); }
private void declareForEach(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) { ConstructDeclarer forEach = extensionDeclarer.withConstruct("foreach") .describedAs("The foreach Processor allows iterating over a collection payload, or any collection obtained by an expression," + " generating a message for each element."); forEach.withChain(); forEach.onDefaultParameterGroup() .withOptionalParameter("collection") .ofType(typeLoader.load(new TypeToken<Iterable<Object>>() { }.getType())) .defaultingTo("#[payload]") .withExpressionSupport(REQUIRED) .describedAs("An expression to that returns a java collection, object array, map or DOM nodes."); forEach.onDefaultParameterGroup() .withOptionalParameter("batchSize") .ofType(typeLoader.load(Integer.class)) .withExpressionSupport(NOT_SUPPORTED) .describedAs("An expression to that returns a java collection, object array, map or DOM nodes."); forEach.onDefaultParameterGroup() .withOptionalParameter("rootMessageVariableName") .ofType(typeLoader.load(String.class)) .defaultingTo("rootMessage") .withExpressionSupport(NOT_SUPPORTED) .describedAs("Property name where the parent message is stored."); forEach.onDefaultParameterGroup() .withOptionalParameter("counterVariableName") .ofType(typeLoader.load(String.class)) .defaultingTo("counter") .withExpressionSupport(NOT_SUPPORTED) .describedAs("Property name used to store the number of message being iterated."); }
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)"); }
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") .ofType(typeLoader.load(Integer.class)); flow.withComponent("source") .withAllowedStereotypes(MuleStereotypes.SOURCE); flow.withChain().setRequired(true); flow.withComponent("errorHandler") .withAllowedStereotypes(ERROR_HANDLER); }
private void declareParseTemplate(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) { OperationDeclarer parseTemplate = extensionDeclarer.withOperation("parseTemplate") .describedAs("A transformer that parses a template defined inline."); parseTemplate.withOutput().ofType(typeLoader.load(String.class)); parseTemplate.withOutputAttributes().ofType(typeLoader.load(void.class)); parseTemplate.onDefaultParameterGroup() .withOptionalParameter("content") .ofType(typeLoader.load(String.class)) .withRole(ParameterRole.PRIMARY_CONTENT) .withExpressionSupport(SUPPORTED) .describedAs("Template to be processed."); parseTemplate.onDefaultParameterGroup() .withOptionalParameter("location") .ofType(typeLoader.load(String.class)) .withExpressionSupport(NOT_SUPPORTED) .describedAs("The location of the template. The order in which the transformer will attempt to load the file are: from the file system, from a URL or from the classpath."); }
private void declareLogger(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) { OperationDeclarer logger = extensionDeclarer.withOperation("logger") .describedAs("Performs logging using an expression that determines what should be logged. By default the current messages is logged " + "using the DEBUG level to the \u0027org.mule.runtime.core.api.processor.LoggerMessageProcessor\u0027 category but " + "the level and category can both be configured to suit your needs. message is specified then the current message is used."); logger.withOutput().ofType(typeLoader.load(void.class)); logger.withOutputAttributes().ofType(typeLoader.load(void.class)); logger.onDefaultParameterGroup() .withOptionalParameter("message") .ofType(typeLoader.load(String.class)) .describedAs("Message that will be logged. Embedded expressions can be used to extract value from the current message. " + "If no message is specified then the current message is used."); logger.onDefaultParameterGroup() .withOptionalParameter("level") .defaultingTo("DEBUG") .ofType(BaseTypeBuilder.create(JAVA).stringType() .enumOf("ERROR", "WARN", "INFO", "DEBUG", "TRACE").build()) .withExpressionSupport(NOT_SUPPORTED) .describedAs("The logging level to be used. Default is DEBUG."); logger.onDefaultParameterGroup() .withOptionalParameter("category") .ofType(typeLoader.load(String.class)) .withExpressionSupport(NOT_SUPPORTED) .describedAs("The log category to be used"); }
private void declareRemoveVariable(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) { OperationDeclarer removeVariable = extensionDeclarer.withOperation("removeVariable") .describedAs("A processor that remove variables by name or regular expression."); removeVariable.withOutput().ofType(typeLoader.load(void.class)); removeVariable.withOutputAttributes().ofType(typeLoader.load(void.class)); removeVariable.onDefaultParameterGroup() .withOptionalParameter("variableName") .ofType(typeLoader.load(String.class)) .withExpressionSupport(NOT_SUPPORTED) .describedAs("The variable name."); }
parameter = groupDeclarer.withRequiredParameter(extensionParameter.getAlias()); } else { parameter = groupDeclarer.withOptionalParameter(extensionParameter.getAlias()) .defaultingTo(extensionParameter.defaultValue().isPresent() ? extensionParameter.defaultValue().get() : null);
private void declareSetVariable(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) { OperationDeclarer setVariable = extensionDeclarer.withOperation("setVariable") .describedAs("A processor that adds variables."); setVariable.withOutput().ofType(typeLoader.load(void.class)); setVariable.withOutputAttributes().ofType(typeLoader.load(void.class)); setVariable.onDefaultParameterGroup() .withOptionalParameter("variableName") .ofType(typeLoader.load(String.class)) .withExpressionSupport(NOT_SUPPORTED) .describedAs("The variable name."); setVariable.onDefaultParameterGroup() .withRequiredParameter("value") .ofType(typeLoader.load(String.class)) .withExpressionSupport(SUPPORTED) .describedAs("The variable value."); setVariable.onDefaultParameterGroup() .withOptionalParameter("encoding") .ofType(typeLoader.load(String.class)) .withExpressionSupport(NOT_SUPPORTED) .describedAs("The encoding of the value assigned to the payload."); setVariable.onDefaultParameterGroup() .withOptionalParameter("mimeType") .ofType(typeLoader.load(String.class)) .withExpressionSupport(NOT_SUPPORTED) .describedAs("The mime type, e.g. text/plain or application/json"); }
.withOptionalParameter("defaultResponseTimeout") .ofType(typeLoader.load(String.class)) .withExpressionSupport(NOT_SUPPORTED) .withOptionalParameter("defaultTransactionTimeout") .ofType(typeLoader.load(String.class)) .withExpressionSupport(NOT_SUPPORTED) .withOptionalParameter("defaultErrorHandler-ref") .ofType(typeLoader.load(String.class)) .withExpressionSupport(NOT_SUPPORTED) .withOptionalParameter("shutdownTimeout") .ofType(typeLoader.load(Integer.class)) .withExpressionSupport(NOT_SUPPORTED) .withOptionalParameter("maxQueueTransactionFilesSize") .ofType(typeLoader.load(Integer.class)) .withExpressionSupport(NOT_SUPPORTED) .withOptionalParameter("defaultObjectSerializer-ref") .ofType(typeLoader.load(String.class)) .withExpressionSupport(NOT_SUPPORTED) .withOptionalParameter("dynamicConfigExpiration") .describedAs(DYNAMIC_CONFIG_EXPIRATION_DESCRIPTION) .ofType(new DynamicConfigExpirationTypeBuilder().buildDynamicConfigExpirationType())
.withOptionalParameter("idExpression") .ofType(typeLoader.load(String.class)) .defaultingTo("#[id]") .withOptionalParameter("valueExpression") .ofType(typeLoader.load(String.class)) .defaultingTo("#[id]") .withOptionalParameter("storePrefix") .ofType(typeLoader.load(String.class)) .withExpressionSupport(NOT_SUPPORTED) .describedAs("Defines the prefix of the object store names. This will only be used for the internally built object store."); validator.onDefaultParameterGroup().withOptionalParameter("objectStore").withDsl( ParameterDslConfiguration.builder() .allowsInlineDefinition(true)
private void declareSetPayload(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) { OperationDeclarer setPayload = extensionDeclarer.withOperation("setPayload") .describedAs("A transformer that sets the payload with the provided value."); setPayload.withOutput().ofType(typeLoader.load(void.class)); setPayload.withOutputAttributes().ofType(typeLoader.load(void.class)); setPayload.onDefaultParameterGroup() .withOptionalParameter("encoding") .ofType(typeLoader.load(String.class)) .withExpressionSupport(NOT_SUPPORTED) .describedAs("The encoding of the value assigned to the payload."); setPayload.onDefaultParameterGroup() .withRequiredParameter("value") .ofType(typeLoader.load(String.class)) .withExpressionSupport(NOT_SUPPORTED) .describedAs("The value to be set on the payload. Supports expressions."); setPayload.onDefaultParameterGroup() .withOptionalParameter("mimeType") .ofType(typeLoader.load(String.class)) .withExpressionSupport(NOT_SUPPORTED) .describedAs("The mime type, e.g. text/plain or application/json"); }
.withOptionalParameter("timeout") .ofType(typeLoader.load(Long.class)) .defaultingTo(Long.MAX_VALUE) .describedAs("Sets a timeout in milliseconds for each route. Values lower or equals than zero means no timeout."); scatterGather.onDefaultParameterGroup() .withOptionalParameter("maxConcurrency") .ofType(typeLoader.load(Integer.class)) .defaultingTo(Integer.MAX_VALUE) .describedAs("This value determines the maximum level of parallelism that will be used by this router. ."); scatterGather.onDefaultParameterGroup() .withOptionalParameter(TARGET_PARAMETER_NAME) .ofType(typeLoader.load(String.class)) .withExpressionSupport(NOT_SUPPORTED) .withOptionalParameter(TARGET_VALUE_PARAMETER_NAME) .ofType(typeLoader.load(String.class)) .defaultingTo(PAYLOAD)
private void declareTry(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) { ConstructDeclarer tryScope = extensionDeclarer.withConstruct("try") .describedAs("Processes the nested list of message processors, " + "within a transaction and with it's own error handler if required."); tryScope.onDefaultParameterGroup() .withOptionalParameter("transactionalAction") .ofType(BaseTypeBuilder.create(JAVA).stringType() .enumOf("INDIFFERENT", "ALWAYS_BEGIN", "BEGIN_OR_JOIN").build()) .defaultingTo("INDIFFERENT") .withExpressionSupport(NOT_SUPPORTED) .withLayout(LayoutModel.builder().tabName("Transactions").build()) .describedAs("The action to take regarding transactions. By default nothing will be done."); tryScope.onDefaultParameterGroup() .withOptionalParameter("transactionType") .ofType(BaseTypeBuilder.create(JAVA).stringType().enumOf("LOCAL", "XA").build()) .defaultingTo("LOCAL") .withExpressionSupport(NOT_SUPPORTED) .describedAs("Transaction type supported. Availability will depend on the runtime version, " + "though LOCAL is always available."); tryScope.withChain(); tryScope.withOptionalComponent("errorHandler") .withAllowedStereotypes(ERROR_HANDLER); }
private void declareRaiseError(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) { OperationDeclarer raiseError = extensionDeclarer.withOperation("raiseError") .describedAs("Throws an error with the specified type and description."); raiseError.withOutput().ofType(typeLoader.load(void.class)); raiseError.withOutputAttributes().ofType(typeLoader.load(void.class)); raiseError.onDefaultParameterGroup() .withRequiredParameter("type") .ofType(typeLoader.load(String.class)) .withExpressionSupport(NOT_SUPPORTED) .describedAs("The error type to raise."); raiseError.onDefaultParameterGroup() .withOptionalParameter("description") .ofType(typeLoader.load(String.class)) .describedAs("The description of this error."); }
.withOptionalParameter("ref") .withAllowedStereotypes(singletonList(ERROR_HANDLER)) .ofType(typeLoader.load(String.class))