dependency injection - Best practices for Eclipse 4 DI -


i'd know best practices eclipse 4 dependency injection. after reading subject on internet, came following strategy.

requirements

share data model of application (e.g. company, employee, customer, ...) framework objects (view parts, handlers, listeners, ...) can access little coupling possible.

proposed strategy

  • i've used lifecycleuri plugin property register handler triggered @ application startup. such handler creates "empty" top-level data model container object , place eclipsecontext. discarded when application stops.

  • all eclipse framework classes (view parts, handlers) use classic di such data model object injected.

  • button listeners created class constructor can't have data model object injected in them. thought created contextinjectionfactory.make() have injection performed. couple class creates listener cif, great advantage injection works out of box.

this best solution i've found yet leverage e4 di little coupling possible. weak spot in opinion coupling cif. question whether strategy exist remove coupling, or alternate solutions same requirements.

you can create service class in project, let's modelservice.

add @creatable , @singleton annotations class :

@creatable @singleton class modelservice{  } 

and let di job using following syntax in parts/handlers/etc ..

@inject modelservice modelservice; 

then can implement methods in service 'createbasemodel()', updatemodel() , on.

this creates low coupling solution : can implement modelservice in separate plugin , define osgi service. solution, can read this lars vogel article.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -