예제 #1
0
 public <T> T getInterface(Object thiz, Class<T> iface) throws ScriptException {
   if (iface == null || !iface.isInterface()) {
     throw new IllegalArgumentException("interface Class expected");
   }
   AccessControlContext accCtxt = AccessController.getContext();
   return iface.cast(
       Proxy.newProxyInstance(
           iface.getClassLoader(),
           new Class[] {iface},
           new InterfaceImplementorInvocationHandler(thiz, accCtxt)));
 }
예제 #2
0
파일: LibRt.java 프로젝트: yamila87/rt_src
 public static void executeMethodClass(
     String pathToJar,
     String pkg,
     String classToGet,
     String methodName,
     String pathToFile,
     long logIdSyncMin,
     long logIdSyncMax)
     throws IOException, ClassNotFoundException, SecurityException, InstantiationException,
         IllegalAccessException, NoSuchMethodException, IllegalArgumentException,
         InvocationTargetException {
   Class<?> c = getClassFromJar(pathToJar, pkg, classToGet);
   Method method = c.getDeclaredMethod(methodName, String.class, long.class, long.class);
   method.invoke(null, pathToFile, logIdSyncMin, logIdSyncMax);
 }
예제 #3
0
파일: LibRt.java 프로젝트: yamila87/rt_src
  private static Class<?> getClassFromJar(String pathToJar, String pkg, String classToGet)
      throws IOException, ClassNotFoundException, SecurityException, InstantiationException,
          IllegalAccessException, NoSuchMethodException, IllegalArgumentException,
          InvocationTargetException {

    JarFile jarFile = new JarFile(pathToJar);
    Enumeration e = jarFile.entries();

    URL[] urls = {new URL("jar:file:" + pathToJar + "!/")};
    ClassLoader cl = URLClassLoader.newInstance(urls);

    Class<?> c = Class.forName(pkg + "." + classToGet, true, cl);

    return c;
  }