mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
finish the JNDI function.
This commit is contained in:
@@ -72,15 +72,43 @@ public class ReflectionUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static Method getObjectMethod(Object obj, String methodName, Integer id) {
|
||||
public static Method getObjectMethod(Object obj, String methodName, Class<?>... parameterTypes) {
|
||||
try {
|
||||
return obj.getClass().getMethod(methodName, Integer.class);
|
||||
return obj.getClass().getMethod(methodName, parameterTypes);
|
||||
} catch (Exception e) {
|
||||
LOG.warn("getObjectMethod fail:class=" + obj.getClass().getName() + " method=" + methodName, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Object callObjectMethod(Object obj, String methodName, Class<?>[] parameterTypes, Object[] parameters) {
|
||||
try {
|
||||
Method m = getObjectMethod(obj, methodName, parameterTypes);
|
||||
return m.invoke(obj, parameters);
|
||||
} catch (Exception e) {
|
||||
LOG.warn("callObjectMethod fail:class=" + obj.getClass().getName() + " method=" + methodName, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Object callObjectMethod(Object obj, Method m, Object[] parameters) {
|
||||
try {
|
||||
return m.invoke(obj, parameters);
|
||||
} catch (Exception e) {
|
||||
LOG.warn("callObjectMethod fail:class=" + obj.getClass().getName() + " method=" + m.getName(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Object callObjectMethod(Object obj, Method m) {
|
||||
try {
|
||||
return m.invoke(obj);
|
||||
} catch (Exception e) {
|
||||
LOG.warn("callObjectMethod fail:class=" + obj.getClass().getName() + " method=" + m.getName(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Object callObjectMethod(Object obj, String methodName, Integer id) {
|
||||
try {
|
||||
Method m = obj.getClass().getMethod(methodName, Integer.class);
|
||||
@@ -91,6 +119,24 @@ public class ReflectionUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static Method getObjectMethod(Object obj, String methodName, Integer id) {
|
||||
try {
|
||||
return obj.getClass().getMethod(methodName, Integer.class);
|
||||
} catch (Exception e) {
|
||||
LOG.warn("getObjectMethod fail:class=" + obj.getClass().getName() + " method=" + methodName, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Object callObjectMethod(Object obj, Method m, Integer id) {
|
||||
try {
|
||||
return m.invoke(obj, id);
|
||||
} catch (Exception e) {
|
||||
LOG.warn("callObjectMethod fail:class=" + obj.getClass().getName() + " method=" + m.getName(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void getTest() {
|
||||
System.out.println("dd");
|
||||
// return "test";
|
||||
|
||||
Reference in New Issue
Block a user