Package org.springframework.core.io

Examples of org.springframework.core.io.Resource.lastModified()


        logger.debug("No media type found for " + resource + " - not sending a content-type header");
      }
    }

    // header phase
    if (new ServletWebRequest(request, response).checkNotModified(resource.lastModified())) {
      logger.debug("Resource not modified - returning 304");
      return;
    }
    setHeaders(response, resource, mediaType);
View Full Code Here


        logger.debug("No media type found for " + resource + " - not sending a content-type header");
      }
    }

    // header phase
    if (new ServletWebRequest(request, response).checkNotModified(resource.lastModified())) {
      logger.debug("Resource not modified - returning 304");
      return;
    }
    setHeaders(response, resource, mediaType);
View Full Code Here

    if (resource.exists()) {
      long fileTimestamp = -1;
      if (this.cacheMillis >= 0) {
        // Last-modified timestamp of file will just be read if caching with timeout.
        try {
          fileTimestamp = resource.lastModified();
          if (propHolder != null && propHolder.getFileTimestamp() == fileTimestamp) {
            if (logger.isDebugEnabled()) {
              logger.debug("Re-caching properties for filename [" + filename + "] - file hasn't been modified");
            }
            propHolder.setRefreshTimestamp(refreshTimestamp);
View Full Code Here


  public long getLastModified(Object templateSource) {
    Resource resource = (Resource) templateSource;
    try {
      return resource.lastModified();
    }
    catch (IOException ex) {
      if (logger.isDebugEnabled()) {
        logger.debug("Could not obtain last-modified timestamp for FreeMarker template in " +
            resource + ": " + ex);
View Full Code Here

    if (resource.exists()) {
      long fileTimestamp = -1;
      if (this.cacheMillis >= 0) {
        // Last-modified timestamp of file will just be read if caching with timeout.
        try {
          fileTimestamp = resource.lastModified();
          if (propHolder != null && propHolder.getFileTimestamp() == fileTimestamp) {
            if (logger.isDebugEnabled()) {
              logger.debug("Re-caching properties for filename [" + filename + "] - file hasn't been modified");
            }
            propHolder.setRefreshTimestamp(refreshTimestamp);
View Full Code Here

  }

  public void testDoesNotPropagateFatalExceptionOnResourceThatCannotBeResolvedToAFile() throws Exception {
    MockControl mock = MockControl.createControl(Resource.class);
    Resource resource = (Resource) mock.getMock();
    resource.lastModified();
    mock.setThrowable(new IOException());
    mock.replay();

    ResourceScriptSource scriptSource = new ResourceScriptSource(resource);
    long lastModified = scriptSource.retrieveLastModifiedTime();
View Full Code Here

  public void testLastModifiedWorksWithResourceThatDoesNotSupportFileBasedReading() throws Exception {
    MockControl mock = MockControl.createControl(Resource.class);
    Resource resource = (Resource) mock.getMock();
    // underlying File is asked for so that the last modified time can be checked...
    resource.lastModified();
    mock.setReturnValue(100, 2);
    // does not support File-based reading; delegates to InputStream-style reading...
    resource.getFile();
    mock.setThrowable(new FileNotFoundException());
    resource.getInputStream();
View Full Code Here

    resource.getFile();
    mock.setThrowable(new FileNotFoundException());
    resource.getInputStream();
    mock.setReturnValue(new ByteArrayInputStream(new byte[0]));
    // And then mock the file changing; i.e. the File says it has been modified
    resource.lastModified();
    mock.setReturnValue(200);
    mock.replay();

    ResourceScriptSource scriptSource = new ResourceScriptSource(resource);
    assertTrue("ResourceScriptSource must start off in the 'isModified' state (it obviously isn't).", scriptSource.isModified());
View Full Code Here

       
        @Override
  public long getLastModified(String name) {
    Resource resource = getResource(name);
    try {
      return resource.lastModified();
    } catch (IOException ex) {
      return -1;
    }
  }
View Full Code Here

        logger.trace("No media type found for " + resource + " - not sending a content-type header");
      }
    }

    // header phase
    if (new ServletWebRequest(request, response).checkNotModified(resource.lastModified())) {
      logger.trace("Resource not modified - returning 304");
      return;
    }
    setHeaders(response, resource, mediaType);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.