Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Just for the records in case someone else has the same problem. Here a small modification to the answer of Vlad in order to avoid having to add the output directory to the Reflections path patterns. The difference is only in the BundleDir class. It seems to work fine in all my tests:</p> <pre><code>public class BundleUrlType implements UrlType { public static final String BUNDLE_PROTOCOL = "bundleresource"; private final Bundle bundle; public BundleUrlType(Bundle bundle) { this.bundle = bundle; } @Override public Dir createDir(URL url) { return new BundleDir(bundle, url); } @Override public boolean matches(URL url) { return BUNDLE_PROTOCOL.equals(url.getProtocol()); } public static class BundleDir implements Dir { private String path; private final Bundle bundle; private static String urlPath(Bundle bundle, URL url) { try { URL resolvedURL = FileLocator.resolve(url); String resolvedURLAsfile = resolvedURL.getFile(); URL bundleRootURL = bundle.getEntry("/"); URL resolvedBundleRootURL = FileLocator.resolve(bundleRootURL); String resolvedBundleRootURLAsfile = resolvedBundleRootURL.getFile(); return("/"+resolvedURLAsfile.substring(resolvedBundleRootURLAsfile.length())); } catch (IOException e) { throw new RuntimeException(e); } } public BundleDir(Bundle bundle, URL url) { //this(bundle, url.getPath()); this(bundle, urlPath(bundle,url)); } public BundleDir(Bundle bundle, String p) { this.bundle = bundle; this.path = p; if (path.startsWith(BUNDLE_PROTOCOL + ":")) { path = path.substring((BUNDLE_PROTOCOL + ":").length()); } } @Override public String getPath() { return path; } @Override public Iterable&lt;File&gt; getFiles() { return new Iterable&lt;Vfs.File&gt;() { public Iterator&lt;Vfs.File&gt; iterator() { return new AbstractIterator&lt;Vfs.File&gt;() { final Enumeration&lt;URL&gt; entries = bundle.findEntries(path, "*.class", true); protected Vfs.File computeNext() { return entries.hasMoreElements() ? new BundleFile(BundleDir.this, entries.nextElement()) : endOfData(); } }; } }; } @Override public void close() { } } public static class BundleFile implements File { private final BundleDir dir; private final String name; private final URL url; public BundleFile(BundleDir dir, URL url) { this.dir = dir; this.url = url; String path = url.getFile(); this.name = path.substring(path.lastIndexOf("/") + 1); } @Override public String getName() { return name; } @Override public String getRelativePath() { return getFullPath().substring(dir.getPath().length()); } @Override public String getFullPath() { return url.getFile(); } @Override public InputStream openInputStream() throws IOException { return url.openStream(); } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload