List of usage examples for org.springframework.data.web JsonProjectingMethodInterceptorFactory JsonProjectingMethodInterceptorFactory
public JsonProjectingMethodInterceptorFactory(MappingProvider mappingProvider)
From source file:org.springframework.data.web.JsonProjectingMethodInterceptorFactoryUnitTests.java
@Before public void setUp() { String json = "{\"firstname\" : \"Dave\", "// + "\"address\" : { \"zipCode\" : \"01097\", \"city\" : \"Dresden\" }," // + "\"addresses\" : [ { \"zipCode\" : \"01097\", \"city\" : \"Dresden\" }]" + " }"; SpelAwareProxyProjectionFactory projectionFactory = new SpelAwareProxyProjectionFactory(); MappingProvider mappingProvider = new JacksonMappingProvider(new ObjectMapper()); projectionFactory.registerMethodInvokerFactory(new JsonProjectingMethodInterceptorFactory(mappingProvider)); this.projectionFactory = projectionFactory; this.customer = projectionFactory.createProjection(Customer.class, new ByteArrayInputStream(json.getBytes())); }
From source file:org.springframework.data.web.ProjectingJackson2HttpMessageConverter.java
/** * Creates a new {@link SpelAwareProxyProjectionFactory} with the {@link JsonProjectingMethodInterceptorFactory} * registered for the given {@link ObjectMapper}. * /*ww w. j a v a 2 s . com*/ * @param mapper must not be {@literal null}. * @return */ private static SpelAwareProxyProjectionFactory initProjectionFactory(ObjectMapper mapper) { Assert.notNull(mapper, "ObjectMapper must not be null!"); SpelAwareProxyProjectionFactory projectionFactory = new SpelAwareProxyProjectionFactory(); projectionFactory.registerMethodInvokerFactory( new JsonProjectingMethodInterceptorFactory(new JacksonMappingProvider(mapper))); return projectionFactory; }