Spring Framework ServletContextResource - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework ServletContextResource class.

This code example shows how to use the following methods:
        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); 
        } 
        return factory.getBroker(); 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:lastModified
	 * 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; 
		} 
		catch (IOException ex) { 
			logger.warn("Couldn't retrieve last-modified timestamp of [" + resource + 
					"] - using ResourceServlet startup time"); 
			return -1; 
		} 
	} 
 
5
CodeRank
This code example shows how to use the following methods:
    public DefaultTemplateFilesResolver soyTemplateFilesResolver() throws Exception { 
        final DefaultTemplateFilesResolver defaultTemplateFilesResolver = new DefaultTemplateFilesResolver(); 
        defaultTemplateFilesResolver.setHotReloadMode(hotReloadMode); 
        defaultTemplateFilesResolver.setRecursive(recursive); 
        defaultTemplateFilesResolver.setFilesExtension(fileExtension); 
        defaultTemplateFilesResolver.setTemplatesLocation(new ServletContextResource(servletContext, templatesPath)); 
 
        return defaultTemplateFilesResolver; 
    } 
 
    @Bean 
    public CompileTimeGlobalModelResolver soyCompileTimeGlobalModelResolver() { 
        return new EmptyCompileTimeGlobalModelResolver(); 
    } 
 
    @Bean 
    public ToSoyDataConverter soyToSoyDataConverter() { 
        return new DefaultToSoyDataConverter(); 
    } 
 
4
CodeRank
This code example shows how to use the following methods:
	} 
 
	private ViewResolver getXmlViewResolver() { 
		XmlViewResolver resolver = new XmlViewResolver(); 
		resolver.setLocation(new ServletContextResource(servletContext, 
				"/WEB-INF/spring/spreadsheet-views.xml")); 
		return resolver; 
	} 
 
	private ViewResolver getJsonViewResolver() { 
		return new JsonViewResolver(); 
	} 
 
	private ViewResolver getMarshallingXmlViewResolver() { 
		Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); 
		marshaller.setClassesToBeBound(Account.class, Transaction.class, 
				Customer.class); 
		return new MarshallingXmlViewResolver(marshaller); 
	} 
 
3
CodeRank
This code example shows how to use the following methods:
 
	@Bean(name = "excelViewResolver") 
	public ViewResolver getXmlViewResolver() { 
		XmlViewResolver resolver = new XmlViewResolver(); 
		resolver.setLocation(new ServletContextResource(servletContext, 
				"/WEB-INF/spring/spreadsheet-views.xml")); 
		return resolver; 
	} 
 
	@Bean(name = "jsonViewResolver") 
	public ViewResolver getJsonViewResolver() { 
		return new JsonViewResolver(); 
	} 
 
	@Bean(name = "marshallingXmlViewResolver") 
	public ViewResolver getMarshallingXmlViewResolver() { 
		Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); 
		marshaller.setClassesToBeBound(Account.class, Transaction.class, 
				Customer.class); 
		return new MarshallingXmlViewResolver(marshaller); 
3
CodeRank