mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1514 - Add support for JacksonAnnotations at bean-properties
Fix where Jackson is not present on the classpath
This commit is contained in:
@@ -3,7 +3,6 @@ package io.ebeaninternal.server.deploy.meta;
|
||||
import io.ebean.annotation.Cache;
|
||||
import io.ebean.annotation.DocStore;
|
||||
import io.ebean.annotation.DocStoreMode;
|
||||
import io.ebean.annotation.PartitionMode;
|
||||
import io.ebean.config.ServerConfig;
|
||||
import io.ebean.config.TableName;
|
||||
import io.ebean.config.dbplatform.IdType;
|
||||
@@ -1260,10 +1259,7 @@ public class DeployBeanDescriptor<T> {
|
||||
*/
|
||||
public Object /*AnnotatedClass*/ getJacksonAnnotatedClass() {
|
||||
if (jacksonAnnotatedClass == null) {
|
||||
com.fasterxml.jackson.databind.ObjectMapper objectMapper = (com.fasterxml.jackson.databind.ObjectMapper) serverConfig.getObjectMapper();
|
||||
com.fasterxml.jackson.databind.JavaType javaType = objectMapper.getTypeFactory().constructType(beanType);
|
||||
jacksonAnnotatedClass = com.fasterxml.jackson.databind.introspect.AnnotatedClassResolver
|
||||
.resolve(objectMapper.getDeserializationConfig(), javaType, objectMapper.getDeserializationConfig());
|
||||
jacksonAnnotatedClass = new DeployBeanObtainJackson(serverConfig, beanType).obtain();
|
||||
}
|
||||
return jacksonAnnotatedClass;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package io.ebeaninternal.server.deploy.meta;
|
||||
|
||||
import com.fasterxml.jackson.databind.JavaType;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.introspect.AnnotatedClassResolver;
|
||||
import io.ebean.config.ServerConfig;
|
||||
|
||||
/**
|
||||
* Used to obtain the Jackson AnnotatedClass for a given bean type utlimately to obtain field level Jackson annotations.
|
||||
*/
|
||||
class DeployBeanObtainJackson<T> {
|
||||
|
||||
private final ServerConfig serverConfig;
|
||||
private final Class<T> beanType;
|
||||
|
||||
DeployBeanObtainJackson(ServerConfig serverConfig, Class<T> beanType) {
|
||||
this.serverConfig = serverConfig;
|
||||
this.beanType = beanType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Jackson AnnotatedClass for the given bean type.
|
||||
*/
|
||||
Object obtain() {
|
||||
|
||||
ObjectMapper objectMapper = (ObjectMapper) serverConfig.getObjectMapper();
|
||||
JavaType javaType = objectMapper.getTypeFactory().constructType(beanType);
|
||||
return AnnotatedClassResolver.resolve(objectMapper.getDeserializationConfig(), javaType, objectMapper.getDeserializationConfig());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user