Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Injecting preferences
Injecting preferences [message #1622033] Wed, 18 February 2015 08:03
Mateusz Malinowski is currently offline Mateusz MalinowskiFriend
Messages: 36
Registered: March 2013
Location: Bristol
Hi all,

I'm not entirely sure if I know how injecting preferences actually works. In Lars Vogel tutorial about preferences [1] in chapter 2 there is information that "The nodePath is the file name used to save the preference values to disk. By default this is the Bundle-SymbolicName of the plug-in. The value parameter specifies the preference key for the value which should be injected."

Having said that, the example at the end of that chapter should call trackUserSettings and trackPasswordSettings methods only once.
prefs.put("user", "TestUser");
should call the first method and
prefs.put("password", "Password");
the second.

I decided to create a new project using the following version of Eclipse:
Version: Kepler Service Release 2
Build id: 20140224-0627

Kepler is the same version on which [1] was based, according to its heading.

The reason I'm posting here is that in my case, both methods are called twice. At the first time user name is set to "TestUser" and password is injected as null, on the second time, user name is re-injecting the same value and password is set to "Password". Shouldn't those calls be split? I mean, when I set "user", shouldn't only methods that listen on that value, be called? Moreover, because I don't have "@Optional" annotation for my methods, shouldn't null values be omitted, according to [2]?

I'm more interested in the answer about injecting methods on preference values change, than the correct behaviour of "@Optional" annotation in this case. This example is very basic, but we can imagine more sophisticated methods that requires multiple values to be injected from preferences. I'd prefer not to store all injecting values as class variables to compare them each time method is triggered.

Many thanks,

Previous Topic:No events received when I listen outside the class who sends
Next Topic:Injecting own object to global Eclipse context
Goto Forum:

Current Time: Thu Jan 28 06:23:42 GMT 2021

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

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

Back to the top