Hi

On Tue, 2009-04-28 at 05:39 +0300, Ittay Dror wrote:
> >   
> I'm working with spring-dm. Generally, I don't like the fact that I now 
> need to inject everything. As for my real use case, it is not possible, 
> since the code requires several Handler objects.

IMHO, I don't see how you can avoid "injection" without actually
coupling against an API. You will either be coupled against OSGi's API,
or your own method for obtaining the handlers (Manager.get() method). If
you're not keen on setter injection, I believe iPOJO supports field
injection (which means that you'll only need to write instance variable
declaratios instead of methods). Spring DM might to too heavyweight for
your needs, but if you're already using it for something else (like its
JMS or JTA helpers) its probably best to stick with that.

I don't really see the problem with injection if you only have a few
handlers per POJO, but if you have dozens or need to manage them
dynamically, you may want to rethink how you're going about things. OSGi
supports service filtering based on an OSGI filter expression, which may
better suit your requirements (as you can construct the string at
runtime in a helper class and use that to obtain the services).

Furthermore, if you need to inject an array of handlers, it should be
possible to do that too. 

Cheers
Chris





---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to