public JarFileArchive(File file, URL url) throws IOException { this(new JarFile(file)); this.url = url; }
private JarFile getRootJarFile(String name) throws IOException { try { if (!name.startsWith(FILE_PROTOCOL)) { throw new IllegalStateException("Not a file URL"); } String path = name.substring(FILE_PROTOCOL.length()); File file = new File(URLDecoder.decode(path, "UTF-8")); Map<File, JarFile> cache = rootFileCache.get(); JarFile result = (cache != null) ? cache.get(file) : null; if (result == null) { result = new JarFile(file); addToRootFileCache(file, result); } return result; } catch (Exception ex) { throw new IOException("Unable to open root Jar file '" + name + "'", ex); } }
"Unable to determine code source archive from " + root); return new JarFile(root);
"Unable to determine code source archive from " + root); return new JarFile(root);
@Override public boolean handlesClasspathResource(ClasspathResource resource, List<ResourceScanListener.ScanResource> scanResources) throws IOException { for(ClasspathResource.OffsetListener jarOffset : resource.getJarOffsets()) { String offset = jarOffset.jarOffset; // must be null, 0 or ending with .jar if (!(offset == null || offset.length() == 0 || offset.endsWith(".jar!/"))) { return false; } } // ok, looks like Spring loaded, or at least something Spring loaded can handle. JarFile jarFile = new JarFile(resource.getClassesSource()); for(ClasspathResource.OffsetListener jarOffset : resource.getJarOffsets()) { if (jarOffset.listeners != null && jarOffset.listeners.size() > 0) { String offset = jarOffset.jarOffset; JarFile processFile = jarFile; if (offset.endsWith(".jar!/")) { processFile = getNestedJarFile(jarFile, offset.substring(0, offset.length() - SEPARATOR.length())); } extractJarEntries(resource, jarOffset, scanResources, processFile); } } return true; }
Enumeration<JarEntry> entries = new JarFile(file).entries(); while (entries.hasMoreElements()) { JarEntry entry = entries.nextElement();
private JarFile createJarFileFromFileEntry(JarEntry entry) throws IOException { if (entry.getMethod() != ZipEntry.STORED) { throw new IllegalStateException("Unable to open nested entry '" + entry.getName() + "'. It has been compressed and nested " + "jar files must be stored without compression. Please check the " + "mechanism used to create your executable jar file"); } RandomAccessData entryData = this.entries.getEntryData(entry.getName()); return new JarFile(this.rootFile, this.pathFromRoot + "!/" + entry.getName(), entryData, JarFileType.NESTED_JAR); }
private JarFile createJarFileFromDirectoryEntry(JarEntry entry) throws IOException { AsciiBytes name = entry.getAsciiBytesName(); JarEntryFilter filter = (candidate) -> { if (candidate.startsWith(name) && !candidate.equals(name)) { return candidate.substring(name.length()); } return null; }; return new JarFile(this.rootFile, this.pathFromRoot + "!/" + entry.getName().substring(0, name.length() - 1), this.data, filter, JarFileType.NESTED_DIRECTORY, this.manifestSupplier); }