private void parseExpressionSupport(ExtensionParameter extensionParameter, ParameterDeclarer parameter) { extensionParameter.getAnnotation(Expression.class) .ifPresent(expression -> parameter.withExpressionSupport(getExpressionSupport(expression))); }
/** * Declares the parameters needed to generate messages */ private void declareSourceParameters(SourceElement sourceType, SourceDeclarer source) { ParameterModelsLoaderDelegate parametersLoader = loader.getFieldParametersLoader(); ParameterDeclarationContext declarationContext = new ParameterDeclarationContext(SOURCE, source.getDeclaration()); List<ParameterDeclarer> parameters = parametersLoader.declare(source, sourceType.getParameters(), declarationContext); parameters.forEach(p -> p.withExpressionSupport(NOT_SUPPORTED)); }
void declareParameters(ComponentDeclarer component, List<ExtensionParameter> methodParameters, List<ExtensionParameter> fieldParameters, ParameterDeclarationContext declarationContext) { loader.getMethodParametersLoader().declare(component, methodParameters, declarationContext); loader.getFieldParametersLoader().declare(component, fieldParameters, declarationContext).forEach(p -> { p.withExpressionSupport(NOT_SUPPORTED); p.withModelProperty(new FieldOperationParameterModelProperty()); }); }
/** * {@inheritDoc} */ @Override public void contribute(ExtensionParameter parameter, ParameterDeclarer declarer, ParameterDeclarationContext declarationContext) { getInfrastructureType(parameter.getType()).ifPresent(infrastructureType -> { if (!isBlank(infrastructureType.getName())) { declarer.withModelProperty(new InfrastructureParameterModelProperty(infrastructureType.getSequence())); declarer.withExpressionSupport(NOT_SUPPORTED); getQName(infrastructureType.getName()).ifPresent(declarer::withModelProperty); getDslConfiguration(infrastructureType.getName()).ifPresent(declarer::withDsl); } }); } }
private void parseExpressionSupport(ExtensionParameter extensionParameter, ParameterDeclarer parameter) { extensionParameter.getAnnotation(Expression.class) .ifPresent(expression -> parameter.withExpressionSupport(getExpressionSupport(expression))); }
/** * Declares a new connection provider for a configuration given a {@link SoapServiceProviderWrapper} declaration. * * @param configDeclarer the configuration declarer that will own the provider * @param provider a {@link SoapServiceProviderWrapper} that describes the {@link SoapServiceProvider} Type. * @param hasCustomTransports if declares custom transport or not. */ public void declare(ConfigurationDeclarer configDeclarer, SoapServiceProviderWrapper provider, boolean hasCustomTransports) { String description = provider.getDescription(); // Declares the Service Provider as a Connection Provider. ConnectionProviderDeclarer providerDeclarer = configDeclarer.withConnectionProvider(provider.getAlias()) .describedAs(description) .withModelProperty(new ConnectionTypeModelProperty(ForwardingSoapClient.class)) //TODO - MULE-14311 - Make loader work in compile time .withModelProperty(new ImplementingTypeModelProperty(provider.getDeclaringClass().get())) .withConnectionManagementType(POOLING) .supportsConnectivityTesting(provider.supportsConnectivityTesting()); ParameterDeclarationContext context = new ParameterDeclarationContext("Service Provider", providerDeclarer.getDeclaration()); parametersLoader.declare(providerDeclarer, provider.getParameters(), context); if (hasCustomTransports) { providerDeclarer.onParameterGroup(TRANSPORT_GROUP) .withRequiredParameter(TRANSPORT_PARAM) .withDisplayModel(DisplayModel.builder().displayName(TRANSPORT_GROUP).build()) .ofType(typeLoader.load(MessageDispatcherProvider.class)) .withLayout(LayoutModel.builder().order(1).tabName(TRANSPORT).build()) .withExpressionSupport(NOT_SUPPORTED); } }
/** * Declares the parameters needed to generate messages */ private void declareSourceParameters(SourceElement sourceType, SourceDeclarer source) { ParameterModelsLoaderDelegate parametersLoader = loader.getFieldParametersLoader(); ParameterDeclarationContext declarationContext = new ParameterDeclarationContext(SOURCE, source.getDeclaration()); List<ParameterDeclarer> parameters = parametersLoader.declare(source, sourceType.getParameters(), declarationContext); parameters.forEach(p -> p.withExpressionSupport(NOT_SUPPORTED)); }
void declareParameters(ComponentDeclarer component, List<ExtensionParameter> methodParameters, List<ExtensionParameter> fieldParameters, ParameterDeclarationContext declarationContext) { loader.getMethodParametersLoader().declare(component, methodParameters, declarationContext); loader.getFieldParametersLoader().declare(component, fieldParameters, declarationContext).forEach(p -> { p.withExpressionSupport(NOT_SUPPORTED); p.withModelProperty(new FieldOperationParameterModelProperty()); }); }
/** * {@inheritDoc} */ @Override public void contribute(ExtensionParameter parameter, ParameterDeclarer declarer, ParameterDeclarationContext declarationContext) { getInfrastructureType(parameter.getType()).ifPresent(infrastructureType -> { if (!isBlank(infrastructureType.getName())) { declarer.withModelProperty(new InfrastructureParameterModelProperty(infrastructureType.getSequence())); declarer.withExpressionSupport(NOT_SUPPORTED); getQName(infrastructureType.getName()).ifPresent(declarer::withModelProperty); getDslConfiguration(infrastructureType.getName()).ifPresent(declarer::withDsl); } }); } }
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 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."); }
.withRequiredParameter("ref") .ofType(typeLoader.load(String.class)) .withExpressionSupport(NOT_SUPPORTED) .describedAs("The name of the error handler to reuse.");
private void declareScheduler(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) { SourceDeclarer scheduler = extensionDeclarer.withMessageSource("scheduler") .hasResponse(false) .describedAs("Source that schedules periodic execution of a flow."); scheduler.withOutput().ofType(typeLoader.load(Object.class)); scheduler.withOutputAttributes().ofType(typeLoader.load(Object.class)); MetadataType baseSchedulingStrategy = typeLoader.load(Scheduler.class); scheduler.onDefaultParameterGroup() .withRequiredParameter("schedulingStrategy") .ofType(baseSchedulingStrategy) .withExpressionSupport(NOT_SUPPORTED); MetadataType fixedFrequencyScheduler = typeLoader.load(FixedFrequencyScheduler.class); MetadataType cronScheduler = typeLoader.load(CronScheduler.class); extensionDeclarer.withSubType(baseSchedulingStrategy, fixedFrequencyScheduler); extensionDeclarer.withSubType(baseSchedulingStrategy, cronScheduler); // workaround for an "org.mule.runtime" package and still export the type in the extension model extensionDeclarer.getDeclaration().addType((ObjectType) baseSchedulingStrategy); extensionDeclarer.getDeclaration().addType((ObjectType) fixedFrequencyScheduler); extensionDeclarer.getDeclaration().addType((ObjectType) cronScheduler); }
.describedAs("Spring configuration that allows to define a set of spring XML files and create an application context with objects to be used in the mule artifact."); ParameterGroupDeclarer parameterGroupDeclarer = springConfig.onDefaultParameterGroup(); parameterGroupDeclarer.withRequiredParameter("files").withExpressionSupport(NOT_SUPPORTED) .withRole(BEHAVIOUR).ofType(typeLoader.load(String.class)); securityManager.onDefaultParameterGroup().withRequiredParameter("providers").withExpressionSupport(NOT_SUPPORTED) .withRole(BEHAVIOUR).ofType(typeBuilder.arrayType().of(typeLoader.load(SecurityProvider.class)).build()); authorizationFilter.withOutputAttributes().ofType(typeBuilder.voidType().build()); authorizationFilter.onDefaultParameterGroup().withRequiredParameter("requiredAuthorities") .withExpressionSupport(NOT_SUPPORTED) .withRole(BEHAVIOUR).ofType(typeLoader.load(String.class));
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 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"); }