use of org.mule.runtime.api.component.ComponentIdentifier in project mule by mulesoft.
the class PolicyPointcutParametersManager method createOperationPointcutParameters.
/**
* Creates {@link PolicyPointcutParameters} for a specific operation. Stored parameters from the source are included in the
* newly created parameters to be able to correlate parameters from both source and operation.
*
* @param operation the operation component to which policies will be applied
* @param event the event which will execute the operation policies
* @param operationParameters a map containing the parameters of the operation
* @return the created {@link PolicyPointcutParameters}
*/
public PolicyPointcutParameters createOperationPointcutParameters(Component operation, CoreEvent event, Map<String, Object> operationParameters) {
ComponentIdentifier operationIdentifier = operation.getLocation().getComponentIdentifier().getIdentifier();
PolicyPointcutParameters sourceParameters = sourceParametersMap.get(event.getContext().getCorrelationId());
OperationPolicyPointcutParametersParameters parameters = new OperationPolicyPointcutParametersParameters(operation, operationParameters, sourceParameters);
Function<OperationPolicyPointcutParametersFactory, PolicyPointcutParameters> creationFunction = factory -> {
try {
return factory.createPolicyPointcutParameters(parameters);
} catch (AbstractMethodError error) {
return factory.createPolicyPointcutParameters(parameters.getOperation(), parameters.getOperationParameters());
}
};
return createPointcutParameters(operation, OperationPolicyPointcutParametersFactory.class, operationPointcutFactories, factory -> factory.supportsOperationIdentifier(operationIdentifier), creationFunction).orElse(new PolicyPointcutParameters(operation, sourceParameters));
}
use of org.mule.runtime.api.component.ComponentIdentifier in project mule by mulesoft.
the class AbstractErrorTypeMatcherTestCase method setUp.
@Before
public void setUp() {
ErrorTypeRepository errorTypeRepository = muleContext.getErrorTypeRepository();
anyErrorType = errorTypeRepository.getAnyErrorType();
ComponentIdentifier transformationIdentifier = ComponentIdentifier.builder().name(TRANSFORMATION_ERROR_IDENTIFIER).namespace(CORE_NAMESPACE_NAME).build();
transformationErrorType = errorTypeRepository.lookupErrorType(transformationIdentifier).get();
ComponentIdentifier expressionIdentifier = ComponentIdentifier.builder().name(EXPRESSION_ERROR_IDENTIFIER).namespace(CORE_NAMESPACE_NAME).build();
expressionErrorType = errorTypeRepository.lookupErrorType(expressionIdentifier).get();
}
use of org.mule.runtime.api.component.ComponentIdentifier in project mule by mulesoft.
the class SingleErrorTypeMatcherTestCase method matchChild.
@Test
public void matchChild() {
ComponentIdentifier customTransformerIdentifier = ComponentIdentifier.builder().name("custom").namespace(CORE_NAMESPACE_NAME).build();
ErrorTypeRepository errorTypeRepository = muleContext.getErrorTypeRepository();
ErrorType customTransformerErrorType = errorTypeRepository.addErrorType(customTransformerIdentifier, transformationErrorType);
ErrorTypeMatcher transformationMatcher = new SingleErrorTypeMatcher(transformationErrorType);
assertThat(transformationMatcher.match(customTransformerErrorType), is(true));
}
use of org.mule.runtime.api.component.ComponentIdentifier in project mule by mulesoft.
the class XmlExtensionLoaderDelegate method extractOutputType.
private void extractOutputType(OutputDeclarer outputDeclarer, ComponentIdentifier componentIdentifier, ComponentModel operationModel, Optional<MetadataType> calculatedOutput) {
Optional<ComponentModel> outputAttributesComponentModel = operationModel.getInnerComponents().stream().filter(child -> child.getIdentifier().equals(componentIdentifier)).findFirst();
outputAttributesComponentModel.ifPresent(outputComponentModel -> outputDeclarer.describedAs(getDescription(outputComponentModel)));
MetadataType metadataType = getMetadataType(outputAttributesComponentModel, calculatedOutput);
outputDeclarer.ofType(metadataType);
}
use of org.mule.runtime.api.component.ComponentIdentifier in project mule by mulesoft.
the class ConfigurationBasedElementModelFactory method addInlineGroup.
private void addInlineGroup(DslElementSyntax elementDsl, Multimap<ComponentIdentifier, ComponentConfiguration> innerComponents, Map<String, String> parameters, DslElementModel.Builder parent, ParameterGroupModel group) {
elementDsl.getChild(group.getName()).ifPresent(groupDsl -> {
Optional<ComponentIdentifier> identifier = getIdentifier(groupDsl);
if (!identifier.isPresent()) {
return;
}
ComponentConfiguration groupComponent = getSingleComponentConfiguration(innerComponents, identifier);
if (groupComponent != null) {
DslElementModel.Builder<ParameterGroupModel> groupElementBuilder = DslElementModel.<ParameterGroupModel>builder().withModel(group).withDsl(groupDsl).withConfig(groupComponent);
Multimap<ComponentIdentifier, ComponentConfiguration> groupInnerComponents = getNestedComponents(groupComponent);
group.getParameterModels().forEach(p -> addElementParameter(groupInnerComponents, parameters, groupDsl, groupElementBuilder, p));
parent.containing(groupElementBuilder.build());
} else if (shoulBuildDefaultGroup(group)) {
builDefaultInlineGroupElement(parent, group, groupDsl, identifier.get());
}
});
}
Aggregations