[
https://issues.apache.org/jira/browse/CAMEL-5940?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13611885#comment-13611885
]
Piotr Klimczak commented on CAMEL-5940:
---------------------------------------
I have made some progress and it seems to work as it should but need to write
more test than just one.
I'm trying the way to load the classpath resource as Claus written. It seems to
be springless as Henryk requested.
During testing I have faced interesting behaviour- loading the resource fails
when leading "/" is used. In my opinion forcing others to not use the leading
"/" may case them some problems (like me- spent one hour) Why not to let to
work both paths?
So maybe the ObjectHelper should have a mehtod like this (instead the current
one):
{code}
/**
* Attempts to load the given resource as a stream using the thread context
* class loader or the class loader used to load this class
*
* @param name the name of the resource to load
* @return the stream or null if it could not be loaded
*/
public static InputStream loadResourceAsStream(String name) {
InputStream in = null;
String resolvedName = resolveUriPath(name);
ClassLoader contextClassLoader =
Thread.currentThread().getContextClassLoader();
if (contextClassLoader != null) {
in = contextClassLoader.getResourceAsStream(resolvedName);
}
if (in == null) {
in =
ObjectHelper.class.getClassLoader().getResourceAsStream(resolvedName);
}
if (in == null) {
in = ObjectHelper.class.getResourceAsStream(resolvedName);
}
return in;
}
{code}
Greetings,
Piotr
> camel-cache - Add option to cache component to easily configure ehcache XML
> file to load by default
> ---------------------------------------------------------------------------------------------------
>
> Key: CAMEL-5940
> URL: https://issues.apache.org/jira/browse/CAMEL-5940
> Project: Camel
> Issue Type: Improvement
> Components: camel-cache
> Reporter: Claus Ibsen
> Fix For: 2.11.1
>
>
> See
> By default ehache.xml is loaded from classpath. We should make it possible to
> configure CacheComponent with a string option that refers to the resource to
> load.
> Then people can do something a like:
> {code}
> <bean id="cache" class="...CacheComponent">
> <property name="configurationFile" value="classpath:com/foo/mycache.xml"/>
> </bean>
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira