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.
Eclipse4/RCP/EAS/OSGi Services
< Eclipse4 | RCP | EAS
Revision as of 08:33, 12 April 2011 by Unnamed Poltroon (Talk) (New page: The Eclipse 4 dependency injection framework exposes '''OSGi services''' for consumption to clients by default. This removes a lot of the boilerplate <tt>ServiceTracker</tt> code and allow...)
The Eclipse 4 dependency injection framework exposes OSGi services for consumption to clients by default. This removes a lot of the boilerplate ServiceTracker code and allows clients to simply annotate a field to have an OSGi service injected.
OSGi APIs
public class Model { private EventAdmin eventAdmin; public Model(BundleContext ctxt) { ServiceTracker tracker = new ServiceTracker<EventAdmin, EventAdmin>(ctxt, EventAdmin.class, null); tracker.open(); eventAdmin = tracker.getService(); } }
Eclipse 4 Dependency Injection
public class Model { @Inject private EventAdmin eventAdmin; }