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(); }
private void declareRoundRobin(ExtensionDeclarer extensionDeclarer) { ConstructDeclarer roundRobin = extensionDeclarer.withConstruct("roundRobin") .describedAs("Send each message received to the next message processor in the circular list of targets."); roundRobin.withRoute("route").withChain(); }
private void declareSubflow(ExtensionDeclarer extensionDeclarer) { ConstructDeclarer flow = extensionDeclarer.withConstruct("subFlow") .allowingTopLevelDefinition(); flow.withChain().setRequired(true).withAllowedStereotypes(PROCESSOR); }
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 declareChoice(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) { ConstructDeclarer choice = extensionDeclarer.withConstruct("choice") .describedAs("Sends the message to the first message processor whose condition has been satisfied. " + "If no conditions were satisfied, sends to the configured default message processor if configured, " + "or throws an exception if not configured.") .withErrorModel(routingError); NestedRouteDeclarer when = choice.withRoute("when").withMinOccurs(1); when.withChain(); when.onDefaultParameterGroup() .withRequiredParameter("expression") .ofType(typeLoader.load(boolean.class)) .describedAs("The expression to evaluate."); choice.withRoute("otherwise").withMaxOccurs(1).withChain(); }
private void declareConfigurationProperties(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) { ConstructDeclarer configuration = extensionDeclarer.withConstruct("configurationProperties") .allowingTopLevelDefinition() .withStereotype(APP_CONFIG) .describedAs("References a file with configuration properties. 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. The file location\n" + " value may also contains references to properties that will only be resolved based on " + "system properties or properties set at deployment time."); }
private void declareErrorHandler(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) { ConstructDeclarer errorHandler = extensionDeclarer.withConstruct("errorHandler") .withStereotype(ERROR_HANDLER) .allowingTopLevelDefinition() .describedAs("Error handler used to reference other ones."); ConstructDeclarer onError = extensionDeclarer.withConstruct("onError") .withStereotype(ON_ERROR) .describedAs("Error handler used to reference other ones.");
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 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 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 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 declareScatterGather(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) { ConstructDeclarer scatterGather = extensionDeclarer.withConstruct("scatterGather") .describedAs("Sends the same message to multiple message processors in parallel.") .withErrorModel(compositeRoutingError);
private void declareConfiguration(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) { ConstructDeclarer configuration = extensionDeclarer.withConstruct("configuration") .allowingTopLevelDefinition() .withStereotype(APP_CONFIG)