Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » @Preferences get injected even they don't change
@Preferences get injected even they don't change [message #1097168] Thu, 29 August 2013 10:18 Go to next message
Nepomuk Seiler is currently offline Nepomuk SeilerFriend
Messages: 88
Registered: December 2010
Member
Hi,

I have a problem with the injection-based listener approach. Values get injected, even if they haven't changed.

I have a handler class which contains these values these methods

@Inject
public void trackDatabaseDriver(@Preference("jdbc_driver") String driver) {
	System.out.println("\tDriver   :\t" + driver);
}

@Inject
public void trackDatabaseURL(@Preference("jdbc_url") String url) {
	System.out.println("\tURL   :\t" + url);
}


And another handler which does this

@Inject
@Preference
IEclipsePreferences preferences;

@Execute
public void execute() throws Exception {
    // doesn't matter where/if I put preferences.flush()
    preferences.put("jdbc_driver", "org.apache.derby.jdbc.EmbeddedDriver");
    preferences.put("jdbc_url", "jdbc:derby:memory:test2;create=true");
}


The flow is as follows.

Application start

Quote:

URL : null
Driver : null


I'm not completely sure why the values get injected, even they didn't changed.

[b]Click SavenPreferencesHandler[b]

Quote:

URL : null
Driver : org.apache.derby.jdbc.EmbeddedDriver
URL : jdbc:derby:memory:test2;create=true
Driver : org.apache.derby.jdbc.EmbeddedDriver


The methods are called twice. Both. Even though I only changed each preference once.


If I use the PreferenceChangeListener it works smooth.

preferences.addPreferenceChangeListener(new IPreferenceChangeListener() {

    @Override
    public void preferenceChange(PreferenceChangeEvent event) {
            System.err.println("KEY " + event.getKey());
            System.err.println("NEW " + event.getNewValue());
            System.err.println("OLD " + event.getOldValue());
        }
    });



Do I have to put the preferences all in different nodes?

thanks,
Muki
Re: @Preferences get injected even they don't change [message #1102409 is a reply to message #1097168] Thu, 05 September 2013 18:38 Go to previous messageGo to next message
Joseph Carroll is currently offline Joseph CarrollFriend
Messages: 174
Registered: May 2012
Location: Milwaukee, WI
Senior Member

This is an open bug 391061

JD

[Updated on: Thu, 05 September 2013 18:38]

Report message to a moderator

Re: @Preferences get injected even they don't change [message #1103079 is a reply to message #1102409] Fri, 06 September 2013 11:05 Go to previous messageGo to next message
Nepomuk Seiler is currently offline Nepomuk SeilerFriend
Messages: 88
Registered: December 2010
Member
Hi,

Thanks. I didn't find that bug.

cheers,
muki
Re: @Preferences get injected even they don't change [message #1103240 is a reply to message #1103079] Fri, 06 September 2013 14:22 Go to previous message
Eric Moffatt is currently offline Eric MoffattFriend
Messages: 118
Registered: July 2009
Senior Member
Just tagged the defect for a look in Luna M3...if we want to encourage folks to use the new mechanisms they have to work..Wink.
Previous Topic:e4 application Compilation impossible with tycho
Next Topic:Toolbar not visible with 4.3 legacy mode
Goto Forum:
  


Current Time: Thu Nov 27 17:33:11 GMT 2014

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

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