Skip to main content



      Home
Home » Eclipse Projects » Eclipse 4 » Eclipse Event System(Register for an Event without any Object)
Eclipse Event System [message #1690677] Mon, 30 March 2015 10:54 Go to next message
Eclipse UserFriend
Hi,

I came across some very strange behavior of the eclipse event system.
Lets consider the following injected methods:
(the difference is the method argument String<->Object)

    @Inject
    @Optional
    public void test1(@UIEventTopic("someEvent") String unused) {
        System.out.println("hello 1");
    }
    
    @Inject
    @Optional
    public void test2(@UIEventTopic("someEvent") Object unused) {
        System.out.println("hello 2");
    }


Since I only use the event (and no object which may be sent with it), I thought that it might be a good idea to just declare the argument as java.lang.Object unused.

But: what happens now is that the method test1 works fine and the method test2 does not. It is called once during object creation but never again.

Does anybody know why this might be? Thank you!
Re: Eclipse Event System [message #1690683 is a reply to message #1690677] Mon, 30 March 2015 11:16 Go to previous messageGo to next message
Eclipse UserFriend
The problem most likely is that someone store an object under the key
java.lang.Object and this way overrules the ExtendedObjectSupplier which
is an extension only queried if the value is NOT found in the
IEclipseContext.

Try to change it to:

public void test2(@UIEventTopic("someEvent")
@Named("_you_will_never_find_me") Object unused) {

Tom

On 30.03.15 16:55, Alexander Klatt wrote:
> Hi,
>
> I came across some very strange behavior of the eclipse event system.
> Lets consider the following injected methods:
> (the difference is the method argument String<->Object)
>
>
> @Inject
> @Optional
> public void test1(@UIEventTopic("someEvent") String unused) {
> System.out.println("hello 1");
> }
> @Inject
> @Optional
> public void test2(@UIEventTopic("someEvent") Object unused) {
> System.out.println("hello 2");
> }
>
>
> Since I only use the event (and no object which may be sent with it), I
> thought that it might be a good idea to just declare the argument as
> java.lang.Object unused.
>
> But: what happens now is that the method test1 works fine and the method
> test2 does not. It is called once during object creation but never again.
>
> Does anybody know why this might be? Thank you!
Re: Eclipse Event System [message #1690689 is a reply to message #1690683] Mon, 30 March 2015 11:42 Go to previous messageGo to next message
Eclipse UserFriend
Thank you! I did not know this... quite an easy pitfall Very Happy.
Re: Eclipse Event System [message #1690698 is a reply to message #1690689] Mon, 30 March 2015 12:32 Go to previous messageGo to next message
Eclipse UserFriend
Yeah I guess fairly nobody does know :-( and IMHO this is an unfixable
bug in the DI container because the core does not know about those
extensions.

Tom

On 30.03.15 17:42, Alexander Klatt wrote:
> Thank you! I did not know this... quite an easy pitfall :d.
Re: Eclipse Event System [message #1690708 is a reply to message #1690698] Mon, 30 March 2015 13:44 Go to previous messageGo to next message
Eclipse UserFriend
Hmm, this behaviour was fixed with bug 398728 back in 4.2.1.

Alexander, do you have a small test case that demonstrates the problem?

Brian.
Re: Eclipse Event System [message #1690772 is a reply to message #1690708] Tue, 31 March 2015 03:42 Go to previous messageGo to next message
Eclipse UserFriend
Okay thanks Brian, this is good to know. The explanation for this is that I still use 4.3 Kepler.
Re: Eclipse Event System [message #1690852 is a reply to message #1690772] Tue, 31 March 2015 11:29 Go to previous messageGo to next message
Eclipse UserFriend
If you're running against 4.3 then you shouldn't be encountering this bug, Alexander. Can you try commenting out your test1 method -- I wonder if it's something to do with having multiple methods within the same class.

Brian.
Re: Eclipse Event System [message #1690971 is a reply to message #1690852] Wed, 01 April 2015 06:54 Go to previous message
Eclipse UserFriend
Okay I probably need to describe my settings a bit further:

- I use a target platform definition for an RCP application
- I import the eclipse plug-ins via the kepler release site: http://download.eclipse.org/releases/kepler
- The version of org.eclipse.e4.core.di is 1.3.0.v20130514-1256

Am I importing it in a wrong way? Or was your bug-fix only applied to Luna?
Previous Topic:Adding a custom widget to MToolBar
Next Topic:change Context for @Inject
Goto Forum:
  


Current Time: Sat Jul 12 17:35:36 EDT 2025

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

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

Back to the top