Search in sources :

Example 1 with OperationDeclarer

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

the class MuleExtensionModelDeclarer method declareIdempotentValidator.

private void declareIdempotentValidator(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) {
    OperationDeclarer validator = extensionDeclarer.withOperation("idempotentMessageValidator").describedAs("Ensures that only unique messages are received by a service by checking the unique ID of the incoming message. " + "Note that the ID used can be generated from the message using an expression defined in the 'idExpression' " + "attribute. Otherwise, a 'DUPLICATE_MESSAGE' error is generated.");
    validator.withOutput().ofType(typeLoader.load(void.class));
    validator.withOutputAttributes().ofType(typeLoader.load(void.class));
    validator.onDefaultParameterGroup().withOptionalParameter("idExpression").ofType(typeLoader.load(String.class)).defaultingTo("#[id]").withDsl(ParameterDslConfiguration.builder().allowsReferences(false).build()).describedAs("Defines one or more expressions to use when extracting the ID from the message. " + "If this property is not set, '#[id]' will be used by default.");
    validator.onDefaultParameterGroup().withOptionalParameter("valueExpression").ofType(typeLoader.load(String.class)).defaultingTo("#[id]").describedAs("Defines one or more expressions to use when extracting the value from the message.");
    validator.onDefaultParameterGroup().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).allowsReferences(true).build()).ofType(typeLoader.load(ObjectStore.class)).withExpressionSupport(NOT_SUPPORTED).withAllowedStereotypes(singletonList(OBJECT_STORE)).describedAs("The object store where the IDs of the processed events are going to be stored. " + "If defined as an argument, it should reference a globally created object store. Otherwise, " + "it can be defined inline or not at all. In the last case, a default object store will be provided.");
    validator.withErrorModel(duplicateMessageError);
}
Also used : OperationDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclarer)

Example 2 with OperationDeclarer

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

the class MuleExtensionModelDeclarer method declareFlowRef.

private void declareFlowRef(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) {
    OperationDeclarer flowRef = extensionDeclarer.withOperation("flowRef").describedAs("Allows a \u0027flow\u0027 to be referenced so that message processing will continue in the referenced flow " + "before returning. Message processing in the referenced \u0027flow\u0027 will occur within the context of the " + "referenced flow and will therefore use its exception strategy, etc.").withErrorModel(routingError);
    flowRef.withOutput().ofType(BaseTypeBuilder.create(JAVA).anyType().build());
    flowRef.withOutputAttributes().ofType(BaseTypeBuilder.create(JAVA).anyType().build());
    flowRef.onDefaultParameterGroup().withRequiredParameter("name").ofType(typeLoader.load(String.class)).withExpressionSupport(NOT_SUPPORTED).describedAs("The name of the flow to call");
}
Also used : OperationDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclarer)

Example 3 with OperationDeclarer

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

the class MuleExtensionModelDeclarer method declareLogger.

private void declareLogger(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) {
    OperationDeclarer logger = extensionDeclarer.withOperation("logger").describedAs("Performs logging using an expression to determine the message to be logged. By default, if a message is not specified, the current Mule Message is logged " + "using the " + DEFAULT_LOG_LEVEL + " level with the \u0027org.mule.runtime.core.api.processor.LoggerMessageProcessor\u0027 category, but " + "the level and category can both be configured to suit your needs.");
    logger.withOutput().ofType(typeLoader.load(void.class));
    logger.withOutputAttributes().ofType(typeLoader.load(void.class));
    logger.onDefaultParameterGroup().withOptionalParameter("message").ofType(typeLoader.load(String.class)).describedAs("The message that will be logged. Embedded expressions can be used to extract values from the current message. " + "If no message is specified, then the current message is used.");
    logger.onDefaultParameterGroup().withOptionalParameter("level").defaultingTo(DEFAULT_LOG_LEVEL).ofType(BaseTypeBuilder.create(JAVA).stringType().enumOf("ERROR", "WARN", "INFO", "DEBUG", "TRACE").build()).withExpressionSupport(NOT_SUPPORTED).describedAs("Sets the log level. Default is " + DEFAULT_LOG_LEVEL + ".");
    logger.onDefaultParameterGroup().withOptionalParameter("category").ofType(typeLoader.load(String.class)).withExpressionSupport(NOT_SUPPORTED).describedAs("Sets the log category");
}
Also used : OperationDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclarer)

Example 4 with OperationDeclarer

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

the class MuleExtensionModelDeclarer method declareRemoveVariable.

private void declareRemoveVariable(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) {
    OperationDeclarer removeVariable = extensionDeclarer.withOperation("removeVariable").describedAs("A processor that removes 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.");
}
Also used : OperationDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclarer)

Example 5 with OperationDeclarer

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

the class SoapInvokeOperationDeclarer method declare.

/**
 * Declares the invoke operation.
 *
 * @param configDeclarer the soap config declarer
 * @param loader         a {@link ClassTypeLoader} to load some parameters types.
 * @param soapErrors     the {@link ErrorModel}s that this operation can throw.
 */
void declare(ConfigurationDeclarer configDeclarer, ClassTypeLoader loader, Set<ErrorModel> soapErrors) {
    ReflectionCache reflectionCache = new ReflectionCache();
    OperationDeclarer operation = configDeclarer.withOperation(OPERATION_NAME).describedAs(OPERATION_DESCRIPTION).requiresConnection(true).blocking(true).withModelProperty(new ComponentExecutorModelProperty(new SoapOperationExecutorFactory())).withModelProperty(new ConnectivityModelProperty(ForwardingSoapClient.class));
    soapErrors.forEach(operation::withErrorModel);
    declareMetadata(operation, loader);
    declareOutput(operation, loader);
    declareMetadataKeyParameters(operation, loader, reflectionCache);
    declareRequestParameters(operation, loader);
}
Also used : ConnectivityModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ConnectivityModelProperty) ForwardingSoapClient(org.mule.runtime.module.extension.soap.internal.runtime.connection.ForwardingSoapClient) ReflectionCache(org.mule.runtime.module.extension.internal.util.ReflectionCache) OperationDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclarer) SoapOperationExecutorFactory(org.mule.runtime.module.extension.soap.internal.runtime.operation.SoapOperationExecutorFactory) ComponentExecutorModelProperty(org.mule.runtime.module.extension.api.loader.java.property.ComponentExecutorModelProperty)

Aggregations

OperationDeclarer (org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclarer)14 HasOperationDeclarer (org.mule.runtime.api.meta.model.declaration.fluent.HasOperationDeclarer)5 ComponentExecutorModelProperty (org.mule.runtime.module.extension.api.loader.java.property.ComponentExecutorModelProperty)4 Method (java.lang.reflect.Method)3 ExtensionDeclarer (org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclarer)3 ExtensionParameter (org.mule.runtime.module.extension.api.loader.java.type.ExtensionParameter)3 ImplementingMethodModelProperty (org.mule.runtime.module.extension.internal.loader.java.property.ImplementingMethodModelProperty)3 ExtensionOperationDescriptorModelProperty (org.mule.runtime.module.extension.internal.loader.java.type.property.ExtensionOperationDescriptorModelProperty)3 ParameterDeclarationContext (org.mule.runtime.module.extension.internal.loader.utils.ParameterDeclarationContext)3 ReflectiveOperationExecutorFactory (org.mule.runtime.module.extension.internal.runtime.execution.ReflectiveOperationExecutorFactory)3 String.format (java.lang.String.format)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Optional (java.util.Optional)2 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Sets (com.google.common.collect.Sets)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1