/* * (non-Javadoc) * * @see * net.jawr.web.resource.bundle.ResourceBundlesHandler#writeBundleTo(java * .lang.String, java.io.Writer) */ @Override public void writeBundleTo(String bundlePath, Writer writer) throws ResourceNotFoundException { // String text = (String) textCache.get(bundlePath); String text = (String) cacheMgr.get(TEXT_CACHE_PREFIX + bundlePath); try { // If it's not cached yet if (null == text) { String charsetName = rsHandler.getConfig().getResourceCharset().name(); ByteArrayOutputStream baOs = new ByteArrayOutputStream(); WritableByteChannel wrChannel = Channels.newChannel(baOs); Writer tempWriter = Channels.newWriter(wrChannel, charsetName); rsHandler.writeBundleTo(bundlePath, tempWriter); text = baOs.toString(charsetName); cacheMgr.put(TEXT_CACHE_PREFIX + bundlePath, text); } // Write the text to the outputstream writer.write(text); writer.flush(); } catch (IOException e) { throw new BundlingProcessException( "Unexpected IOException writing bundle[" + bundlePath + "]", e); } }
/** * Build a cached wrapper around the supplied ResourceBundlesHandler. * * @param rsHandler */ public CachedResourceBundlesHandler(ResourceBundlesHandler rsHandler) { super(); this.rsHandler = rsHandler; cacheMgr = CacheManagerFactory.getCacheManager(rsHandler.getConfig(), rsHandler.getResourceType()); }
/* * (non-Javadoc) * * @see net.jawr.web.resource.bundle.ResourceBundlesHandler#getConfig() */ @Override public JawrConfig getConfig() { return rsHandler.getConfig(); }