Example usage for org.springframework.integration.support.json JsonObjectMapperProvider newInstance

List of usage examples for org.springframework.integration.support.json JsonObjectMapperProvider newInstance

Introduction

In this page you can find the example usage for org.springframework.integration.support.json JsonObjectMapperProvider newInstance.

Prototype

@SuppressWarnings("deprecation")
public static JsonObjectMapper<?, ?> newInstance() 

Source Link

Document

Return an object mapper if available.

Usage

From source file:org.springframework.integration.handler.support.MessagingMethodInvokerHelper.java

private MessagingMethodInvokerHelper(Object targetObject, Class<? extends Annotation> annotationType,
        Method method, Class<?> expectedType, boolean canProcessMessageList) {

    this.annotationType = annotationType;
    this.canProcessMessageList = canProcessMessageList;
    Assert.notNull(method, "method must not be null");
    this.method = method;
    this.requiresReply = expectedType != null;
    if (expectedType != null) {
        Assert.isTrue(method.getReturnType() != Void.class && method.getReturnType() != Void.TYPE,
                "method must have a return type");
        this.expectedType = TypeDescriptor.valueOf(expectedType);
    } else {//from www. j av a  2  s .co m
        this.expectedType = null;
    }

    Assert.notNull(targetObject, "targetObject must not be null");
    this.targetObject = targetObject;
    try {
        InvocableHandlerMethod invocableHandlerMethod = this.messageHandlerMethodFactory
                .createInvocableHandlerMethod(targetObject, method);
        this.handlerMethod = new HandlerMethod(invocableHandlerMethod, canProcessMessageList);
        this.defaultHandlerMethod = null;
        checkSpelInvokerRequired(getTargetClass(targetObject), method, this.handlerMethod);
    } catch (IneligibleMethodException e) {
        throw new IllegalArgumentException(e);
    }
    this.handlerMethods = null;
    this.handlerMessageMethods = null;
    this.handlerMethodsList = null;
    setDisplayString(targetObject, method);

    JsonObjectMapper<?, ?> mapper;
    try {
        mapper = JsonObjectMapperProvider.newInstance();
    } catch (IllegalStateException e) {
        mapper = null;
    }
    this.jsonObjectMapper = mapper;
}

From source file:org.springframework.integration.handler.support.MessagingMethodInvokerHelper.java

private MessagingMethodInvokerHelper(Object targetObject, Class<? extends Annotation> annotationType,
        String methodName, Class<?> expectedType, boolean canProcessMessageList) {
    this.annotationType = annotationType;
    this.methodName = methodName;
    this.canProcessMessageList = canProcessMessageList;
    Assert.notNull(targetObject, "targetObject must not be null");
    if (expectedType != null) {
        this.expectedType = TypeDescriptor.valueOf(expectedType);
    } else {//from ww w .jav a2s .c om
        this.expectedType = null;
    }
    this.targetObject = targetObject;
    Map<String, Map<Class<?>, HandlerMethod>> handlerMethodsForTarget = findHandlerMethodsForTarget(
            targetObject, annotationType, methodName, expectedType != null);
    Map<Class<?>, HandlerMethod> handlerMethods = handlerMethodsForTarget.get(CANDIDATE_METHODS);
    Map<Class<?>, HandlerMethod> handlerMessageMethods = handlerMethodsForTarget.get(CANDIDATE_MESSAGE_METHODS);
    if ((handlerMethods.size() == 1 && handlerMessageMethods.isEmpty())
            || (handlerMessageMethods.size() == 1 && handlerMethods.isEmpty())) {
        if (handlerMethods.size() == 1) {
            this.handlerMethod = handlerMethods.values().iterator().next();
        } else {
            this.handlerMethod = handlerMessageMethods.values().iterator().next();
        }
        this.handlerMethods = null;
        this.handlerMessageMethods = null;
        this.handlerMethodsList = null;
    } else {
        this.handlerMethod = null;
        this.handlerMethods = handlerMethods;
        this.handlerMessageMethods = handlerMessageMethods;
        this.handlerMethodsList = new LinkedList<>();

        //TODO Consider to use global option to determine a precedence of methods
        this.handlerMethodsList.add(this.handlerMethods);
        this.handlerMethodsList.add(this.handlerMessageMethods);
    }
    setDisplayString(targetObject, methodName);
    JsonObjectMapper<?, ?> mapper;
    try {
        mapper = JsonObjectMapperProvider.newInstance();
    } catch (IllegalStateException e) {
        mapper = null;
    }
    this.jsonObjectMapper = mapper;
}