/** * Find all .tld files in the given jar. * * @param uri the uri to jar file * @return the collection of tlds as url references * @throws IOException if unable to scan the jar file */ public Collection<URL> getTlds (URI uri) throws IOException { HashSet<URL> tlds = new HashSet<URL>(); String jarUri = uriJarPrefix(uri, "!/"); URL url = new URL(jarUri); JarURLConnection jarConn = (JarURLConnection) url.openConnection(); jarConn.setUseCaches(Resource.getDefaultUseCaches()); JarFile jarFile = jarConn.getJarFile(); Enumeration<JarEntry> entries = jarFile.entries(); while (entries.hasMoreElements()) { JarEntry e = entries.nextElement(); String name = e.getName(); if (name.startsWith("META-INF") && name.endsWith(".tld")) { tlds.add(new URL(jarUri + name)); } } if (!Resource.getDefaultUseCaches()) jarFile.close(); return tlds; }
@Override protected java.net.URLConnection openConnection(URL u) throws IOException { JarURLConnection c = new sun.net.www.protocol.jar.JarURLConnection(u, this); c.setUseCaches(false); return c; } }
jc.setUseCaches(getUseCaches()); jarFile=jc.getJarFile();
jc.setUseCaches(getUseCaches()); jarFile=jc.getJarFile();
private static URL lookMavenMetadataFileUrlFromJar(File artifactFile, String mavenMetadataFileName) { String mavenMetadataFilePath = MULE_ARTIFACT_PATH_INSIDE_JAR + "/" + mavenMetadataFileName; URL possibleUrl; try { possibleUrl = getUrlWithinJar(artifactFile, mavenMetadataFilePath); /* * A specific implementation of JarURLConnection is required to read jar content because not all implementations * support ways to disable connection caching. Disabling connection caching is necessary to avoid file descriptor leaks. */ JarURLConnection jarConnection = new sun.net.www.protocol.jar.JarURLConnection(possibleUrl, new sun.net.www.protocol.jar.Handler()); jarConnection.setUseCaches(false); try (InputStream ignored = jarConnection.getInputStream()) { return possibleUrl; } catch (Exception e) { List<URL> jarMavenUrls = getUrlsWithinJar(artifactFile, META_INF + "/" + "maven"); Optional<URL> mavenMetadataUrl = jarMavenUrls.stream().filter(url -> url.toString().endsWith(mavenMetadataFileName)).findAny(); if (!mavenMetadataUrl.isPresent()) { throw new ArtifactDescriptorCreateException(format("The identifier '%s' requires the file '%s' within the artifact(error found while reading artifact '%s')", artifactFile.getName(), mavenMetadataFileName, artifactFile.getAbsolutePath())); } return mavenMetadataUrl.get(); } } catch (IOException e) { throw new MuleRuntimeException(e); } }
final JarURLConnection jarCon = (JarURLConnection) con; jarCon.setUseCaches(false); jarFile = jarCon.getJarFile(); jarFileUrl = jarCon.getJarFileURL().toExternalForm();
c.setUseCaches(getUseCaches()); jarFile=c.getJarFile();
c.setUseCaches(getUseCaches()); jar_file=c.getJarFile(); close_jar_file = !getUseCaches();
public JarFileUrlNestedJar(URL url) throws IOException { jarFileURL = url; JarURLConnection jarConn = (JarURLConnection) url.openConnection(); jarConn.setUseCaches(false); warFile = jarConn.getJarFile(); String urlAsString = url.toString(); int pathStart = urlAsString.indexOf("!/") + 2; String jarPath = urlAsString.substring(pathStart); jarEntry = warFile.getJarEntry(jarPath); }
public JarFileUrlNestedJar(URL url) throws IOException { super(url); JarURLConnection jarConn = (JarURLConnection) url.openConnection(); jarConn.setUseCaches(false); warFile = jarConn.getJarFile(); String urlAsString = url.toString(); int pathStart = urlAsString.indexOf("!/") + 2; String jarPath = urlAsString.substring(pathStart); jarEntry = warFile.getJarEntry(jarPath); }
public JarFileUrlNestedJar(URL url) throws IOException { jarFileURL = url; JarURLConnection jarConn = (JarURLConnection) url.openConnection(); jarConn.setUseCaches(false); warFile = jarConn.getJarFile(); String urlAsString = url.toString(); int pathStart = urlAsString.indexOf("!/") + 2; String jarPath = urlAsString.substring(pathStart); jarEntry = warFile.getJarEntry(jarPath); }
@Override InputStream getInputStream() throws IOException { if (this.jarFile == null) { JarURLConnection connection = (JarURLConnection) this.localUrl.openConnection(); connection.setUseCaches(false); this.jarFile = connection.getJarFile(); this.jarEntry = connection.getJarEntry(); } if (this.jarFile == null || this.jarEntry == null) return null; return this.jarFile.getInputStream(this.jarEntry); }
private JarFile getJarFile(URL jarFileUrl) throws IOException { JarFile jarFile = null; if (jarFileUrl != null) { JarURLConnection conn = (JarURLConnection) jarFileUrl.openConnection(); conn.setUseCaches(false); conn.connect(); jarFile = conn.getJarFile(); } return jarFile; }
private JarFile getJarFile(URL jarFileUrl) throws IOException { JarFile jarFile = null; if (jarFileUrl != null) { JarURLConnection conn = (JarURLConnection) jarFileUrl.openConnection(); conn.setUseCaches(false); conn.connect(); jarFile = conn.getJarFile(); } return jarFile; }
private JarFile getJarFile(URL jarFileUrl) throws IOException { JarFile jarFile = null; if (jarFileUrl != null) { JarURLConnection conn = (JarURLConnection) jarFileUrl.openConnection(); conn.setUseCaches(false); conn.connect(); jarFile = conn.getJarFile(); } return jarFile; }
private JarFile getJarFile(URL jarFileUrl) throws IOException { JarFile jarFile = null; if (jarFileUrl != null) { JarURLConnection conn = (JarURLConnection) jarFileUrl.openConnection(); conn.setUseCaches(false); conn.connect(); jarFile = conn.getJarFile(); } return jarFile; }
private JarFile getJarFile(URL jarFileUrl) throws IOException { JarFile jarFile = null; if (jarFileUrl != null) { JarURLConnection conn = (JarURLConnection) jarFileUrl.openConnection(); conn.setUseCaches(false); conn.connect(); jarFile = conn.getJarFile(); } return jarFile; }
private JarFile getJarFile(URL jarFileUrl) throws IOException { JarFile jarFile = null; if (jarFileUrl != null) { JarURLConnection conn = (JarURLConnection) jarFileUrl.openConnection(); conn.setUseCaches(false); conn.connect(); jarFile = conn.getJarFile(); } return jarFile; }
private JarFile getJarFile(URL jarFileUrl) throws IOException { JarFile jarFile = null; if (jarFileUrl != null) { JarURLConnection conn = (JarURLConnection) jarFileUrl.openConnection(); conn.setUseCaches(false); conn.connect(); jarFile = conn.getJarFile(); } return jarFile; }
@Override protected java.net.URLConnection openConnection(URL u) throws IOException { JarURLConnection c = new sun.net.www.protocol.jar.JarURLConnection(u, this); c.setUseCaches(false); return c; } }