I'm in the process of transitioning a Vaadin war web application with
web.xml to the Pax Web Whiteboard extender.

One thing that was lost in the transition, was the web application
context path.  The web.xml of the original webapp let the Vaadin servlet
match everything from "/*" which matched both the application itself and
the static resources from "/VAADIN/*".
 
https://github.com/steinarb/ukelonn/blob/ef57228437a305ef1d15b5671ddc82c59a04d572/ukelonn.bundle/src/main/webapp/WEB-INF/web.xml#L36

In the maven-bundle-plugin config (this was a war bundle meant for
karaf), I set the Web-ContextPath header in the manifest.mf of the war:
 
https://github.com/steinarb/ukelonn/blob/ef57228437a305ef1d15b5671ddc82c59a04d572/ukelonn.bundle/pom.xml#L179

Because the application context was "ukelonn", the actual path of the
web application was "/ukelonn/*", with the Vaadin static resources being
under "/ukelonn/VAADIN/*".

I've now got the Pax Web Whiteboard version working.  However, in the
Pax Web Whiteboard version, the application context was gone and I had
to let the servlet match two paths from the top, ie.: "/ukelonn/*"
(containing the webapp) and "/VAADIN/*" (containing the static resources
of Vaadin).
 
https://github.com/steinarb/ukelonn/blob/7b69f7f081f56541d58f1dc8a4c619cd18ac02d6/ukelonn.bundle/src/main/java/no/priv/bang/ukelonn/impl/UkelonnServlet.java#L39
and the Shiro filter (handling authentication and authorization)
 
https://github.com/steinarb/ukelonn/blob/7b69f7f081f56541d58f1dc8a4c619cd18ac02d6/ukelonn.bundle/src/main/java/no/priv/bang/ukelonn/impl/UkelonnShiroFilter.java#L41

The downside of this, is that if I have two webapps that use VAADIN, the
webapps will have to use the exact same version of VAADIN.

I have now tried to add a context path to the property argument of the
@Component annotation, but that doesn't seem to work: the Vaadin servlet
now matches everything from the top (because of the "/*" pattern) and I
don't see the context anywhere.

The servlet annotation looks like this:
@Component(
    property= {
        HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN+"=/*",
        HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME+"=ukelonn",
        HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME+"=ukelonn",
        HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH+"=/ukelonn"},
    service=Servlet.class,
    immediate=true
)
public class UkelonnServlet extends TouchKitServlet {


The filter annotation looks like this:
@Component(
    property= {
        HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN+"=/*",
        "servletNames=ukelonn",
        HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=ukelonn",
        HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH + "=/ukelonn"},
    service=Filter.class,
    immediate=true
)
public class UkelonnShiroFilter extends AbstractShiroFilter {


Does anyone know how to set the context on a servlet (and a filter) when
using Pax Web Whiteboard Extender with OSGi Declarative Services (DS)?

Thanks!

- Steinar

-- 
-- 
------------------
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to