Package java.net

Examples of java.net.URLClassLoader.loadClass()


        URL[] runtimeClasspath = classPathRegistry.getClassPathUrls("GRADLE_RUNTIME");
        ClassLoader rootClassLoader = ClassLoader.getSystemClassLoader().getParent();
        URLClassLoader antClassLoader = new URLClassLoader(antClasspath, rootClassLoader);
        URLClassLoader runtimeClassLoader = new URLClassLoader(runtimeClasspath, antClassLoader);
        Thread.currentThread().setContextClassLoader(runtimeClassLoader);
        Class mainClass = runtimeClassLoader.loadClass(mainClassName);
        Method mainMethod = mainClass.getMethod("main", String[].class);
        mainMethod.invoke(null, new Object[]{args});
    }
}
View Full Code Here


       
        URLClassLoader loader =
            URLClassLoader.newInstance(new URL[] {classDir.toURL()},
                                       null);
       
        Class<?> clz = loader.loadClass("org.objectweb.header_test.TestHeader");
        assertNotNull("TestHeader class instance should be present", clz);
       
        clz = loader.loadClass("org.objectweb.header_test.types.ObjectFactory");
        assertNotNull("ObjectFactory class instance should be present", clz);
       
View Full Code Here

                                       null);
       
        Class<?> clz = loader.loadClass("org.objectweb.header_test.TestHeader");
        assertNotNull("TestHeader class instance should be present", clz);
       
        clz = loader.loadClass("org.objectweb.header_test.types.ObjectFactory");
        assertNotNull("ObjectFactory class instance should be present", clz);
       
        clz = loader.loadClass("org.objectweb.hwrouter.types.FaultDetail");
        assertNotNull("FaultDetail class instance should be present", clz);
       
View Full Code Here

        assertNotNull("TestHeader class instance should be present", clz);
       
        clz = loader.loadClass("org.objectweb.header_test.types.ObjectFactory");
        assertNotNull("ObjectFactory class instance should be present", clz);
       
        clz = loader.loadClass("org.objectweb.hwrouter.types.FaultDetail");
        assertNotNull("FaultDetail class instance should be present", clz);
       
        try {
            clz = loader.loadClass("org.objectweb.hwrouter.types.NotPresent");
            fail("Should throw a ClassNotFoundException");
View Full Code Here

       
        clz = loader.loadClass("org.objectweb.hwrouter.types.FaultDetail");
        assertNotNull("FaultDetail class instance should be present", clz);
       
        try {
            clz = loader.loadClass("org.objectweb.hwrouter.types.NotPresent");
            fail("Should throw a ClassNotFoundException");
        } catch (ClassNotFoundException cnfe) {
            //Expecetd Exception
        }
    }
View Full Code Here

      try {
         cl = factory.getXmlBlasterClassLoader();
         if( log.isLoggable(Level.FINE)) log.fine("Get first instance of org.xmlBlaster.Main via own class loader.");

         this.xmlBlasterMain = (I_Main)cl.loadClass("org.xmlBlaster.Main").newInstance();
         // java.util.Properties props = glob.getProperty().getProperties();
         // this.xmlBlasterMain.init(props);
         this.xmlBlasterMain.init(glob);
         /*
         Class[] paramClasses = { glob.getArgs().getClass() };
View Full Code Here

            if (log.isLoggable(Level.FINE)) log.fine("useXmlBlasterClassloader=true: Trying Class.forName('" + pluginName + "') ...");

            URLClassLoader myLoader = factory.getPluginClassLoader(pluginInfo);
            if (log.isLoggable(Level.FINE)) log.fine("Found " + myLoader.getURLs().length + " plugin specific jar files for '" + pluginName + "' preferenced by xmlBlaster classLoader");

            plugin = (I_Plugin)myLoader.loadClass(pluginName).newInstance();
            if (log.isLoggable(Level.FINE)) log.fine("Found I_Plugin '" + pluginName + "', loaded by PluginClassLoader");
         }
         else { // Use JVM default class loader:
           Class cl = java.lang.Class.forName(pluginName);
           plugin = (I_Plugin)cl.newInstance();
View Full Code Here

    public static synchronized Class loadClass(String className, ClassLoader parent) {
        Class clazz = null;
        URL[] urls = ProcessorUtil.pathToURLs(getClassPath());
        URLClassLoader classLoader = new URLClassLoader(urls, parent);
        try {
            clazz = classLoader.loadClass(className);
        } catch (Exception e) {
            Message msg = new Message("FAIL_TO_LOAD_CLASS", LOG, className);
            throw new ToolException(msg, e);
        }
        return clazz;
View Full Code Here

   protected void testURLClassLoader(VirtualFile ear) throws Exception
   {
      URL[] cp = getEarClassPath(ear);
      log.error("ear classpath: "+Arrays.asList(cp));
      URLClassLoader loader = new URLClassLoader(cp);
      loader.loadClass("org.jboss.seam.example.booking.Hotel");
      loader.loadClass("org.jboss.seam.debug.Contexts");     
   }

   public void testULRClassloading() throws Exception
   {
View Full Code Here

   {
      URL[] cp = getEarClassPath(ear);
      log.error("ear classpath: "+Arrays.asList(cp));
      URLClassLoader loader = new URLClassLoader(cp);
      loader.loadClass("org.jboss.seam.example.booking.Hotel");
      loader.loadClass("org.jboss.seam.debug.Contexts");     
   }

   public void testULRClassloading() throws Exception
   {
      VirtualFile ear = getRoot();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.