Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




Eclipse Plug-in Developer Guide
Previous Page Home Next Page


The workbench defines a number of services that can be retrieved from the Services provide a way for components to retrieve information about the workbench without always having to go to the global singleton: PlatformUI.getWorkbench(). For example:

		IHandlerService handlerService = (IHandlerService) getSite()

Some services provide 2 optional abilities, which are usually specified in the service interface javadoc:

  • Services that support listeners can clean up the listeners automatically when the component's (used to get the service) is disposed.
  • Services can provide more localized services depending on which component they are requested from.

See Associating a handler programmically with a command... for an example of the activation localization provided by the org.eclipse.ui.handlers.IHandlerService.

Services Provided by the Workbench

The services provided to by the workbench now includes some of the most common services that an org.eclipse.ui.IWorkbenchPart would require. Support for service related optional abilities are specified in the service javadoc. The availability of the service is at and below the level specified.

Service Description Availability
IBindingService Provides services related to the binding architecture (e.g., keyboard shortcuts) within the workbench. Globally
ICommandService Provides services related to the command architecture within the workbench. Globally
ICommandImageService Provides a look-up facility for images associated with commands. Globally
IContextService Provides services related to contexts in the Eclipse workbench, like context activation and definitions. Globally
IContributionService Instances of this service are capable of providing standard mechanisms that clients may use to order, display, and generally work with contributions to the Workbench. Globally
IEvaluationService Evaluate a core expression against the workbench application context and report updates using a Boolean property. Also provides the main source for the workbench application context. Globally
IFocusService Tracks focusGained and focusLost events for a Control registered with this service, and provides the control and its registered ID as variables to the application evaluation context for evaluation by the various services. Globally
IHandlerService Provides services related to activating and deactivating handlers within the workbench. Globally
IMenuService Provides services related to the menu architecture within the workbench. It can be used to populate MenuManagers and ToolBarManagers by components. Globally
IPageService A page service tracks the page and perspective lifecycle events within a workbench window. Workbench Window
IPartService A part service tracks the creation and activation of parts within a workbench window. Workbench Window
IProgressService The progress service is the primary interface to the workbench progress support. Globally
IWorkbenchSiteProgressService The part progress service is an IProgressService that adds API for jobs that change the state in a IWorkbenchPartSite while they are being run. Part Site
ISaveablesLifecycleListener Parts that implement org.eclipse.ui.ISaveablesSource should notify their ISaveablesLifecycleListener, available as a service from their site, about org.eclipse.ui.Saveable objects that have been added to or removed from the part. Implementations of ISaveablesSource that are not parts should retrieve this service from the org.eclipse.ui.IWorkbench object. Globally
ISelectionService A selection service tracks the selection within an a workbench window. Workbench Window

Contributing a Service

Plug-in developers providing a framework in eclipse may also want to provide a service. This can be done using the extension point. Define a service factory based on and then specify what services the factory can return. A factory can create more than one type of service, but multiple factories cannot contribute to the same service type.


The create method of the passes in 3 parameters:

Workbench services are organized so there is a global service providing the needed functionality, and a chain of children services. The children services provide the listener cleanup and any data needed to localize the service request.

A service factory should return the global service when the parentLocator returns null when asked for the serviceInterface. The global service may be the implementation, or a proxy to a plugin provided manager or OSGi service.

		Object parentService = parentLocator.getService(IPersonService.class);
		if (parentService == null) {
			return new PersonService(locator);
		return new PersonServiceSlave(locator, (IPersonService) parentService);
		// or ...
		Object parentService = parentLocator.getService(IPersonService.class);
		if (parentService == null) {
			return Activator.getDefault().getPersonManager();
		return new PersonServiceSlave(locator, (IPersonService) parentService);
		// or as a front to an OSGi service.
		Object parentService = parentLocator.getService(IPersonService.class);
		if (parentService == null) {
			PersonServiceProxy proxy = new PersonServiceProxy(locator,
			return proxy;
		PersonServiceProxy proxy = new PersonServiceProxy(locator,
		return proxy;

In the OSGi service snippet above, instead of having each child IPersonService know its parent, each IPersonService talks directly to the OSGi service and uses the parent to calculate its "level" which allows it to localize any functionality it provides.

  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire