Can a Java class implementing a DS component expose more than one
OSGi service?

My usecase is that I have a DS component implementing a servlet Filter,
plugging into the web whiteboard.
 
https://github.com/steinarb/oldalbum/blob/master/oldalbum.web.security/src/main/java/no/priv/bang/oldalbum/web/security/OldAlbumShiroFilter.java#L35

And then I would like a way to retrigger configuration of the filter and
the simplest way would be if the filter could expose a service with a
method that could be used to trigger reconfiguration.

What if I subtype the Filter interface with a new interface and expose
that interface from the component, would still be able to "find" the web
whiteboard? (I think not, because if I remember correctly if a class
does not directly implement an interface, the interface for the service
must be specified in @Component annotation...?)

Hm... looks like the service parameter of @Component can be an array...?
 
https://docs.osgi.org/specification/osgi.cmpn/8.0.0/service.component.html#org.osgi.service.component.annotations.Component.service--

I'll try.

Hm... looks like the Filter interface has an init() method...?
 
https://docs.oracle.com/cd/E17802_01/products/products/servlet/2.5/docs/servlet-2_5-mr2/javax/servlet/Filter.html#init(javax.servlet.FilterConfig)

Could that be used, I wonder?

No, implemented by shiro AbstractFilter, probably best not to mess with
that...?

So: I will try a new interface with a single callback method and inject
that service into a REST endpoint and see if I can make the filter
reconfigure itself.

Reply via email to