private synchronized ReferenceCountedJar open() throws IOException { if (wrappedJar == null) { wrappedJar = JarFactory.newInstance(url); } referenceCount++; return this; }
/** * Opens a stream to access the TLD. * * @return a stream containing the TLD content * @throws IOException if there was a problem opening the stream */ public InputStream openStream() throws IOException { if (entryName == null) { return url.openStream(); } else { URL entryUrl = JarFactory.getJarEntryURL(url, entryName); return entryUrl.openStream(); } }
public Jar openJar() throws IOException { if (entryName == null) { return null; } else { return JarFactory.newInstance(url); } }
/** * Opens a stream to access the TLD. * * @return a stream containing the TLD content * @throws IOException if there was a problem opening the stream */ public InputStream openStream() throws IOException { if (entryName == null) { return url.openStream(); } else { URL entryUrl = JarFactory.getJarEntryURL(url, entryName); return entryUrl.openStream(); } }
public Jar getJar() throws IOException { if (entryName == null) { return null; } else { return JarFactory.newInstance(url); } }
/** * Opens a stream to access the TLD. * * @return a stream containing the TLD content * @throws IOException if there was a problem opening the stream */ public InputStream openStream() throws IOException { if (entryName == null) { return url.openStream(); } else { URL entryUrl = JarFactory.getJarEntryURL(url, entryName); return entryUrl.openStream(); } }
String jarPath = "META-INF/resources/" + path; for (URL jarUrl : resourceJARs) { try (Jar jar = JarFactory.newInstance(jarUrl)) { if (jar.exists(jarPath)) { return new URL(jar.getURL(jarPath));
url = new URL(base + configFile); } else { url = JarFactory.getJarEntryURL(jarUrl, configFile);
private List<URL> scanForResourceJARs(Set<WebXml> orderedFragments, Collection<WebXml> fragments) throws JasperException { List<URL> resourceJars = new ArrayList<>(); // Build list of potential resource JARs. Use same ordering as ContextConfig Set<WebXml> resourceFragments = new LinkedHashSet<>(); for (WebXml fragment : orderedFragments) { resourceFragments.add(fragment); } for (WebXml fragment : fragments) { if (!resourceFragments.contains(fragment)) { resourceFragments.add(fragment); } } for (WebXml resourceFragment : resourceFragments) { try (Jar jar = JarFactory.newInstance(resourceFragment.getURL())) { if (jar.exists("META-INF/resources/")) { // This is a resource JAR resourceJars.add(resourceFragment.getURL()); } } catch (IOException ioe) { throw new JasperException(ioe); } } return resourceJars; }
url = new URL(base + configFile); } else { url = JarFactory.getJarEntryURL(jarUrl, configFile);
private void processFile(JarScanType scanType, JarScannerCallback callback, URL url, String webappPath, boolean isWebapp, Deque<URL> classPathUrlsToProcess) throws IOException { try { File f = new File(url.toURI()); if (f.isFile()) { // Treat this file as a JAR try (Jar jar = JarFactory.newInstance(UriUtil.buildJarUrl(f))) { processManifest(jar, isWebapp, classPathUrlsToProcess); callback.scan(jar, webappPath, isWebapp); } } else if (f.isDirectory()) { if (scanType == JarScanType.PLUGGABILITY) { callback.scan(f, webappPath, isWebapp); } else { if (new File(f.getAbsoluteFile(), Constants.META_INF).isDirectory()) { callback.scan(f, webappPath, isWebapp); } } } } catch (URISyntaxException e) { throw new IOException(e); } }
/** * Scan a URL for JARs with the optional extensions to look at all files and all directories. */ private void process(JarScanType scanType, JarScannerCallback callback, URL url, String webappPath, boolean isWebapp, Deque<URL> classPathUrlsToProcess) throws IOException { if (log.isTraceEnabled()) { log.trace(SM.getString("jarScan.jarUrlStart", url)); } if (Constants.URL_PROTOCOL_JAR.equals(url.getProtocol()) || url.getPath() .endsWith(Constants.JAR_EXT)) { try (Jar jar = JarFactory.newInstance(url)) { processManifest(jar, isWebapp, classPathUrlsToProcess); callback.scan(jar, webappPath, isWebapp); } } else if (Constants.URL_PROTOCOL_FILE.equals(url.getProtocol())) { processFile(scanType, callback, url, webappPath, isWebapp, classPathUrlsToProcess); } }
@Override public void scan(final JarScanType jarScanType, final ServletContext servletContext, final JarScannerCallback callback) { switch (jarScanType) { case PLUGGABILITY: CdiArchive.class.cast(WebScannerService.class.cast(WebBeansContext.getInstance().getScannerService()).getFinder().getArchive()) .classesByUrl().keySet().stream() .filter(u -> !"jar:file://!/".equals(u)) // not a fake in memory url .forEach(u -> { try { final URL url = new URL(u); final File asFile = Files.toFile(url); if (asFile.getName().endsWith(Constants.JAR_EXT)) { try (final Jar jar = JarFactory.newInstance(asFile.toURI().toURL())) { callback.scan(jar, u, true); } } else if (asFile.isDirectory()) { callback.scan(asFile, asFile.getAbsolutePath(), true); } } catch (final MalformedURLException e) { // skip } catch (final IOException ioe) { throw new IllegalArgumentException(ioe); } }); return; case TLD: default: } }
@Override public void scan(final JarScanType jarScanType, final ServletContext servletContext, final JarScannerCallback callback) { switch (jarScanType) { case PLUGGABILITY: CdiArchive.class.cast(WebScannerService.class.cast(WebBeansContext.getInstance().getScannerService()).getFinder().getArchive()) .classesByUrl().keySet().stream() .filter(u -> !"jar:file://!/".equals(u)) // not a fake in memory url .forEach(u -> { try { final URL url = new URL(u); final File asFile = Files.toFile(url); if (asFile.getName().endsWith(Constants.JAR_EXT)) { try (final Jar jar = JarFactory.newInstance(asFile.toURI().toURL())) { callback.scan(jar, u, true); } } else if (asFile.isDirectory()) { callback.scan(asFile, asFile.getAbsolutePath(), true); } } catch (final MalformedURLException e) { // skip } catch (final IOException ioe) { throw new IllegalArgumentException(ioe); } }); return; case TLD: default: } }
String jarPath = "META-INF/resources" + path; for (URL jarUrl : resourceJARs) { try (Jar jar = JarFactory.newInstance(jarUrl)) { jar.nextEntry(); for (String entryName = jar.getEntryName();
try { if ("jar".equals(url.getProtocol())) { jar = JarFactory.newInstance(url); is = jar.getInputStream(SCI_LOCATION); } else if ("file".equals(url.getProtocol())) {
try (Jar jar = JarFactory.newInstance(url)) { if (isScanManifest()) { processManifest(jar, isWebapp, classPathUrlsToProcess); try (Jar jar = JarFactory.newInstance(jarURL)) { if (isScanManifest()) { processManifest(jar, isWebapp, classPathUrlsToProcess);
try (Jar jar = JarFactory.newInstance(url)) { if (isScanManifest()) { processManifest(jar, isWebapp, classPathUrlsToProcess); try (Jar jar = JarFactory.newInstance(jarURL)) { if (isScanManifest()) { processManifest(jar, isWebapp, classPathUrlsToProcess);
try { if ("jar".equals(url.getProtocol())) { jar = JarFactory.newInstance(url); is = jar.getInputStream(SCI_LOCATION); } else if ("file".equals(url.getProtocol())) {
try { if ("jar".equals(url.getProtocol()) || url.toString().endsWith(".jar")) { try (Jar jar = JarFactory.newInstance(url)) { jar.nextEntry(); String entryName = jar.getEntryName();