X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2Futil%2FBundleResourceLoader.java;h=30aba1ab7ca820b3dc324c02835daaa4f8eba5f3;hb=3d611c76cc8df95ab66d27307acf9521c3130556;hp=387e02ed4e83f7f5a9b5d9a442501c29021e3638;hpb=85ced0e58ded00f296948b6dff51f84994855080;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms/src/org/argeo/cms/util/BundleResourceLoader.java b/org.argeo.cms/src/org/argeo/cms/util/BundleResourceLoader.java index 387e02ed4..30aba1ab7 100644 --- a/org.argeo.cms/src/org/argeo/cms/util/BundleResourceLoader.java +++ b/org.argeo.cms/src/org/argeo/cms/util/BundleResourceLoader.java @@ -2,7 +2,12 @@ package org.argeo.cms.util; import java.io.IOException; import java.io.InputStream; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import org.argeo.cms.CmsException; import org.eclipse.rap.rwt.service.ResourceLoader; @@ -22,11 +27,26 @@ public class BundleResourceLoader implements ResourceLoader { throws IOException { // TODO deal with other bundles Bundle bundle = bundleContext.getBundle(); + // String location = + // bundle.getLocation().substring("initial@reference:".length()); + // if (location.startsWith("file:")) { + // Path path = null; + // try { + // path = Paths.get(new URI(location)); + // } catch (URISyntaxException e) { + // e.printStackTrace(); + // } + // if (path != null) { + // Path resourcePath = path.resolve(resourceName); + // if (Files.exists(resourcePath)) + // return Files.newInputStream(resourcePath); + // } + // } URL res = bundle.getResource(resourceName); if (res == null) throw new CmsException("Resource " + resourceName + " not found in bundle " + bundle.getSymbolicName()); - return bundleContext.getBundle().getResource(resourceName).openStream(); + return res.openStream(); } }