Exactly. You can also use PublishHook to see when people register a service and then register your corresponding wrapped service. --
BJ Hargrave Senior Technical Staff Member, IBM OSGi Fellow and CTO of the OSGi Alliance [email protected] office: +1 386 848 1781 mobile: +1 386 848 3788 From: David Bosschaert <[email protected]> To: OSGi Developer Mail List <[email protected]> Date: 2009/01/13 12:46 Subject: Re: [osgi-dev] Interceptors in OSGi for Services : local and remote Sent by: [email protected] Hi Des, AFAIK, the spec doesn't say anything about snooping. However, one thing you could do is register an additional OSGi Service implementing the same interface in the OSGi Service Registry and then simply forward calls to the service you want to snoop. You can even prevent bundles from seeing the original service (so they will get yours) when they look up the service. This can be done using a FindHook [1]. The FindHook has the following API: void find(BundleContext context, java.lang.String name, java.lang.String filter, boolean allServices, java.util.Collection references) The findhook API is designed to allow references to be removed from the references collection. You can implement a findhook that removes visibility of the real service for certain bundles so that your snoop service will be used by those bundles instead. FindHook is a feature that was introduced recently in the OSGi Service Registry (RFC 126). I think today its only implemented by the latest Equinox 3.5. Hope this helps... David [1] RFC 126 in http://www.osgi.org/download/osgi-4.2-early-draft2.pdf Des Carbery wrote: > Hi - > > I'm trying to write a bundle that can be deployed into any OSGi > container that will be able to snoop on all OSGi Service calls. I'm > interested in monitoring Service calls between bundles, local and > remote. I want my bundle to add an interceptor to all Service > invocations in order to monitor the traffic. > > I've gone through the draft 4.2 spec and I was hoping that either "RFC > 126 - Service Registry Hooks" or "RFC 119 - Distributed OSGi" would > provide some new standardised mechanism to do this. However I can't > find any way to do this. > > When I read the section "7 Considered Alternatives" there seemed to be > a number of suggestions that would fulfill my requirements which were > ruled out intentionally. > > Is there something else in the 4.2 draft or in an earlier spec that > can enable me to write such a bundle? > > Regards, > Des > > > ------------------------------------------------------------------------ > > _______________________________________________ > OSGi Developer Mail List > [email protected] > https://mail.osgi.org/mailman/listinfo/osgi-dev _______________________________________________ OSGi Developer Mail List [email protected] https://mail.osgi.org/mailman/listinfo/osgi-dev
_______________________________________________ OSGi Developer Mail List [email protected] https://mail.osgi.org/mailman/listinfo/osgi-dev
