use of org.mule.runtime.module.extension.internal.runtime.resolver.ExtensionsClientArgumentResolver in project mule by mulesoft.
the class MethodArgumentResolverDelegate method initArgumentResolvers.
private void initArgumentResolvers() {
final Class<?>[] parameterTypes = method.getParameterTypes();
if (isEmpty(parameterTypes)) {
argumentResolvers = new ArgumentResolver[] {};
return;
}
argumentResolvers = new ArgumentResolver[parameterTypes.length];
Annotation[][] parameterAnnotations = method.getParameterAnnotations();
Parameter[] parameters = method.getParameters();
parameterGroupResolvers = getParameterGroupResolvers(parameterGroupModels);
final List<String> paramNames = getParamNames(method);
for (int i = 0; i < parameterTypes.length; i++) {
final Class<?> parameterType = parameterTypes[i];
Map<Class<? extends Annotation>, Annotation> annotations = toMap(parameterAnnotations[i]);
ArgumentResolver<?> argumentResolver;
if (annotations.containsKey(Config.class)) {
argumentResolver = CONFIGURATION_ARGUMENT_RESOLVER;
} else if (annotations.containsKey(Connection.class)) {
argumentResolver = CONNECTOR_ARGUMENT_RESOLVER;
} else if (annotations.containsKey(DefaultEncoding.class)) {
argumentResolver = DEFAULT_ENCODING_ARGUMENT_RESOLVER;
} else if (Error.class.isAssignableFrom(parameterType)) {
argumentResolver = ERROR_ARGUMENT_RESOLVER;
} else if (SourceCallbackContext.class.equals(parameterType)) {
argumentResolver = SOURCE_CALLBACK_CONTEXT_ARGUMENT_RESOLVER;
} else if (isParameterContainer(annotations.keySet(), typeLoader.load(parameterType)) && !((ParameterGroup) annotations.get(ParameterGroup.class)).showInDsl()) {
argumentResolver = parameterGroupResolvers.get(parameters[i]);
} else if (ParameterResolver.class.equals(parameterType)) {
argumentResolver = new ParameterResolverArgumentResolver<>(paramNames.get(i));
} else if (TypedValue.class.equals(parameterType)) {
argumentResolver = new TypedValueArgumentResolver<>(paramNames.get(i));
} else if (Literal.class.equals(parameterType)) {
argumentResolver = new LiteralArgumentResolver<>(paramNames.get(i), parameterType);
} else if (CompletionCallback.class.equals(parameterType)) {
argumentResolver = NON_BLOCKING_CALLBACK_ARGUMENT_RESOLVER;
} else if (ExtensionsClient.class.equals(parameterType)) {
argumentResolver = new ExtensionsClientArgumentResolver(registry, policyManager);
} else if (RouterCompletionCallback.class.equals(parameterType)) {
argumentResolver = ROUTER_CALLBACK_ARGUMENT_RESOLVER;
} else if (VoidCompletionCallback.class.equals(parameterType)) {
argumentResolver = VOID_CALLBACK_ARGUMENT_RESOLVER;
} else if (MediaType.class.equals(parameterType)) {
argumentResolver = MEDIA_TYPE_ARGUMENT_RESOLVER;
} else if (AuthenticationHandler.class.equals(parameterType)) {
argumentResolver = SECURITY_CONTEXT_HANDLER;
} else if (FlowListener.class.equals(parameterType)) {
argumentResolver = FLOW_LISTENER_ARGUMENT_RESOLVER;
} else if (StreamingHelper.class.equals(parameterType)) {
argumentResolver = STREAMING_HELPER_ARGUMENT_RESOLVER;
} else if (SourceResult.class.equals(parameterType)) {
argumentResolver = SOURCE_RESULT_ARGUMENT_RESOLVER;
} else if (BackPressureContext.class.equals(parameterType)) {
argumentResolver = BACK_PRESSURE_CONTEXT_ARGUMENT_RESOLVER;
} else if (SourceCompletionCallback.class.equals(parameterType)) {
argumentResolver = ASYNC_SOURCE_COMPLETION_CALLBACK_ARGUMENT_RESOLVER;
} else if (ComponentLocation.class.equals(parameterType)) {
argumentResolver = COMPONENT_LOCATION_ARGUMENT_RESOLVER;
} else if (OperationTransactionalAction.class.equals(parameterType)) {
argumentResolver = OPERATION_TRANSACTIONAL_ACTION_ARGUMENT_RESOLVER;
} else if (CorrelationInfo.class.equals(parameterType)) {
argumentResolver = CORRELATION_INFO_ARGUMENT_RESOLVER;
} else if (NotificationEmitter.class.equals(parameterType)) {
argumentResolver = NOTIFICATION_HANDLER_ARGUMENT_RESOLVER;
} else {
argumentResolver = new ByParameterNameArgumentResolver<>(paramNames.get(i));
}
argumentResolvers[i] = argumentResolver;
}
}
use of org.mule.runtime.module.extension.internal.runtime.resolver.ExtensionsClientArgumentResolver in project mule by mulesoft.
the class SoapOperationExecutor method execute.
/**
* {@inheritDoc}
*/
@Override
public Publisher<Object> execute(ExecutionContext<OperationModel> context) {
try {
String serviceId = context.getParameter(SERVICE_PARAM);
ForwardingSoapClient connection = (ForwardingSoapClient) connectionResolver.resolve(context).get();
Map<String, String> customHeaders = connection.getCustomHeaders(serviceId, getOperation(context));
SoapRequest request = getRequest(context, customHeaders);
SoapClient soapClient = connection.getSoapClient(serviceId);
SoapResponse response = connection.getExtensionsClientDispatcher(() -> new ExtensionsClientArgumentResolver(registry, policyManager).resolve(context).get()).map(d -> soapClient.consume(request, d)).orElseGet(() -> soapClient.consume(request));
return justOrEmpty(response.getAsResult(streamingHelperArgumentResolver.resolve(context).get()));
} catch (MessageTransformerException | TransformerException e) {
return error(e);
} catch (Exception e) {
return error(soapExceptionEnricher.enrich(e));
} catch (Throwable t) {
return error(wrapFatal(t));
}
}
Aggregations