/** * Construct. * * @param scope The scope class to detect the resource * @param path absolute path to resource */ public LessResource(final Class<?> scope, final String path) { this.scope = scope; this.path = path; try { this.lastModified = Connections.getLastModified(Thread.currentThread().getContextClassLoader().getResource(path)); } catch (IOException e) { throw new WicketRuntimeException(e); } }
@Override public Time lastModifiedTime() { try { final ServletContext context = ((WebApplication)Application.get()).getServletContext(); final URL resourceURL = context.getResource(url); if (resourceURL == null) { throw new FileNotFoundException("Unable to find resource '" + url + "' in the servlet context"); } return Connections.getLastModified(resourceURL); } catch (IOException e) { log.warn("failed to retrieve last modified timestamp", e); return null; } }
@Override public Time lastModifiedTime() { try { final ServletContext context = ((WebApplication)Application.get()).getServletContext(); final URL resourceURL = context.getResource(url); if (resourceURL == null) { throw new FileNotFoundException("Unable to find resource '" + url + "' in the servlet context"); } return Connections.getLastModified(resourceURL); } catch (IOException e) { log.warn("failed to retrieve last modified timestamp", e); return null; } }
/** * @see org.apache.wicket.util.watch.IModifiable#lastModifiedTime() * @return The last time this resource was modified */ @Override public Time lastModifiedTime() { try { // get url modification timestamp final Time time = Connections.getLastModified(url); // if timestamp changed: update content length and last modified date if (Objects.equal(time, lastModified) == false) { lastModified = time; updateContentLength(); } return lastModified; } catch (IOException e) { log.warn("getLastModified() for '{}' failed: {}", url, e.getMessage()); // allow modification watcher to detect the problem return null; } }
/** * @see org.apache.wicket.util.watch.IModifiable#lastModifiedTime() * @return The last time this resource was modified */ @Override public Time lastModifiedTime() { try { // get url modification timestamp final Time time = Connections.getLastModified(url); // if timestamp changed: update content length and last modified date if (Objects.equal(time, lastModified) == false) { lastModified = time; updateContentLength(); } return lastModified; } catch (IOException e) { log.warn("getLastModified() for '{}' failed: {}", url, e.getMessage()); // allow modification watcher to detect the problem return null; } }
long lastModified = Connections.getLastModified(url);