Community
Participate
Working Groups
In an typical riena-application OSGI-Services don't get unbound while the application is running, so why do have to write a bind and unbind method for every service? At the moment we have to inject a service like this: private IMyService myService; @InjectService public void bind(IMyService service) { this.myService = service; } public void unbind(IMyService service) { this.myService = null; } I would prefer to declare the InjectService-Annotation on the member variable itself and get rid of the boilerplate code: @InjectService private IMyService myService;
Just my 2 € cents: Even if we assume that an unbind() is very unlikely to be called in ´typical´ rcp application I wonder how this: @InjectService private IMyService myService; can handle injection of multiple services (same interface). Additionally encapsulating the access with bind/unbind allows to perform special actions in case a service arrives or goes away.
I think the way to go is to use the JSR 330 that e4 is using to live and die with all the limitation and capibilities they have. My 2 cent on member injection versus method injection is that you probably could use both in different usecases. I would like to keep bind and unbind and there are (as Stefan pointed out) a number of disadvantages of using member variable injection. - you get no event on bind and unbind - no injection of multiple services So on member variable injection you would assume that always require the attribute service ranking to make sense. (or use that as default)
Don't get me wrong. The member injection should just be an option, not the only choice. +1 on JSR 330 support in Riena!
sooner or later we are going to switch to JSR-330 whch allows this already. I see no advantage to extend our own injection mechanism.