Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache CXF ContainerRequestFilter with RSA and DS

I'm migrating CXF REST endpoints from blueprint to Declarative Services that runs on Apache Karaf. I use Aries RSA and DOSGI. In the old code ContainerRequestFilter is used (specified in blueprint), but I am not sure how it can be used with DS? From [0] I can see that javax.servlet.Filter can be registered and I wonder what is the right approach. Is it possible to register ContainerRequestFilter by using DS annotations?

[0] http://cxf.apache.org/distributed-osgi-reference.html

like image 400
Boban Petkovic Avatar asked Feb 13 '26 09:02

Boban Petkovic


1 Answers

This is now possible using the JAX-RS Whiteboard from OSGi R7. Registering a JAX-RS extension is as simple as making it an OSGi service providing the relevant service interface(s) - in this case ContainerRequestFilter and adding the service property "osgi.jaxrs.extension=true".

By also using R7 features from Declarative Services and bnd 4.0.0 this service property can be applied to Declarative Services components using the new ComponentPropertyType meta-annotations. A standard annotation @JaxrsExtension is part of the JAX-RS whiteboard specification.

For example:

@JaxrsResource
@Component
public class MyRequestFilter implements ContainerRequestFilter {

    // Implementation goes in here

}

The OSGi enRoute project provides other examples of using the JAX-RS whiteboard in its examples

like image 134
Tim Ward Avatar answered Feb 17 '26 10:02

Tim Ward



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!