Re: Http Whiteboard

2018-10-22 Thread Tim Ward
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  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
> {…}


RE: Http Whiteboard

2018-10-23 Thread Leschke, Scott
Thanks Tim.  That was the problem. I noticed that just after I sent the email 
but hadn’t had a chance to try it yet.  I pulled that from a YouTube video Ray 
Auge did way back in 2014 and sort of blindly regurgitated what I saw.

There’s something else I noticed though.  It would seem that it’s still 
necessary to define
Web-ContextPath .bnd file as it doesn’t appear to work without that.  Is that 
right?

From: Tim Ward 
Sent: Monday, October 22, 2018 4:28 PM
To: user@karaf.apache.org
Subject: Re: Http Whiteboard

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 
mailto:slesc...@medline.com>> 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
{…}


Re: Http Whiteboard

2018-10-23 Thread Tim Ward
I wouldn’t expect you to need anything specific in your bnd file. 
Web-ContextPath is part of a different OSGi specification (the Web Application 
Bundle spec) so there shouldn’t be any need for that at all.

Best Regards,

Tim

> On 23 Oct 2018, at 17:06, Leschke, Scott  wrote:
> 
> Thanks Tim.  That was the problem. I noticed that just after I sent the email 
> but hadn’t had a chance to try it yet.  I pulled that from a YouTube video 
> Ray Auge did way back in 2014 and sort of blindly regurgitated what I saw.  
>  
> There’s something else I noticed though.  It would seem that it’s still 
> necessary to define
> Web-ContextPath .bnd file as it doesn’t appear to work without that.  Is that 
> right?
>  
> From: Tim Ward  
> Sent: Monday, October 22, 2018 4:28 PM
> To: user@karaf.apache.org
> Subject: Re: Http Whiteboard
>  
> 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  <mailto:slesc...@medline.com>> 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
> {…}



RE: Http Whiteboard

2018-10-23 Thread Leschke, Scott
Thanks Tim,

That’s exactly what I thought but without it I get the following from Jetty.
HTTP ERROR 404
Problem accessing /myApp/. Reason:
Not Found

Perhaps that’s related to something else and the presence/absence of 
Web-ContextPath is triggering the other issue.  I’ll see what I can figure out 
in that regard.

I do have one last question though. I’m wondering what the syntax is to 
associate multiple URL patterns with a single servlet.  I assume I can use 
wildcarding and stuff like that but can I use a Java RE?  How about a URL list? 
 Comma separated, bounded by braces, brackets?

I’m thought I had a copy of the R6 compendium squirreled away so that I could 
just look it up but it may be on my machine at home and for some reason I’m not 
seeing it at osgi.org even though I’m sure it’s there somewhere.

Scott

From: Tim Ward 
Sent: Tuesday, October 23, 2018 10:09 AM
To: user@karaf.apache.org
Subject: Re: Http Whiteboard

I wouldn’t expect you to need anything specific in your bnd file. 
Web-ContextPath is part of a different OSGi specification (the Web Application 
Bundle spec) so there shouldn’t be any need for that at all.

Best Regards,

Tim


On 23 Oct 2018, at 17:06, Leschke, Scott 
mailto:slesc...@medline.com>> wrote:

Thanks Tim.  That was the problem. I noticed that just after I sent the email 
but hadn’t had a chance to try it yet.  I pulled that from a YouTube video Ray 
Auge did way back in 2014 and sort of blindly regurgitated what I saw.

There’s something else I noticed though.  It would seem that it’s still 
necessary to define
Web-ContextPath .bnd file as it doesn’t appear to work without that.  Is that 
right?

From: Tim Ward mailto:tim.w...@paremus.com>>
Sent: Monday, October 22, 2018 4:28 PM
To: user@karaf.apache.org<mailto:user@karaf.apache.org>
Subject: Re: Http Whiteboard

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 
mailto:slesc...@medline.com>> 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
{…}



Re: Http Whiteboard

2018-10-23 Thread Tim Ward
You can have multiple patterns just by adding the property as a 
String[]/Collection. See 
https://osgi.org/javadoc/osgi.cmpn/7.0.0/org/osgi/service/http/whiteboard/propertytypes/HttpWhiteboardServletPattern.html#value--
 
<https://osgi.org/javadoc/osgi.cmpn/7.0.0/org/osgi/service/http/whiteboard/propertytypes/HttpWhiteboardServletPattern.html#value-->
 which is the component property type for that whiteboard property.

If you can’t use component property types then repeated single value entries in 
the property element get aggregated into an array.

Tim

> On 23 Oct 2018, at 17:32, Leschke, Scott  wrote:
> 
> Thanks Tim,
>  
> That’s exactly what I thought but without it I get the following from Jetty.
> HTTP ERROR 404
> Problem accessing /myApp/. Reason:
> Not Found
>  
> Perhaps that’s related to something else and the presence/absence of 
> Web-ContextPath is triggering the other issue.  I’ll see what I can figure 
> out in that regard.
>  
> I do have one last question though. I’m wondering what the syntax is to 
> associate multiple URL patterns with a single servlet.  I assume I can use 
> wildcarding and stuff like that but can I use a Java RE?  How about a URL 
> list?  Comma separated, bounded by braces, brackets?
>  
> I’m thought I had a copy of the R6 compendium squirreled away so that I could 
> just look it up but it may be on my machine at home and for some reason I’m 
> not seeing it at osgi.org <http://osgi.org/> even though I’m sure it’s there 
> somewhere.
>  
> Scott
>  
> From: Tim Ward  
> Sent: Tuesday, October 23, 2018 10:09 AM
> To: user@karaf.apache.org
> Subject: Re: Http Whiteboard
>  
> I wouldn’t expect you to need anything specific in your bnd file. 
> Web-ContextPath is part of a different OSGi specification (the Web 
> Application Bundle spec) so there shouldn’t be any need for that at all.
>  
> Best Regards,
>  
> Tim
> 
> 
> On 23 Oct 2018, at 17:06, Leschke, Scott  <mailto:slesc...@medline.com>> wrote:
>  
> Thanks Tim.  That was the problem. I noticed that just after I sent the email 
> but hadn’t had a chance to try it yet.  I pulled that from a YouTube video 
> Ray Auge did way back in 2014 and sort of blindly regurgitated what I saw.  
>  
> There’s something else I noticed though.  It would seem that it’s still 
> necessary to define
> Web-ContextPath .bnd file as it doesn’t appear to work without that.  Is that 
> right?
>  
> From: Tim Ward mailto:tim.w...@paremus.com>> 
> Sent: Monday, October 22, 2018 4:28 PM
> To: user@karaf.apache.org <mailto:user@karaf.apache.org>
> Subject: Re: Http Whiteboard
>  
> 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  <mailto:slesc...@medline.com>> 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
> {…}



RE: Http Whiteboard

2018-10-23 Thread Leschke, Scott
I’m a bit confused.  I’m doing this with OSGi R6 so the URL pattern list has to 
be the latter part of the string created by:

HTTP_WHITEBOARD_SERVLET_PATTERN + ‘=’  + PATTERN_LIST

does it not?

From: Tim Ward 
Sent: Tuesday, October 23, 2018 10:58 AM
To: user@karaf.apache.org
Subject: Re: Http Whiteboard

You can have multiple patterns just by adding the property as a 
String[]/Collection. See 
https://osgi.org/javadoc/osgi.cmpn/7.0.0/org/osgi/service/http/whiteboard/propertytypes/HttpWhiteboardServletPattern.html#value--
 which is the component property type for that whiteboard property.

If you can’t use component property types then repeated single value entries in 
the property element get aggregated into an array.

Tim


