On 7/8/11 15:02, Shamik Bandopadhyay wrote:
Hi,Based on my experience so far,I found it hard to deal with a File object within an OSGi bundle, specially, if you are working with a third party library which takes a file object. In my case I'm using Gate library which takes File objects only as configuration data.I was initially having the required files as part of the bundle, hoping that it'll work fine by using the absolute path. But later I hit the raodblock since OSGi doesn't allow you to get the full file path (unless you are using equinox/eclipse). It only deals with bundle URL or inputstream, which ofcourse won't work in case of Gate. As per my requirement, I need to update the config files at times.I thought of leveraging the hot deploy feature by simply dropping a new version of the bundle with the updated config files. Apparently, it won't work bcos of the File restriction. I can externalize the files and use the full file path instead. But what I'm trying to understand is if there's a way to refresh the bundle automatically when the files are being updated externally. Gate is being initialized through spring at the startup using these config files. Now, if I update teh files w/o re-starting the bundle, will OSGi / Spring DM be able to update the bundle with the new file reference?
OSGi won't, that's for sure. Spring DM/Blueprint might, but I guess that depends on how you are supplying the File to your bundle. For example, if you were using Declarative Services or iPOJO, then you can use Config Admin to inject configuration properties so you could inject the new absolute path to a file...Config Admin doesn't support File type properties though.
Of course, some of this depends on if the bundle you want to inject with a File can accept a file change after it is already started. If not, your only choice might be to stop and restart it.
As an aside, if you copy a file into your bundle's private data area, then you can get the absolute path that way, since you can get back the File object and ask for the absolute path.
-> richard
I'll appreciate if someone can share their experience. - Thanks
--------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

