DBproxy spring null pointer modify
This commit is contained in:
parent
9463e2805e
commit
112d81dc01
27
src/main/java/com/loafle/overflow/DBProxyMain.java
Normal file
27
src/main/java/com/loafle/overflow/DBProxyMain.java
Normal file
|
@ -0,0 +1,27 @@
|
|||
package com.loafle.overflow;
|
||||
|
||||
import com.loafle.overflow.proxy.db.DBProxy;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 23.
|
||||
*/
|
||||
public class DBProxyMain {
|
||||
|
||||
|
||||
public static void main(String[] args) throws IOException, InterruptedException {
|
||||
|
||||
if(args.length <= 0) {
|
||||
System.out.println("Port args");
|
||||
System.out.println("first parameter is Port Number");
|
||||
return;
|
||||
}
|
||||
|
||||
int port = Integer.valueOf(args[0]);
|
||||
|
||||
final DBProxy server = new DBProxy();
|
||||
server.start(port);
|
||||
server.blockUntilShutdown();
|
||||
}
|
||||
}
|
|
@ -16,7 +16,8 @@ import com.loafle.overflow.module.sensor.dao.SensorItemDao;
|
|||
import com.loafle.overflow.module.target.dao.TargetDAO;
|
||||
import io.grpc.ServerBuilder;
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -39,61 +40,23 @@ public class DBProxy {
|
|||
|
||||
private static Map<String, JpaRepository> daoMap = null;
|
||||
|
||||
@Autowired
|
||||
private MemberDAO memberDAO;
|
||||
|
||||
@Autowired
|
||||
private ProbeDAO probeDAO;
|
||||
|
||||
@Autowired
|
||||
private NoAuthProbeDAO noAuthProbeDAO;
|
||||
|
||||
@Autowired
|
||||
private ApiKeyDAO apiKeyDao;
|
||||
|
||||
@Autowired
|
||||
private EmailAuthDAO emailAuthDAO;
|
||||
|
||||
@Autowired
|
||||
private TargetDAO targetDAO;
|
||||
//
|
||||
// @Autowired
|
||||
// private CrawlerDAO crawlerDAO;
|
||||
//
|
||||
// @Autowired
|
||||
// private CrawlerInputItemDAO crawlerInputItemDAO;
|
||||
//
|
||||
// @Autowired
|
||||
// private CrawlerInputItemMappingDAO crawlerInputItemMappingDAO;
|
||||
|
||||
@Autowired
|
||||
private SensorDao sensorDao;
|
||||
|
||||
// @Autowired
|
||||
// private SensorItemCategoryDao sensorItemCategoryDao;
|
||||
|
||||
@Autowired
|
||||
private SensorItemDao sensorItemDao;
|
||||
|
||||
// @Autowired
|
||||
// private SensorItemMappingDao sensorItemMappingDao;
|
||||
|
||||
public DBProxy() {
|
||||
daoMap = new ConcurrentHashMap();
|
||||
|
||||
daoMap.put("member", memberDAO);
|
||||
daoMap.put("probe", probeDAO);
|
||||
daoMap.put("noauthAgent", noAuthProbeDAO);
|
||||
daoMap.put("apiKey", apiKeyDao);
|
||||
daoMap.put("emailAuth", emailAuthDAO);
|
||||
ApplicationContext ctx = new AnnotationConfigApplicationContext("com.loafle.overflow");
|
||||
|
||||
daoMap.put("member", ctx.getBean(MemberDAO.class));
|
||||
daoMap.put("probe", ctx.getBean(ProbeDAO.class));
|
||||
daoMap.put("noauthAgent", ctx.getBean(NoAuthProbeDAO.class));
|
||||
daoMap.put("emailAuth", ctx.getBean(EmailAuthDAO.class));
|
||||
daoMap.put("sensor", ctx.getBean(SensorDao.class));
|
||||
daoMap.put("sensorItem", ctx.getBean(SensorItemDao.class));
|
||||
|
||||
// daoMap.put("target", targetDAO);
|
||||
// daoMap.put("crawler", crawlerDAO);
|
||||
// daoMap.put("crawlerInputItem", crawlerInputItemDAO);
|
||||
// daoMap.put("crawlerInputItemMapping", crawlerInputItemMappingDAO);
|
||||
|
||||
daoMap.put("sensor", sensorDao);
|
||||
// daoMap.put("sensorItemCategory", sensorItemCategoryDao);
|
||||
daoMap.put("sensorItem", sensorItemDao);
|
||||
// daoMap.put("sensorItemMapping", sensorItemMappingDao);
|
||||
}
|
||||
|
||||
|
@ -195,25 +158,9 @@ public class DBProxy {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private void blockUntilShutdown() throws InterruptedException {
|
||||
public void blockUntilShutdown() throws InterruptedException {
|
||||
if (server != null) {
|
||||
server.awaitTermination();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException, InterruptedException {
|
||||
|
||||
if(args.length <= 0) {
|
||||
System.out.println("Port args");
|
||||
System.out.println("first parameter is Port Number");
|
||||
return;
|
||||
}
|
||||
|
||||
int port = Integer.valueOf(args[0]);
|
||||
|
||||
final DBProxy server = new DBProxy();
|
||||
server.start(port);
|
||||
server.blockUntilShutdown();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user