Hi Dhiego,
I suggest you look into an existing implementation of dependency management and
injection such as OSGi Declarative Services (my favorite) or OSGi Blueprint. In
addition there exist other things like Apache Felix iPojo or Apache Felix
DependencyManager.
All of these help you with managing components and their dependencies and
"activating" components only when dependencies are satisified.
Regards
Felix
Am 25.02.2013 um 20:53 schrieb Dhiego Abrantes de Oliveira Martins:
> Thanks, Neil !
>
> I dont want to fix in a specific bundle. So, Im not sure about 'bad smell'.
> :-)
>
> Im implementing a kind of mechanism for automatic activation, given a
> request to my component.
> I have a mapping of ObjectX and if this object is resolved, all items of
> dependence must be resolved as well.
>
> *For example:*
> <objectX>
> <service1 service-spec="br.com.dhiego.ServiceOne">
> <service2 service-spec="br.com.dhiego.ServiceTwo">
> <service3 service-spec="br.com.dhiego.ServiceThree">
> </ objectX>
>
> No matter what happens, if my ObjectX is called, services 1, 2 and 3 must
> be activated. For this, I need to check the bundles that provide these
> services ("service-spec" tag, in xml) and then activate them.
>
>
> Abs,
> __
> *Dhiego** **Abrantes** de Oliveira Martins*
> *Computer Science, M.Sc. Candidate at UFPE*
> www.dhiegoabrantes.com
> +55 83 9999.1081
> ***Any fool can write code that a computer can understand. Good programmers
> write code that humans can understand*. (Martin Fowler)
>
>
> 2013/2/25 Neil Bartlett <[email protected]>
>
>> No. Only active bundles can provide services. And in fact, bundles can
>> choose to register or unregister services whenever they like, as long as
>> they remain active, so you can't assume the bundle will provide a service
>> simply because it is active.
>>
>> As the consumer of a service you shouldn't care about the state of the
>> bundle it comes from, or indeed which bundle it comes from. Attempts to do
>> this constitute a very bad "code smell" in OSGi.
>>
>> Neil
>>
>>
>> On Mon, Feb 25, 2013 at 7:14 PM, Dhiego Abrantes de Oliveira Martins <
>> [email protected]> wrote:
>>
>>> Hi,
>>>
>>> I need to find the bundle that provides or implements a service
>>> br.com.dhiego.ServiceOne, for example.
>>>
>>> If the bundle is running, a service reference is returned, no problems
>>> here. However, if it was stopped, nothing is returned.
>>>
>>> So, I need all bundles, even resolved (stopped, but installed) bundles
>> that
>>> provides or implements this service.
>>>
>>> It's possible? How can I do? Anyone can help-me?
>>>
>>> []'s
>>>
>>> Dhiego
>>>
>>
--
Felix Meschberger | Principal Scientist | Adobe
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]