@Before public void before() throws Exception { connectedOperation = spy(new ExtensionDeclarer() .withOperation(CONNECTED_OPERATION) .requiresConnection(true) .getDeclaration()); notConnectedOperation = spy(new ExtensionDeclarer() .withOperation(NOT_CONNECTED_OPERATION) .requiresConnection(false) .getDeclaration()); when(extensionLoadingContext.getExtensionDeclarer()).thenReturn(extensionDeclarer); when(extensionDeclarer.getDeclaration()).thenReturn(extensionDeclaration); when(extensionDeclaration.getOperations()).thenReturn(asList(connectedOperation, notConnectedOperation)); }
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."); }
private void declareFlowRef(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) { OperationDeclarer flowRef = extensionDeclarer.withOperation("flowRef") .describedAs("Allows a \u0027flow\u0027 to be referenced such that the 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"); }
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."); }
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 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"); }
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 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"); }
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' "
.withRole(BEHAVIOUR).ofType(typeBuilder.arrayType().of(typeLoader.load(SecurityProvider.class)).build()); final OperationDeclarer authorizationFilter = extensionDeclarer.withOperation("authorization-filter") .describedAs("Authorize users against a required set of authorities."); authorizationFilter.withOutput().ofType(typeBuilder.voidType().build());