Skip to main content



      Home
Home » Eclipse Projects » Equinox » Specifying bundle.properties
Specifying bundle.properties [message #67487] Tue, 16 May 2006 16:52 Go to next message
Eclipse UserFriend
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 17: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 02:30 Go to previous messageGo to next message
Eclipse UserFriend
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 15:02 Go to previous message
Eclipse UserFriend
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: Fri Apr 25 19:25:29 EDT 2025

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

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

Back to the top