On 23 Oct 2018, at 17:32, Leschke, Scott 
mailto:slesc...@medline.com>> wrote:

Thanks Tim,

That’s exactly what I thought but without it I get the following from Jetty.
HTTP ERROR 404
Problem accessing /myApp/. Reason:
Not Found

Perhaps that’s related to something else and the presence/absence of 
Web-ContextPath is triggering the other issue.  I’ll see what I can figure out 
in that regard.

I do have one last question though. I’m wondering what the syntax is to 
associate multiple URL patterns with a single servlet.  I assume I can use 
wildcarding and stuff like that but can I use a Java RE?  How about a URL list? 
 Comma separated, bounded by braces, brackets?

I’m thought I had a copy of the R6 compendium squirreled away so that I could 
just look it up but it may be on my machine at home and for some reason I’m not 
seeing it at osgi.org<http://osgi.org/> even though I’m sure it’s there 
somewhere.

Scott

From: Tim Ward mailto:tim.w...@paremus.com>>
Sent: Tuesday, October 23, 2018 10:09 AM
To: user@karaf.apache.org<mailto:user@karaf.apache.org>
Subject: Re: Http Whiteboard

I wouldn’t expect you to need anything specific in your bnd file. 
Web-ContextPath is part of a different OSGi specification (the Web Application 
Bundle spec) so there shouldn’t be any need for that at all.

Best Regards,

Tim



On 23 Oct 2018, at 17:06, Leschke, Scott 
mailto:slesc...@medline.com>> wrote:

Thanks Tim.  That was the problem. I noticed that just after I sent the email 
but hadn’t had a chance to try it yet.  I pulled that from a YouTube video Ray 
Auge did way back in 2014 and sort of blindly regurgitated what I saw.

There’s something else I noticed though.  It would seem that it’s still 
necessary to define
Web-ContextPath .bnd file as it doesn’t appear to work without that.  Is that 
right?

From: Tim Ward mailto:tim.w...@paremus.com>>
Sent: Monday, October 22, 2018 4:28 PM
To: user@karaf.apache.org<mailto:user@karaf.apache.org>
Subject: Re: Http Whiteboard

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 
mailto:slesc...@medline.com>> 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
{…}



Re: Http Whiteboard

2018-10-23 Thread Tim Ward
You should be able to do:

HTTP_WHITEBOARD_SERVLET_PATTERN + ‘=’  + PATTERN_1,
HTTP_WHITEBOARD_SERVLET_PATTERN + ‘=’  + PATTERN_2,
HTTP_WHITEBOARD_SERVLET_PATTERN + ‘=’  + PATTERN_3,
HTTP_WHITEBOARD_SERVLET_PATTERN + ‘=’  + PATTERN_4,
...


Sent from my iPhone

> On 23 Oct 2018, at 18:06, Leschke, Scott  wrote:
> 
> HTTP_WHITEBOARD_SERVLET_PATTERN + ‘=’  + PATTERN_LIST


RE: Http Whiteboard

2018-10-23 Thread Leschke, Scott
OK, got it.  Sorry I realize now that’s what you were trying to tell me but I 
was slow on the uptake.

Thanks

From: Tim Ward 
Sent: Tuesday, October 23, 2018 11:14 AM
To: user@karaf.apache.org
Subject: Re: Http Whiteboard

You should be able to do:

HTTP_WHITEBOARD_SERVLET_PATTERN + ‘=’  + PATTERN_1,
HTTP_WHITEBOARD_SERVLET_PATTERN + ‘=’  + PATTERN_2,
HTTP_WHITEBOARD_SERVLET_PATTERN + ‘=’  + PATTERN_3,
HTTP_WHITEBOARD_SERVLET_PATTERN + ‘=’  + PATTERN_4,
...


Sent from my iPhone

On 23 Oct 2018, at 18:06, Leschke, Scott 
mailto:slesc...@medline.com>> wrote:
HTTP_WHITEBOARD_SERVLET_PATTERN + ‘=’  + PATTERN_LIST


Re: Http Whiteboard

2018-10-23 Thread Steinar Bang
> "Leschke, Scott" :

> Thanks Tim,
> That’s exactly what I thought but without it I get the following from Jetty.
> HTTP ERROR 404
> Problem accessing /myApp/. Reason:
> Not Found

> Perhaps that’s related to something else and the presence/absence of
> Web-ContextPath is triggering the other issue.  I’ll see what I can
> figure out in that regard.

Here is a working example:
 1. This defines the web context "/ukelonn" (and attaches a shiro filter
to the web context)
 
https://github.com/steinarb/ukelonn/blob/8442f5df62bc973902085705c637e65c3bc00f8c/ukelonn.web.security/src/main/java/no/priv/bang/ukelonn/web/security/UkelonnServletContextHelper.java#L7
 
https://github.com/steinarb/ukelonn/blob/8442f5df62bc973902085705c637e65c3bc00f8c/ukelonn.web.security/src/main/java/no/priv/bang/ukelonn/web/security/UkelonnShiroFilter.java#L42

 2. Here are servlets that register with the webcontext
 
https://github.com/steinarb/ukelonn/blob/8442f5df62bc973902085705c637e65c3bc00f8c/ukelonn.web.services/src/main/java/no/priv/bang/ukelonn/api/UkelonnRestApiServlet.java#L37
 
https://github.com/steinarb/ukelonn/blob/8442f5df62bc973902085705c637e65c3bc00f8c/ukelonn.web.frontend/src/main/java/no/priv/bang/ukelonn/web/frontend/UkelonnServlet.java#L36

The syntax for registering with the context ie.
   HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT + "=(" + 
HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME +"=ukelonn)",
is a bit clumsy, but it works.

(I have on my todo list to figure out if the servlet API 3.0 annotations
can be used instead...)



Re: Http Whiteboard

2018-10-23 Thread Jean-Baptiste Onofré
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
> 
> {…}
> 


Re: Http Whiteboard

2018-10-23 Thread Steinar Bang
> Steinar Bang :

> Here is a working example:

One thing I forgot about the working example:
 - I need to have HTTP whiteboard loaded when I start the servlet
   components

I accomplish this by adding a dependency to the pax-http-whiteboard
feature in the template karaf feature files of the bundles holding the
DS components that contain services that want to register with the HTTP
whiteboad:
  
https://github.com/steinarb/ukelonn/blob/8442f5df62bc973902085705c637e65c3bc00f8c/ukelonn.web.security/src/main/feature/feature.xml#L21

>  1. This defines the web context "/ukelonn" (and attaches a shiro filter
> to the web context)
>  
> https://github.com/steinarb/ukelonn/blob/8442f5df62bc973902085705c637e65c3bc00f8c/ukelonn.web.security/src/main/java/no/priv/bang/ukelonn/web/security/UkelonnServletContextHelper.java#L7
>  
> https://github.com/steinarb/ukelonn/blob/8442f5df62bc973902085705c637e65c3bc00f8c/ukelonn.web.security/src/main/java/no/priv/bang/ukelonn/web/security/UkelonnShiroFilter.java#L42

>  2. Here are servlets that register with the webcontext
>  
> https://github.com/steinarb/ukelonn/blob/8442f5df62bc973902085705c637e65c3bc00f8c/ukelonn.web.services/src/main/java/no/priv/bang/ukelonn/api/UkelonnRestApiServlet.java#L37
>  
> https://github.com/steinarb/ukelonn/blob/8442f5df62bc973902085705c637e65c3bc00f8c/ukelonn.web.frontend/src/main/java/no/priv/bang/ukelonn/web/frontend/UkelonnServlet.java#L36

> The syntax for registering with the context ie.
>HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT + "=(" + 
> HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME +"=ukelonn)",
> is a bit clumsy, but it works.

