troubleshooting Question

OSGi bundle -> Singleton

Avatar of Aranbarri
Aranbarri asked on
JavaEditors IDEs
2 Comments1 Solution3132 ViewsLast Modified:
Hello everybody;

I'm starting to use OSGi and I'm a little "noob" in the bussiness.

My problem is the next;

I have a bundle that I need to be singleton, because it must be accessed by another two bundles at the same time; I mean, two different bundles are going to use it, and when one of them modifies some of the values inside the first bundle, the change must be seen by the second bundle.

I'm working with Eclipse and in the file there's an option to make the bundle singleton, but I don't know if that's working.

I explain: To probe if the bundle is singleton, I used the option in the file to make "plug-in as singleton". Then, I inserted a new property inside the first bundle(the one that must be singleton). The property is just an String, message, who's default value is "Not altered".I also implemented two function, setMessage(String) and getMessage.
Well, with the second bundle I modify the value to "Altered by bundle2". But when I read the value with bundle3, the message value is ALWAYS "Not altered" , UNLESS I set Message as STATIC.

My doubt is the next; When I put Message as static, it always works. I modify the value and when I read it , it writes "Altered by bundle2", perfect. But that works always, even If I don't choose the "this plug-in as singleton" option in the file. It seems that it doesn't care if I mark it as singleton if I just put static in the property.

But this way I don't know if it's really a singleton or what. It doesn't make sense to me... does this mean that if I want the actualized values of the properties I need to mark them as static, and nothing else?

I attach an Image because my english is soooo poor and I don't know if I explain correctly what I want to do.

Thanks a lot for your time dudes,

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros