Examples of JarURLConnection


Examples of java.net.JarURLConnection

        if (!docBase.mkdir()) {
            throw new IllegalStateException(String.format("Unable to create directory: %s", docBase.getAbsolutePath()));
        }

        // Expand the jar into the new document base directory
        JarURLConnection juc = (JarURLConnection) jar.openConnection();
        juc.setUseCaches(false);
        JarFile jarFile = null;
        InputStream input = null;
        try {
            jarFile = juc.getJarFile();
            Enumeration<JarEntry> jarEntries = jarFile.entries();
            while (jarEntries.hasMoreElements()) {
                JarEntry jarEntry = jarEntries.nextElement();
                String name = jarEntry.getName();
                int last = name.lastIndexOf('/');
View Full Code Here

Examples of java.net.JarURLConnection

                if ("zip".equals(resourceUrl.getProtocol())) {
                    url = url.replaceAll("zip:", "jar:file:");
                }
                final URL jarUrl = new URL(url);

                final JarURLConnection connection = (JarURLConnection) jarUrl.openConnection();
                final JarFile jarFile = connection.getJarFile();
                String blockName = jarFile.getManifest().getMainAttributes().getValue("Cocoon-Block-Name");
                if (blockName == null) {
                    String jarPath = jarFile.getName();
                    // extract jar name
                    String jarName = jarPath.substring(jarPath.lastIndexOf(File.separatorChar) + 1);
View Full Code Here

Examples of java.net.JarURLConnection

                // "jar:{url-to-jar}!/{resource-path}"
                // to open the jar, we can simply remove everything after "!/"
                int pos = url.indexOf('!');
                url = url.substring(0, pos + 2); // +2 as we include "!/"
                final URL jarUrl = new URL(url);
                final JarURLConnection connection = (JarURLConnection) jarUrl.openConnection();
                final JarFile jarFile = connection.getJarFile();
                deploy(jarFile, pattern, destinationDirectory);
            }
        }
    }
View Full Code Here

Examples of java.net.JarURLConnection

      }
  } else {
      try {
    // It does not work with the filesystem: we must
    // be in the case of a package contained in a jar file.
    JarURLConnection conn = (JarURLConnection)url.openConnection();
    String starts = conn.getEntryName();
    JarFile jfile = conn.getJarFile();
    Enumeration e = jfile.entries();
    while (e.hasMoreElements()) {
        ZipEntry entry = (ZipEntry)e.nextElement();
        String entryname = entry.getName();
        if (entryname.startsWith(starts)
View Full Code Here

Examples of java.net.JarURLConnection


        @Override
        protected URLConnection openConnection(URL u) throws IOException
        {
            return new JarURLConnection(u)
            {
                @Override
                public JarFile getJarFile() throws IOException
                {
                    BundleRevisionImpl revision = (BundleRevisionImpl) m_revision.get();
View Full Code Here

Examples of java.net.JarURLConnection

        "resources/install.oak/sub/five.jar"
    };
   
    private ClassLoader mockClassLoader(String ... paths) throws MalformedURLException, IOException {
        final ClassLoader cl = Mockito.mock(ClassLoader.class);
        final JarURLConnection conn = Mockito.mock(JarURLConnection.class);
        final URLStreamHandler handler = new URLStreamHandler() {
            @Override
            protected URLConnection openConnection(final URL url) throws IOException {
                if(throwExceptionOnOpenConnection) {
                    throw new IOException("Throwing up for testing that");
                }
                return conn;
            }
        };
        final JarFile f = Mockito.mock(JarFile.class);
        final URL url = new URL("jar://some.jar", "localhost", 1234, "some.jar", handler);
       
        final Vector<JarEntry> entries = new Vector<JarEntry>();
        for(String path : paths) {
            entries.add(new JarEntry(path));
        }
       
        when(cl.getResource(Matchers.contains("install"))).thenReturn(url);
        when(conn.getJarFile()).thenReturn(f);
        when(f.entries()).thenReturn(entries.elements());
       
        return cl;
    }
View Full Code Here

Examples of java.net.JarURLConnection

                }
            } else {
                // Tag library is packaged in JAR file
                try {
                    URL jarFileUrl = new URL("jar:" + location[0] + "!/");
                    JarURLConnection conn = (JarURLConnection) jarFileUrl
                            .openConnection();
                    conn.setUseCaches(false);
                    conn.connect();
                    jarFile = conn.getJarFile();
                    ZipEntry jarEntry = jarFile.getEntry(location[1]);
                    in = jarFile.getInputStream(jarEntry);
                    parseTLD(ctxt, location[0], in, jarFileUrl);
                } catch (Exception ex) {
                    err.jspError("jsp.error.tld.unable_to_read", location[0],
View Full Code Here

Examples of java.net.JarURLConnection

                        try {
                            URLConnection urlConnection = url.openConnection();
                            urlConnection.setUseCaches(false);

                            if (urlConnection instanceof JarURLConnection) {
                                JarURLConnection jarUrlConnection = (JarURLConnection) urlConnection;
                                return jarUrlConnection.getManifest();
                            } else {
                                jis = new JarInputStream(urlConnection.getInputStream());
                                return jis.getManifest();
                            }
                        } catch (IOException e) {
View Full Code Here

Examples of java.net.JarURLConnection

                        ignoredPackages);
            } catch (URISyntaxException e) {
                throw new IOException(e.getMessage());
            }
        } else if (location.getProtocol().equals("jar")) {
            JarURLConnection juc = (JarURLConnection) location.openConnection();
            findPackages(juc, basePackage, baseClass, classes);
        }

        Collections.sort(classes, new Comparator<Class<? extends T>>() {
View Full Code Here

Examples of java.net.JarURLConnection

                        ignoredPackages);
            } catch (URISyntaxException e) {
                throw new IOException(e.getMessage());
            }
        } else if (location.getProtocol().equals("jar")) {
            JarURLConnection juc = (JarURLConnection) location.openConnection();
            findClassesInJar(juc, basePackage, baseClass, classes);
        }

        Collections.sort(classes, new Comparator<Class<? extends T>>() {
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.