> (I have on my todo list to figure out if the servlet API 3.0 annotations
> can be used instead...)





Re: Http Whiteboard - Pax-Web multiple instances

2020-01-31 Thread Markus Rathgeb
Hi,

if I understand your question correctly I assume it fits to this two
discussions:

* 
https://lists.apache.org/thread.html/69182ee8feef88896f840efde48146053997119e820ef037853c1c9b%40%3Cuser.karaf.apache.org%3E
* 
https://lists.apache.org/thread.html/4c76641e9ad8c4f2096f96308f320b5ef00e55f2d6ed7a8fdb35f8c5%40%3Cuser.karaf.apache.org%3E

Correct?
If this is the case perhaps someone already added a full example and
eventually added an improvement on Pax Web (I don't know).


Re: Http Whiteboard - Pax-Web multiple instances

2020-01-31 Thread Jean-Baptiste Onofré
Hi,

It should be possible with virtual hosting:

http://blog.nanthrax.net/?p=352

Regards
JB

On 31/01/2020 14:32, Alex Soto wrote:
> Hello all,
> 
> Is it possible to have more than one instance of Http Whiteboard
> component in the same Karaf instance bound to different ports?
> 
> 
> Best regards,
> Alex soto
> 
> 
> 
> 

-- 
Jean-Baptiste Onofré
jbono...@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com


Re: Http Whiteboard - Pax-Web multiple instances

2020-01-31 Thread Markus Rathgeb
Hi JB,

as I comment that link already in the first thread and also answered
to your link in the second thread:

> Isn't this similar to this thread (at least after some comments):
> https://lists.apache.org/thread.html/69182ee8feef88896f840efde48146053997119e820ef037853c1c9b@%3Cuser.karaf.apache.org%3E
> You also referenced to http://blog.nanthrax.net/?p=352
> My observations has been that it should work for "Web Bundles" and I
> did not found (that time) a way to get it working for servlets.

May I ask you if you already checked that this is really still working
for servlets?


Re: Http Whiteboard - Pax-Web multiple instances

2020-01-31 Thread Jean-Baptiste Onofré
Good point ;)

I missed your comments.

Let me add a example in karaf distro to illustrate (and so test) if it
works.

Regards
JB

On 31/01/2020 15:06, Markus Rathgeb wrote:
> Hi JB,
> 
> as I comment that link already in the first thread and also answered
> to your link in the second thread:
> 
>> Isn't this similar to this thread (at least after some comments):
>> https://lists.apache.org/thread.html/69182ee8feef88896f840efde48146053997119e820ef037853c1c9b@%3Cuser.karaf.apache.org%3E
>> You also referenced to http://blog.nanthrax.net/?p=352
>> My observations has been that it should work for "Web Bundles" and I
>> did not found (that time) a way to get it working for servlets.
> 
> May I ask you if you already checked that this is really still working
> for servlets?
> 

-- 
Jean-Baptiste Onofré
jbono...@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com


Re: Http Whiteboard - Pax-Web multiple instances

2020-01-31 Thread Alex Soto
Thanks JB and Markus,

This is very close to what I am looking for (I still need to read more the 
examples) but in my particular case, I am using Camel Rest DSL (with servlet 
component) connecting it to the OSGi managed org.osgi.service.http.HttpService. 
 In other words, I am not using the Camel Jetty component for my rest services. 
 This is how I am setting up Camel to use the OSGi HTTP Service:








 



https://lists.apache.org/thread.html/69182ee8feef88896f840efde48146053997119e820ef037853c1c9b@%3Cuser.karaf.apache.org%3E
>> You also referenced to http://blog.nanthrax.net/?p=352
>> My observations has been that it should work for "Web Bundles" and I
>> did not found (that time) a way to get it working for servlets.
> 
> May I ask you if you already checked that this is really still working
> for servlets?



Re: Http Whiteboard - Pax-Web multiple instances

2020-01-31 Thread Alex Soto
This seems to work for me, but I have my doubts.   Following the example here: 
https://github.com/ops4j/org.ops4j.pax.web/tree/master/samples/whiteboard-extended
 

  I made the following changes. 

In my blueprint:




  externalAPIContext
  



























In my jetty.xml:



























externalAPIConnector





In my Camel Context:








But,  I am wondering if this correct, because in the example the Servlet is 
registered with service property httpContext.id, which I am not setting 
anywhere. The Jetty Connector name is configured in the  
org.ops4j.pax.web.service.whiteboard.HttpContextMapping,  but I don’t see how 
it is matched to my Camel Servlet. Notice that the 
org.apache.camel.component.servlet.osgi.OsgiServletRegisterer bean is the one 
registering the servlet with the OSGi HTTP Service, but there is no way to 
specify the httpContext.id property.  Is this property required to match the 
HttpContextMapping to the Servlet?

Any insight is appreciated.

Best regards,
Alex soto




> On Jan 31, 2020, at 9:29 AM, Alex Soto  wrote:
> 
> Thanks JB and Markus,
> 
> This is very close to what I am looking for (I still need to read more the 
> examples) but in my particular case, I am using Camel Rest DSL (with servlet 
> component) connecting it to the OSGi managed 
> org.osgi.service.http.HttpService.  In other words, I am not using the Camel 
> Jetty component for my rest services.  This is how I am setting up Camel to 
> use the OSGi HTTP Service:
> 
>interface="org.osgi.service.http.HttpService" />
>class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
>class=“org.apache.camel.component.servlet.osgi.OsgiServletRegisterer" 
> init-method="register" destroy-method="unregister”>
>/>
>   
>   
>   
>   
>
> 
>contextPath="{{context.path}}{{api.root.path}}" 
>   port="{{port}}"
>   enableCORS="false"
>   clientRequestValidation="true">
>   
>value="RestApiServlet”/>
>   ...
> 
> 
> So, the question is how do I bind the Camel servlet to a specific Jetty 
> connection?
> Would the MANIFEST headers do it?  If so, then that applies to the entire 
> bundle.
> 
> Best regards,
> Alex soto
> 
> 
> 
> 
>> On Jan 31, 2020, at 9:06 AM, Markus Rathgeb > > wrote:
>> 
>> Hi JB,
>> 
>> as I comment that link already in the first thread and also answered
>> to your link in the second thread:
>> 
>>> Isn't this similar to this thread (at least after some comments):
>>> https://lists.apache.org/thread.html/69182ee8feef88896f840efde48146053997119e820ef037853c1c9b@%3Cuser.karaf.apache.org%3E
>>>  
>>> 
>>> You also referenced to http://blog.nanthrax.net/?p=352
>>> My observations has been that it should work for "Web Bundles" and I
>>> did not found (that time) a way to get it working for servlets.
>> 
>> May I ask you if you already checked that this is really still wor

Re: Http Whiteboard - Pax-Web multiple instances

2020-02-03 Thread Achim Nierbeck
Hi,

the functionality should be working, as the samples provided by the pax-web
project are also used for the integration tests, which do work ...  at
least the last time I tested :D
for details about how it works, please take a look at the pax-web project
:)

regards, Achim


Am Fr., 31. Jan. 2020 um 19:30 Uhr schrieb Alex Soto :

