public static File get() { return jarLocation(JarLocation.class); }
public static File toFile(final String classFileName, final URL url) { String path = url.getFile(); path = path.substring(0, path.length() - classFileName.length()); return new File(decode(path)); }
private static File jarLocation(final URL url, final String classFileName) throws MalformedURLException { if ("jar".equals(url.getProtocol())) { final String spec = url.getFile(); return new File(JarLocation.decode(new URL(spec.substring(0, spec.indexOf('!'))).getFile())); } else if ("file".equals(url.getProtocol())) { return JarLocation.toFile(classFileName, url); } return null; }
public static File jarFromResource(final String resourceName) { return jarFromResource(Thread.currentThread().getContextClassLoader(), resourceName); }
public static File jarLocation(final Class clazz) { try { final String classFileName = clazz.getName().replace(".", "/") + ".class"; final ClassLoader loader = clazz.getClassLoader(); return jarFromResource(loader, classFileName); } catch (final RuntimeException e) { throw e; } catch (final Exception e) { throw new IllegalStateException(e); } }
public static File get() { return jarLocation(JarLocation.class); }
public static File toFile(final String classFileName, final URL url) { String path = url.getFile(); path = path.substring(0, path.length() - classFileName.length()); return new File(decode(path)); }
public static File jarFromResource(final ClassLoader loader, final String resourceName) { try { URL url = loader.getResource(resourceName); if (url == null) { throw new IllegalStateException("classloader.getResource(classFileName) returned a null URL"); } if ("jar".equals(url.getProtocol())) { 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); } url = new URL(spec.substring(0, separator++)); return new File(decode(url.getFile())); } else if ("file".equals(url.getProtocol())) { return toFile(resourceName, url); } else { throw new IllegalArgumentException("Unsupported URL scheme: " + url.toExternalForm()); } } catch (final RuntimeException e) { throw e; } catch (final Exception e) { throw new IllegalStateException(e); } }
public static File get() { return jarLocation(JarLocation.class); }
public static File toFile(URL url) { if ("jar".equals(url.getProtocol())) { try { 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 (MalformedURLException e) { throw new IllegalStateException(e); } } else if ("file".equals(url.getProtocol())) { return new File(decode(url.getFile())); } else { throw new IllegalArgumentException("Unsupported URL scheme: " + url.toExternalForm()); } }
private static URL findJar(final String s, final String api) { try { final File tomEELibJar = PATHS.findTomEELibJar(s); return (tomEELibJar == null ? jarLocation(TomEETldScanner.class.getClassLoader().loadClass(api)) : tomEELibJar).toURI().toURL(); } catch (final Throwable e) { // no-op } return null; } // used to dump container ones when nothing is in apps
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()); } }
private CustomizableURLClassLoader createCustomizableURLClassLoader(final ClassLoader systemClassLoader) { final CustomizableURLClassLoader customizableURLClassLoader = new CustomizableURLClassLoader(systemClassLoader); try { customizableURLClassLoader.add(jarLocation(SystemClassPath.class).toURI().toURL()); } catch (final MalformedURLException e) { // no-op } return customizableURLClassLoader; }
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()); } }
@Override public File findTomEELibJar(final String prefix) { File jar = findJar(getCatalinaLibDir(), prefix); if (jar == null) { // maybe tomcat/openejb integration final String tomeeWar = System.getProperty("tomee.war"); if (tomeeWar != null) { jar = findJar(new File(tomeeWar, "lib"), prefix); } if ((jar == null || !jar.exists()) && prefix.equals("openejb-jpa-integration")) { jar = JarLocation.jarLocation(MakeTxLookup.class); } } return jar; }
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()); } }
final File l1 = jarLocation(c1); final File l2 = jarLocation(c2); if (l1 == null) { return 1;
url = JarLocation.jarLocation(loadedClass).toURI().toURL().toExternalForm(); } catch (final MalformedURLException e) { url = classLocation(loadedClass).toExternalForm();