Hello Thai, I don't see anything wrong.
It looks like they all "target" the default "ServletContextHelper" (i.e. the same context) and so the filter should apply to each. You should be able to check by getting the HttpServiceRuntime [1] service and calling the method `calculateRequestInfoDTO(String path)` to see what the runtime thinks is wired up for that path. Sincerely, - Ray [1] https://osgi.org/specification/osgi.cmpn/7.0.0/service.http.whiteboard.html#org.osgi.service.http.runtime.HttpServiceRuntime On Wed, Sep 12, 2018 at 2:39 PM, Nhut Thai Le via osgi-dev < osgi-dev@mail.osgi.org> wrote: > Hello, > > I want to have a filter at the root of my application where all http > requests must pass through, so I make a Servlet filter: > @Component( > service=Filter.class, > scope=ServiceScope.PROTOTYPE, > property= { > "osgi.http.whiteboard.filter.name=AuthenticationFilter", > "osgi.http.whiteboard.filter.pattern=/*", > "service.ranking:Integer=10" > } > ) > public final class AuthenticationFilter implements Filter {...} > ----------------------------- > Then I have some servlets (in other bundles) defined like this: > @Component( > service = Servlet.class, > property= { > "osgi.http.whiteboard.servlet.pattern=/token" > } > ) > public class AccessTokenServlet extends HttpServlet{...} > ------------------------------- > I also have some resource services in other bundles: > @Component(service = IconsResourceService.class, > property = { > "osgi.http.whiteboard.resource.pattern=/static/icons/*", > "osgi.http.whiteboard.resource.prefix=/icons" > } > ) > public class IconsResourceService {} > ----------------------- > However, my filter never trigger when i request the icon (static resource) > or token (servlet). My understanding is that the 3 components above reside > in different bundles thus they have different servlet contexts so the > filter wont trigger. I can created a ServletContextHelper and select it in > the Servlet component annotation but this wont help in the case of the > resource service. Is there other way to share filter across bundles? > > Thai > > _______________________________________________ > OSGi Developer Mail List > osgi-dev@mail.osgi.org > https://mail.osgi.org/mailman/listinfo/osgi-dev > -- *Raymond Augé* <http://www.liferay.com/web/raymond.auge/profile> (@rotty3000) Senior Software Architect *Liferay, Inc.* <http://www.liferay.com> (@Liferay) Board Member & EEG Co-Chair, OSGi Alliance <http://osgi.org> (@OSGiAlliance)
_______________________________________________ OSGi Developer Mail List osgi-dev@mail.osgi.org https://mail.osgi.org/mailman/listinfo/osgi-dev