use of org.mule.runtime.module.extension.internal.loader.utils.ParameterDeclarationContext in project mule by mulesoft.
the class RouterModelLoaderDelegate method declareRoutes.
private void declareRoutes(ConstructDeclarer router, List<ExtensionParameter> routes) {
routes.forEach(route -> {
NestedRouteDeclarer routeDeclarer = router.withRoute(route.getAlias()).describedAs(route.getDescription()).withMinOccurs(route.isRequired() ? 1 : 0);
route.getType().getDeclaringClass().ifPresent(clazz -> routeDeclarer.withModelProperty(new ImplementingTypeModelProperty(clazz)));
final List<FieldElement> parameters = route.getType().getAnnotatedFields(Parameter.class);
loader.getFieldParametersLoader().declare(routeDeclarer, parameters, new ParameterDeclarationContext(CONSTRUCT, router.getDeclaration()));
});
}
use of org.mule.runtime.module.extension.internal.loader.utils.ParameterDeclarationContext in project mule by mulesoft.
the class ScopeModelLoaderDelegate method declareScope.
void declareScope(ExtensionDeclarer extensionDeclarer, HasOperationDeclarer ownerDeclarer, OperationContainerElement enclosingType, OperationElement scopeMethod, Optional<ExtensionParameter> configParameter, Optional<ExtensionParameter> connectionParameter) {
HasOperationDeclarer actualDeclarer = (HasOperationDeclarer) loader.selectDeclarerBasedOnConfig(extensionDeclarer, (Declarer) ownerDeclarer, configParameter, connectionParameter);
checkDefinition(!configParameter.isPresent(), format("Scope '%s' requires a config, but that is not allowed, remove such parameter", scopeMethod.getName()));
checkDefinition(!connectionParameter.isPresent(), format("Scope '%s' requires a connection, but that is not allowed, remove such parameter", scopeMethod.getName()));
checkDefinition(isNonBlocking(scopeMethod), format("Scope '%s' does not declare a '%s' parameter. One is required for all operations " + "that receive and execute a Chain of other components", scopeMethod.getAlias(), CompletionCallback.class.getSimpleName()));
if (operationDeclarers.containsKey(scopeMethod)) {
actualDeclarer.withOperation(operationDeclarers.get(scopeMethod));
return;
}
final OperationDeclarer scope = actualDeclarer.withOperation(scopeMethod.getAlias());
scope.withModelProperty(new ExtensionOperationDescriptorModelProperty(scopeMethod));
Optional<Method> method = scopeMethod.getMethod();
Optional<Class<?>> declaringClass = enclosingType.getDeclaringClass();
if (method.isPresent() && declaringClass.isPresent()) {
scope.withModelProperty(new ImplementingMethodModelProperty(method.get())).withModelProperty(new ComponentExecutorModelProperty(new ReflectiveOperationExecutorFactory<>(declaringClass.get(), method.get())));
}
processMimeType(scope, scopeMethod);
processNonBlockingOperation(scope, scopeMethod, false);
List<ExtensionParameter> processorChain = scopeMethod.getParameters().stream().filter(ModelLoaderUtils::isProcessorChain).collect(toList());
checkDefinition(processorChain.size() <= 1, format("Scope '%s' declares too many parameters of type '%s', only one input of this kind is supported." + "Offending parameters are: %s", scopeMethod.getAlias(), Chain.class.getSimpleName(), processorChain.stream().map(ExtensionParameter::getName).collect(toList())));
declareParameters(scope, scopeMethod.getParameters(), scopeMethod.getEnclosingType().getParameters(), new ParameterDeclarationContext(SCOPE, scope.getDeclaration()));
loader.addExceptionEnricher(scopeMethod, scope);
operationDeclarers.put(scopeMethod, scope);
}
use of org.mule.runtime.module.extension.internal.loader.utils.ParameterDeclarationContext in project mule by mulesoft.
the class SourceModelLoaderDelegate method declareSourceParameters.
/**
* 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));
}
use of org.mule.runtime.module.extension.internal.loader.utils.ParameterDeclarationContext in project mule by mulesoft.
the class SoapServiceProviderDeclarer method declare.
/**
* 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)).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);
}
}
use of org.mule.runtime.module.extension.internal.loader.utils.ParameterDeclarationContext in project mule by mulesoft.
the class SourceModelLoaderDelegate method declareSourceCallbackParameters.
private void declareSourceCallbackParameters(SourceDeclarer source, Optional<MethodElement> sourceCallback, Supplier<ParameterizedDeclarer> callback) {
sourceCallback.ifPresent(method -> {
ParameterDeclarationContext declarationContext = new ParameterDeclarationContext(SOURCE, source.getDeclaration());
loader.getMethodParametersLoader().declare(callback.get(), method.getParameters(), declarationContext);
});
}
Aggregations