Search in sources :

Example 1 with ByParameterNameArgumentResolver

use of org.mule.runtime.module.extension.internal.runtime.resolver.ByParameterNameArgumentResolver 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;
    }
}
Also used : SourceResult(org.mule.runtime.extension.api.runtime.source.SourceResult) ExtensionsClientArgumentResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ExtensionsClientArgumentResolver) MediaType(org.mule.runtime.api.metadata.MediaType) OperationTransactionalAction(org.mule.runtime.extension.api.tx.OperationTransactionalAction) TypedValue(org.mule.runtime.api.metadata.TypedValue) Connection(org.mule.runtime.extension.api.annotation.param.Connection) Error(org.mule.runtime.api.message.Error) Annotation(java.lang.annotation.Annotation) FlowListener(org.mule.runtime.extension.api.runtime.operation.FlowListener) NotificationEmitter(org.mule.runtime.extension.api.notification.NotificationEmitter) ByParameterNameArgumentResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ByParameterNameArgumentResolver) CompletionCallback(org.mule.runtime.extension.api.runtime.process.CompletionCallback) RouterCompletionCallback(org.mule.runtime.extension.api.runtime.process.RouterCompletionCallback) VoidCompletionCallback(org.mule.runtime.extension.api.runtime.process.VoidCompletionCallback) SourceCompletionCallback(org.mule.runtime.extension.api.runtime.source.SourceCompletionCallback) RouterCompletionCallback(org.mule.runtime.extension.api.runtime.process.RouterCompletionCallback) Parameter(java.lang.reflect.Parameter) SourceCompletionCallback(org.mule.runtime.extension.api.runtime.source.SourceCompletionCallback) TypedValueArgumentResolver(org.mule.runtime.module.extension.internal.runtime.resolver.TypedValueArgumentResolver)

Aggregations

Annotation (java.lang.annotation.Annotation)1 Parameter (java.lang.reflect.Parameter)1 Error (org.mule.runtime.api.message.Error)1 MediaType (org.mule.runtime.api.metadata.MediaType)1 TypedValue (org.mule.runtime.api.metadata.TypedValue)1 Connection (org.mule.runtime.extension.api.annotation.param.Connection)1 NotificationEmitter (org.mule.runtime.extension.api.notification.NotificationEmitter)1 FlowListener (org.mule.runtime.extension.api.runtime.operation.FlowListener)1 CompletionCallback (org.mule.runtime.extension.api.runtime.process.CompletionCallback)1 RouterCompletionCallback (org.mule.runtime.extension.api.runtime.process.RouterCompletionCallback)1 VoidCompletionCallback (org.mule.runtime.extension.api.runtime.process.VoidCompletionCallback)1 SourceCompletionCallback (org.mule.runtime.extension.api.runtime.source.SourceCompletionCallback)1 SourceResult (org.mule.runtime.extension.api.runtime.source.SourceResult)1 OperationTransactionalAction (org.mule.runtime.extension.api.tx.OperationTransactionalAction)1 ByParameterNameArgumentResolver (org.mule.runtime.module.extension.internal.runtime.resolver.ByParameterNameArgumentResolver)1 ExtensionsClientArgumentResolver (org.mule.runtime.module.extension.internal.runtime.resolver.ExtensionsClientArgumentResolver)1 TypedValueArgumentResolver (org.mule.runtime.module.extension.internal.runtime.resolver.TypedValueArgumentResolver)1