private static File toFile(URL url) { if (!"file".equals(url.getProtocol())) throw new IllegalArgumentException("not a file url: " + url); String path = url.getFile(); File dir = new File(decode(path)); if (dir.getName().equals("META-INF")) { dir = dir.getParentFile(); // Scrape "META-INF" off } return dir; }
private 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 toFile(URL url) { if (!"file".equals(url.getProtocol())) throw new IllegalArgumentException("not a file url: " + url); String path = url.getFile(); File dir = new File(decode(path)); if (dir.getName().equals("META-INF")) { dir = dir.getParentFile(); // Scrape "META-INF" off } return dir; }
private static File toFile(URL url) { if (!"file".equals(url.getProtocol())) throw new IllegalArgumentException("not a file url: " + url); String path = url.getFile(); File dir = new File(decode(path)); if (dir.getName().equals("META-INF")) { dir = dir.getParentFile(); // Scrape "META-INF" off } return dir; }
public JarArchive(ClassLoader loader, URL url) { // if (!"jar".equals(url.getProtocol())) throw new IllegalArgumentException("not a jar url: " + url); try { this.loader = loader; this.url = url; URL u = url; String jarPath = url.getFile(); if (jarPath.contains("!")) { jarPath = jarPath.substring(0, jarPath.indexOf("!")); u = new URL(jarPath); } jar = new JarFile(FileArchive.decode(u.getFile())); // no more an url } catch (IOException e) { throw new IllegalStateException(e); } }
public JarArchive(ClassLoader loader, URL url) { // if (!"jar".equals(url.getProtocol())) throw new IllegalArgumentException("not a jar url: " + url); try { this.loader = loader; this.url = url; URL u = url; String jarPath = url.getFile(); if (jarPath.contains("!")) { jarPath = jarPath.substring(0, jarPath.indexOf("!")); u = new URL(jarPath); } jar = new JarFile(FileArchive.decode(u.getFile())); // no more an url } catch (IOException e) { throw new IllegalStateException(e); } }
public static File toFile(final URL url) { if ("jar".equals(url.getProtocol())) { try { final String spec = url.getFile(); final int separator = spec.indexOf('!'); if (separator == -1) { return null; } return toFile(new URL(spec.substring(0, separator + 1))); } catch (final MalformedURLException e) { return null; } } else if ("file".equals(url.getProtocol())) { String path = FileArchive.decode(url.getFile()); if (path.endsWith("!")) { path = path.substring(0, path.length() - 1); } return new File(path); } return null; }
public static File toFile(final URL url) { if ("jar".equals(url.getProtocol())) { try { final String spec = url.getFile(); final int separator = spec.indexOf('!'); if (separator == -1) { return null; } return toFile(new URL(spec.substring(0, separator + 1))); } catch (final MalformedURLException e) { return null; } } else if ("file".equals(url.getProtocol())) { String path = FileArchive.decode(url.getFile()); if (path.endsWith("!")) { path = path.substring(0, path.length() - 1); } return new File(path); } return null; }
protected boolean isContainerClass(final Filter filter, final String name) { // workaround until beam is able to have a consistent packaging - i.e. no extensions/io in its core if (excludeClassesFilter.accept(name)) { // check if it is beam-sdks-java-core, if so then it is considered as a // container class final URL resource = ComponentManager.class.getClassLoader().getResource(name.replace('.', '/') + ".class"); if (resource != null) { if (resource.getFile().startsWith("mvn:org.apache.beam/beam-sdks-java-core/")) { // studio return true; } else if ("jar".equals(resource.getProtocol())) { // standalone final String file = resource.getFile(); final int separator = file.indexOf('!'); if (separator > 0) { try { final String strippedJar = new File(decode(new URL(file.substring(0, separator)).getFile())).getName(); return strippedJar.startsWith("beam-sdks-java-core-") || strippedJar.startsWith("org.apache.beam.beam-sdks-java-core-"); } catch (final MalformedURLException e) { // let it return false } } } } return false; } return name != null && filter.accept(name); }
if (separator > 0) { try { plugin = new File(decode(new URL(spec.substring(0, separator)).getFile())); } catch (final MalformedURLException e) {
String beanArchiveLocation = FileArchive.decode(beanArchiveUrl.toExternalForm());
@SuppressWarnings("deprecation") protected static void installJaas() { final String path = SystemInstance.get().getOptions().get("java.security.auth.login.config", (String) null); if (path != null) { return; } final URL loginConfig = ConfUtils.getConfResource("login.config"); JavaSecurityManagers.setSystemProperty("java.security.auth.login.config", FileArchive.decode(loginConfig.toExternalForm())); }