-
1. Re: How to access a classpath file from a bean
ffang Sep 30, 2010 8:27 AM (in response to larasith)Hi,
Have no idea about your whole scenario.
Could you please provide more info about this issue?
Something like more details about your user scenario, which smx version you are using, which component get involved etc.
Do you want reference a file from another bundle, or in same bundle? Or you didn't use bundle at all?
Freeman
-
2. Re: How to access a classpath file from a bean
larasith Sep 30, 2010 9:29 AM (in response to ffang)hi, my routing is the following:
i tried with several certificate path:
apns.p12
classpath:apns.p12
classpath:/apns.p12
in my project, this file is under:
src/main/resources
and i'm trying to access it through:
FileInputStream fin = new FileInputStream(certificatePath);
Edited by: larasith on Sep 30, 2010 1:28 PM
Edited by: larasith on Sep 30, 2010 1:28 PM
-
3. Re: How to access a classpath file from a bean
ffang Sep 30, 2010 9:49 AM (in response to larasith)Hi,
So all stuff is in same bundle? The camel router, Pusher Bean and apns.p12?
Freeman
-
4. Re: How to access a classpath file from a bean
larasith Sep 30, 2010 10:25 AM (in response to ffang)All is in the same bundle
-
pusherService.png 21.4 KB
-
-
5. Re: How to access a classpath file from a bean
davsclaus Sep 30, 2010 10:43 AM (in response to larasith)If you need to load from the classpath you should load it as such. The FileInputStream is for loading from file system (eg not classpath).
But since its in the same bundle you may be able to load it using regular JDK load resource from classpath stuff. Just google at bit how to do that.
In Camel we have a ClassResolver which we use to load resources from classpath. It allows us to do this regardless if we run on OSGi, JBoss (have its own classloader thingy), WebSphere etc.
CamelContext.getClassResolver(). And it has methods to load resources, such as loadResourceAsStream
-
6. Re: How to access a classpath file from a bean
larasith Sep 30, 2010 11:14 AM (in response to davsclaus)Ok, but how i can access to CamelContext instance?, it is a Interface
-
7. Re: How to access a classpath file from a bean
davsclaus Oct 1, 2010 1:09 AM (in response to larasith)Just add CamelContext as parameter to your method, and Camel will automatic provide it to you when the method is invoked by Camel.
-
8. Re: How to access a classpath file from a bean
davsclaus Oct 1, 2010 1:10 AM (in response to davsclaus)All this is explained in the Camel in Action book, chapter 4.
There are discounts on the books this week:
Save 41% on Manning books: Camel in Action or ActiveMQ in Action.
Use code s2941. Expires 6th oct. http://www.manning.com/ibsen/