This commit is contained in:
crusader 2018-04-24 21:57:05 +09:00
parent 8625e10e00
commit 591f5f5e9a
21 changed files with 330 additions and 369 deletions

14
pom.xml
View File

@ -25,10 +25,10 @@
<spring.data.jpa.version>1.11.4.RELEASE</spring.data.jpa.version> <spring.data.jpa.version>1.11.4.RELEASE</spring.data.jpa.version>
<spring.data.redis.version>1.8.7.RELEASE</spring.data.redis.version> <spring.data.redis.version>1.8.7.RELEASE</spring.data.redis.version>
<spring.crypto.version>4.2.3.RELEASE</spring.crypto.version> <spring.crypto.version>4.2.3.RELEASE</spring.crypto.version>
<gson.version>2.8.2</gson.version>
<hibernate.version>5.2.10.Final</hibernate.version> <hibernate.version>5.2.10.Final</hibernate.version>
<javax.mail.version>1.4.7</javax.mail.version> <javax.mail.version>1.4.7</javax.mail.version>
<javax.mail-api.version>1.6.0</javax.mail-api.version> <javax.mail-api.version>1.6.0</javax.mail-api.version>
<jackson.mapper.version>1.9.13</jackson.mapper.version>
<apache.velocity.version>1.7</apache.velocity.version> <apache.velocity.version>1.7</apache.velocity.version>
<docker.registry.name>docker.loafle.net/overflow</docker.registry.name> <docker.registry.name>docker.loafle.net/overflow</docker.registry.name>
<googleauth.version>1.1.2</googleauth.version> <googleauth.version>1.1.2</googleauth.version>
@ -97,12 +97,6 @@
<version>9.4-1200-jdbc41</version> <version>9.4-1200-jdbc41</version>
</dependency> </dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>${jackson.mapper.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager --> <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager -->
<dependency> <dependency>
@ -124,6 +118,12 @@
<version>${spring.crypto.version}</version> <version>${spring.crypto.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson.version}</version>
</dependency>
<!-- Mail --> <!-- Mail -->
<!-- https://mvnrepository.com/artifact/javax.mail/mail --> <!-- https://mvnrepository.com/artifact/javax.mail/mail -->
<dependency> <dependency>

View File

@ -1,7 +1,5 @@
package com.loafle.overflow.central.module.discovery.service; package com.loafle.overflow.central.module.discovery.service;
import com.loafle.overflow.central.commons.service.MessagePublisher; import com.loafle.overflow.central.commons.service.MessagePublisher;
import com.loafle.overflow.central.commons.utils.SessionMetadata; import com.loafle.overflow.central.commons.utils.SessionMetadata;
import com.loafle.overflow.core.annotation.ProbeAPI; import com.loafle.overflow.core.annotation.ProbeAPI;
@ -10,11 +8,9 @@ import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.model.discovery.*; import com.loafle.overflow.model.discovery.*;
import com.loafle.overflow.service.central.discovery.DiscoveryService; import com.loafle.overflow.service.central.discovery.DiscoveryService;
import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.Date; import java.util.Date;
/** /**
@ -26,17 +22,6 @@ public class CentralDiscoveryService implements DiscoveryService {
@Autowired @Autowired
private MessagePublisher messagePublisher; private MessagePublisher messagePublisher;
public void startDiscovery(DiscoveryStartInfo startInfo) throws OverflowException,IOException {
ObjectMapper objectMapper = new ObjectMapper();
String json = objectMapper.writeValueAsString(startInfo);
System.out.println("Start Discovery");
System.out.println(json);
// this.messagePublisher.publishToProbe("/auth", noAuthProbe.getTempProbeKey(), "NoAuthProbeService.acceptNoAuthProbe", probe.getProbeKey());
}
@WebappAPI @WebappAPI
public void discoverZone(String probeID, DiscoverZone discoveryZone) throws OverflowException { public void discoverZone(String probeID, DiscoverZone discoveryZone) throws OverflowException {
String requesterSessionID = SessionMetadata.getSessionID(); String requesterSessionID = SessionMetadata.getSessionID();
@ -59,10 +44,12 @@ public class CentralDiscoveryService implements DiscoveryService {
} }
@WebappAPI @WebappAPI
public void discoverService(String probeID, Port port, com.loafle.overflow.model.discovery.DiscoverService discoveryService) throws OverflowException { public void discoverService(String probeID, Port port,
com.loafle.overflow.model.discovery.DiscoverService discoveryService) throws OverflowException {
String requesterSessionID = SessionMetadata.getSessionID(); String requesterSessionID = SessionMetadata.getSessionID();
messagePublisher.publishToProbe(probeID, "DiscoveryService.DiscoverService", requesterSessionID, port, discoveryService); messagePublisher.publishToProbe(probeID, "DiscoveryService.DiscoverService", requesterSessionID, port,
discoveryService);
} }
@ProbeAPI @ProbeAPI
@ -91,7 +78,8 @@ public class CentralDiscoveryService implements DiscoveryService {
} }
@ProbeAPI @ProbeAPI
public void discoveredService(String requesterSessionID, com.loafle.overflow.model.discovery.Service service) throws OverflowException { public void discoveredService(String requesterSessionID, com.loafle.overflow.model.discovery.Service service)
throws OverflowException {
messagePublisher.publishToMemberSession(requesterSessionID, "DiscoveryService.discoveredService", service); messagePublisher.publishToMemberSession(requesterSessionID, "DiscoveryService.discoveredService", service);
} }

View File

@ -1,5 +1,7 @@
package com.loafle.overflow.central.module.generator.service; package com.loafle.overflow.central.module.generator.service;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.loafle.overflow.central.commons.utils.StringConvertor; import com.loafle.overflow.central.commons.utils.StringConvertor;
import com.loafle.overflow.core.exception.OverflowException; import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.core.type.PortType; import com.loafle.overflow.core.type.PortType;
@ -17,8 +19,6 @@ import com.loafle.overflow.model.sensorconfig.SensorConfig;
import com.loafle.overflow.model.sensorconfig.Target; import com.loafle.overflow.model.sensorconfig.Target;
import com.loafle.overflow.service.central.auth.AuthCrawlerService; import com.loafle.overflow.service.central.auth.AuthCrawlerService;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -41,6 +41,9 @@ public class InfraHostGenerator {
@Autowired @Autowired
private AuthCrawlerService authCrawlerService; private AuthCrawlerService authCrawlerService;
@Autowired
private Gson gson;
public String process(Sensor dbSensor, List<SensorItem> sensorItems, Infra infra) throws Exception { public String process(Sensor dbSensor, List<SensorItem> sensorItems, Infra infra) throws Exception {
InfraHost infraHost = (InfraHost) infra; InfraHost infraHost = (InfraHost) infra;
@ -70,12 +73,10 @@ public class InfraHostGenerator {
this.infraHostWMIGenerator.process(sensorItems, keyMap, dbSensor, sensorConfig); this.infraHostWMIGenerator.process(sensorItems, keyMap, dbSensor, sensorConfig);
} }
ObjectMapper objectMapper = new ObjectMapper(); return gson.toJson(sensorConfig);
return objectMapper.writeValueAsString(sensorConfig);
} }
private Target createTarget(InfraHost infraHost, Sensor dbSensor) private Target createTarget(InfraHost infraHost, Sensor dbSensor) throws Exception {
throws Exception {
AuthCrawler authCrawler = this.authCrawlerService.readAuth(dbSensor.getCrawler(), dbSensor.getTarget()); AuthCrawler authCrawler = this.authCrawlerService.readAuth(dbSensor.getCrawler(), dbSensor.getTarget());
@ -87,10 +88,7 @@ public class InfraHostGenerator {
Connection connection = new Connection(); Connection connection = new Connection();
connection.setIp(StringConvertor.intToIp(infraHost.getIp())); connection.setIp(StringConvertor.intToIp(infraHost.getIp()));
HashMap<String, String> optionMap; HashMap<String, String> optionMap = this.gson.fromJson(authCrawler.getAuthJson(), TypeToken.getParameterized(HashMap.class, String.class, String.class).getType());
optionMap = new ObjectMapper().readValue(authCrawler.getAuthJson(),
new TypeReference<HashMap<String, String>>() {
});
if (dbSensor.getCrawler().getId() == MetaCrawlerEnum.WMI_CRAWLER.getValue()) { if (dbSensor.getCrawler().getId() == MetaCrawlerEnum.WMI_CRAWLER.getValue()) {
connection.setPort(135); connection.setPort(135);

View File

@ -1,5 +1,7 @@
package com.loafle.overflow.central.module.generator.service; package com.loafle.overflow.central.module.generator.service;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.loafle.overflow.model.meta.MetaSensorItemKey; import com.loafle.overflow.model.meta.MetaSensorItemKey;
import com.loafle.overflow.model.sensor.Sensor; import com.loafle.overflow.model.sensor.Sensor;
import com.loafle.overflow.model.sensor.SensorItem; import com.loafle.overflow.model.sensor.SensorItem;
@ -9,8 +11,6 @@ import com.loafle.overflow.model.sensorconfig.MappingInfo;
import com.loafle.overflow.model.sensorconfig.QueryInfo; import com.loafle.overflow.model.sensorconfig.QueryInfo;
import com.loafle.overflow.model.sensorconfig.SensorConfig; import com.loafle.overflow.model.sensorconfig.SensorConfig;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -29,6 +29,9 @@ public class InfraHostWMIGenerator {
@Autowired @Autowired
private GenerateUtil generateUtil; private GenerateUtil generateUtil;
@Autowired
private Gson gson;
public void process(List<SensorItem> sensorItems, Map<Integer, MetaSensorItemKey> keyMap, Sensor dbSensor, public void process(List<SensorItem> sensorItems, Map<Integer, MetaSensorItemKey> keyMap, Sensor dbSensor,
SensorConfig sensorConfig) throws Exception { SensorConfig sensorConfig) throws Exception {
@ -84,9 +87,7 @@ public class InfraHostWMIGenerator {
String json = tempItemKey.getOption(); String json = tempItemKey.getOption();
if (json != null && json.length() > 0) { if (json != null && json.length() > 0) {
HashMap<String, Object> optionMap; HashMap<String, String> optionMap = this.gson.fromJson(json, TypeToken.getParameterized(HashMap.class, String.class, String.class).getType());
optionMap = new ObjectMapper().readValue(json, new TypeReference<HashMap<String, Object>>() {
});
Object obj = null; Object obj = null;
obj = optionMap.get("appends"); obj = optionMap.get("appends");

View File

@ -1,5 +1,7 @@
package com.loafle.overflow.central.module.generator.service; package com.loafle.overflow.central.module.generator.service;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.loafle.overflow.central.commons.utils.StringConvertor; import com.loafle.overflow.central.commons.utils.StringConvertor;
import com.loafle.overflow.core.type.PortType; import com.loafle.overflow.core.type.PortType;
import com.loafle.overflow.model.auth.AuthCrawler; import com.loafle.overflow.model.auth.AuthCrawler;
@ -16,8 +18,6 @@ import com.loafle.overflow.model.sensorconfig.SensorConfig;
import com.loafle.overflow.model.sensorconfig.Target; import com.loafle.overflow.model.sensorconfig.Target;
import com.loafle.overflow.service.central.auth.AuthCrawlerService; import com.loafle.overflow.service.central.auth.AuthCrawlerService;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -44,6 +44,9 @@ public class InfraServiceGenerator {
@Autowired @Autowired
private AuthCrawlerService authCrawlerService; private AuthCrawlerService authCrawlerService;
@Autowired
private Gson gson;
public String process(Sensor dbSensor, List<SensorItem> sensorItems, Infra infra) throws Exception { public String process(Sensor dbSensor, List<SensorItem> sensorItems, Infra infra) throws Exception {
com.loafle.overflow.model.infra.InfraService infraService = (com.loafle.overflow.model.infra.InfraService)infra; com.loafle.overflow.model.infra.InfraService infraService = (com.loafle.overflow.model.infra.InfraService)infra;
@ -75,8 +78,7 @@ public class InfraServiceGenerator {
this.infraServiceJMXGenerator.process(sensorItems, keyMap, dbSensor, sensorConfig); this.infraServiceJMXGenerator.process(sensorItems, keyMap, dbSensor, sensorConfig);
} }
ObjectMapper objectMapper = new ObjectMapper(); return gson.toJson(sensorConfig);
return objectMapper.writeValueAsString(sensorConfig);
} }
private Target createTarget(InfraService infraService, Sensor sensor) throws Exception { private Target createTarget(InfraService infraService, Sensor sensor) throws Exception {
@ -96,8 +98,7 @@ public class InfraServiceGenerator {
target.setConnection(connection); target.setConnection(connection);
HashMap<String,String> optionMap; HashMap<String, String> optionMap = this.gson.fromJson(authCrawler.getAuthJson(), TypeToken.getParameterized(HashMap.class, String.class, String.class).getType());
optionMap = new ObjectMapper().readValue(authCrawler.getAuthJson(), new TypeReference<HashMap<String,String>>() {});
Map<String, Object> auth = new HashMap<>(); Map<String, Object> auth = new HashMap<>();

View File

@ -1,5 +1,7 @@
package com.loafle.overflow.central.module.generator.service; package com.loafle.overflow.central.module.generator.service;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.loafle.overflow.model.meta.MetaSensorItemKey; import com.loafle.overflow.model.meta.MetaSensorItemKey;
import com.loafle.overflow.model.sensor.Sensor; import com.loafle.overflow.model.sensor.Sensor;
import com.loafle.overflow.model.sensor.SensorItem; import com.loafle.overflow.model.sensor.SensorItem;
@ -9,8 +11,6 @@ import com.loafle.overflow.model.sensorconfig.MappingInfo;
import com.loafle.overflow.model.sensorconfig.QueryInfo; import com.loafle.overflow.model.sensorconfig.QueryInfo;
import com.loafle.overflow.model.sensorconfig.SensorConfig; import com.loafle.overflow.model.sensorconfig.SensorConfig;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -28,6 +28,9 @@ public class InfraServiceJMXGenerator {
@Autowired @Autowired
private GenerateUtil generateUtil; private GenerateUtil generateUtil;
@Autowired
private Gson gson;
public void process(List<SensorItem> sensorItems, Map<Integer, MetaSensorItemKey> keyMap, Sensor dbSensor, public void process(List<SensorItem> sensorItems, Map<Integer, MetaSensorItemKey> keyMap, Sensor dbSensor,
SensorConfig sensorConfig) throws Exception { SensorConfig sensorConfig) throws Exception {
Map<String, List<MetaSensorItemKey>> metricMap = null; Map<String, List<MetaSensorItemKey>> metricMap = null;
@ -70,9 +73,7 @@ public class InfraServiceJMXGenerator {
List<String> arrayCol = null; List<String> arrayCol = null;
if (json != null && json.length() > 0) { if (json != null && json.length() > 0) {
HashMap<String, Object> optionMap; HashMap<String, String> optionMap = this.gson.fromJson(json, TypeToken.getParameterized(HashMap.class, String.class, String.class).getType());
optionMap = new ObjectMapper().readValue(json, new TypeReference<HashMap<String, Object>>() {
});
Object obj = null; Object obj = null;
obj = optionMap.get("aliases"); obj = optionMap.get("aliases");

View File

@ -1,5 +1,7 @@
package com.loafle.overflow.central.module.generator.service; package com.loafle.overflow.central.module.generator.service;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.loafle.overflow.core.exception.OverflowException; import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.model.meta.MetaSensorItemKey; import com.loafle.overflow.model.meta.MetaSensorItemKey;
import com.loafle.overflow.model.sensor.Sensor; import com.loafle.overflow.model.sensor.Sensor;
@ -10,10 +12,6 @@ import com.loafle.overflow.model.sensorconfig.MappingInfo;
import com.loafle.overflow.model.sensorconfig.QueryInfo; import com.loafle.overflow.model.sensorconfig.QueryInfo;
import com.loafle.overflow.model.sensorconfig.SensorConfig; import com.loafle.overflow.model.sensorconfig.SensorConfig;
import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -31,6 +29,8 @@ public class InfraServiceMysqlGenerator {
@Autowired @Autowired
private GenerateUtil generateUtil; private GenerateUtil generateUtil;
@Autowired
private Gson gson;
public void process(List<SensorItem> sensorItems, Map<Integer, MetaSensorItemKey> keyMap, Sensor dbSensor, public void process(List<SensorItem> sensorItems, Map<Integer, MetaSensorItemKey> keyMap, Sensor dbSensor,
SensorConfig sensorConfig) throws Exception { SensorConfig sensorConfig) throws Exception {
@ -83,9 +83,7 @@ public class InfraServiceMysqlGenerator {
String json = tempItemKey.getOption(); String json = tempItemKey.getOption();
if (json != null && json.length() > 0) { if (json != null && json.length() > 0) {
HashMap<String, Object> optionMap; HashMap<String, String> optionMap = this.gson.fromJson(json, TypeToken.getParameterized(HashMap.class, String.class, String.class).getType());
optionMap = new ObjectMapper().readValue(json, new TypeReference<HashMap<String, Object>>() {
});
Object obj = null; Object obj = null;
obj = optionMap.get("valueColumn"); obj = optionMap.get("valueColumn");

View File

@ -4,10 +4,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.List; import java.util.List;
import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.core.model.PageParams; import com.loafle.overflow.core.model.PageParams;
import com.loafle.overflow.model.infra.Infra; import com.loafle.overflow.model.infra.Infra;
import com.loafle.overflow.model.sensor.Sensor; import com.loafle.overflow.model.sensor.Sensor;

View File

@ -1,5 +1,7 @@
package com.loafle.overflow.central.module.noauthprobe.service; package com.loafle.overflow.central.module.noauthprobe.service;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.loafle.overflow.central.commons.service.MessagePublisher; import com.loafle.overflow.central.commons.service.MessagePublisher;
import com.loafle.overflow.central.commons.stereotype.ProbeAPI; import com.loafle.overflow.central.commons.stereotype.ProbeAPI;
import com.loafle.overflow.central.commons.stereotype.WebappAPI; import com.loafle.overflow.central.commons.stereotype.WebappAPI;
@ -20,8 +22,6 @@ import com.loafle.overflow.service.central.domain.DomainMemberService;
import com.loafle.overflow.service.central.noauthprobe.NoAuthProbeService; import com.loafle.overflow.service.central.noauthprobe.NoAuthProbeService;
import com.loafle.overflow.service.central.probe.ProbeService; import com.loafle.overflow.service.central.probe.ProbeService;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -46,15 +46,15 @@ public class CentralNoAuthProbeService implements NoAuthProbeService{
@Autowired @Autowired
private ProbeService probeService; private ProbeService probeService;
@Autowired
private ObjectMapper objectMapper;
@Autowired @Autowired
private MessagePublisher messagePublisher; private MessagePublisher messagePublisher;
@Autowired @Autowired
private DomainMemberService domainMemberService; private DomainMemberService domainMemberService;
@Autowired
private Gson gson;
@ProbeAPI @ProbeAPI
public NoAuthProbe regist(NoAuthProbe noAuthProbe) throws OverflowException{ public NoAuthProbe regist(NoAuthProbe noAuthProbe) throws OverflowException{
@ -99,12 +99,7 @@ public class CentralNoAuthProbeService implements NoAuthProbeService{
probe.setAuthorizeMember(new Member(domainMember.getMember().getId())); probe.setAuthorizeMember(new Member(domainMember.getMember().getId()));
probe.setStatus(new MetaProbeStatus((short)1)); probe.setStatus(new MetaProbeStatus((short)1));
Map<String, Object> objMap = null; HashMap<String, Object> objMap = this.gson.fromJson(noAuthProbe.getDescription(), TypeToken.getParameterized(HashMap.class, String.class, Object.class).getType());
try {
objMap = this.objectMapper.readValue(noAuthProbe.getDescription(), new TypeReference<HashMap<String,Object>>() {});
} catch (Exception e) {
e.printStackTrace();
}
Map<String, String> hostMap = (Map<String, String>) objMap.get("host"); Map<String, String> hostMap = (Map<String, String>) objMap.get("host");
Map<String, String> netMap = (Map<String, String>) objMap.get("network"); Map<String, String> netMap = (Map<String, String>) objMap.get("network");

View File

@ -1,18 +1,15 @@
package com.loafle.overflow.central.proxy; package com.loafle.overflow.central.proxy;
import com.google.gson.internal.Primitives; import com.google.gson.Gson;
import com.google.protobuf.ByteString; import com.google.protobuf.ByteString;
import com.loafle.overflow.core.exception.OverflowException; import com.loafle.overflow.core.exception.OverflowException;
import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.JavaType;
import org.springframework.aop.support.AopUtils; import org.springframework.aop.support.AopUtils;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.io.IOException;
import java.lang.reflect.*; import java.lang.reflect.*;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -26,15 +23,13 @@ public class ServiceInvoker {
// @Autowired // @Autowired
private ApplicationContext context; private ApplicationContext context;
private ObjectMapper objectMapper;
private Map<String, Cache> serviceCacheMap; private Map<String, Cache> serviceCacheMap;
@Autowired
private Gson gson;
public ServiceInvoker(ApplicationContext context) { public ServiceInvoker(ApplicationContext context) {
this.context = context; this.context = context;
objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
serviceCacheMap = new HashMap<>(); serviceCacheMap = new HashMap<>();
} }
@ -122,15 +117,7 @@ public class ServiceInvoker {
} }
private Object getValue(Type parameterType, String json) throws IllegalArgumentException { private Object getValue(Type parameterType, String json) throws IllegalArgumentException {
JavaType targetType = objectMapper.getTypeFactory().constructType(parameterType); return this.gson.fromJson(json, parameterType);
if (!Primitives.isPrimitive(parameterType) && !parameterType.getTypeName().equals(String.class.getName())) {
try {
return objectMapper.readValue(json, targetType);
} catch (IOException e) {
throw new IllegalArgumentException("");
}
}
return objectMapper.convertValue(json, targetType);
} }
private Object[] getParameters(Type[] parameterTypes, List<ByteString> params) throws IllegalArgumentException { private Object[] getParameters(Type[] parameterTypes, List<ByteString> params) throws IllegalArgumentException {
@ -187,11 +174,7 @@ public class ServiceInvoker {
throw new OverflowException("internal error", e); throw new OverflowException("internal error", e);
} }
try { jsonInString = this.gson.toJson(result);
jsonInString = objectMapper.writeValueAsString(result);
} catch (IOException e) {
throw new OverflowException("internal error", e);
}
return jsonInString; return jsonInString;
} }

View File

@ -1,12 +1,12 @@
package com.loafle.overflow.central.redis.service; package com.loafle.overflow.central.redis.service;
import com.google.gson.Gson;
import com.loafle.overflow.central.commons.service.MessagePublisher; import com.loafle.overflow.central.commons.service.MessagePublisher;
import com.loafle.overflow.core.exception.OverflowException; import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.core.model.PublishMessage; import com.loafle.overflow.core.model.PublishMessage;
import com.loafle.overflow.model.member.Member; import com.loafle.overflow.model.member.Member;
import com.loafle.overflow.service.central.member.MemberService; import com.loafle.overflow.service.central.member.MemberService;
import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
@ -27,7 +27,7 @@ public class RedisMessagePublisher implements MessagePublisher {
@Autowired @Autowired
private RedisTemplate<String, Object> redisTemplate; private RedisTemplate<String, Object> redisTemplate;
@Autowired @Autowired
private ObjectMapper objectMapper; private Gson gson;
@Autowired @Autowired
private MemberService memberService; private MemberService memberService;
@ -36,52 +36,60 @@ public class RedisMessagePublisher implements MessagePublisher {
public RedisMessagePublisher() { public RedisMessagePublisher() {
} }
public RedisMessagePublisher(final RedisTemplate<String, Object> redisTemplate, final Map<String, ChannelTopic> topics) { public RedisMessagePublisher(final RedisTemplate<String, Object> redisTemplate,
final Map<String, ChannelTopic> topics) {
this.redisTemplate = redisTemplate; this.redisTemplate = redisTemplate;
this.topics = topics; this.topics = topics;
} }
public void publishToDomainMembers(final long domainID, final String method, final Object... params) throws OverflowException { public void publishToDomainMembers(final long domainID, final String method, final Object... params)
throws OverflowException {
PublishMessage message = new PublishMessage(); PublishMessage message = new PublishMessage();
message.setTargetType(PublishMessage.TargetType.MEMBER); message.setTargetType(PublishMessage.TargetType.MEMBER);
message.setTargets(getMemberListByDomainID(domainID)); message.setTargets(getMemberListByDomainID(domainID));
this.publish(CHANNEL_WEBAPP, message, method, params); this.publish(CHANNEL_WEBAPP, message, method, params);
} }
public void publishToDomainMembersByProbeKey(final String probeKey, final String method, final Object... params) throws OverflowException {
public void publishToDomainMembersByProbeKey(final String probeKey, final String method, final Object... params)
throws OverflowException {
PublishMessage message = new PublishMessage(); PublishMessage message = new PublishMessage();
message.setTargetType(PublishMessage.TargetType.MEMBER); message.setTargetType(PublishMessage.TargetType.MEMBER);
message.setTargets(getMemberListByProbeKey(probeKey)); message.setTargets(getMemberListByProbeKey(probeKey));
this.publish(CHANNEL_WEBAPP, message, method, params); this.publish(CHANNEL_WEBAPP, message, method, params);
} }
public void publishToMember(final String memberID, final String method, final Object... params) throws OverflowException { public void publishToMember(final String memberID, final String method, final Object... params)
throws OverflowException {
PublishMessage message = new PublishMessage(); PublishMessage message = new PublishMessage();
message.setTargetType(PublishMessage.TargetType.MEMBER); message.setTargetType(PublishMessage.TargetType.MEMBER);
message.addTarget(memberID); message.addTarget(memberID);
this.publish(CHANNEL_WEBAPP, message, method, params); this.publish(CHANNEL_WEBAPP, message, method, params);
} }
public void publishToMemberSession(final String memberSessionID, final String method, final Object... params) throws OverflowException {
public void publishToMemberSession(final String memberSessionID, final String method, final Object... params)
throws OverflowException {
PublishMessage message = new PublishMessage(); PublishMessage message = new PublishMessage();
message.setTargetType(PublishMessage.TargetType.MEMBER_SESSION); message.setTargetType(PublishMessage.TargetType.MEMBER_SESSION);
message.addTarget(memberSessionID); message.addTarget(memberSessionID);
this.publish(CHANNEL_WEBAPP, message, method, params); this.publish(CHANNEL_WEBAPP, message, method, params);
} }
public void publishToNoAuthProbe(final String tempProbeKey, final String method, final Object... params) throws OverflowException { public void publishToNoAuthProbe(final String tempProbeKey, final String method, final Object... params)
throws OverflowException {
PublishMessage message = new PublishMessage(); PublishMessage message = new PublishMessage();
message.setTargetType(PublishMessage.TargetType.PROBE); message.setTargetType(PublishMessage.TargetType.PROBE);
message.addTarget(tempProbeKey); message.addTarget(tempProbeKey);
this.publish(CHANNEL_NOAUTH_PROBE, message, method, params); this.publish(CHANNEL_NOAUTH_PROBE, message, method, params);
} }
public void publishToProbe(final String probeKey, final String method, final Object... params) throws OverflowException { public void publishToProbe(final String probeKey, final String method, final Object... params)
throws OverflowException {
PublishMessage message = new PublishMessage(); PublishMessage message = new PublishMessage();
message.setTargetType(PublishMessage.TargetType.PROBE); message.setTargetType(PublishMessage.TargetType.PROBE);
message.addTarget(probeKey); message.addTarget(probeKey);
this.publish(CHANNEL_PROBE, message, method, params); this.publish(CHANNEL_PROBE, message, method, params);
} }
@Cacheable("memberListByDomain") @Cacheable("memberListByDomain")
protected List<String> getMemberListByDomainID(final long domainID) throws OverflowException { protected List<String> getMemberListByDomainID(final long domainID) throws OverflowException {
return this.getMemberList(memberService.readAllByDomainID(domainID)); return this.getMemberList(memberService.readAllByDomainID(domainID));
@ -94,7 +102,7 @@ public class RedisMessagePublisher implements MessagePublisher {
protected List<String> getMemberList(final List<Member> members) { protected List<String> getMemberList(final List<Member> members) {
List<String> results = new ArrayList<>(members.size()); List<String> results = new ArrayList<>(members.size());
for (Member member: members) { for (Member member : members) {
results.add(member.getEmail()); results.add(member.getEmail());
} }
@ -105,28 +113,19 @@ public class RedisMessagePublisher implements MessagePublisher {
ChannelTopic topic = this.topics.get(channel); ChannelTopic topic = this.topics.get(channel);
message.setMessage(new PublishMessage.PublishMessageBody(method, this.getMessageBody(params))); message.setMessage(new PublishMessage.PublishMessageBody(method, this.getMessageBody(params)));
try { String json = this.gson.toJson(message);
String json = this.objectMapper.writeValueAsString(message);
redisTemplate.convertAndSend(topic.getTopic(), json); redisTemplate.convertAndSend(topic.getTopic(), json);
} catch (IOException e) {
e.printStackTrace();
}
} }
protected List<String> getMessageBody(final Object... params) { protected List<String> getMessageBody(final Object... params) {
List<String> results = new ArrayList<>(params.length); List<String> results = new ArrayList<>(params.length);
try {
for (Object param : params) { for (Object param : params) {
if (param.getClass().equals(String.class)) { if (param.getClass().equals(String.class)) {
results.add((String)param); results.add((String) param);
} else { } else {
results.add(objectMapper.writeValueAsString(param)); results.add(this.gson.toJson(param));
} }
} }
} catch (IOException e) {
e.printStackTrace();
}
return results; return results;
} }

View File

@ -1,7 +1,7 @@
package com.loafle.overflow.central.spring; package com.loafle.overflow.central.spring;
import org.codehaus.jackson.map.DeserializationConfig; import com.google.gson.Gson;
import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.context.annotation.*; import org.springframework.context.annotation.*;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
@ -9,45 +9,34 @@ import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
* Created by insanity on 17. 6. 13. * Created by insanity on 17. 6. 13.
*/ */
@Configuration @Configuration
@ComponentScan(basePackages = {"com.loafle.overflow"}, excludeFilters = @ComponentScan.Filter({Configuration.class})) @ComponentScan(basePackages = {
@Import({ "com.loafle.overflow" }, excludeFilters = @ComponentScan.Filter({ Configuration.class }))
JdbcConfiguration.class, @Import({ JdbcConfiguration.class, MailConfiguration.class, RedisConfiguration.class, CacheConfiguration.class })
MailConfiguration.class, @PropertySource({ "classpath:database.properties", "classpath:mail.properties", "classpath:redis.properties",
RedisConfiguration.class, "classpath:cache.properties" })
CacheConfiguration.class
})
@PropertySource({
"classpath:database.properties",
"classpath:mail.properties",
"classpath:redis.properties",
"classpath:cache.properties"
})
public class AppConfig { public class AppConfig {
// @Bean // @Bean
// public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() { // public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() {
// PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer(); // PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
//// ppc.setLocation(new ClassPathResource("database.properties")); //// ppc.setLocation(new ClassPathResource("database.properties"));
// ppc.setLocations(new Resource[] { // ppc.setLocations(new Resource[] {
// new ClassPathResource("database.properties"), // new ClassPathResource("database.properties"),
// new ClassPathResource("mail.properties"), // new ClassPathResource("mail.properties"),
// new ClassPathResource("redis.properties") // new ClassPathResource("redis.properties")
// }); // });
// ppc.setIgnoreUnresolvablePlaceholders(true); // ppc.setIgnoreUnresolvablePlaceholders(true);
// //
// return ppc; // return ppc;
// } // }
@Bean @Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer(); return new PropertySourcesPlaceholderConfigurer();
} }
@Bean @Bean
public ObjectMapper getObjectMapper() { public Gson gson() {
Gson gson = new Gson();
ObjectMapper objectMapper = new ObjectMapper(); return gson;
objectMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
return objectMapper;
} }
} }

