public static File toFile(final URL url) { return Files.toFile(url); }
public static File toFile(final URL url) { return Files.toFile(url); }
private long lastModified(final ClassLoader loader, final String resourceClass) { if (resourceClass == null) { return 0; } final URL url = loader.getResource(resourceClass.replace('.', '/') + ".class"); if (url == null) { final File file = new File(resourceClass); if (file.exists()) { return file.lastModified(); } return 0; } try { return toFile(url).lastModified(); } catch (final RuntimeException re) { return 0; } }
private static String md5(final URL url) { final File file = Files.toFile(url); if (file.isFile()) { return md5(file); } else if (file.isDirectory()) { return md5Dir(file); } return null; // not readable etc }
public static File toFile(final URL url) { if ("jar".equals(url.getProtocol())) { try { final String spec = url.getFile(); int separator = spec.indexOf('!'); /* * REMIND: we don't handle nested JAR URLs */ if (separator == -1) { throw new MalformedURLException("no ! found in jar url spec:" + spec); } return toFile(new URL(spec.substring(0, separator++))); } catch (final MalformedURLException e) { throw new IllegalStateException(e); } } else if ("file".equals(url.getProtocol())) { String path = decode(url.getFile()); if (path.endsWith("!")) { path = path.substring(0, path.length() - 1); } return new File(path); } else { throw new IllegalArgumentException("Unsupported URL scheme: " + url.toExternalForm()); } }
public static File toFile(final URL url) { if ("jar".equals(url.getProtocol())) { try { final String spec = url.getFile(); int separator = spec.indexOf('!'); /* * REMIND: we don't handle nested JAR URLs */ if (separator == -1) { throw new MalformedURLException("no ! found in jar url spec:" + spec); } return toFile(new URL(spec.substring(0, separator++))); } catch (final MalformedURLException e) { throw new IllegalStateException(e); } } else if ("file".equals(url.getProtocol())) { String path = decode(url.getFile()); if (path.endsWith("!")) { path = path.substring(0, path.length() - 1); } return new File(path); } else { throw new IllegalArgumentException("Unsupported URL scheme: " + url.toExternalForm()); } }
protected String filteredCommand() { String val = command; int expandStart; while ((expandStart = val.indexOf("@[classpath:")) >= 0) { final int end = val.indexOf("]", expandStart); if (end < 0) { break; } final String expandable = simpleValue(val.substring(expandStart + "@[classpath:".length(), end)); final List<URL> repos = new ArrayList<>(Files.listJars(ProvisioningUtil.realLocation(expandable))); Collections.sort(repos, (o1, o2) -> o1.toExternalForm().compareTo(o2.toExternalForm())); final StringBuilder cp = new StringBuilder(); for (final URL u : repos) { cp.append(Files.toFile(u)).append(System.getProperty("path.separator")); } if (cp.length() > 0) { cp.setLength(cp.length() - System.getProperty("path.separator").length()); } val = val.substring(0, expandStart) + cp.toString() + (end < val.length() ? val.substring(end + 1) : ""); } return simpleValue(val); }
private void ensureMyFacesDontLooseFacesContext(final StandardContext standardContext) { for (final Container w : standardContext.findChildren()) { if (!Wrapper.class.isInstance(w)) { continue; } final Wrapper wrapper = Wrapper.class.cast(w); if ("FacesServlet".equals(wrapper.getName()) && "javax.faces.webapp.FacesServlet".equals(wrapper.getServletClass())) { final ClassLoader loader = standardContext.getLoader().getClassLoader(); try { if (Files.toFile(loader.getResource("javax/faces/webapp/FacesServlet.class")).getName().startsWith("myfaces")) { loader.loadClass("org.apache.tomee.myfaces.TomEEWorkaroundFacesServlet"); wrapper.setServletClass("org.apache.tomee.myfaces.TomEEWorkaroundFacesServlet"); break; } } catch (final Throwable t) { // not there, not a big deal in most of cases } } } }
final File file = toFile(u); if (!file.isDirectory()) { files.add(file);
final File file = toFile(u); if (!file.isDirectory()) { files.add(file);
while (it.hasNext()) { final URL next = it.next(); final File file = Files.toFile(next); if (!file.isFile() && NewLoaderLogic.skip(next)) { it.remove(); while (it.hasNext()) { final URL next = it.next(); final File file = Files.toFile(next); if (!file.isFile() && NewLoaderLogic.skip(next)) { it.remove(); final Iterator<URL> it = list.iterator(); while (it.hasNext()) { final String fileName = Files.toFile(it.next()).getName(); if (fileName.startsWith("openwebbeans-"/*jsf|el22*/) && fileName.endsWith(".jar")) { it.remove();