Search code examples
javaosgiinterceptorkarafblueprint-osgi

How to register an org.apache.aries.blueprint.Interceptor in OSGi Karaf?


I'm trying to implement a simple Interceptor to invoke methods of registered services in an OSGi Karaf environment. The services are published via blueprint configuration and, although there are working examples how to intercept CXF web-services, I can't find any documentation of how to register an implementation of org.apache.aries.blueprint.Interceptor.

This feature must have been introduced a few years ago according to Jira.

In broadest sense this question is related to Can I inject proxies in front of Blueprint services published by other bundles? that is solved with proxies whereas an interceptor approach is only discussed on the surface.

If the functionality I'm looking for is labeled differently within apache terminology, I'd still find a working end-2-end example very useful as the thread above only states the theoretical approach.


Solution

  • You can only add blueprint interceptors in namespace handlers not completely outside the bundle.

    For an example of implementing a namespace see blueprint-authz. As you can see in the example you will have to introduce a simple element that the user has to add to his xml. This seems to be the only way to get a hook into the blueprint initialization.