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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to