> This seems to work for me, but I have my doubts.   Following the example
> here:
> https://github.com/ops4j/org.ops4j.pax.web/tree/master/samples/whiteboard-extended
> I made the following changes.
>
> In my blueprint:
>
>  "org.ops4j.pax.web.service.whiteboard.HttpContextMapping">
> 
> 
>   externalAPIContext
>   
> 
>
>
>  "org.ops4j.pax.web.extender.whiteboard.runtime.DefaultHttpContextMapping">
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>
>
>  "org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
>
>
>  />
>  "org.apache.camel.component.servlet.osgi.OsgiServletRegisterer"
> init-method="register"
> destroy-method="unregister">
>
>
> 
> 
> 
> 
> 
> 
>
>
> In my jetty.xml:
>
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> externalAPIConnector
> 
> 
> 
>
>
> In my Camel Context:
>
>  component="servlet"
> bindingMode="xml"
> contextPath="{{context.path}}{{api.root.path}}"
> port="{{port}}"
> enableCORS="false"
> clientRequestValidation="true">
>
> 
> 
> 
>
>
> But,  I am wondering if this correct, because in the example the Servlet
> is registered with service property *httpContext.id
> *, which I am not setting anywhere. The Jetty
> Connector name is configured in the
> *org.ops4j.pax.web.service.whiteboard.HttpContextMapping*,  but I don’t
> see how it is matched to my Camel Servlet. Notice that the
> *org.apache.camel.component.servlet.osgi.OsgiServletRegisterer *bean is
> the one registering the servlet with the OSGi HTTP Service, but there is no
> way to specify the *httpContext.id  *property*.  *Is
> this property required to match the HttpContextMapping to the Servlet?
>
> Any insight is appreciated.
>
> Best regards,
> Alex soto
>
>
>
>
> On Jan 31, 2020, at 9:29 AM, Alex Soto  wrote:
>
> Thanks JB and Markus,
>
> This is very close to what I am looking for (I still need to read more the
> examples) but in my particular case, I am using Camel Rest DSL (with
> servlet component) connecting it to the OSGi managed 
> *org.osgi.service.http.HttpService.
>  *In other words, I am not using the Camel Jetty component for my rest
> services.  This is how I am setting up Camel to use the OSGi HTTP Service:
>
>  />
>  "org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
>  org.apache.camel.component.servlet.osgi.OsgiServletRegisterer" init-method
> ="register" destroy-method="unregister”>
> 
> 
> 
> 
> 
> 
>
>  "{{context.path}}{{api.root.path}}"
> port="{{port}}"
> enableCORS="false"
> clientRequestValidation="true">
> 
> https://lists.apache.org/thread.html/69182ee8feef88896f840efde48146053997119e820ef037853c1c9b@%3Cuser.karaf.apache.org%3E
> You also referenced to http://blog.nanthrax.net/?p=352
> My observations has been that it should work for "Web Bundles" and I
> did not found (that time) a way to get it working for servlets.
>
>
> May I ask you if you already checked that this is really still working
> for servlets?
>
>
>
>

-- 

Apache Member
Apache Karaf  Committer & PMC
OPS4J Pax Web  Committer &
Project Lead
blog 
Co-Author of Apache Karaf Cookbook 


Re: Http Whiteboard - Pax-Web multiple instances

2020-02-03 Thread Markus Rathgeb
Hm, I checkout the master branch of Pax Web and grepped the samples

grep -ri Web-VirtualHosts samples

No hits. Can you point me to the sample that is using Web-VirtualHosts?

Achim: FYI it seems the link in your signature
"http://wiki.ops4j.org/display/paxweb/Pax+Web/"; does not exist
anymore.


Re: Http Whiteboard - Pax-Web multiple instances

2020-02-03 Thread Achim Nierbeck
Hi,

This is the source:
https://github.com/ops4j/org.ops4j.pax.web/blob/master/samples/whiteboard-extended/src/main/java/org/ops4j/pax/web/extender/samples/whiteboard/internal/Activator.java
and here is the very very old blog about it, I wrote after implementing it
:-)
https://nierbeck.de/2013/05/bind-certain-web-applications-to-specific-httpconnectors-ii/

hope it helps :)


regards, Achim


Am Mo., 3. Feb. 2020 um 21:49 Uhr schrieb Markus Rathgeb <
maggu2...@gmail.com>:

> Hm, I checkout the master branch of Pax Web and grepped the samples
>
> grep -ri Web-VirtualHosts samples
>
> No hits. Can you point me to the sample that is using Web-VirtualHosts?
>
> Achim: FYI it seems the link in your signature
> "http://wiki.ops4j.org/display/paxweb/Pax+Web/"; does not exist
> anymore.
>


-- 

Apache Member
Apache Karaf  Committer & PMC
OPS4J Pax Web  Committer &
Project Lead
blog 
Co-Author of Apache Karaf Cookbook 


Re: Http Whiteboard - Pax-Web multiple instances

2020-02-03 Thread Jean-Baptiste Onofré
As reminder, here's another blog: http://blog.nanthrax.net/?p=352

Regards
JB

On 04/02/2020 08:33, Achim Nierbeck wrote:
> Hi,
> 
> This is the source:
> https://github.com/ops4j/org.ops4j.pax.web/blob/master/samples/whiteboard-extended/src/main/java/org/ops4j/pax/web/extender/samples/whiteboard/internal/Activator.java
> and here is the very very old blog about it, I wrote after implementing
> it :-)
> https://nierbeck.de/2013/05/bind-certain-web-applications-to-specific-httpconnectors-ii/
> 
> hope it helps :)
> 
> 
> regards, Achim
> 
> 
> Am Mo., 3. Feb. 2020 um 21:49 Uhr schrieb Markus Rathgeb
> mailto:maggu2...@gmail.com>>:
> 
> Hm, I checkout the master branch of Pax Web and grepped the samples
> 
> grep -ri Web-VirtualHosts samples
> 
> No hits. Can you point me to the sample that is using Web-VirtualHosts?
> 
> Achim: FYI it seems the link in your signature
> "http://wiki.ops4j.org/display/paxweb/Pax+Web/"; does not exist
> anymore.
> 
> 
> 
> -- 
> 
> Apache Member
> Apache Karaf  Committer & PMC
> OPS4J Pax Web  Committer
> & Project Lead
> blog 
> Co-Author of Apache Karaf Cookbook 
> 

-- 
Jean-Baptiste Onofré
jbono...@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com


Re: Http Whiteboard - Pax-Web multiple instances

2020-02-04 Thread Markus Rathgeb
Hi all,

the both examples and its mechanism differs (thanks for providing it).

The one JB refers to is using a bundle header. This example has (the
time I tested it) not worked for me. My research (at the time I
comment this the first time) has been that this works for the usage of
the "Web Application Specification" only. I did not check it again,
but I was not aware that something has been changed.

The one Achim refers to uses a HttpContextMapping service additional
to the Servlet service and sets the necessary properties.
Achim, thanks a lot for your example. This one is working for me!

> https://github.com/ops4j/org.ops4j.pax.web/blob/master/samples/whiteboard-extended/src/main/java/org/ops4j/pax/web/extender/samples/whiteboard/internal/Activator.java

As it is only an example, it does not matter, but there is a bug in
this example.
All the http context mapping service registrations are assigned to
"httpContextMappingReg" and all servlet registrations to "servletReg".
The respective ...2 and ...3 variables are not used.
So, there is only one of each service unregistered and freed.

Best regards,
Markus


Re: Http Whiteboard - Pax-Web multiple instances

2020-02-04 Thread Achim Nierbeck
Hi Markus,

if you find bugs, please fix them ;)
Regarding the different samples. That's been the second blog, I wrote two
at the time.
The given sample is for the WhiteBoard approach, but you can also have the
Web-Container approach.
See the first Blog for details, that's where I outsourced my thoughts of
the time ;)

regards, Achim


Am Di., 4. Feb. 2020 um 12:17 Uhr schrieb Markus Rathgeb <
maggu2...@gmail.com>:

