-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
appearently filesystem.getUri also blocks it
- Loading branch information
1 parent
8d188fa
commit 662ff5f
Showing
7 changed files
with
75 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 0 additions & 40 deletions
40
src/main/java/xyz/wagyourtail/jvmdg/classloader/providers/FileSystemResourceProvider.java
This file was deleted.
Oops, something went wrong.
59 changes: 59 additions & 0 deletions
59
src/main/java/xyz/wagyourtail/jvmdg/classloader/providers/JarFileResourceProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package xyz.wagyourtail.jvmdg.classloader.providers; | ||
|
||
import xyz.wagyourtail.jvmdg.classloader.ResourceProvider; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.net.URL; | ||
import java.net.URLConnection; | ||
import java.net.URLStreamHandler; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.Enumeration; | ||
import java.util.List; | ||
import java.util.jar.JarEntry; | ||
import java.util.jar.JarFile; | ||
|
||
public class JarFileResourceProvider implements ResourceProvider { | ||
private final JarFile jarFile; | ||
|
||
public JarFileResourceProvider(JarFile jarFile) { | ||
this.jarFile = jarFile; | ||
} | ||
|
||
|
||
@Override | ||
public Enumeration<URL> getResources(String name) throws IOException { | ||
final JarEntry entry = jarFile.getJarEntry(name); | ||
if (entry == null) { | ||
return Collections.emptyEnumeration(); | ||
} | ||
return Collections.enumeration(Collections.singletonList(new URL("x-buffer", null, -1, name, new URLStreamHandler() { | ||
@Override | ||
protected URLConnection openConnection(final URL u1) { | ||
return new URLConnection(u1) { | ||
@Override | ||
public void connect() { | ||
} | ||
|
||
@Override | ||
public InputStream getInputStream() { | ||
try { | ||
return jarFile.getInputStream(entry); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
}; | ||
} | ||
}))); | ||
} | ||
|
||
@Override | ||
public void close() throws IOException { | ||
jarFile.close(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters