hstaudacher / osgi-jax-rs-connector

An OSGi - JAX-RS 2.0 Connector, software repository available on the link below
http://hstaudacher.github.io/osgi-jax-rs-connector
Other
190 stars 98 forks source link

ServiceFilter of ResourceTracker should be configurable #33

Closed diroza closed 10 years ago

diroza commented 10 years ago

The ResourceTracker currently tracks all services using objectClass=*. In order to use thte jax-rs-connector only for certain services, this filter must be changable, e.g. to objectClass=com.mycompany.*.

So there must be a possibility to configure this filter from outside, e.g. via service property.

hstaudacher commented 10 years ago

I would suggest to use the config admin because we already use it to configure the root path. Would you like to implement it and open a pull request?

Are you aware that you can register you resource and set the service property com.eclipsesource.jaxrs.publish to false to prevent publishing? Does this help in any way?

diroza commented 10 years ago

Yes, I'm aware of com.eclipsesource.jaxrs.publish property, but this blacklisting approach isn't applicable in my case. What I need is a kind of whitelisting. The ResourceTracker should only consider services of my own.

I'll see when I can implement it.

dcaillia commented 10 years ago

Would it be a good idea to have bundles express their interest (in being handled by osgi-jax-rs-connector)? For example by only picking up services from bundles that depend on some capability that you provide?

I'm looking for something like "cdi is enabled if there's a meta-inf/bean.xml file" -> "osgi-jax-rs-connector will publshig jax-rs resources only if the bundle "wants" it.

hstaudacher commented 10 years ago

I added an interface called ResourceFilter which can be registered as an OSGi service. The publisher will look up this service an call the getFilter method. You can implement this method to create a custom filter for the tracker.

For now this is not dynamic. You need to register the ResourceFilter before the publisher bundle is started. In future version we might change this. But I think it's sufficient for now.