> Hi all,
>
> the both examples and its mechanism differs (thanks for providing it).
>
> The one JB refers to is using a bundle header. This example has (the
> time I tested it) not worked for me. My research (at the time I
> comment this the first time) has been that this works for the usage of
> the "Web Application Specification" only. I did not check it again,
> but I was not aware that something has been changed.
>
> The one Achim refers to uses a HttpContextMapping service additional
> to the Servlet service and sets the necessary properties.
> Achim, thanks a lot for your example. This one is working for me!
>
> >
> https://github.com/ops4j/org.ops4j.pax.web/blob/master/samples/whiteboard-extended/src/main/java/org/ops4j/pax/web/extender/samples/whiteboard/internal/Activator.java
>
> As it is only an example, it does not matter, but there is a bug in
> this example.
> All the http context mapping service registrations are assigned to
> "httpContextMappingReg" and all servlet registrations to "servletReg".
> The respective ...2 and ...3 variables are not used.
> So, there is only one of each service unregistered and freed.
>
> Best regards,
> Markus
>


-- 

Apache Member
Apache Karaf  Committer & PMC
OPS4J Pax Web  Committer &
Project Lead
blog 
Co-Author of Apache Karaf Cookbook 


Re: Http Whiteboard - Pax-Web multiple instances

2020-02-05 Thread Alex Soto
Anybody can validate this approach?
As I said, it appears to work, except in my case I don’t see how to specify the 
context.id  property in the Camel Servlet.
JB?



> On Jan 31, 2020, at 1:30 PM, Alex Soto  wrote:
> 
> This seems to work for me, but I have my doubts.   Following the example 
> here: 
> https://github.com/ops4j/org.ops4j.pax.web/tree/master/samples/whiteboard-extended
>  
> 
>   I made the following changes. 
> 
> In my blueprint:
> 
>interface="org.ops4j.pax.web.service.whiteboard.HttpContextMapping">
>   
>   http://httpcontext.id/>">
> externalAPIContext
> 
>   
>   
>class="org.ops4j.pax.web.extender.whiteboard.runtime.DefaultHttpContextMapping">
>value="externalAPIContext" />
>value="#{context.path}#{api.root.path}" />
>   
>   
>value="127.0.0.1"/>
>value="externalAPIConnector"/>
>   
>   
>   
>   
>   
>class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
>   
>interface="org.osgi.service.http.HttpService" />
>class="org.apache.camel.component.servlet.osgi.OsgiServletRegisterer"
>   init-method="register" 
>   destroy-method="unregister">
>   
>/>
>   
>   
>   
>   
>   
> 
> 
> In my jetty.xml:
> 
>   
>   
>   
>   
>   
>   
>   
>type="org.eclipse.jetty.server.ConnectionFactory">
>   
>class="org.eclipse.jetty.server.HttpConnectionFactory">
>name="config">
>refid="httpConfig" />
>   
>   
>   
>   
>   
>   
>default="127.0.0.1" />
>   
>   
>default="8285" />
>   
>   
>default="3" />
>   
>   externalAPIConnector
>   
>   
>   
> 
> 
> In my Camel Context:
> 
>  component="servlet"
>   bindingMode="xml" 
>   contextPath="{{context.path}}{{api.root.path}}" 
>   port="{{port}}"
>   enableCORS="false"
>   clientRequestValidation="true">
> 
>   
>value="ResponderRestApiServlet"/>
>   
> 
> 
> But,  I am wondering if this correct, because in the example the Servlet is 
> registered with service property httpContext.id , 
> which I am not setting anywhere. The Jetty Connector name is configured in 
> the  org.ops4j.pax.web.service.whiteboard.HttpContextMapping,  but I don’t 
> see how it is matched to my Camel Servlet. Notice that the 
> org.apache.camel.component.servlet.osgi.OsgiServletRegisterer bean is the one 
> registering the servlet with the OSGi HTTP Service, but there is no way to 
> specify the httpContext.id  property.  Is this 
> property required to match the HttpContextMapping to the Servlet?
> 
> Any insight is appreciated.
> 
> Best regards,
> Alex soto
> 
> 
> 
> 
>> On Jan 31, 2020, at 9:29 AM, Alex Soto > > wrote:
>> 
>> Thanks JB and Markus,
>> 
>> This is very close to what I am looking for (I still need to read more the 
>> examples) but in my particular case, I am using Camel Rest DSL (with servlet 
>> component) connecting it to the OSGi managed 
>> org.osgi.service.http.HttpService.  In other words, I am not using the Camel 
>> Jetty component for my rest services.  This is how I am setting up Camel to 
>> use the OSGi HTTP Service:
>> 
>>  > interface="org.osgi.service.http.HttpService" />
>>  > class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
>>  > class=“org.apache.camel.component.servlet.osgi.OsgiServletRegisterer" 
>> init-

Re: Http Whiteboard - Pax-Web multiple instances

2020-02-05 Thread Jean-Baptiste Onofre
Hi Alex,

I will add a full example tomorrow. I’m fully busy today.

Regards
JB

> Le 5 févr. 2020 à 19:23, Alex Soto  a écrit :
> 
> Anybody can validate this approach?
> As I said, it appears to work, except in my case I don’t see how to specify 
> the context.id  property in the Camel Servlet.
> JB?
> 
> 
> 
>> On Jan 31, 2020, at 1:30 PM, Alex Soto > > wrote:
>> 
>> This seems to work for me, but I have my doubts.   Following the example 
>> here: 
>> https://github.com/ops4j/org.ops4j.pax.web/tree/master/samples/whiteboard-extended
>>  
>> 
>>   I made the following changes. 
>> 
>> In my blueprint:
>> 
>>  > interface="org.ops4j.pax.web.service.whiteboard.HttpContextMapping">
>>  
>>  http://httpcontext.id/>">
>>externalAPIContext
>>
>>  
>>  
>>  > class="org.ops4j.pax.web.extender.whiteboard.runtime.DefaultHttpContextMapping">
>>  > value="externalAPIContext" />
>>  > value="#{context.path}#{api.root.path}" />
>>  
>>  
>>  > value="127.0.0.1"/>
>>  > value="externalAPIConnector"/>
>>  
>>  
>>  
>>  
>>  
>>  > class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
>>  
>>  > interface="org.osgi.service.http.HttpService" />
>>  > class="org.apache.camel.component.servlet.osgi.OsgiServletRegisterer"
>>  init-method="register" 
>>  destroy-method="unregister">
>>  
>>  > />
>>  
>>  
>>  
>>  
>>  
>> 
>> 
>> In my jetty.xml:
>> 
>>  
>>  
>>  
>>  
>>  
>>  
>>  
>>  > type="org.eclipse.jetty.server.ConnectionFactory">
>>  
>>  > class="org.eclipse.jetty.server.HttpConnectionFactory">
>>  > name="config">
>>  > refid="httpConfig" />
>>  
>>  
>>  
>>  
>>  
>>  
>>  > default="127.0.0.1" />
>>  
>>  
>>  > default="8285" />
>>  
>>  
>>  > default="3" />
>>  
>>  externalAPIConnector
>>  
>>  
>>  
>> 
>> 
>> In my Camel Context:
>> 
>>  >  component="servlet"
>>  bindingMode="xml" 
>>  contextPath="{{context.path}}{{api.root.path}}" 
>>  port="{{port}}"
>>  enableCORS="false"
>>  clientRequestValidation="true">
>> 
>>  
>>  > value="ResponderRestApiServlet"/>
>>  
>> 
>> 
>> But,  I am wondering if this correct, because in the example the Servlet is 
>> registered with service property httpContext.id , 
>> which I am not setting anywhere. The Jetty Connector name is configured in 
>> the  org.ops4j.pax.web.service.whiteboard.HttpContextMapping,  but I don’t 
>> see how it is matched to my Camel Servlet. Notice that the 
>> org.apache.camel.component.servlet.osgi.OsgiServletRegisterer bean is the 
>> one registering the servlet with the OSGi HTTP Service, but there is no way 
>> to specify the httpContext.id  property.  Is this 
>> property required to match the HttpContextMapping to the Servlet?
>> 
>> Any insight is appreciated.
>> 
>> Best regards,
>> Alex soto
>> 
>> 
>> 
>> 
>>> On Jan 31, 2020, at 9:29 AM, Alex Soto >> > wrote:
>>> 
>>> Thanks JB and Markus,
>>> 
>>> This is very close to what I am looking for (I still need to read more the 
>>> examples) but in my particular case, I am using Camel Rest DSL (with 
>>> servlet component) connecting it to the OSGi managed 
>>> org.osgi.service.http.HttpService.  In other words, I am not using the 
>>> Camel Jetty component for my rest services.  This is how I am setting up 
>>> Camel to use the OSGi

