[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] Registering two services in the same bundle


one concrete example where the services need to be provided as a unit is the support for JTA (coming in the Enterprise Profile soon). In the JTA case, the provider is mandated to implement 3 services and register them, among them UserTransaction and TransactionManager. Since they come from the JTA spec, they cannot be easily combined.


"In the end everything will be right. But since things are not right, we are not at the end yet!"
   -- Unknown

On Nov 16, 2009, at 3:32 PM, Neil Bartlett wrote:


While Thomas's suggestion is absolutely correct, I think you need to step back from the problem a little and ask if this is the right approach.

If your consumer bundle needs the Interface1 service then it should simply bind to an instance of Interface1. If it also needs the Interface2 service then it should just bind to Interface2. The consumer should not *require* both services to be offered by the same object, because this will severely limit the ability of other producers to offer an alternative implementation for those services. In other words, you are coupling your consumer to an implementation detail of the producer which it shouldn't care about.

On the other hand, if your API is such that these interfaces really should be published and consumed as a unit, then maybe you should just merge them into one interface, or declare a new Interface3 that extends both Interface1 and Interface2.