I’m pretty sure that your ServletContextHelper isn’t advertised as a service 
and is therefore invisible to the whiteboard. ServletContextHelper is not an 
interface so you need to be explicit. 

Tim

Sent from my iPhone

> On 22 Oct 2018, at 23:04, Leschke, Scott <[email protected]> wrote:
> 
>  
> I’ve in the process of trying to convert a couple of servlets over to user 
> HttpWhiteboard. I looked online for an example and it seemed pretty straight 
> forward.
> Based on my understanding, I came up with the following but it doesn’t work. 
> Jetty doesn’t have a myApp context. I assume there is something missing?
>  
> Help?
>  
> Scott
>  
>  
> @Component(
>        property  = {
>               HTTP_WHITEBOARD_CONTEXT_NAME + '=' + ContextHelper.CTX_NAME,
>               HTTP_WHITEBOARD_CONTEXT_PATH + '=' + ContextHelper.CTX_PATH
>        }
> )
> public class ContextHelper
>        extends org.osgi.service.http.context.ServletContextHelper
> {
>        public static final String CTX_NAME = "myApp";
>        public static final String CTX_PATH = '/' + CTX_NAME;
> }
>  
>  
> @Component(
>        name      = “myApp.listings",
>        property  = {
>               HTTP_WHITEBOARD_CONTEXT_SELECT  + "=(" + 
> HTTP_WHITEBOARD_CONTEXT_NAME + '=' + ContextHelper.CTX_NAME + ')',
>               HTTP_WHITEBOARD_SERVLET_NAME    + '=' + "MyApp Listings",
>               HTTP_WHITEBOARD_SERVLET_PATTERN + '=' + "/list/*"
>        },
>        service   = Servlet.class,
>        immediate = true)
> @Designate(
>        ocd = AppConfig.class)
> public class Listings
>        implements HttpServlet
> {…}

Reply via email to