View File

@ -1,6 +1,5 @@
package com.loafle.overflow.central.spring; package com.loafle.overflow.central.spring;
import org.codehaus.jackson.map.ObjectMapper;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;

View File

@ -1,5 +1,6 @@
package com.loafle.overflow.central.module.infra.service; package com.loafle.overflow.central.module.infra.service;
import com.google.gson.Gson;
import com.loafle.overflow.central.spring.AppConfigTest; import com.loafle.overflow.central.spring.AppConfigTest;
import com.loafle.overflow.core.exception.OverflowException; import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.model.infra.InfraHost; import com.loafle.overflow.model.infra.InfraHost;
@ -7,7 +8,6 @@ import com.loafle.overflow.model.infra.InfraOS;
import com.loafle.overflow.model.meta.MetaInfraType; import com.loafle.overflow.model.meta.MetaInfraType;
import com.loafle.overflow.service.central.infra.InfraHostService; import com.loafle.overflow.service.central.infra.InfraHostService;
import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -26,6 +26,9 @@ public class InfraHostServiceTest {
@Autowired @Autowired
private InfraHostService infraHostService; private InfraHostService infraHostService;
@Autowired
private Gson gson;
@Test @Test
// @Ignore // @Ignore
public void regist() throws Exception { public void regist() throws Exception {
@ -55,8 +58,7 @@ public class InfraHostServiceTest {
InfraHost infraHost = this.infraHostService.read(1); InfraHost infraHost = this.infraHostService.read(1);
ObjectMapper objectMapper = new ObjectMapper(); String json = gson.toJson(infraHost);
String json = objectMapper.writeValueAsString(infraHost);
System.out.println(json); System.out.println(json);

View File

@ -1,11 +1,11 @@
package com.loafle.overflow.central.module.infra.service; package com.loafle.overflow.central.module.infra.service;
import com.google.gson.Gson;
import com.loafle.overflow.central.spring.AppConfigTest; import com.loafle.overflow.central.spring.AppConfigTest;
import com.loafle.overflow.model.infra.InfraMachine; import com.loafle.overflow.model.infra.InfraMachine;
import com.loafle.overflow.model.meta.MetaInfraType; import com.loafle.overflow.model.meta.MetaInfraType;
import com.loafle.overflow.service.central.infra.InfraMachineService; import com.loafle.overflow.service.central.infra.InfraMachineService;
import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -24,7 +24,10 @@ public class InfraMachineServiceTest {
@Autowired @Autowired
private InfraMachineService infraMachineService; private InfraMachineService infraMachineService;
// @Ignore @Autowired
private Gson gson;
// @Ignore
@Test @Test
public void regist() throws Exception { public void regist() throws Exception {
@ -49,8 +52,7 @@ public class InfraMachineServiceTest {
InfraMachine infraMachine = this.infraMachineService.read(1); InfraMachine infraMachine = this.infraMachineService.read(1);
ObjectMapper objectMapper = new ObjectMapper(); String json = gson.toJson(infraMachine);
String json = objectMapper.writeValueAsString(infraMachine);
System.out.println(json); System.out.println(json);
} }

View File

@ -1,12 +1,12 @@
package com.loafle.overflow.central.module.infra.service; package com.loafle.overflow.central.module.infra.service;
import com.google.gson.Gson;
import com.loafle.overflow.central.spring.AppConfigTest; import com.loafle.overflow.central.spring.AppConfigTest;
import com.loafle.overflow.model.infra.InfraOS; import com.loafle.overflow.model.infra.InfraOS;
import com.loafle.overflow.model.infra.InfraOSApplication; import com.loafle.overflow.model.infra.InfraOSApplication;
import com.loafle.overflow.model.meta.MetaInfraType; import com.loafle.overflow.model.meta.MetaInfraType;
import com.loafle.overflow.service.central.infra.InfraOSApplicationService; import com.loafle.overflow.service.central.infra.InfraOSApplicationService;
import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -24,6 +24,9 @@ public class InfraOSApplicationServiceTest {
@Autowired @Autowired
private InfraOSApplicationService infraOSApplicationService; private InfraOSApplicationService infraOSApplicationService;
@Autowired
private Gson gson;
// @Ignore // @Ignore
@Test @Test
public void regist() throws Exception { public void regist() throws Exception {
@ -53,9 +56,7 @@ public class InfraOSApplicationServiceTest {
Assert.assertNotNull(infraOSApplication); Assert.assertNotNull(infraOSApplication);
ObjectMapper objectMapper = new ObjectMapper(); String json = gson.toJson(infraOSApplication);
String json = objectMapper.writeValueAsString(infraOSApplication);
System.out.println(json); System.out.println(json);
} }

View File

@ -1,12 +1,12 @@
package com.loafle.overflow.central.module.infra.service; package com.loafle.overflow.central.module.infra.service;
import com.google.gson.Gson;
import com.loafle.overflow.central.spring.AppConfigTest; import com.loafle.overflow.central.spring.AppConfigTest;
import com.loafle.overflow.model.infra.InfraOS; import com.loafle.overflow.model.infra.InfraOS;
import com.loafle.overflow.model.infra.InfraOSDaemon; import com.loafle.overflow.model.infra.InfraOSDaemon;
import com.loafle.overflow.model.meta.MetaInfraType; import com.loafle.overflow.model.meta.MetaInfraType;
import com.loafle.overflow.service.central.infra.InfraOSDaemonService; import com.loafle.overflow.service.central.infra.InfraOSDaemonService;
import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -24,6 +24,9 @@ public class InfraOSDaemonServiceTest {
@Autowired @Autowired
private InfraOSDaemonService infraOSDaemonService; private InfraOSDaemonService infraOSDaemonService;
@Autowired
private Gson gson;
// @Ignore // @Ignore
@Test @Test
public void regist() throws Exception { public void regist() throws Exception {
@ -52,8 +55,7 @@ public class InfraOSDaemonServiceTest {
InfraOSDaemon infraOSDaemon = this.infraOSDaemonService.read(1); InfraOSDaemon infraOSDaemon = this.infraOSDaemonService.read(1);
Assert.assertNotNull(infraOSDaemon); Assert.assertNotNull(infraOSDaemon);
ObjectMapper objectMapper = new ObjectMapper(); String json = gson.toJson(infraOSDaemon);
String json = objectMapper.writeValueAsString(infraOSDaemon);
System.out.println(json); System.out.println(json);
} }

View File

@ -1,5 +1,6 @@
package com.loafle.overflow.central.module.infra.service; package com.loafle.overflow.central.module.infra.service;
import com.google.gson.Gson;
import com.loafle.overflow.central.spring.AppConfigTest; import com.loafle.overflow.central.spring.AppConfigTest;
import com.loafle.overflow.core.exception.OverflowException; import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.model.infra.InfraOS; import com.loafle.overflow.model.infra.InfraOS;
@ -23,6 +24,8 @@ public class InfraOSPortServiceTest {
@Autowired @Autowired
private InfraOSPortService infraOSPortService; private InfraOSPortService infraOSPortService;
@Autowired
private Gson gson;
// @Ignore // @Ignore
@Test @Test

View File

@ -1,5 +1,6 @@
package com.loafle.overflow.central.module.infra.service; package com.loafle.overflow.central.module.infra.service;
import com.google.gson.Gson;
import com.loafle.overflow.central.spring.AppConfigTest; import com.loafle.overflow.central.spring.AppConfigTest;
import com.loafle.overflow.model.infra.InfraMachine; import com.loafle.overflow.model.infra.InfraMachine;
import com.loafle.overflow.model.infra.InfraOS; import com.loafle.overflow.model.infra.InfraOS;
@ -7,7 +8,6 @@ import com.loafle.overflow.model.meta.MetaInfraType;
import com.loafle.overflow.model.meta.MetaInfraVendor; import com.loafle.overflow.model.meta.MetaInfraVendor;
import com.loafle.overflow.service.central.infra.InfraOSService; import com.loafle.overflow.service.central.infra.InfraOSService;
import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -23,6 +23,8 @@ public class InfraOSServiceTest {
@Autowired @Autowired
private InfraOSService infraOSService; private InfraOSService infraOSService;
@Autowired
private Gson gson;
@Test @Test
// @Ignore // @Ignore
@ -53,8 +55,7 @@ public class InfraOSServiceTest {
public void read() throws Exception { public void read() throws Exception {
InfraOS infraOS = this.infraOSService.read(1); InfraOS infraOS = this.infraOSService.read(1);
ObjectMapper objectMapper = new ObjectMapper(); String json = gson.toJson(infraOS);
String json = objectMapper.writeValueAsString(infraOS);
System.out.println(json); System.out.println(json);
} }

View File

@ -1,5 +1,6 @@
package com.loafle.overflow.central.module.infra.service; package com.loafle.overflow.central.module.infra.service;
import com.google.gson.Gson;
import com.loafle.overflow.central.spring.AppConfigTest; import com.loafle.overflow.central.spring.AppConfigTest;
import com.loafle.overflow.model.infra.InfraHost; import com.loafle.overflow.model.infra.InfraHost;
import com.loafle.overflow.model.infra.InfraService; import com.loafle.overflow.model.infra.InfraService;
@ -23,5 +24,7 @@ public class InfraServiceServiceTest {
@Autowired @Autowired
private InfraServiceService infraServiceService; private InfraServiceService infraServiceService;
@Autowired
private Gson gson;
} }

View File

@ -1,7 +1,5 @@
package com.loafle.overflow.central.spring; package com.loafle.overflow.central.spring;
import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.context.annotation.*; import org.springframework.context.annotation.*;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
@ -12,6 +10,8 @@ import org.springframework.test.context.TestPropertySource;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import com.google.gson.Gson;
/** /**
* Created by geek on 17. 8. 8. * Created by geek on 17. 8. 8.
*/ */
@ -51,12 +51,9 @@ public class AppConfigTest {
} }
@Bean @Bean
public ObjectMapper getObjectMapper() { public Gson gson() {
Gson gson = new Gson();
ObjectMapper objectMapper = new ObjectMapper(); return gson;
objectMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
return objectMapper;
} }
} }