/** * Retrieves a resource stream from the classpath. * * @param relativePath relative path of the resource to fetch * @return InputStream to the resource (may be null) */ public InputStream resourceAsStream(String relativePath) { return Scala.orNull(env.resourceAsStream(relativePath)); }
/** * Retrieves a resource stream from the classpath. * * @param relativePath relative path of the resource to fetch * @return InputStream to the resource (may be null) */ public InputStream resourceAsStream(String relativePath) { return Scala.orNull(env.resourceAsStream(relativePath)); }
/** * Retrieves a resource stream from the classpath. * * @param relativePath relative path of the resource to fetch * @return InputStream to the resource (may be null) */ public InputStream resourceAsStream(String relativePath) { return Scala.orNull(env.resourceAsStream(relativePath)); }
/** * Retrieves a resource stream from the classpath. * * @param relativePath relative path of the resource to fetch * @return InputStream to the resource (may be null) */ public InputStream resourceAsStream(String relativePath) { return Scala.orNull(env.resourceAsStream(relativePath)); }
@Override public CSSResource getCSSResource(String uri) { Option<InputStream> option = environment.asScala().resourceAsStream(uri); if (option.isDefined()) return new CSSResource(option.get()); try { // uri is in fact a complete URL new URL(uri).getPath(); return super.getCSSResource(uri); } catch (MalformedURLException e) { LOG.error("fetching css " + uri, e); throw new RuntimeException(e); } }
@Override public byte[] getBinaryResource(String uri) { Option<InputStream> option = environment.asScala().resourceAsStream(uri); if (option.isDefined()) { InputStream stream = option.get(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { copy(stream, baos); } catch (IOException e) { LOG.error("fetching binary " + uri, e); throw new RuntimeException(e); } return baos.toByteArray(); } else { return super.getBinaryResource(uri); } }
@Override public XMLResource getXMLResource(String uri) { Option<InputStream> option = environment.asScala().resourceAsStream(uri); if (option.isDefined()) { return XMLResource.load(option.get()); } else { return super.getXMLResource(uri); } }
@Override public ImageResource getImageResource(String uri) { Option<InputStream> option = environment.asScala().resourceAsStream(uri); if (option.isDefined()) { InputStream stream = option.get(); try { Image image = Image.getInstance(getData(stream)); scaleToOutputResolution(image); return new ImageResource(uri, new ITextFSImage(image)); } catch (Exception e) { LOG.error("fetching image " + uri, e); throw new RuntimeException(e); } } else { return super.getImageResource(uri); } }