|
@ -1,6 +1,8 @@ |
|
|
package com.my.graphiteDigesterBg.diframe.util; |
|
|
package com.my.graphiteDigesterBg.diframe.util; |
|
|
import java.io.File; |
|
|
import java.io.File; |
|
|
import java.io.IOException; |
|
|
import java.io.IOException; |
|
|
|
|
|
import java.lang.reflect.InvocationTargetException; |
|
|
|
|
|
import java.lang.reflect.Method; |
|
|
import java.net.JarURLConnection; |
|
|
import java.net.JarURLConnection; |
|
|
import java.net.URL; |
|
|
import java.net.URL; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
@ -8,8 +10,27 @@ import java.util.Collections; |
|
|
import java.util.Enumeration; |
|
|
import java.util.Enumeration; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.jar.JarEntry; |
|
|
import java.util.jar.JarEntry; |
|
|
|
|
|
|
|
|
public class DiClassHelper { |
|
|
public class DiClassHelper { |
|
|
|
|
|
// invoke method |
|
|
|
|
|
public static Object invokeMethod(Object obj, String methodName, List<Object> args) throws NoSuchMethodException { |
|
|
|
|
|
try { |
|
|
|
|
|
Class<?>[] parameterTypes = new Class<?>[args.size()]; |
|
|
|
|
|
for (int i = 0; i < args.size(); i++) { |
|
|
|
|
|
parameterTypes[i] = args.get(i).getClass(); |
|
|
|
|
|
} |
|
|
|
|
|
Method method = obj.getClass().getMethod(methodName, parameterTypes); |
|
|
|
|
|
|
|
|
|
|
|
if ( method.getReturnType().equals(Void.TYPE) ) { |
|
|
|
|
|
method.invoke(obj, args.toArray()); |
|
|
|
|
|
return null; |
|
|
|
|
|
} else { |
|
|
|
|
|
return method.invoke(obj, args.toArray()); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (IllegalAccessException | InvocationTargetException e) { |
|
|
|
|
|
throw new RuntimeException(e); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// get all classes in package |
|
|
// get all classes in package |
|
|
public static List<Class<?>> getAllClassesInPackage(String packageName) { |
|
|
public static List<Class<?>> getAllClassesInPackage(String packageName) { |
|
|
List<Class<?>> classes = new ArrayList<>(); |
|
|
List<Class<?>> classes = new ArrayList<>(); |
|
|