Harvesting the power of Eclipse 4 Context Functions

Session Type: 
Standard Talk [25 minutes]

With the new dependency injection framework provided with Eclipse 4 you can inject services anywhere you need them. Context Functions can be used for providing the specific implementation to the interface. The special thing about them is that this relation can be a function of the Eclipse Context's state rather than a predefined, hard-wired Interface-Implementation connection.

By design the framework makes it possible to customize the way this wiring is made. This ability opens up a wide range of dynamics which can be performed in the process of selecting the service implementation.

Harvesting this power for the needs of your own application is the topic of this talk. The talk will demonstrate this using two examples:

1 - Dynamically selecting a different implementation of the same service based on a value in the context. This will be a sample 911 emergency call service (only one dispatch() method) which dispatches a police, firetruck or ambulance depending on the word (fire, crime or accident) in the call for help (state of the Eclipse Context).

2 - By using web service clients as injected services, we will see a dynamic switching of dispatch requests to different places in some kind of mini fail-over (will simulate the failing of a service) and load-balancing mechanism. All done inside the context function.

An emphasis will be put on the fact that all this is completely transparent to the user. The client of the injection keeps using @Inject without being aware of the dynamics behind.

This talk will benefit the attendants in showing the power of the Context Functions in the Eclipse framework because, even though public API, being deep in the guts of the Eclipse code makes it not commonly looked at and thus not commonly exploited.

Schedule info



Eclipse Technology
Experience level: 

Copyright © 2012 The Eclipse Foundation. All Rights Reserved.