Package java.net

Examples of java.net.URLClassLoader


        return cfg;
    }
   
    private URLClassLoader createSEIClassLoader(File classDir) {
       
        URLClassLoader loader = null;
        try {
            loader = URLClassLoader.newInstance(new URL[]{classDir.toURL()},
                                                Thread.currentThread().getContextClassLoader());
        } catch (MalformedURLException mue) {
            throw new WebServiceException("URLClassLoader creation failed", mue);
View Full Code Here


        private Collection<Class<?>> find(Matcher matcher) throws MalformedURLException {
            List<Class<?>> classes = new ArrayList<Class<?>>();
           
            File root = new File(rootPath);
            URL[] urls = {root.toURL()};
            URLClassLoader loader = new URLClassLoader(urls, parent);
           
            find(root, loader, classes, matcher);
            return classes;
        }
View Full Code Here

        writer.write(RESOURCE_DATA);
        writer.write("\n");
        writer.close();

        URL[] urls = {resource.getParentFile().toURL()};
        ClassLoader loader = new URLClassLoader(urls);
        assertNotNull(loader.getResourceAsStream(resourceName));
        assertNull(ClassLoader.getSystemResourceAsStream(resourceName));
        clr = new ClassLoaderResolver(loader);
    }
View Full Code Here

                    getLog().debug("adding to classpath '" + file + "'");
                }
                classpathUrls[ctr] = file.toURI().toURL();
            }

            final URLClassLoader loader =
                new URLClassLoader(classpathUrls,
                    Thread.currentThread().getContextClassLoader());
            Thread.currentThread().setContextClassLoader(loader);
        }
    }
View Full Code Here

     */
    protected void initializeClassLoaderWithJdbcDriver()
        throws MalformedURLException
    {
        Thread.currentThread().setContextClassLoader(
            new URLClassLoader(
                new URL[] {new File(this.jdbcDriverJar).toURI().toURL()},
                Thread.currentThread().getContextClassLoader()));
    }
View Full Code Here

        final String jdbcDriverJar = this.getRequiredProperty(
                options,
                "jdbcDriverJar");
        if (jdbcDriverJarLoader == null)
        {
            jdbcDriverJarLoader = new URLClassLoader(new URL[] {new File(jdbcDriverJar).toURI().toURL()});
        }
        return jdbcDriverJarLoader;
    }
View Full Code Here

   /*
    * Start the server
    */
   public void run() {
      ClassLoaderFactory factory = glob.getClassLoaderFactory();
      URLClassLoader cl = null;

      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() };
         Object[] params = { glob.getArgs() };
         java.lang.reflect.Constructor constructor = mainClass.getDeclaredConstructor( paramClasses );
         mainObject = constructor.newInstance( params );
         if ( mainObject instanceof org.xmlBlaster.Main ) {
         }
         else {
            log.error( ME, "Error in constructing org.xmlBlaster.Main!");
            System.exit(-1);
         }
         */
         log.info("Successfully loaded org.xmlBlaster.Main instance with specific classloader");
      } catch(Throwable e) {
         if (cl != null)
            log.severe("Problems loading org.xmlBlaster.Main with ClassLoader "+cl.getClass().getName()+": " + e.toString() + " -> using default classloader");
         else
            log.severe("Problems loading org.xmlBlaster.Main (classloader = 'null' ???): " + e.toString() + " -> using default classloader");
         this.xmlBlasterMain = new org.xmlBlaster.Main(glob);
         log.info("Successfully loaded org.xmlBlaster.Main instance with default classloader");
      }
View Full Code Here

            }
        }

        // 2: If URLClassLoader implements Closeable, use that.
        if (Closeable.class.isAssignableFrom(URLClassLoader.class))
            return new URLClassLoader(urls, thisClassLoader);

        // 3: Try using private reflection-based CloseableURLClassLoader
        try {
            return new CloseableURLClassLoader(urls, thisClassLoader);
        } catch (Throwable t) {
            // ignore errors loading workaround class loader, fall through
        }

        // 4: If all else fails, use plain old standard URLClassLoader
        return new URLClassLoader(urls, thisClassLoader);
    }
View Full Code Here

   }
  
  
   public void testVersionTransformerCache() {
      try {
         URLClassLoader cl = (URLClassLoader)getClass().getClassLoader();
         URL[] urls = cl.getURLs();
         String url = null;
         for (int i=0; i < urls.length; i++) {
            int pos = urls[i].getFile().indexOf(File.separator + "xmlBlaster" + File.separator + "lib" + File.separator);
            if (pos > -1) {
               url = urls[i].getFile().substring(0, pos);
               break;
            }
         }
         if (url == null)
            url = "";
         log.info("The found xmlBlaster url is '" + url + "'");
         StringBuffer buf = new StringBuffer();
         buf.append(File.separator).append("xmlBlaster");
         buf.append(File.separator).append("testsuite");
         buf.append(File.separator).append("data");
         buf.append(File.separator).append("xsl").append(File.separator);
         String name = "file:" + url + buf.toString();
         URL[] tmpUrls = new URL[] { new URL(name) };
         URLClassLoader subLoader = URLClassLoader.newInstance(tmpUrls, cl);
        
         // Object obj = subLoader.loadClass(TestHelperClasses.class.getName()).newInstance();
         // Method method = obj.getClass().getMethod("testVersionTransformerCacheInternal", null);
         // method.invoke(obj, null);
        
View Full Code Here

      try {
         ClassLoaderFactory factory = glob.getClassLoaderFactory();
         if (factory != null) {
            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

TOP

Related Classes of java.net.URLClassLoader

Copyright © 2018 www.massapicom. 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.