felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Carsten Ziegeler <cziege...@apache.org>
Subject Re: Servlet whiteboard registration vs. direct registration - Filter not working
Date Sat, 23 May 2015 10:25:09 GMT
Hi Thomas,

right now, the http service part and the http whiteboard part use
different servlet contexts. That's why a filter registered through one
way does not apply to servlets registered the other way.
The semantics of the context handling between those two solutions is
slightly different and mixing them in one context creates some problems.
Afaik, other implementations of the http whiteboard do the same and keep
things separate. And by separate it means that the default context of
the http service is not the same context as the default context of the
http whiteboard service.

Now, each whiteboard service can specify a "select" property to select
the contexts it applies to, by default this is the default context of
the whiteboard service. This is an LDAP filter expression where you can
specify "select all contexts". We can argue that in this case it should
also apply to the default context of the http service - right now, it
doesn't but I guess this would be valuable addition. However, this part
is not handled by the spec, so you bind yourself to a particular
implementation atm.


Am 22.05.15 um 12:50 schrieb Thomas Driessen:
> Hi again,
> I have two Servlets and one Filter.
> The first servlet is registrated via whiteboard like this:
> @Component(properties={
> @Property(name="osgi.http.whiteboard.servlet.name", value="MyServlet"),
> @Property(name="osgi.http.whiteboard.servlet.pattern", value="/testone")})
> public class MyWhiteboardServlet implements Servlet {
> ...
> The second Servlet is registrated directly via HttpService like this:
> @Component
> public class MyManualServlet implements Servlet {
>  @ServiceDependency
> private volatile HttpService httpService;
>  @Start
> public void start(){
> try {
> httpService.registerServlet("/testtwo", this, null, null);
> } catch (ServletException e) {
> e.printStackTrace();
> } catch (NamespaceException e) {
> e.printStackTrace();
> }
> }
> ...
> Then I added a Filter also via whiteboard registration like this:
> @Component(properties={
> @Property(name="osgi.http.whiteboard.filter.name", value="MyFilter"),
> @Property(name="osgi.http.whiteboard.filter.pattern", value="/*")})
> public class MyFilter implements Filter {
> ...
> Everythings starts up fine, but when it comes to requests, only the
> "MyWhiteboardServlet" is filtered correctly. When I try to access the
> "MyManualServlet" nothing happens and the Filter is not invoked.
> Is this an intended behaviour?
> I know I'm mixing up different registration styles, but I assumed, that
> internally both are registered the same way?
> In my current project I'm forced to support both styles, as some third
> party libraries I use, are using the direct registration, while others use
> the whiteboard registration.
> Any advice on this problem is appreciated :)
> Best regards,
> Thomas

Carsten Ziegeler
Adobe Research Switzerland

To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org

View raw message