Package org.springframework.web.context.support

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


  public void afterPropertiesSet() throws Exception {
    Assert.notNull(relativeModuleRootLocation);
  }

  public Resource getRootDirectory() {
    return new ServletContextResource(servletContext, relativeModuleRootLocation);
  }
View Full Code Here


  }
 
  public List<Resource> getApplicationModuleClassLocations(String moduleName) {
    String applicationVersionString = StringUtils.hasText(applicationVersion) ? "-" + applicationVersion : "";
    String fullResourceName = relativeModuleRootLocation + "/" + moduleName + applicationVersionString + ".jar";
    Resource servletContextResource = new ServletContextResource(servletContext, fullResourceName);
    return Collections.singletonList(servletContextResource);
  }
View Full Code Here

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

    assertEquals(resource2, new UrlResource("file:core/../core/io/./Resource.class"));
  }

  public void testServletContextResource() throws IOException {
    MockServletContext sc = new MockServletContext();
    Resource resource = new ServletContextResource(sc, "org/springframework/core/io/Resource.class");
    doTestResource(resource);
    assertEquals(resource, new ServletContextResource(sc, "org/springframework/core/../core/io/./Resource.class"));
  }
View Full Code Here

    assertEquals(new UrlResource("file:dir/subdir"), relative);
  }

  public void testServletContextResourceWithRelativePath() throws IOException {
    MockServletContext sc = new MockServletContext();
    Resource resource = new ServletContextResource(sc, "dir/");
    Resource relative = resource.createRelative("subdir");
    assertEquals(new ServletContextResource(sc, "dir/subdir"), relative);
  }
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) {
            context.log("Failed to create broker: " + e, e);
View Full Code Here

    private ServletContext servletContext;

  @Override
  public void setAsText(String path) throws IllegalArgumentException {
    Resource resource = new ServletContextResource(servletContext, path);

        try {
      setValue(new InputStreamReader(resource.getInputStream()));
    }
    catch (IOException ex) {
      throw new IllegalArgumentException(
          "Could not retrieve InputStream for " + resource + ": " + ex.getMessage());
    }
View Full Code Here

     * This implementation supports file paths beneath the root of the ServletContext.
     * @see ServletContextResource
     */
    @Override
    protected Resource getResourceByPath(String path) {
        return new ServletContextResource(servletContext, path);
    }
View Full Code Here

    @Override
    protected void prepareBeanFactory(ConfigurableListableBeanFactory beanFactory) {
        if (configLocations.length > 0) {
            for (String configLocation : configLocations) {
                BeanBuilder beanBuilder = new BeanBuilder(getParent(),getClassLoader());
                final ServletContextResource resource = new ServletContextResource(getServletContext(), configLocation);
                beanBuilder.loadBeans(resource);
                beanBuilder.registerBeans(this);
            }
        }
        super.prepareBeanFactory(beanFactory);
View Full Code Here

    public Resource getResourceForUri(String uri) {
        GroovyPageScriptSource scriptSource = getResourceWithinContext(uri);
        if (scriptSource != null && (scriptSource instanceof GroovyPageResourceScriptSource)) {
            return ((GroovyPageResourceScriptSource)scriptSource).getResource();
        }
        return new ServletContextResource(servletContext, uri);
    }
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.