From 98f13e9c1e40cd11e5e7123b34dae45180533410 Mon Sep 17 00:00:00 2001 From: insanity Date: Fri, 23 Jun 2017 17:31:12 +0900 Subject: [PATCH] dbproxy modified --- .../com/loafle/overflow/proxy/db/DBProxy.java | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/loafle/overflow/proxy/db/DBProxy.java b/src/main/java/com/loafle/overflow/proxy/db/DBProxy.java index b6fc01c..6de5d29 100644 --- a/src/main/java/com/loafle/overflow/proxy/db/DBProxy.java +++ b/src/main/java/com/loafle/overflow/proxy/db/DBProxy.java @@ -3,11 +3,9 @@ package com.loafle.overflow.proxy.db; import com.loafle.overflow.db.api.DBGrpc; import com.loafle.overflow.db.api.DBInput; import com.loafle.overflow.db.api.DBOutput; - import com.loafle.overflow.module.domain.dao.DomainDAO; import com.loafle.overflow.module.email.dao.EmailAuthDAO; import com.loafle.overflow.module.member.dao.MemberDAO; - import com.loafle.overflow.module.noauthprobe.dao.NoAuthProbeDAO; import com.loafle.overflow.module.probe.dao.ProbeDAO; import com.loafle.overflow.module.sensor.dao.SensorDao; @@ -19,7 +17,6 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext import org.springframework.data.jpa.repository.JpaRepository; import java.io.IOException; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; @@ -137,23 +134,32 @@ public class DBProxy { paramTypes.add(cls); } - try { - //Check if it belongs to the JPABaseDAO. - method = dao.getClass().getSuperclass().getMethod(methodName, Object.class); - retObj = method.invoke(dao, valueList.toArray(new Object[valueList.size()])); - }catch(NoSuchMethodException e) { - if(params.size() > 0) { - method = dao.getClass().getMethod(methodName, paramTypes.toArray(new Class[paramTypes.size()])); - retObj = method.invoke(dao, valueList.toArray(new Object[valueList.size()])); - }else { - method = dao.getClass().getMethod(methodName); - retObj = method.invoke(dao); - } - }catch(InvocationTargetException e) { - e.printStackTrace(); + if(params.size() > 0) { + method = dao.getClass().getMethod(methodName, Object.class); + //method = dao.getClass().getMethod(methodName, paramTypes.toArray(new Class[paramTypes.size()])); + retObj = method.invoke(dao, valueList.toArray(new Object[valueList.size()])); + }else { + method = dao.getClass().getMethod(methodName); + retObj = method.invoke(dao); } +// try { +// method = dao.getClass().getSuperclass().getMethod(methodName, Object.class); +// retObj = method.invoke(dao, valueList.toArray(new Object[valueList.size()])); +// +// }catch(NoSuchMethodException e) { +// if(params.size() > 0) { +// method = dao.getClass().getMethod(methodName, paramTypes.toArray(new Class[paramTypes.size()])); +// retObj = method.invoke(dao, valueList.toArray(new Object[valueList.size()])); +// }else { +// method = dao.getClass().getMethod(methodName); +// retObj = method.invoke(dao); +// } +// }catch(InvocationTargetException e) { +// e.printStackTrace(); +// } + return mapper.writeValueAsString(retObj); } }