Package org.springframework.web.context.support

Examples of org.springframework.web.context.support.ServletContextResource


    protected final Log log = LogFactory.getLog(getClass());

    public InputStream getResource(ServletContext servletContext, String path) {
        InputStream in = null;
        try {
            in = new ServletContextResource(servletContext, path).getInputStream();
        } catch (Exception e) {
            log.debug("Could not find resource [" + path + "] in servlet context.");
        } finally {
            if (in == null) in = getClass().getResourceAsStream(path);
            try {
View Full Code Here


        this.servletContext = servletContext;
    }

    protected String getView(String className) {
        String path = "crud/" + className.replaceAll("\\.", "/").toLowerCase() + "_search";
        ServletContextResource resource = new ServletContextResource(servletContext, "WEB-INF/jsp/" + path + ".jsp");
        return resource.exists() ? path : "crud/template_search";
    }
View Full Code Here

        this.servletContext = servletContext;
    }

    protected String getView(String className) {
        String path = "crud/" + className.replaceAll("\\.", "/").toLowerCase();
        ServletContextResource resource = new ServletContextResource(servletContext, "WEB-INF/jsp/" + path + ".jsp");
        return resource.exists() ? path : "crud/template";
    }
View Full Code Here

        // load the file
        File file = loader.find(reqPath);

        if (file == null && scloader != null) {
            //try loading as a servlet resource
            ServletContextResource resource = (ServletContextResource) scloader.getResource(reqPath);
            if (resource != null && resource.exists()) {
                file = resource.getFile();
            }
        }
       
        if (file == null) {
            //return a 404
View Full Code Here

        String brokerURI = context.getInitParameter(INIT_PARAM_BROKER_URI);
        if (brokerURI == null) {
            brokerURI = "activemq.xml";
        }
        context.log("Loading ActiveMQ Broker configuration from: " + brokerURI);
        Resource resource = new ServletContextResource(context, brokerURI);
        BrokerFactoryBean factory = new BrokerFactoryBean(resource);
        try {
            factory.afterPropertiesSet();
        }
        catch (Exception e) {
View Full Code Here

   * Return the file timestamp for the given resource.
   * @param resourceUrl the URL of the resource
   * @return the file timestamp in milliseconds, or -1 if not determinable
   */
  protected long getFileTimestamp(String resourceUrl) {
    ServletContextResource resource = new ServletContextResource(getServletContext(), resourceUrl);
    try {
      long lastModifiedTime = resource.lastModified();
      if (logger.isDebugEnabled()) {
        logger.debug("Last-modified timestamp of " + resource + " is " + lastModifiedTime);
      }
      return lastModifiedTime;
    }
View Full Code Here

  public void testUpload() throws Exception {
   
    DBCentro dbCentro = new DBCentro();
    dbCentro.preparaDb();
   
    byte[] bytes = IOUtils.toByteArray((new ServletContextResource(_ctx.getServletContext(),"/logo.png")).getInputStream());
    MultipartFile file = new MockMultipartFile("file","logo.png","image/png",bytes);
    _reqMock.addFile(file);
    _reqMock.setMethod("POST");

    _reqMock.setRequestURI("/upload.page");
View Full Code Here

    Resource[] resources = new Resource[locations.size()];
 
    for (int i = 0; i < locations.size(); i++) {
      // note that this is relying on the contextClassLoader to be set up
      // correctly
      resources[i] = new ServletContextResource(servletContext, locations.get(i));
    }
    return resources;
  }
View Full Code Here

  private ServletContext servletContext;

  @Override
  protected Resource getResourceForPath(String prefix, String location, ClassLoader classLoader) {
    return new ServletContextResource(this.servletContext, prefix + location);
  }
View Full Code Here

    public final void testGetResourceForPath() {       
        replay(servletContext);
        Resource resource = resourceLoader.getResource("/mypath", null);
        assertTrue(resource instanceof ServletContextResource);
        ServletContextResource r = (ServletContextResource)resource;
        assertSame(servletContext, r.getServletContext());
        verify(servletContext);
    }
View Full Code Here

TOP

Related Classes of org.springframework.web.context.support.ServletContextResource

Copyright © 2018 www.massapicom. 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.