You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by chronozphere <ch...@gmail.com> on 2011/05/27 21:22:45 UTC

Passing services to other bundles

Hello,

I'm using felix for a project of mine that uses a lot of services/interfaces
for communication between bundles. For example, one bundle contains a
manager to manage X resources. Each X resource contains multiple Y resources
and every Y resource has some Z resources. Ofcourse, these resources are
accessible as services.

It is tempting to let this bundle register an XManager service, who's
interface just returns X service interfaces (my own defined type). The good
thing about this is that other modules can directly access the X resources
and their corresponding Y and Z resources.

However, I have the impression that you have to use the mechanism provided
by ServiceReference and context.getService(). This would mean that I have to
keep track of all X service-instances in each of my client bundles, in order
to unget them when no longer needed. Moreover, I would need to do the same
with the Y and Z that can be accessed through each X service. I would need a
big number of getService() calls all over my code and it wouldn't look nice.

So, is it neccesary to use the getService/ungetService calls EVERYTIME you
want to access services from other bundles, or can I just pass the
interfaces around if I want? What are the implications of doing the latter? 

Thanks alot!

P.S: The bundles I'm programming are not part of a program which is
completely used offline. So the bundles will be available at all times
during the program's lifetime.
-- 
View this message in context: http://old.nabble.com/Passing-services-to-other-bundles-tp31719679p31719679.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Passing services to other bundles

Posted by chronozphere <ch...@gmail.com>.
Thanks for your reply! 

So the only "real" service here is the one at the root (The manager). I was
under the impression that everything that was passed over a bundle-bundle
boundary had to be a service, but I guess you're right. The resources are
just objects that don't really correspond to services.


Richard S. Hall wrote:
> 
> Why make them available as services if you don't want to access them as 
> services? Just create one service (e.g., a ResourceRegistry) from which 
> you can access your other objects.
> 
> Otherwise, use something like iPOJO or DS to manage your services for 
> you and don't worry about it.
> 
> -> richard
> 
> On 5/27/11 15:22, chronozphere wrote:
>> Hello,
>>
>> I'm using felix for a project of mine that uses a lot of
>> services/interfaces
>> for communication between bundles. For example, one bundle contains a
>> manager to manage X resources. Each X resource contains multiple Y
>> resources
>> and every Y resource has some Z resources. Ofcourse, these resources are
>> accessible as services.
>>
>> It is tempting to let this bundle register an XManager service, who's
>> interface just returns X service interfaces (my own defined type). The
>> good
>> thing about this is that other modules can directly access the X
>> resources
>> and their corresponding Y and Z resources.
>>
>> However, I have the impression that you have to use the mechanism
>> provided
>> by ServiceReference and context.getService(). This would mean that I have
>> to
>> keep track of all X service-instances in each of my client bundles, in
>> order
>> to unget them when no longer needed. Moreover, I would need to do the
>> same
>> with the Y and Z that can be accessed through each X service. I would
>> need a
>> big number of getService() calls all over my code and it wouldn't look
>> nice.
>>
>> So, is it neccesary to use the getService/ungetService calls EVERYTIME
>> you
>> want to access services from other bundles, or can I just pass the
>> interfaces around if I want? What are the implications of doing the
>> latter?
>>
>> Thanks alot!
>>
>> P.S: The bundles I'm programming are not part of a program which is
>> completely used offline. So the bundles will be available at all times
>> during the program's lifetime.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Passing-services-to-other-bundles-tp31719679p31719799.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Passing services to other bundles

Posted by "Richard S. Hall" <he...@ungoverned.org>.
Why make them available as services if you don't want to access them as 
services? Just create one service (e.g., a ResourceRegistry) from which 
you can access your other objects.

Otherwise, use something like iPOJO or DS to manage your services for 
you and don't worry about it.

-> richard

On 5/27/11 15:22, chronozphere wrote:
> Hello,
>
> I'm using felix for a project of mine that uses a lot of services/interfaces
> for communication between bundles. For example, one bundle contains a
> manager to manage X resources. Each X resource contains multiple Y resources
> and every Y resource has some Z resources. Ofcourse, these resources are
> accessible as services.
>
> It is tempting to let this bundle register an XManager service, who's
> interface just returns X service interfaces (my own defined type). The good
> thing about this is that other modules can directly access the X resources
> and their corresponding Y and Z resources.
>
> However, I have the impression that you have to use the mechanism provided
> by ServiceReference and context.getService(). This would mean that I have to
> keep track of all X service-instances in each of my client bundles, in order
> to unget them when no longer needed. Moreover, I would need to do the same
> with the Y and Z that can be accessed through each X service. I would need a
> big number of getService() calls all over my code and it wouldn't look nice.
>
> So, is it neccesary to use the getService/ungetService calls EVERYTIME you
> want to access services from other bundles, or can I just pass the
> interfaces around if I want? What are the implications of doing the latter?
>
> Thanks alot!
>
> P.S: The bundles I'm programming are not part of a program which is
> completely used offline. So the bundles will be available at all times
> during the program's lifetime.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org