| 
38 | 38 | import org.springframework.lang.Nullable;  | 
39 | 39 | import org.springframework.util.Assert;  | 
40 | 40 | 
 
  | 
41 |  | -import com.fasterxml.jackson.databind.ObjectMapper;  | 
42 | 41 | import com.jayway.jsonpath.Configuration;  | 
43 | 42 | import com.jayway.jsonpath.DocumentContext;  | 
44 | 43 | import com.jayway.jsonpath.JsonPath;  | 
 | 
47 | 46 | import com.jayway.jsonpath.PathNotFoundException;  | 
48 | 47 | import com.jayway.jsonpath.TypeRef;  | 
49 | 48 | import com.jayway.jsonpath.spi.mapper.MappingProvider;  | 
 | 49 | +import com.jayway.jsonpath.spi.json.JsonProvider;  | 
50 | 50 | 
 
  | 
51 | 51 | /**  | 
52 | 52 |  * {@link MethodInterceptorFactory} to create a {@link MethodInterceptor} that will  | 
53 | 53 |  *  | 
54 | 54 |  * @author Oliver Gierke  | 
55 | 55 |  * @author Mark Paluch  | 
 | 56 | + * @author Mikhael Sokolov  | 
56 | 57 |  * @soundtrack Jeff Coffin - Fruitcake (The Inside Of The Outside)  | 
57 | 58 |  * @since 1.13  | 
58 | 59 |  */  | 
59 | 60 | public class JsonProjectingMethodInterceptorFactory implements MethodInterceptorFactory {  | 
60 | 61 | 
 
  | 
61 | 62 | 	private final ParseContext context;  | 
62 | 63 | 
 
  | 
 | 64 | +    /**  | 
 | 65 | +     * Creates a new {@link JsonProjectingMethodInterceptorFactory} using the given {@link MappingProvider} and {@link JsonProvider}.  | 
 | 66 | +     *  | 
 | 67 | +     * @param mappingProvider must not be {@literal null}.  | 
 | 68 | +     * @param jsonProvider must not be {@literal null}.  | 
 | 69 | +     */  | 
 | 70 | +    public JsonProjectingMethodInterceptorFactory(MappingProvider mappingProvider, JsonProvider jsonProvider) {  | 
 | 71 | + | 
 | 72 | +        Assert.notNull(mappingProvider, "MappingProvider must not be null!");  | 
 | 73 | +        Assert.notNull(jsonProvider, "JsonProvider must not be null!");  | 
 | 74 | + | 
 | 75 | +        Configuration configuration = Configuration.builder()//  | 
 | 76 | +                .options(Option.ALWAYS_RETURN_LIST)//  | 
 | 77 | +                .mappingProvider(mappingProvider)//  | 
 | 78 | +                .jsonProvider(jsonProvider)//  | 
 | 79 | +                .build();  | 
 | 80 | + | 
 | 81 | +        this.context = JsonPath.using(configuration);  | 
 | 82 | +    }  | 
 | 83 | + | 
63 | 84 | 	/**  | 
64 |  | -	 * Creates a new {@link JsonProjectingMethodInterceptorFactory} using the given {@link ObjectMapper}.  | 
 | 85 | +	 * Creates a new {@link JsonProjectingMethodInterceptorFactory} using the given {@link MappingProvider}.  | 
65 | 86 | 	 *  | 
66 |  | -	 * @param mapper must not be {@literal null}.  | 
 | 87 | +	 * @param mappingProvider must not be {@literal null}.  | 
67 | 88 | 	 */  | 
 | 89 | +	@Deprecated  | 
68 | 90 | 	public JsonProjectingMethodInterceptorFactory(MappingProvider mappingProvider) {  | 
69 |  | - | 
70 |  | -		Assert.notNull(mappingProvider, "MappingProvider must not be null!");  | 
71 |  | - | 
72 |  | -		Configuration build = Configuration.builder()//  | 
73 |  | -				.options(Option.ALWAYS_RETURN_LIST)//  | 
74 |  | -				.mappingProvider(mappingProvider)//  | 
75 |  | -				.build();  | 
76 |  | - | 
77 |  | -		this.context = JsonPath.using(build);  | 
 | 91 | +	    this(mappingProvider, Configuration.defaultConfiguration().jsonProvider());  | 
78 | 92 | 	}  | 
79 | 93 | 
 
  | 
80 | 94 | 	/*  | 
 | 
0 commit comments