Re: Http Whiteboard - Pax-Web multiple instances

2020-02-05 Thread Alex Soto
Thank you JB!

Best regards,
Alex soto




> On Feb 5, 2020, at 3:09 PM, Jean-Baptiste Onofre  wrote:
> 
> Hi Alex,
> 
> I will add a full example tomorrow. I’m fully busy today.
> 
> Regards
> JB
> 
>> Le 5 févr. 2020 à 19:23, Alex Soto > > a écrit :
>> 
>> Anybody can validate this approach?
>> As I said, it appears to work, except in my case I don’t see how to specify 
>> the context.id  property in the Camel Servlet.
>> JB?
>> 
>> 
>> 
>>> On Jan 31, 2020, at 1:30 PM, Alex Soto >> > wrote:
>>> 
>>> This seems to work for me, but I have my doubts.   Following the example 
>>> here: 
>>> https://github.com/ops4j/org.ops4j.pax.web/tree/master/samples/whiteboard-extended
>>>  
>>> 
>>>   I made the following changes. 
>>> 
>>> In my blueprint:
>>> 
>>> >> interface="org.ops4j.pax.web.service.whiteboard.HttpContextMapping">
>>> 
>>> http://httpcontext.id/>">
>>>   externalAPIContext
>>>   
>>> 
>>> 
>>> >> class="org.ops4j.pax.web.extender.whiteboard.runtime.DefaultHttpContextMapping">
>>> >> value="externalAPIContext" />
>>> >> value="#{context.path}#{api.root.path}" />
>>> 
>>> 
>>> >> value="127.0.0.1"/>
>>> >> value="externalAPIConnector"/>
>>> 
>>> 
>>> 
>>> 
>>> 
>>> >> class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
>>> 
>>> >> interface="org.osgi.service.http.HttpService" />
>>> >> class="org.apache.camel.component.servlet.osgi.OsgiServletRegisterer"
>>> init-method="register" 
>>> destroy-method="unregister">
>>> 
>>> >> />
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> In my jetty.xml:
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> >> type="org.eclipse.jetty.server.ConnectionFactory">
>>> 
>>> >> class="org.eclipse.jetty.server.HttpConnectionFactory">
>>> >> name="config">
>>> >> refid="httpConfig" />
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> >> default="127.0.0.1" />
>>> 
>>> 
>>> >> default="8285" />
>>> 
>>> 
>>> >> default="3" />
>>> 
>>> externalAPIConnector
>>> 
>>> 
>>> 
>>> 
>>> 
>>> In my Camel Context:
>>> 
>>> >> component="servlet"
>>> bindingMode="xml" 
>>> contextPath="{{context.path}}{{api.root.path}}" 
>>> port="{{port}}"
>>> enableCORS="false"
>>> clientRequestValidation="true">
>>> 
>>> 
>>> >> value="ResponderRestApiServlet"/>
>>> 
>>> 
>>> 
>>> But,  I am wondering if this correct, because in the example the Servlet is 
>>> registered with service property httpContext.id , 
>>> which I am not setting anywhere. The Jetty Connector name is configured in 
>>> the  org.ops4j.pax.web.service.whiteboard.HttpContextMapping,  but I don’t 
>>> see how it is matched to my Camel Servlet. Notice that the 
>>> org.apache.camel.component.servlet.osgi.OsgiServletRegisterer bean is the 
>>> one registering the servlet with the OSGi HTTP Service, but there is no way 
>>> to specify the httpContext.id  property.  Is this 
>>> property required to match the HttpContextMapping to the Servlet?
>>> 
>>> Any insight is appreciated.
>>> 
>>> Best regards,
>>> Alex soto
>>> 
>>> 
>>> 
>>> 
 On Jan 31, 2020, at 9:29 AM, Alex Soto >>> > wrote:
 
 Thanks JB and Markus,
 
 This is very close to what I am looking for (I still need to read more the 
 examples) but in my particular case, I am using Camel Rest DSL (with 
 servl

Re: Http Whiteboard - Pax-Web multiple instances

2020-02-12 Thread Alex Soto
I’m sorry to ask, JB, I know you are busy, but did you have time for this 
example?

Best regards,
Alex soto




> On Feb 5, 2020, at 3:09 PM, Jean-Baptiste Onofre  wrote:
> 
> Hi Alex,
> 
> I will add a full example tomorrow. I’m fully busy today.
> 
> Regards
> JB
> 
>> Le 5 févr. 2020 à 19:23, Alex Soto > > a écrit :
>> 
>> Anybody can validate this approach?
>> As I said, it appears to work, except in my case I don’t see how to specify 
>> the context.id  property in the Camel Servlet.
>> JB?
>> 
>> 
>> 
>>> On Jan 31, 2020, at 1:30 PM, Alex Soto >> > wrote:
>>> 
>>> This seems to work for me, but I have my doubts.   Following the example 
>>> here: 
>>> https://github.com/ops4j/org.ops4j.pax.web/tree/master/samples/whiteboard-extended
>>>  
>>> 
>>>   I made the following changes. 
>>> 
>>> In my blueprint:
>>> 
>>> >> interface="org.ops4j.pax.web.service.whiteboard.HttpContextMapping">
>>> 
>>> http://httpcontext.id/>">
>>>   externalAPIContext
>>>   
>>> 
>>> 
>>> >> class="org.ops4j.pax.web.extender.whiteboard.runtime.DefaultHttpContextMapping">
>>> >> value="externalAPIContext" />
>>> >> value="#{context.path}#{api.root.path}" />
>>> 
>>> 
>>> >> value="127.0.0.1"/>
>>> >> value="externalAPIConnector"/>
>>> 
>>> 
>>> 
>>> 
>>> 
>>> >> class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
>>> 
>>> >> interface="org.osgi.service.http.HttpService" />
>>> >> class="org.apache.camel.component.servlet.osgi.OsgiServletRegisterer"
>>> init-method="register" 
>>> destroy-method="unregister">
>>> 
>>> >> />
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> In my jetty.xml:
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> >> type="org.eclipse.jetty.server.ConnectionFactory">
>>> 
>>> >> class="org.eclipse.jetty.server.HttpConnectionFactory">
>>> >> name="config">
>>> >> refid="httpConfig" />
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> >> default="127.0.0.1" />
>>> 
>>> 
>>> >> default="8285" />
>>> 
>>> 
>>> >> default="3" />
>>> 
>>> externalAPIConnector
>>> 
>>> 
>>> 
>>> 
>>> 
>>> In my Camel Context:
>>> 
>>> >> component="servlet"
>>> bindingMode="xml" 
>>> contextPath="{{context.path}}{{api.root.path}}" 
>>> port="{{port}}"
>>> enableCORS="false"
>>> clientRequestValidation="true">
>>> 
>>> 
>>> >> value="ResponderRestApiServlet"/>
>>> 
>>> 
>>> 
>>> But,  I am wondering if this correct, because in the example the Servlet is 
>>> registered with service property httpContext.id , 
>>> which I am not setting anywhere. The Jetty Connector name is configured in 
>>> the  org.ops4j.pax.web.service.whiteboard.HttpContextMapping,  but I don’t 
>>> see how it is matched to my Camel Servlet. Notice that the 
>>> org.apache.camel.component.servlet.osgi.OsgiServletRegisterer bean is the 
>>> one registering the servlet with the OSGi HTTP Service, but there is no way 
>>> to specify the httpContext.id  property.  Is this 
>>> property required to match the HttpContextMapping to the Servlet?
>>> 
>>> Any insight is appreciated.
>>> 
>>> Best regards,
>>> Alex soto
>>> 
>>> 
>>> 
>>> 
 On Jan 31, 2020, at 9:29 AM, Alex Soto >>> > wrote:
 
 Thanks JB and Markus,
 
 This is very close to what I am looking for (I still need to read more the 
 examples) 

Re: Http Whiteboard - Pax-Web multiple instances

2020-02-12 Thread Jean-Baptiste Onofre
Hi Alex,

I’m very sorry, I completely forgot :/

I’m working on it today and tomorrow.

Sorry again :/

Regards
JB

> Le 12 févr. 2020 à 18:09, Alex Soto  a écrit :
> 
> I’m sorry to ask, JB, I know you are busy, but did you have time for this 
> example?
> 
> Best regards,
> Alex soto
> 
> 
> 
> 
>> On Feb 5, 2020, at 3:09 PM, Jean-Baptiste Onofre > > wrote:
>> 
>> Hi Alex,
>> 
>> I will add a full example tomorrow. I’m fully busy today.
>> 
>> Regards
>> JB
>> 
>>> Le 5 févr. 2020 à 19:23, Alex Soto >> > a écrit :
>>> 
>>> Anybody can validate this approach?
>>> As I said, it appears to work, except in my case I don’t see how to specify 
>>> the context.id  property in the Camel Servlet.
>>> JB?
>>> 
>>> 
>>> 
 On Jan 31, 2020, at 1:30 PM, Alex Soto >>> > wrote:
 
 This seems to work for me, but I have my doubts.   Following the example 
 here: 
 https://github.com/ops4j/org.ops4j.pax.web/tree/master/samples/whiteboard-extended
  
 
   I made the following changes. 
 
 In my blueprint:
 
>>> interface="org.ops4j.pax.web.service.whiteboard.HttpContextMapping">

http://httpcontext.id/>">
  externalAPIContext
  


>>> class="org.ops4j.pax.web.extender.whiteboard.runtime.DefaultHttpContextMapping">
>>> value="externalAPIContext" />
>>> value="#{context.path}#{api.root.path}" />


>>> value="127.0.0.1"/>
>>> value="externalAPIConnector"/>





>>> class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>

>>> interface="org.osgi.service.http.HttpService" />
>>> class="org.apache.camel.component.servlet.osgi.OsgiServletRegisterer"
init-method="register" 
destroy-method="unregister">

>>> />





 
 
 In my jetty.xml:
 







>>> type="org.eclipse.jetty.server.ConnectionFactory">

>>> class="org.eclipse.jetty.server.HttpConnectionFactory">
>>> name="config">
>>> refid="httpConfig" />






>>> default="127.0.0.1" />


>>> default="8285" />


>>> default="3" />

externalAPIConnector



 
 
 In my Camel Context:
 
>>>component="servlet"
bindingMode="xml" 
contextPath="{{context.path}}{{api.root.path}}" 
port="{{port}}"
enableCORS="false"
clientRequestValidation="true">
 

>>> value="ResponderRestApiServlet"/>

 
 
 But,  I am wondering if this correct, because in the example the Servlet 
 is registered with service property httpContext.id 
 , which I am not setting anywhere. The Jetty 
 Connector name is configured in the  
 org.ops4j.pax.web.service.whiteboard.HttpContextMapping,  but I don’t see 
 how it is matched to my Camel Servlet. Notice that the 
 org.apache.camel.component.servlet.osgi.OsgiServletRegisterer bean is the 
 one registering the servlet with the OSGi HTTP Service, but there is no 
 way to specify the httpContext.id  property.  Is 
 this property required to match the HttpContextMapping to the Servlet?
 
 Any insight is

Re: Http Whiteboard - Pax-Web multiple instances

2020-02-13 Thread Alex Soto
No worries,  I really appreciate it. 
Just need some clarity on how to setup separate Pax-Web to expose Web and Rest 
interfaces on different ports.

Best regards,
Alex soto




> On Feb 13, 2020, at 1:51 AM, Jean-Baptiste Onofre  wrote:
> 
> Hi Alex,
> 
> I’m very sorry, I completely forgot :/
> 
> I’m working on it today and tomorrow.
> 
> Sorry again :/
> 
> Regards
> JB
> 
>> Le 12 févr. 2020 à 18:09, Alex Soto > > a écrit :
>> 
>> I’m sorry to ask, JB, I know you are busy, but did you have time for this 
>> example?
>> 
>> Best regards,
>> Alex soto
>> 
>> 
>> 
>> 
>>> On Feb 5, 2020, at 3:09 PM, Jean-Baptiste Onofre >> > wrote:
>>> 
>>> Hi Alex,
>>> 
>>> I will add a full example tomorrow. I’m fully busy today.
>>> 
>>> Regards
>>> JB
>>> 
 Le 5 févr. 2020 à 19:23, Alex Soto >>> > a écrit :
 
 Anybody can validate this approach?
 As I said, it appears to work, except in my case I don’t see how to 
 specify the context.id  property in the Camel Servlet.
 JB?
 
 
 
> On Jan 31, 2020, at 1:30 PM, Alex Soto  > wrote:
> 
> This seems to work for me, but I have my doubts.   Following the example 
> here: 
> https://github.com/ops4j/org.ops4j.pax.web/tree/master/samples/whiteboard-extended
>  
> 
>   I made the following changes. 
> 
> In my blueprint:
> 
>    interface="org.ops4j.pax.web.service.whiteboard.HttpContextMapping">
>   
>   http://httpcontext.id/>">
> externalAPIContext
> 
>   
>   
>    class="org.ops4j.pax.web.extender.whiteboard.runtime.DefaultHttpContextMapping">
>    value="externalAPIContext" />
>    value="#{context.path}#{api.root.path}" />
>   
>   
>    value="127.0.0.1"/>
>    value="externalAPIConnector"/>
>   
>   
>   
>   
>   
>    class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
>   
>    interface="org.osgi.service.http.HttpService" />
>    class="org.apache.camel.component.servlet.osgi.OsgiServletRegisterer"
>   init-method="register" 
>   destroy-method="unregister">
>   
>    />
>   
>   
>   
>   
>   
> 
> 
> In my jetty.xml:
> 
>   
>   
>   
>   
>   
>   
>   
>    type="org.eclipse.jetty.server.ConnectionFactory">
>   
>    class="org.eclipse.jetty.server.HttpConnectionFactory">
>    name="config">
>    refid="httpConfig" />
>   
>   
>   
>   
>   
>   
>    default="127.0.0.1" />
>   
>   
>    default="8285" />
>   
>   
>    default="3" />
>   
>   externalAPIConnector
>   
>   
>   
> 
> 
> In my Camel Context:
> 
>      component="servlet"
>   bindingMode="xml" 
>   contextPath="{{context.path}}{{api.root.path}}" 
>   port="{{port}}"
>   enableCORS="false"
>   clientRequestValidation="true">
> 
>   
>    value="ResponderRestApiServlet"/>
>   
> 
> 
> But,  I am wondering if this correct, because in the example the Servlet 
> is registered with service property httpContext.id 
> , which I am not setting anywhere. The Jetty 
> Connector name is configured in the  
> org.ops4j.pax.web.service.whiteboard.HttpContextMapping,  but I don’t see 
> how it is matched to

Re: Http Whiteboard - Pax-Web multiple instances

2020-03-09 Thread Alex Soto
Well, this is not working for me.  Following the provided example, I am 
registering the servlet:

public class Activator implements BundleActivator {

private static final String ID = "admin-jolokia";
private static final String PATH = "/jolokia";
private ServiceRegistration httpContextMappingReg;
private ServiceRegistration servletReg;

@Override
public void start(final BundleContext bundleContext) throws Exception {
Dictionary props = new Hashtable<>();
props.put(ExtenderConstants.PROPERTY_HTTP_CONTEXT_ID, ID);

HashMap contextMappingParams = new HashMap<>();

contextMappingParams.put(ExtenderConstants.PROPERTY_HTTP_CONNECTORS, 
"internalConnector");

httpContextMappingReg = bundleContext.registerService(
HttpContextMapping.class, new 
WhiteboardHttpContextMapping(
ID,
PATH,
contextMappingParams),
props);

props = new Hashtable<>();
props.put(ExtenderConstants.PROPERTY_ALIAS, PATH);
props.put(ExtenderConstants.PROPERTY_HTTP_CONTEXT_ID, ID);
props.put(WebContainerConstants.SERVLET_NAME, "JolokiaServlet");
servletReg = bundleContext.registerService(Servlet.class, new 
JolokiaServlet(bundleContext), props);
}

@Override
public void stop(BundleContext bundleContext) throws Exception {
if (servletReg != null) {
servletReg.unregister();
servletReg = null;
}
if (httpContextMappingReg != null) {
httpContextMappingReg.unregister();
httpContextMappingReg = null;
}
}
}

To avoid automatic registration by Jolokia, I configure Jolokia to not register 
the Servlet:


org.jolokia.realm=karaf
org.jolokia.listenForHttpService=false


The servlet appears to be registered:


karaf@root()> service:list Servlet
[javax.servlet.Servlet]
---
 alias = /jolokia
 httpContext.id = admin-jolokia
 service.bundleid = 38
 service.id = 379
 service.scope = singleton
 servlet-name = JolokiaServlet
Provided by : 
 EncryptedQuery :: Responder :: Admin (38)
Used by: 
 OPS4J Pax Web - Extender - Whiteboard (317)


And:

karaf@root()> http:list
ID  │ Servlet   │ Servlet-Name │ State   │ 
Alias │ Url
┼───┼──┼─┼───┼─
38  │ JolokiaServlet│ JolokiaServlet   │ Deployed│ 
/jolokia  │ [/jolokia/*]


However, a GET request always returns error 404 in all ports.
If I remove the configuration and the Activator, then Jolokia is bound to all 
interfaces, but the it is not prompting for authentication. 

Any ideas about what I may be doing wrong?

Best regards,
Alex soto




> On Feb 4, 2020, at 6:17 AM, Markus Rathgeb  wrote:
> 
> Hi all,
> 
> the both examples and its mechanism differs (thanks for providing it).
> 
> The one JB refers to is using a bundle header. This example has (the
> time I tested it) not worked for me. My research (at the time I
> comment this the first time) has been that this works for the usage of
> the "Web Application Specification" only. I did not check it again,
> but I was not aware that something has been changed.
> 
> The one Achim refers to uses a HttpContextMapping service additional
> to the Servlet service and sets the necessary properties.
> Achim, thanks a lot for your example. This one is working for me!
> 
>> https://github.com/ops4j/org.ops4j.pax.web/blob/master/samples/whiteboard-extended/src/main/java/org/ops4j/pax/web/extender/samples/whiteboard/internal/Activator.java
> 
> As it is only an example, it does not matter, but there is a bug in
> this example.
> All the http context mapping service registrations are assigned to
> "httpContextMappingReg" and all servlet registrations to "servletReg".
> The respective ...2 and ...3 variables are not used.
> So, there is only one of each service unregistered and freed.
> 
> Best regards,
> Markus



Re: Http Whiteboard - Pax-Web multiple instances

2020-03-10 Thread Alex Soto
Ok, so I tried deploying  the unmodified Whiteboard extended sample (version 
7.2.14) from 
https://github.com/ops4j/org.ops4j.pax.web/tree/web-7.2.14/samples/whiteboard-extended
 

 in Karaf 4.2.8.
I made sure my jetty xml has the jettyConn1 connection:



























jettyConn1




I can see the servlets are deployed:

karaf@root()> http:list 


ID  │ Servlet   │ Servlet-Name │ State   │ 
Alias │ Url
───┼──┼──┼─┼───┼─
309 │ WhiteboardServlet │ ServletModel-26  │ Deployed│ 
/whiteboard   │ [/whiteboard/*]
309 │ WhiteboardServlet │ ServletModel-28  │ Deployed│ 
/whiteboard2  │ [/whiteboard2/*]
309 │ WhiteboardServlet │ ServletModel-30  │ Deployed│ 
/whiteboard3  │ [/whiteboard3/*]
309 │ WhiteboardServlet │ ServletModel-32  │ Deployed│ 
/whiteboard4  │ [/whiteboard4/*]

But Jetty is responding 404 to GET on  http://localhost:8282/whiteboard 
 , same for all other ports.

I see this warning in the log file:

2020-03-10T10:12:07,497 | WARN  | features-3-thread-1 | ContextHandler  
 | 245 - org.eclipse.jetty.util - 9.4.22.v20191022 | ContextHandler 
[localhost, @jettyConn1] has a connector only entry e.g. "@connector" and one 
or more host only entries. 
The host entries will be ignored to match legacy behavior.  To clear this 
warning remove the host entries or update to use at least one host@connector 
syntax entry that will match a host for an specific connector


What does this warning means?
Why is Jetty responding with a 404?


Best regards,
Alex soto




> On Mar 9, 2020, at 4:52 PM, Alex Soto  wrote:
> 
> Well, this is not working for me.  Following the provided example, I am 
> registering the servlet:
> 
> public class Activator implements BundleActivator {
> 
>   private static final String ID = "admin-jolokia";
>   private static final String PATH = "/jolokia";
>   private ServiceRegistration httpContextMappingReg;
>   private ServiceRegistration servletReg;
> 
>   @Override
>   public void start(final BundleContext bundleContext) throws Exception {
>   Dictionary props = new Hashtable<>();
>   props.put(ExtenderConstants.PROPERTY_HTTP_CONTEXT_ID, ID);
> 
>   HashMap contextMappingParams = new HashMap<>();
>   
> contextMappingParams.put(ExtenderConstants.PROPERTY_HTTP_CONNECTORS, 
> "internalConnector");
> 
>   httpContextMappingReg = bundleContext.registerService(
>   HttpContextMapping.class, new 
> WhiteboardHttpContextMapping(
>   ID,
>   PATH,
>   contextMappingParams),
>   props);
> 
>   props = new Hashtable<>();
>   props.put(ExtenderConstants.PROPERTY_ALIAS, PATH);
>   props.put(ExtenderConstants.PROPERTY_HTTP_CONTEXT_ID, ID);
>   props.put(WebContainerConstants.SERVLET_NAME, "JolokiaServlet");
>   servletReg = bundleContext.registerService(Servlet.class, new 
> JolokiaServlet(bundleContext), props);
>   }
> 
>   @Override
>   public void stop(BundleContext bundleContext) throws Exception {
>   if (servletReg != null) {
>   servletReg.unregister();
>   se