Package java.net

Examples of java.net.URLClassLoader.findResource()


                    "/WEB-INF/beans.xml",
                    "/META-INF/beans.xml",
                };

                for (final String path : paths) {
                    final URL resource = loader.findResource(path);
                    if (resource != null) {
                        return resource;
                    }
                }
            } catch (final Exception e) {
View Full Code Here


            return resURL;
         }
      };
      Thread.currentThread().setContextClassLoader(urlLoader);

      URL configURL = urlLoader.findResource("META-INF/standard-jaxrpc-client-config.xml");
      assertTrue("Invalid config url: " + configURL, configURL.toExternalForm().indexOf("jbws1653") > 0);

      InitialContext iniCtx = getInitialContext();
      Service service = (Service)iniCtx.lookup("java:comp/env/service/TestService");
      TestEndpoint port = (TestEndpoint)service.getPort(TestEndpoint.class);
View Full Code Here

   }

   public InteropClientConfig createClientConfig()
   {
      URLClassLoader ctxLoader = (URLClassLoader)Thread.currentThread().getContextClassLoader();
      URL scenariosDescriptor = ctxLoader.findResource("META-INF/scenarios.xml");
      if(scenariosDescriptor!=null)
      {
         try
         {
            Element configRoot = DOMUtils.parse( scenariosDescriptor.openStream() );
View Full Code Here

  }

  private Manifest getManifestForMyJarFile(Class<?> aClass) throws IOException {
    URL url = aClass.getProtectionDomain().getCodeSource().getLocation();
    URLClassLoader cl = new URLClassLoader(new URL[]{url});
    URL manifestUrl = cl.findResource("META-INF/MANIFEST.MF");
    if (manifestUrl == null) {
      return new Manifest();
    } else {
      return new Manifest(manifestUrl.openStream());
    }
View Full Code Here

    /**
     * Regression for Harmony-2237
     */
    public void test_getResource() throws Exception {
        URLClassLoader urlLoader = getURLClassLoader();
        assertNull(urlLoader.findResource("XXX")); //$NON-NLS-1$
    }

    private static URLClassLoader getURLClassLoader() {
        String classPath = System.getProperty("java.class.path");
        StringTokenizer tok = new StringTokenizer(classPath, File.pathSeparator);
View Full Code Here

        final URL base = getClass().getResource("lf.jar");

        final URL[] urls = { base };
        final URLClassLoader ucl = new URLClassLoader(urls, null, new TestFactory());

        final URL res = ucl.findResource("swt.dll");
        assertNotNull(res);

        final URI e = new URI("jar:" + base.toExternalForm() + "!/swt.dll");
        final URI a = res.toURI();
        assertEquals(e, a);
View Full Code Here

        URL[] urls = new URL[1];
        urls[0] = new URL("file:/" + resPath + "/JarIndex/hyts_11.jar");
        URLClassLoader ucl = URLClassLoader.newInstance(urls, null);

        URL resURL = ucl.findResource("Test.txt");
        URL reference = new URL("jar:file:/" + resPath.replace('\\', '/')
                + "/JarIndex/hyts_14.jar!/Test.txt");
        assertEquals("Resource not found: " + resURL + " ref: " + reference,
                reference, resURL);
View Full Code Here

        }

        Support_Resources.copyFile(resources, "JarIndex", "hyts_22-new.jar");
        urls[0] = new URL("file:/" + resPath + "/JarIndex/hyts_22-new.jar");
        ucl = URLClassLoader.newInstance(urls, null);
        assertNotNull("Cannot find resource", ucl.findResource("cpack/"));
        Support_Resources.copyFile(resources, "JarIndex", "hyts_11.jar");
        urls[0] = new URL("file:/" + resPath + "/JarIndex/hyts_31.jar");
        ucl = URLClassLoader.newInstance(urls, null);

        try {
View Full Code Here

        Enumeration en = urlClassloader.findResources("bpack/");
        assertTrue(en.hasMoreElements());
        URL expected = new URL("jar:file:/" + resPath.replace('\\', '/')
                + "/JarIndex/hyts_22.jar!/bpack/");
        assertEquals(expected, (URL) en.nextElement());
        assertEquals(expected, urlClassloader.findResource("bpack/"));
    }

    /**
     * @tests java.net.URLClassLoader#getResource(java.lang.String)
     */
 
View Full Code Here

    /**
     * Regression for Harmony-2237
     */
    public void test_getResource() throws Exception {
        URLClassLoader urlLoader = getURLClassLoader();
        assertNull(urlLoader.findResource("XXX")); //$NON-NLS-1$
    }

    private static URLClassLoader getURLClassLoader() {
        String classPath = System.getProperty("java.class.path");
        StringTokenizer tok = new StringTokenizer(classPath, File.pathSeparator);
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.