Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Eclipse4/RCP/Dependency Injection

< Eclipse4‎ | RCP
Revision as of 14:18, 7 April 2011 by Unnamed Poltroon (Talk)

The Eclipse 4 Application Platform provides a [| JSR 330]-compatible dependency injection (DI) framework, similar to [Spring] or [Guice].

Instead of PlatformUI.getWorkbench.getHelpSystem(), have the HelpSystem constructor injected.


DI provides a number of advantages:

  • Clients are able to write POJOs and list the services they need. The DI framework provides
  • Useful for testing: the assumptions are placed in the DI container rather than in the client code

DI has some disadvantages too:

  • Concerns about discoverability of services - cannot use code completion to find out what is available.

DI Overview

Using the E4AP DI Framework

  • plugins: org.eclipse.e4.core.di, org.eclipse.e4.core.di.extensions, and org.eclipse.e4.ui.di
  • JSR 330 annotations: @Inject, @PostConstruct, @PreDestroy, @Named
  • E4AP-specific annotations: @Preference, @Event, @UIEvent
  • The IEclipseContext

Back to the top