Question about @EventTopic annotations [message #870134] |
Sun, 06 May 2012 21:38 |
Fabio Mancinelli Messages: 16 Registered: July 2009 |
Junior Member |
|
|
Hi everybody,
I am playing with the IEventBroker service and @EventTopic injections
but I have some unexpected behaviors that I don't understand, so I am
asking for some help.
I am using Eclipse Juno M6 + Eclipse E4 Tools + Eclipse E4 Tools Bridge
for 3.x
Basically I have two POJOs (PublishView and SubscribeView) that define
two views, one with a button for posting events, and the other one which
defines a handler.
I also have two DIViewPart for displaying these views inside an instance
of the SDK.
The code is pretty straighforward and it's here:
http://pastebin.com/dTTq4Knw
The PublishView has an injected IEventBroker field so that I can do a
eventBroker.send("foo", "Hello") when the button is pressed.
The SubscribeView has the following method for handling the events
posted on the "foo" topic:
@Inject
public void handleFoo(@EventTopic("foo") Object data) {
System.out.format("Received foo: %s\n", data);
}
Now, what I expected was to see on the console a "Received foo: hello"
message each time I press the button. But, instead, I have the following
behavior:
1) If I run the plugin in the SDK, at startup I see on the console a
message like this one:
Received foo:
org.eclipse.equinox.console.command.adapter.CommandProviderAdapter@217a26f4
1.1) When I click the button, eventBroker.send("foo", "hello") is called
but nothing is received by the handler
2) If I run the plugin as an E4 RCP application, at startup I see on the
console the following exception:
org.eclipse.e4.core.di.InjectionException: Unable to process
"SubscribeView#handleFoo()": no actual value was found for the argument
"Object[@org.eclipse.e4.ui.di.UIEventTopic(value=foo)]".
2.1) If I click the button everything works. I correctly see "Received
foo: Hello" messages on the console every time I press the button.
Now the questions are:
* What are the two "spurious" events that I receive at startup? I mean,
"foo" is not a topic that should be used anywhere in the platform, so
why do I receive events from the platform on that topic?
* Why the brokering mechanism doesn't work in the SDK while it seems to
work fine in the RCP application? Is it a limitation of the Bridge?
Thank you for your help.
-Fabio
|
|
|
Re: Question about @EventTopic annotations [message #870169 is a reply to message #870134] |
Mon, 07 May 2012 06:56 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
Am 06.05.12 23:38, schrieb Fabio Mancinelli:
> Hi everybody,
>
> I am playing with the IEventBroker service and @EventTopic injections
> but I have some unexpected behaviors that I don't understand, so I am
> asking for some help.
>
> I am using Eclipse Juno M6 + Eclipse E4 Tools + Eclipse E4 Tools Bridge
> for 3.x
>
> Basically I have two POJOs (PublishView and SubscribeView) that define
> two views, one with a button for posting events, and the other one which
> defines a handler.
>
> I also have two DIViewPart for displaying these views inside an instance
> of the SDK.
>
> The code is pretty straighforward and it's here:
> http://pastebin.com/dTTq4Knw
>
> The PublishView has an injected IEventBroker field so that I can do a
> eventBroker.send("foo", "Hello") when the button is pressed.
>
> The SubscribeView has the following method for handling the events
> posted on the "foo" topic:
>
> @Inject
> public void handleFoo(@EventTopic("foo") Object data) {
> System.out.format("Received foo: %s\n", data);
> }
>
> Now, what I expected was to see on the console a "Received foo: hello"
> message each time I press the button. But, instead, I have the following
> behavior:
>
> 1) If I run the plugin in the SDK, at startup I see on the console a
> message like this one:
>
> Received foo:
> org.eclipse.equinox.console.command.adapter.CommandProviderAdapter@217a26f4
>
> 1.1) When I click the button, eventBroker.send("foo", "hello") is called
> but nothing is received by the handler
>
> 2) If I run the plugin as an E4 RCP application, at startup I see on the
> console the following exception:
>
> org.eclipse.e4.core.di.InjectionException: Unable to process
> "SubscribeView#handleFoo()": no actual value was found for the argument
> "Object[@org.eclipse.e4.ui.di.UIEventTopic(value=foo)]".
>
You should put a @Optional in there and the message will go away.
> 2.1) If I click the button everything works. I correctly see "Received
> foo: Hello" messages on the console every time I press the button.
>
> Now the questions are:
>
> * What are the two "spurious" events that I receive at startup? I mean,
> "foo" is not a topic that should be used anywhere in the platform, so
> why do I receive events from the platform on that topic?
It looks like the event injection code is not stepping in correctly
>
> * Why the brokering mechanism doesn't work in the SDK while it seems to
> work fine in the RCP application? Is it a limitation of the Bridge?
>
Need to check this but there should not be a difference. I'll come back
once I tried this my own.
Tom
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.27289 seconds