<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.1" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Loading resources from files or the classpath</title>
	<link>http://www.memestorm.com/blog/loading-resources-from-files-or-the-classpath/</link>
	<description>Exploring the Spring Framework and Application Development</description>
	<pubDate>Fri, 21 Nov 2008 12:23:59 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.1</generator>

	<item>
		<title>By: J Wilks</title>
		<link>http://www.memestorm.com/blog/loading-resources-from-files-or-the-classpath/#comment-102</link>
		<author>J Wilks</author>
		<pubDate>Wed, 05 Apr 2006 15:39:49 +0000</pubDate>
		<guid>http://www.memestorm.com/blog/loading-resources-from-files-or-the-classpath/#comment-102</guid>
					<description>I was surprised how hard it was to get XmlWebApplicationContext to use a resource root *other than* the root of the webapp. For security reasons you usually want your configuration files under /WEB-INF/, not the actual webapp root. But if you place them there, your app context XML file has to reference "/WEB-INF/db/init.sql" -- which means that configuration file is no longer useful outside of a web container context.</description>
		<content:encoded><![CDATA[<p>I was surprised how hard it was to get XmlWebApplicationContext to use a resource root *other than* the root of the webapp. For security reasons you usually want your configuration files under /WEB-INF/, not the actual webapp root. But if you place them there, your app context XML file has to reference &#8220;/WEB-INF/db/init.sql&#8221; &#8212; which means that configuration file is no longer useful outside of a web container context.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: A Korver</title>
		<link>http://www.memestorm.com/blog/loading-resources-from-files-or-the-classpath/#comment-265</link>
		<author>A Korver</author>
		<pubDate>Fri, 05 May 2006 17:16:35 +0000</pubDate>
		<guid>http://www.memestorm.com/blog/loading-resources-from-files-or-the-classpath/#comment-265</guid>
					<description>From the Spring docs.....Thus you can eliminate the ResourceAware interface and the String file location, instead, just use a Resource property and set it.

"If the bean itself is going to determine and supply the resource path through some sort of dynamic process it probably makes sense for the bean to use the ResourceLoader interface to load resources. Consider as an example the loading of a template of some sort, where the specific one needed that depends on the role of the user. If on the other hand the resources are static, it makes sense to eliminate the use of the ResourceLoader interface completely, and just have the bean expose the Resource properties it needs, and expect that they will be injected into it.

What makes it trivial to then inject these properties, is that all application contexts register and use a special JavaBeans PropertyEditor which can convert String paths to Resource objects. So if myBean has a template property of type Resource, it can be configured with a text string for that resource, as follows:


  
"

http://static.springframework.org/spring/docs/1.2.x/reference/resources.html</description>
		<content:encoded><![CDATA[<p>From the Spring docs&#8230;..Thus you can eliminate the ResourceAware interface and the String file location, instead, just use a Resource property and set it.</p>
<p>&#8220;If the bean itself is going to determine and supply the resource path through some sort of dynamic process it probably makes sense for the bean to use the ResourceLoader interface to load resources. Consider as an example the loading of a template of some sort, where the specific one needed that depends on the role of the user. If on the other hand the resources are static, it makes sense to eliminate the use of the ResourceLoader interface completely, and just have the bean expose the Resource properties it needs, and expect that they will be injected into it.</p>
<p>What makes it trivial to then inject these properties, is that all application contexts register and use a special JavaBeans PropertyEditor which can convert String paths to Resource objects. So if myBean has a template property of type Resource, it can be configured with a text string for that resource, as follows:</p>
<p>&#8221;</p>
<p><a href="http://static.springframework.org/spring/docs/1.2.x/reference/resources.html" rel="nofollow">http://static.springframework.org/spring/docs/1.2.x/reference/resources.html</a></p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Gaurav Sood</title>
		<link>http://www.memestorm.com/blog/loading-resources-from-files-or-the-classpath/#comment-1214</link>
		<author>Gaurav Sood</author>
		<pubDate>Wed, 02 Aug 2006 16:43:12 +0000</pubDate>
		<guid>http://www.memestorm.com/blog/loading-resources-from-files-or-the-classpath/#comment-1214</guid>
					<description>I'm stuck with the same problem, having to load a resource which is not in /WEB-INF/... Apparently my webapps work fine but the integration test is unable to get the resource from the classpath. Can anyone help</description>
		<content:encoded><![CDATA[<p>I&#8217;m stuck with the same problem, having to load a resource which is not in /WEB-INF/&#8230; Apparently my webapps work fine but the integration test is unable to get the resource from the classpath. Can anyone help</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Bill Poitras</title>
		<link>http://www.memestorm.com/blog/loading-resources-from-files-or-the-classpath/#comment-1453</link>
		<author>Bill Poitras</author>
		<pubDate>Thu, 17 Aug 2006 17:33:01 +0000</pubDate>
		<guid>http://www.memestorm.com/blog/loading-resources-from-files-or-the-classpath/#comment-1453</guid>
					<description>Instead of using a property of type String, try using File or InputStream.  Spring resource editors will automatically do the conversion for you (although you need to close InputStream).  For classpath resources begin the string with "classpath:"</description>
		<content:encoded><![CDATA[<p>Instead of using a property of type String, try using File or InputStream.  Spring resource editors will automatically do the conversion for you (although you need to close InputStream).  For classpath resources begin the string with &#8220;classpath:&#8221;</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Jamie Cramb</title>
		<link>http://www.memestorm.com/blog/loading-resources-from-files-or-the-classpath/#comment-59463</link>
		<author>Jamie Cramb</author>
		<pubDate>Mon, 03 Nov 2008 19:10:38 +0000</pubDate>
		<guid>http://www.memestorm.com/blog/loading-resources-from-files-or-the-classpath/#comment-59463</guid>
					<description>Bump!

Thanks, been trying to find a way to do this for a while now; works like a charm :).

Cheers</description>
		<content:encoded><![CDATA[<p>Bump!</p>
<p>Thanks, been trying to find a way to do this for a while now; works like a charm :).</p>
<p>Cheers</p>
]]></content:encoded>
				</item>
</channel>
</rss>
