List of usage examples for com.google.gwt.dev.resource Resource getLastModified
public abstract long getLastModified();
From source file:org.cruxframework.crux.core.rebind.screen.ScreenFactory.java
License:Apache License
/** * Factory method for screens./*from ww w . j a v a2 s.c o m*/ * @param id * @param device device property for this permutation being compiled * @return * @throws ScreenConfigException */ public Screen getScreen(String id, String device) throws ScreenConfigException { try { String cacheKey = device == null ? id : id + "_" + device; Screen screen = screenCache.get(cacheKey); if (screen != null) { return screen; } Resource resource = screenLoader.getScreen(id); if (resource == null) { throw new ScreenConfigException("Error retrieving screen [" + id + "].crux.xml."); } InputStream inputStream = resource.openContents(); Document screenView = viewFactory.getViewDocument(id, device, inputStream); StreamUtils.safeCloseStream(inputStream); if (screenView == null) { throw new ScreenConfigException("Screen [" + id + "].crux.xml not found!"); } screen = parseScreen(id, device, screenView, resource.getLastModified()); if (screen != null) { screen.setLastModified(resource.getLastModified()); screenCache.put(cacheKey, screen); } return screen; } catch (IOException e) { throw new ScreenConfigException("Error retrieving screen [" + id + "].crux.xml.", e); } }
From source file:org.cruxframework.crux.core.rebind.screen.ViewFactory.java
License:Apache License
/** * Factory method for views.// w w w.j av a2s . co m * @param id viewId * @param device device property for this permutation being compiled * @return * @throws ScreenConfigException */ public View getView(String id, String device) throws ScreenConfigException { String cacheKey = id + "_" + device; if (cache.containsKey(cacheKey)) { return cache.get(cacheKey); } Resource resource = context.getScreenLoader().getViewLoader().getView(id); if (resource == null) { throw new ScreenConfigException("View [" + id + "] not found!"); } InputStream inputStream; try { inputStream = resource.openContents(); } catch (IOException e) { throw new ScreenConfigException("View [" + id + "] not found!"); } Document viewDoc = viewProcessor.getView(inputStream, id, device); StreamUtils.safeCloseStream(inputStream); View view = getView(id, device, viewDoc, resource.getLastModified(), false); cache.put(cacheKey, view); return view; }