Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » How to register an Event Broker at startup
How to register an Event Broker at startup [message #1100482] Tue, 03 September 2013 03:05 Go to next message
Thomas Wilhelm is currently offline Thomas Wilhelm
Messages: 28
Registered: September 2013
Junior Member
Hey all,

i want to register at startup of my application. I already have a LifecycleManager registered but this LifecycleManager is responsible to show the Login Dialog (as shown in the Vogella example) and i dont want to put additional functions there.

So what can i do? I tried to add a second LifeCycleManager but this doesn´t work (my first one will be disabled), can i add something like an initializer like in Eclipse 3.8 ? Any other ideas ?

Thanks for any help

Thomas
Re: How to register an Event Broker at startup [message #1100503 is a reply to message #1100482] Tue, 03 September 2013 03:35 Go to previous messageGo to next message
Christoph Keimel is currently offline Christoph Keimel
Messages: 346
Registered: December 2010
Location: Germany
Senior Member
Hi Thomas

you can add a AddOn to your application model.

Regards
Christoph
Re: How to register an Event Broker at startup [message #1100506 is a reply to message #1100503] Tue, 03 September 2013 03:37 Go to previous messageGo to next message
Thomas Wilhelm is currently offline Thomas Wilhelm
Messages: 28
Registered: September 2013
Junior Member
Hi Christoph,

thanks for you help, i also found this solution, but i didnt found a tutorial and my solution doesnt work. What i´ve done is:
- create and register a fragment
- create a model fragment and add an "Addon" for id "org.eclipse.e4.core.commands.service" (i dont think this is correct but which id do i have to use?)
- create a class having a method with @PostConstruct annotation.

The class is never called so something must be wrong.
Thanks for further help.

Thomas
Re: How to register an Event Broker at startup [message #1100570 is a reply to message #1100506] Tue, 03 September 2013 05:25 Go to previous messageGo to next message
Christoph Keimel is currently offline Christoph Keimel
Messages: 346
Registered: December 2010
Location: Germany
Senior Member
Hi Thomas

you can choose your own id for your AddOn (my.company.addon.xxx). It should not be an ID that is used by the framework.

Possible problems:
- The fragment is not loaded correctly
- @PostContstruct is not called (depending on the version you are using you might need to add a dependency to Imported Packages on javax.annotation. There are some posts on this topic in the forum.)

Try to add your AddOn to the core application model first and then move it to the fragment as soon as it works.

We use a similar approach, which probably looks much like what you are doing.
public class MyAddon {
	@PostConstruct
	public void init(final IEventBroker eventBroker) {
		eventBroker.subscribe(..., myHandler);
	}
}


Hope that helps.

Christoph
Re: How to register an Event Broker at startup [message #1100599 is a reply to message #1100570] Tue, 03 September 2013 06:20 Go to previous message
Thomas Wilhelm is currently offline Thomas Wilhelm
Messages: 28
Registered: September 2013
Junior Member
Hi Christoph,

thanks again for your help. Now i got it! My mistake was that i had a wrong "Element Id" on the Model Fragment. It must be the id of my application and the featurename must be "addons".

Now it works, thanks alot
Thomas
Previous Topic:How to handle closeable button of part
Next Topic:Injection of own objects in handler
Goto Forum:
  


Current Time: Wed Aug 20 12:51:57 EDT 2014

Powered by FUDForum. Page generated in 0.02055 seconds