Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How to set services into handler
How to set services into handler [message #485225] Thu, 10 September 2009 20:30 Go to next message
Eclipse UserFriend
Originally posted by: iossif.gmx.de

Hi,

i've got a very simple question. I have a simple application where I
defined some handler under the org.eclipse.ui.handler extension point.

I also created some handler-classes implementing the execute-method.
There I want to call a simple service-method of service class outside of
the application. At the moment I simply create an instance and call the
service. But thats not what I need, because I want to configure the
service into the handler class. Also remembering the IoC-Principle I
want to set the service into that class.

How do I get the service into the handler or where do I configure the
properties of the handler?

Whats the recommended way?

Thanks for your help
Re: How to set services into handler [message #485268 is a reply to message #485225] Fri, 11 September 2009 04:51 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.Friend
Messages: 621
Registered: July 2009
Senior Member
iossif wrote:
> How do I get the service into the handler or where do I configure the
> properties of the handler?

Which service are you referring to?

--
- Prakash

Platform UI Team, IBM
http://blog.eclipse-tips.com
Re: How to set services into handler [message #485291 is a reply to message #485268] Fri, 11 September 2009 08:32 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 5
Registered: September 2009
Junior Member
Prakash G.R. wrote:

> Which service are you referring to?

Hi,

its nothing special. In this case its a service that sends a message to a
remote interface.

this.service.send(ShortMessage shortMessage);

Another example I ask for how to get the service class into the handler:

this.presenter.openEditor(Favorite favorite);

The presenter opens an editor with the actual favorite selection. How to
put the presenter into the handler?

I'am a little bit confused where the handlers are created and where to set
my services into this handlers. The handler examples I've seen before
don't use external infrastructure or stupidly create their dependencies
themself inside the handler.

You see, its a more general question, where to set such services classes
into a handler. Maybe I am on the wrong track.

Are there any best practices?

Thanks
Re: How to set services into handler [message #485369 is a reply to message #485291] Fri, 11 September 2009 14:00 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Well ...

Currently when the handler executes, it gets the ExecutionEvent and from that can get the application context. That's an IEvaluationContext. From there you have access to any variables coming from a source provider (like the ones listed in org.eclipse.ui.ISources).

As for services, there are 2 kinds.

1) OSGi services. They can be requested from your BundleContext/ServiceTracker, usually be interacting with your Activator.

2) eclipse framework services. They're contributed through the org.eclipse.ui.services EP and retrieved through an IServiceLocator. Current IServiceLocators are any editor or view site, the workbench windows, and the workbench (PlatformUI.getWorkbench()) itself.

currently, you can reach out to a workbench/part/window or use OSGi services and your activator. We hope to add a way to get an IServiceLocator from your ExecutionEvent or application context.

PW


Re: How to set services into handler [message #485483 is a reply to message #485369] Fri, 11 September 2009 22:00 Go to previous message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 5
Registered: September 2009
Junior Member
Paul Webster schrieb:
> Well ...
> Currently when the handler executes, it gets the ExecutionEvent and from
> that can get the application context. That's an IEvaluationContext.
> From there you have access to any variables coming from a source
> provider (like the ones listed in org.eclipse.ui.ISources).
>
> As for services, there are 2 kinds.
>
> 1) OSGi services. They can be requested from your
> BundleContext/ServiceTracker, usually be interacting with your Activator.

Thats it! Thanks for advice!

I will use OSGi services in conjunction with Spring DM because I already
have some application contexts on my client. So the only thing I need to
do: publish them as OSGi-Services.

Advice for followers: I found easy to use information on
http://springosgi.googlepages.com/ch03.html.

> 2) eclipse framework services. They're contributed through the
> org.eclipse.ui.services EP and retrieved through an IServiceLocator.
> Current IServiceLocators are any editor or view site, the workbench
> windows, and the workbench (PlatformUI.getWorkbench()) itself.

I will rethink that option for controlling views and presentation logic.
Previous Topic:General Question about Handlers & Commands
Next Topic:Customize Perspective Dialog not working
Goto Forum:
  


Current Time: Tue Apr 23 17:39:03 GMT 2024

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

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

Back to the top