Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Specifying bundle.properties
Specifying bundle.properties [message #67487] Tue, 16 May 2006 20:52 Go to next message
Cameron Ross is currently offline Cameron RossFriend
Messages: 17
Registered: July 2009
Junior Member
Hello,

I would like to allow a bundle to be configured via a bundle.properties
file. I was hopeful that I could place this file within my bundle and
then acccess the preoperties defined within using
BundleContext.getProperty(String). Unfortunately, this does not work for
me. Is there a standard way of dealing with bundle specific properties
within equinox?

Cameron.
Re: Specifying bundle.properties [message #67508 is a reply to message #67487] Tue, 16 May 2006 21:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: neil.integility.com

So, you want load a properties file that exists in the bundle? You should
just load it as a classpath resource in the normal way:

InputStream propsStream =
MyClass.class.getResourceAsStream("/bundle.properties");
Properties props = new Properties();
props.load(propsStream);

Regards
Neil
Re: Specifying bundle.properties [message #67529 is a reply to message #67508] Wed, 17 May 2006 06:30 Go to previous messageGo to next message
Danail Nachev is currently offline Danail NachevFriend
Messages: 36
Registered: July 2009
Member
You might be interested in looking in the Configuration Admin service too.

Neil Bartlett wrote:
> So, you want load a properties file that exists in the bundle? You
> should just load it as a classpath resource in the normal way:
>
> InputStream propsStream =
> MyClass.class.getResourceAsStream("/bundle.properties");
> Properties props = new Properties();
> props.load(propsStream);
>
> Regards
> Neil
>
Re: Specifying bundle.properties [message #68058 is a reply to message #67508] Wed, 24 May 2006 19:02 Go to previous message
Thomas Watson is currently offline Thomas WatsonFriend
Messages: 503
Registered: July 2009
Senior Member
Neil Bartlett wrote:
> So, you want load a properties file that exists in the bundle? You
> should just load it as a classpath resource in the normal way:
>
> InputStream propsStream =
> MyClass.class.getResourceAsStream("/bundle.properties");
> Properties props = new Properties();
> props.load(propsStream);
>
> Regards
> Neil
>

Notice that Class.getResourceAsStream will use your bundles class loader
to load the resource, this implies that you could get the resource from
another bundle if you import the package your resource is located. I
recommend you use Bundle#getEntry("/bundle.properties") to get
guarantee you load the properties file from yourself.

Tom.
Previous Topic:Obtaining a bundle as bytes
Next Topic:handling jar: URLS?
Goto Forum:
  


Current Time: Thu Mar 28 18:41:15 GMT 2024

Powered by FUDForum. Page generated in 0.02598 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top