Hi Scott,

sorry for the later answer, I was traveling yesterday.

You have an example in the Karaf distribution:

https://github.com/apache/karaf/tree/master/examples/karaf-servlet-example/karaf-servlet-example-annotation

We also have an example in Winegrower:

https://github.com/jbonofre/winegrower/tree/master/winegrower-examples/http

Basically, if you register a Servlet service with name and urlPatterns
as service properties, and you have the http-whiteboard feature
installed, it should work straight forward.

Regards
JB

On 22/10/2018 23:04, Leschke, Scott 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