You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Alex Soto <al...@envieta.com> on 2020/01/31 13:32:05 UTC

Http Whiteboard - Pax-Web multiple instances

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





Re: Http Whiteboard - Pax-Web multiple instances

Posted by Achim Nierbeck <bc...@googlemail.com>.
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 <
maggu2810@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 <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Re: Http Whiteboard - Pax-Web multiple instances

Posted by Alex Soto <al...@envieta.com>.
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 <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:

	<Call name="addConnector">
		<Arg>
			<New class="org.eclipse.jetty.server.ServerConnector">
				<Arg name="server">
					<Ref refid="Server" />
				</Arg>
				<Arg name="factories">
					<Array type="org.eclipse.jetty.server.ConnectionFactory">
						<Item>
							<New class="org.eclipse.jetty.server.HttpConnectionFactory">
								<Arg name="config">
									<Ref refid="httpConfig" />
								</Arg>
							</New>
						</Item>
					</Array>
				</Arg>
				<Set name="host">
					<Property name="jetty.host" default="localhost" />
				</Set>
				<Set name="port">
					<Property name="jetty.port" default="8282" />
				</Set>
				<Set name="idleTimeout">
					<Property name="http.timeout" default="30000" />
				</Set>
				<Set name="name">jettyConn1</Set>
			</New>
		</Arg>
	</Call>

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 <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 <al...@envieta.com> 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<HttpContextMapping> httpContextMappingReg;
> 	private ServiceRegistration<Servlet> servletReg;
> 
> 	@Override
> 	public void start(final BundleContext bundleContext) throws Exception {
> 		Dictionary<String, String> props = new Hashtable<>();
> 		props.put(ExtenderConstants.PROPERTY_HTTP_CONTEXT_ID, ID);
> 
> 		HashMap<String, String> 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:
> 
> 		<config name="org.jolokia.osgi">
> 			org.jolokia.realm=karaf
> 			org.jolokia.listenForHttpService=false
> 		</config>
> 
> The servlet appears to be registered:
> 
> 
> karaf@root()> service:list Servlet
> [javax.servlet.Servlet]
> -----------------------
>  alias = /jolokia
>  httpContext.id <http://httpcontext.id/> = admin-jolokia
>  service.bundleid = 38
>  service.id <http://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 <maggu2810@gmail.com <ma...@gmail.com>> 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 <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

Posted by Alex Soto <al...@envieta.com>.
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<HttpContextMapping> httpContextMappingReg;
	private ServiceRegistration<Servlet> servletReg;

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

		HashMap<String, String> 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:

		<config name="org.jolokia.osgi">
			org.jolokia.realm=karaf
			org.jolokia.listenForHttpService=false
		</config>

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 <ma...@gmail.com> 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

Posted by Markus Rathgeb <ma...@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

Re: Http Whiteboard - Pax-Web multiple instances

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
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
> <maggu2810@gmail.com <ma...@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 <http://karaf.apache.org/> Committer & PMC
> OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer
> & Project Lead
> blog <http://notizblog.nierbeck.de/>
> Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>
> 

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

Re: Http Whiteboard - Pax-Web multiple instances

Posted by Achim Nierbeck <bc...@googlemail.com>.
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 <
maggu2810@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 <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Re: Http Whiteboard - Pax-Web multiple instances

Posted by Markus Rathgeb <ma...@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.

Re: Http Whiteboard - Pax-Web multiple instances

Posted by Achim Nierbeck <bc...@googlemail.com>.
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 <alex.soto@envieta.com
>:

> 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:
>
> <service interface=
> "org.ops4j.pax.web.service.whiteboard.HttpContextMapping">
> <service-properties>
> <entry key="httpContext.id">
>           <value>externalAPIContext</value>
>       </entry>
> </service-properties>
>
>
> <bean class=
> "org.ops4j.pax.web.extender.whiteboard.runtime.DefaultHttpContextMapping">
> <property name="httpContextId" value="externalAPIContext" />
> <property name="path" value="#{context.path}#{api.root.path}" />
> <property name="parameters">
> <map>
> <entry key="httpContext.virtualhosts" value="127.0.0.1"/>
> <entry key="httpContext.connectors" value="externalAPIConnector"/>
> </map>
> </property>
> </bean>
> </service>
>
>
> <bean id="camelServlet" class=
> "org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
>
>
> <reference id="httpService" interface="org.osgi.service.http.HttpService"
> />
> <bean class=
> "org.apache.camel.component.servlet.osgi.OsgiServletRegisterer"
> init-method="register"
> destroy-method="unregister">
>
>
> <property name="alias" value="#{context.path}#{api.root.path}" />
> <property name="httpService" ref="httpService" />
> <property name="servlet" ref="camelServlet" />
> <property name="servletName" value="ResponderRestApiServlet"/>
> <property name="matchOnUriPrefix" value="true"/>
> </bean>
>
>
> In my jetty.xml:
>
> <Call name="addConnector">
> <Arg>
> <New class="org.eclipse.jetty.server.ServerConnector">
> <Arg name="server">
> <Ref refid="Server" />
> </Arg>
> <Arg name="factories">
> <Array type="org.eclipse.jetty.server.ConnectionFactory">
> <Item>
> <New class="org.eclipse.jetty.server.HttpConnectionFactory">
> <Arg name="config">
> <Ref refid="httpConfig" />
> </Arg>
> </New>
> </Item>
> </Array>
> </Arg>
> <Set name="host">
> <Property name="jetty.host" default="127.0.0.1" />
> </Set>
> <Set name="port">
> <Property name="jetty.port" default="8285" />
> </Set>
> <Set name="idleTimeout">
> <Property name="http.timeout" default="30000" />
> </Set>
> <Set name="name">externalAPIConnector</Set>
> </New>
> </Arg>
> </Call>
>
>
> In my Camel Context:
>
> <restConfiguration
> component="servlet"
> bindingMode="xml"
> contextPath="{{context.path}}{{api.root.path}}"
> port="{{port}}"
> enableCORS="false"
> clientRequestValidation="true">
>
> <componentProperty key="matchOnUriPrefix" value="true"/>
> <endpointProperty key="servletName" value="ResponderRestApiServlet"/>
> </restConfiguration>
>
>
> But,  I am wondering if this correct, because in the example the Servlet
> is registered with service property *httpContext.id
> <http://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 <http://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 <al...@envieta.com> 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:
>
> <reference id="httpService" interface="org.osgi.service.http.HttpService"
> />
> <bean id="camelServlet" class=
> "org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
> <bean class=“
> org.apache.camel.component.servlet.osgi.OsgiServletRegisterer" init-method
> ="register" destroy-method="unregister”>
> <property name="alias" value="#{context.path}#{api.root.path}" />
> <property name="httpService" ref="httpService" />
> <property name="servlet" ref="camelServlet" />
> <property name="servletName" value="RestApiServlet"/>
> <property name="matchOnUriPrefix" value="true"/>
> </bean>
>
> <restConfiguration component=“servlet" bindingMode="xml" contextPath=
> "{{context.path}}{{api.root.path}}"
> port="{{port}}"
> enableCORS="false"
> clientRequestValidation="true">
> <componentProperty key="matchOnUriPrefix" value="true"/>
> <endpointProperty key="servletName" 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 <ma...@gmail.com> 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?
>
>
>
>

-- 

Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Re: Http Whiteboard - Pax-Web multiple instances

Posted by Alex Soto <al...@envieta.com>.
Thank you JB!

Best regards,
Alex soto




> On Feb 5, 2020, at 3:09 PM, Jean-Baptiste Onofre <jb...@nanthrax.net> 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 <alex.soto@envieta.com <ma...@envieta.com>> 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 <http://context.id/> property in the Camel Servlet.
>> JB?
>> 
>> 
>> 
>>> On Jan 31, 2020, at 1:30 PM, Alex Soto <alex.soto@envieta.com <ma...@envieta.com>> 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 <https://github.com/ops4j/org.ops4j.pax.web/tree/master/samples/whiteboard-extended>  I made the following changes. 
>>> 
>>> In my blueprint:
>>> 
>>> 	<service interface="org.ops4j.pax.web.service.whiteboard.HttpContextMapping">
>>> 		<service-properties>
>>> 			<entry key="httpContext.id <http://httpcontext.id/>">
>>> 		          <value>externalAPIContext</value>
>>> 		      </entry>
>>> 		</service-properties>
>>> 		
>>> 		<bean class="org.ops4j.pax.web.extender.whiteboard.runtime.DefaultHttpContextMapping">
>>> 			<property name="httpContextId" value="externalAPIContext" />
>>> 			<property name="path" value="#{context.path}#{api.root.path}" />
>>> 			<property name="parameters">
>>> 				<map>
>>> 					<entry key="httpContext.virtualhosts" value="127.0.0.1"/>
>>> 					<entry key="httpContext.connectors" value="externalAPIConnector"/>
>>> 				</map>
>>> 			</property>
>>> 		</bean>
>>> 	</service>
>>> 	
>>> 	<bean id="camelServlet" class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
>>> 	
>>> 	<reference id="httpService" interface="org.osgi.service.http.HttpService" />
>>> 	<bean class="org.apache.camel.component.servlet.osgi.OsgiServletRegisterer"
>>> 		init-method="register" 
>>> 		destroy-method="unregister">
>>> 		
>>> 		<property name="alias" value="#{context.path}#{api.root.path}" />
>>> 		<property name="httpService" ref="httpService" />
>>> 		<property name="servlet" ref="camelServlet" />
>>> 		<property name="servletName" value="ResponderRestApiServlet"/>
>>> 		<property name="matchOnUriPrefix" value="true"/>
>>> 	</bean>
>>> 
>>> 
>>> In my jetty.xml:
>>> 
>>> 	<Call name="addConnector">
>>> 		<Arg>
>>> 			<New class="org.eclipse.jetty.server.ServerConnector">
>>> 				<Arg name="server">
>>> 					<Ref refid="Server" />
>>> 				</Arg>
>>> 				<Arg name="factories">
>>> 					<Array type="org.eclipse.jetty.server.ConnectionFactory">
>>> 						<Item>
>>> 							<New class="org.eclipse.jetty.server.HttpConnectionFactory">
>>> 								<Arg name="config">
>>> 									<Ref refid="httpConfig" />
>>> 								</Arg>
>>> 							</New>
>>> 						</Item>
>>> 					</Array>
>>> 				</Arg>
>>> 				<Set name="host">
>>> 					<Property name="jetty.host" default="127.0.0.1" />
>>> 				</Set>
>>> 				<Set name="port">
>>> 					<Property name="jetty.port" default="8285" />
>>> 				</Set>
>>> 				<Set name="idleTimeout">
>>> 					<Property name="http.timeout" default="30000" />
>>> 				</Set>
>>> 				<Set name="name">externalAPIConnector</Set>
>>> 			</New>
>>> 		</Arg>
>>> 	</Call>
>>> 
>>> 
>>> In my Camel Context:
>>> 
>>> 	<restConfiguration 
>>> 		component="servlet"
>>> 		bindingMode="xml" 
>>> 		contextPath="{{context.path}}{{api.root.path}}" 
>>> 		port="{{port}}"
>>> 		enableCORS="false"
>>> 		clientRequestValidation="true">
>>> 
>>> 		<componentProperty key="matchOnUriPrefix" value="true"/>
>>> 		<endpointProperty key="servletName" value="ResponderRestApiServlet"/>
>>> 		</restConfiguration>
>>> 
>>> 
>>> But,  I am wondering if this correct, because in the example the Servlet is registered with service property httpContext.id <http://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 <http://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 <alex.soto@envieta.com <ma...@envieta.com>> 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:
>>>> 
>>>> 	<reference id="httpService" interface="org.osgi.service.http.HttpService" />
>>>> 	<bean id="camelServlet" class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
>>>> 	<bean class=“org.apache.camel.component.servlet.osgi.OsgiServletRegisterer" init-method="register" destroy-method="unregister”>
>>>> 		<property name="alias" value="#{context.path}#{api.root.path}" />
>>>> 		<property name="httpService" ref="httpService" />
>>>> 		<property name="servlet" ref="camelServlet" />
>>>> 		<property name="servletName" value="RestApiServlet"/>
>>>> 		<property name="matchOnUriPrefix" value="true"/>
>>>> 	</bean> 
>>>> 
>>>> 	<restConfiguration component=“servlet" bindingMode="xml" contextPath="{{context.path}}{{api.root.path}}" 
>>>> 			port="{{port}}"
>>>> 			enableCORS="false"
>>>> 			clientRequestValidation="true">
>>>> 			<componentProperty key="matchOnUriPrefix" value="true"/>
>>>> 			<endpointProperty key="servletName" 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 <maggu2810@gmail.com <ma...@gmail.com>> 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 <https://lists.apache.org/thread.html/69182ee8feef88896f840efde48146053997119e820ef037853c1c9b@%3Cuser.karaf.apache.org%3E>
>>>>>> You also referenced to http://blog.nanthrax.net/?p=352 <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

Posted by Alex Soto <al...@envieta.com>.
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 <jb...@nanthrax.net> 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 <alex.soto@envieta.com <ma...@envieta.com>> 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 <jb@nanthrax.net <ma...@nanthrax.net>> 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 <alex.soto@envieta.com <ma...@envieta.com>> 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 <http://context.id/> property in the Camel Servlet.
>>>> JB?
>>>> 
>>>> 
>>>> 
>>>>> On Jan 31, 2020, at 1:30 PM, Alex Soto <alex.soto@envieta.com <ma...@envieta.com>> 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 <https://github.com/ops4j/org.ops4j.pax.web/tree/master/samples/whiteboard-extended>  I made the following changes. 
>>>>> 
>>>>> In my blueprint:
>>>>> 
>>>>> 	<service interface="org.ops4j.pax.web.service.whiteboard.HttpContextMapping">
>>>>> 		<service-properties>
>>>>> 			<entry key="httpContext.id <http://httpcontext.id/>">
>>>>> 		          <value>externalAPIContext</value>
>>>>> 		      </entry>
>>>>> 		</service-properties>
>>>>> 		
>>>>> 		<bean class="org.ops4j.pax.web.extender.whiteboard.runtime.DefaultHttpContextMapping">
>>>>> 			<property name="httpContextId" value="externalAPIContext" />
>>>>> 			<property name="path" value="#{context.path}#{api.root.path}" />
>>>>> 			<property name="parameters">
>>>>> 				<map>
>>>>> 					<entry key="httpContext.virtualhosts" value="127.0.0.1"/>
>>>>> 					<entry key="httpContext.connectors" value="externalAPIConnector"/>
>>>>> 				</map>
>>>>> 			</property>
>>>>> 		</bean>
>>>>> 	</service>
>>>>> 	
>>>>> 	<bean id="camelServlet" class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
>>>>> 	
>>>>> 	<reference id="httpService" interface="org.osgi.service.http.HttpService" />
>>>>> 	<bean class="org.apache.camel.component.servlet.osgi.OsgiServletRegisterer"
>>>>> 		init-method="register" 
>>>>> 		destroy-method="unregister">
>>>>> 		
>>>>> 		<property name="alias" value="#{context.path}#{api.root.path}" />
>>>>> 		<property name="httpService" ref="httpService" />
>>>>> 		<property name="servlet" ref="camelServlet" />
>>>>> 		<property name="servletName" value="ResponderRestApiServlet"/>
>>>>> 		<property name="matchOnUriPrefix" value="true"/>
>>>>> 	</bean>
>>>>> 
>>>>> 
>>>>> In my jetty.xml:
>>>>> 
>>>>> 	<Call name="addConnector">
>>>>> 		<Arg>
>>>>> 			<New class="org.eclipse.jetty.server.ServerConnector">
>>>>> 				<Arg name="server">
>>>>> 					<Ref refid="Server" />
>>>>> 				</Arg>
>>>>> 				<Arg name="factories">
>>>>> 					<Array type="org.eclipse.jetty.server.ConnectionFactory">
>>>>> 						<Item>
>>>>> 							<New class="org.eclipse.jetty.server.HttpConnectionFactory">
>>>>> 								<Arg name="config">
>>>>> 									<Ref refid="httpConfig" />
>>>>> 								</Arg>
>>>>> 							</New>
>>>>> 						</Item>
>>>>> 					</Array>
>>>>> 				</Arg>
>>>>> 				<Set name="host">
>>>>> 					<Property name="jetty.host" default="127.0.0.1" />
>>>>> 				</Set>
>>>>> 				<Set name="port">
>>>>> 					<Property name="jetty.port" default="8285" />
>>>>> 				</Set>
>>>>> 				<Set name="idleTimeout">
>>>>> 					<Property name="http.timeout" default="30000" />
>>>>> 				</Set>
>>>>> 				<Set name="name">externalAPIConnector</Set>
>>>>> 			</New>
>>>>> 		</Arg>
>>>>> 	</Call>
>>>>> 
>>>>> 
>>>>> In my Camel Context:
>>>>> 
>>>>> 	<restConfiguration 
>>>>> 		component="servlet"
>>>>> 		bindingMode="xml" 
>>>>> 		contextPath="{{context.path}}{{api.root.path}}" 
>>>>> 		port="{{port}}"
>>>>> 		enableCORS="false"
>>>>> 		clientRequestValidation="true">
>>>>> 
>>>>> 		<componentProperty key="matchOnUriPrefix" value="true"/>
>>>>> 		<endpointProperty key="servletName" value="ResponderRestApiServlet"/>
>>>>> 		</restConfiguration>
>>>>> 
>>>>> 
>>>>> But,  I am wondering if this correct, because in the example the Servlet is registered with service property httpContext.id <http://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 <http://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 <alex.soto@envieta.com <ma...@envieta.com>> 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:
>>>>>> 
>>>>>> 	<reference id="httpService" interface="org.osgi.service.http.HttpService" />
>>>>>> 	<bean id="camelServlet" class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
>>>>>> 	<bean class=“org.apache.camel.component.servlet.osgi.OsgiServletRegisterer" init-method="register" destroy-method="unregister”>
>>>>>> 		<property name="alias" value="#{context.path}#{api.root.path}" />
>>>>>> 		<property name="httpService" ref="httpService" />
>>>>>> 		<property name="servlet" ref="camelServlet" />
>>>>>> 		<property name="servletName" value="RestApiServlet"/>
>>>>>> 		<property name="matchOnUriPrefix" value="true"/>
>>>>>> 	</bean> 
>>>>>> 
>>>>>> 	<restConfiguration component=“servlet" bindingMode="xml" contextPath="{{context.path}}{{api.root.path}}" 
>>>>>> 			port="{{port}}"
>>>>>> 			enableCORS="false"
>>>>>> 			clientRequestValidation="true">
>>>>>> 			<componentProperty key="matchOnUriPrefix" value="true"/>
>>>>>> 			<endpointProperty key="servletName" 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 <maggu2810@gmail.com <ma...@gmail.com>> 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 <https://lists.apache.org/thread.html/69182ee8feef88896f840efde48146053997119e820ef037853c1c9b@%3Cuser.karaf.apache.org%3E>
>>>>>>>> You also referenced to http://blog.nanthrax.net/?p=352 <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

Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
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 <al...@envieta.com> 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 <jb@nanthrax.net <ma...@nanthrax.net>> 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 <alex.soto@envieta.com <ma...@envieta.com>> 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 <http://context.id/> property in the Camel Servlet.
>>> JB?
>>> 
>>> 
>>> 
>>>> On Jan 31, 2020, at 1:30 PM, Alex Soto <alex.soto@envieta.com <ma...@envieta.com>> 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 <https://github.com/ops4j/org.ops4j.pax.web/tree/master/samples/whiteboard-extended>  I made the following changes. 
>>>> 
>>>> In my blueprint:
>>>> 
>>>> 	<service interface="org.ops4j.pax.web.service.whiteboard.HttpContextMapping">
>>>> 		<service-properties>
>>>> 			<entry key="httpContext.id <http://httpcontext.id/>">
>>>> 		          <value>externalAPIContext</value>
>>>> 		      </entry>
>>>> 		</service-properties>
>>>> 		
>>>> 		<bean class="org.ops4j.pax.web.extender.whiteboard.runtime.DefaultHttpContextMapping">
>>>> 			<property name="httpContextId" value="externalAPIContext" />
>>>> 			<property name="path" value="#{context.path}#{api.root.path}" />
>>>> 			<property name="parameters">
>>>> 				<map>
>>>> 					<entry key="httpContext.virtualhosts" value="127.0.0.1"/>
>>>> 					<entry key="httpContext.connectors" value="externalAPIConnector"/>
>>>> 				</map>
>>>> 			</property>
>>>> 		</bean>
>>>> 	</service>
>>>> 	
>>>> 	<bean id="camelServlet" class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
>>>> 	
>>>> 	<reference id="httpService" interface="org.osgi.service.http.HttpService" />
>>>> 	<bean class="org.apache.camel.component.servlet.osgi.OsgiServletRegisterer"
>>>> 		init-method="register" 
>>>> 		destroy-method="unregister">
>>>> 		
>>>> 		<property name="alias" value="#{context.path}#{api.root.path}" />
>>>> 		<property name="httpService" ref="httpService" />
>>>> 		<property name="servlet" ref="camelServlet" />
>>>> 		<property name="servletName" value="ResponderRestApiServlet"/>
>>>> 		<property name="matchOnUriPrefix" value="true"/>
>>>> 	</bean>
>>>> 
>>>> 
>>>> In my jetty.xml:
>>>> 
>>>> 	<Call name="addConnector">
>>>> 		<Arg>
>>>> 			<New class="org.eclipse.jetty.server.ServerConnector">
>>>> 				<Arg name="server">
>>>> 					<Ref refid="Server" />
>>>> 				</Arg>
>>>> 				<Arg name="factories">
>>>> 					<Array type="org.eclipse.jetty.server.ConnectionFactory">
>>>> 						<Item>
>>>> 							<New class="org.eclipse.jetty.server.HttpConnectionFactory">
>>>> 								<Arg name="config">
>>>> 									<Ref refid="httpConfig" />
>>>> 								</Arg>
>>>> 							</New>
>>>> 						</Item>
>>>> 					</Array>
>>>> 				</Arg>
>>>> 				<Set name="host">
>>>> 					<Property name="jetty.host" default="127.0.0.1" />
>>>> 				</Set>
>>>> 				<Set name="port">
>>>> 					<Property name="jetty.port" default="8285" />
>>>> 				</Set>
>>>> 				<Set name="idleTimeout">
>>>> 					<Property name="http.timeout" default="30000" />
>>>> 				</Set>
>>>> 				<Set name="name">externalAPIConnector</Set>
>>>> 			</New>
>>>> 		</Arg>
>>>> 	</Call>
>>>> 
>>>> 
>>>> In my Camel Context:
>>>> 
>>>> 	<restConfiguration 
>>>> 		component="servlet"
>>>> 		bindingMode="xml" 
>>>> 		contextPath="{{context.path}}{{api.root.path}}" 
>>>> 		port="{{port}}"
>>>> 		enableCORS="false"
>>>> 		clientRequestValidation="true">
>>>> 
>>>> 		<componentProperty key="matchOnUriPrefix" value="true"/>
>>>> 		<endpointProperty key="servletName" value="ResponderRestApiServlet"/>
>>>> 		</restConfiguration>
>>>> 
>>>> 
>>>> But,  I am wondering if this correct, because in the example the Servlet is registered with service property httpContext.id <http://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 <http://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 <alex.soto@envieta.com <ma...@envieta.com>> 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:
>>>>> 
>>>>> 	<reference id="httpService" interface="org.osgi.service.http.HttpService" />
>>>>> 	<bean id="camelServlet" class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
>>>>> 	<bean class=“org.apache.camel.component.servlet.osgi.OsgiServletRegisterer" init-method="register" destroy-method="unregister”>
>>>>> 		<property name="alias" value="#{context.path}#{api.root.path}" />
>>>>> 		<property name="httpService" ref="httpService" />
>>>>> 		<property name="servlet" ref="camelServlet" />
>>>>> 		<property name="servletName" value="RestApiServlet"/>
>>>>> 		<property name="matchOnUriPrefix" value="true"/>
>>>>> 	</bean> 
>>>>> 
>>>>> 	<restConfiguration component=“servlet" bindingMode="xml" contextPath="{{context.path}}{{api.root.path}}" 
>>>>> 			port="{{port}}"
>>>>> 			enableCORS="false"
>>>>> 			clientRequestValidation="true">
>>>>> 			<componentProperty key="matchOnUriPrefix" value="true"/>
>>>>> 			<endpointProperty key="servletName" 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 <maggu2810@gmail.com <ma...@gmail.com>> 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 <https://lists.apache.org/thread.html/69182ee8feef88896f840efde48146053997119e820ef037853c1c9b@%3Cuser.karaf.apache.org%3E>
>>>>>>> You also referenced to http://blog.nanthrax.net/?p=352 <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

Posted by Alex Soto <al...@envieta.com>.
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 <jb...@nanthrax.net> 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 <alex.soto@envieta.com <ma...@envieta.com>> 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 <http://context.id/> property in the Camel Servlet.
>> JB?
>> 
>> 
>> 
>>> On Jan 31, 2020, at 1:30 PM, Alex Soto <alex.soto@envieta.com <ma...@envieta.com>> 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 <https://github.com/ops4j/org.ops4j.pax.web/tree/master/samples/whiteboard-extended>  I made the following changes. 
>>> 
>>> In my blueprint:
>>> 
>>> 	<service interface="org.ops4j.pax.web.service.whiteboard.HttpContextMapping">
>>> 		<service-properties>
>>> 			<entry key="httpContext.id <http://httpcontext.id/>">
>>> 		          <value>externalAPIContext</value>
>>> 		      </entry>
>>> 		</service-properties>
>>> 		
>>> 		<bean class="org.ops4j.pax.web.extender.whiteboard.runtime.DefaultHttpContextMapping">
>>> 			<property name="httpContextId" value="externalAPIContext" />
>>> 			<property name="path" value="#{context.path}#{api.root.path}" />
>>> 			<property name="parameters">
>>> 				<map>
>>> 					<entry key="httpContext.virtualhosts" value="127.0.0.1"/>
>>> 					<entry key="httpContext.connectors" value="externalAPIConnector"/>
>>> 				</map>
>>> 			</property>
>>> 		</bean>
>>> 	</service>
>>> 	
>>> 	<bean id="camelServlet" class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
>>> 	
>>> 	<reference id="httpService" interface="org.osgi.service.http.HttpService" />
>>> 	<bean class="org.apache.camel.component.servlet.osgi.OsgiServletRegisterer"
>>> 		init-method="register" 
>>> 		destroy-method="unregister">
>>> 		
>>> 		<property name="alias" value="#{context.path}#{api.root.path}" />
>>> 		<property name="httpService" ref="httpService" />
>>> 		<property name="servlet" ref="camelServlet" />
>>> 		<property name="servletName" value="ResponderRestApiServlet"/>
>>> 		<property name="matchOnUriPrefix" value="true"/>
>>> 	</bean>
>>> 
>>> 
>>> In my jetty.xml:
>>> 
>>> 	<Call name="addConnector">
>>> 		<Arg>
>>> 			<New class="org.eclipse.jetty.server.ServerConnector">
>>> 				<Arg name="server">
>>> 					<Ref refid="Server" />
>>> 				</Arg>
>>> 				<Arg name="factories">
>>> 					<Array type="org.eclipse.jetty.server.ConnectionFactory">
>>> 						<Item>
>>> 							<New class="org.eclipse.jetty.server.HttpConnectionFactory">
>>> 								<Arg name="config">
>>> 									<Ref refid="httpConfig" />
>>> 								</Arg>
>>> 							</New>
>>> 						</Item>
>>> 					</Array>
>>> 				</Arg>
>>> 				<Set name="host">
>>> 					<Property name="jetty.host" default="127.0.0.1" />
>>> 				</Set>
>>> 				<Set name="port">
>>> 					<Property name="jetty.port" default="8285" />
>>> 				</Set>
>>> 				<Set name="idleTimeout">
>>> 					<Property name="http.timeout" default="30000" />
>>> 				</Set>
>>> 				<Set name="name">externalAPIConnector</Set>
>>> 			</New>
>>> 		</Arg>
>>> 	</Call>
>>> 
>>> 
>>> In my Camel Context:
>>> 
>>> 	<restConfiguration 
>>> 		component="servlet"
>>> 		bindingMode="xml" 
>>> 		contextPath="{{context.path}}{{api.root.path}}" 
>>> 		port="{{port}}"
>>> 		enableCORS="false"
>>> 		clientRequestValidation="true">
>>> 
>>> 		<componentProperty key="matchOnUriPrefix" value="true"/>
>>> 		<endpointProperty key="servletName" value="ResponderRestApiServlet"/>
>>> 		</restConfiguration>
>>> 
>>> 
>>> But,  I am wondering if this correct, because in the example the Servlet is registered with service property httpContext.id <http://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 <http://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 <alex.soto@envieta.com <ma...@envieta.com>> 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:
>>>> 
>>>> 	<reference id="httpService" interface="org.osgi.service.http.HttpService" />
>>>> 	<bean id="camelServlet" class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
>>>> 	<bean class=“org.apache.camel.component.servlet.osgi.OsgiServletRegisterer" init-method="register" destroy-method="unregister”>
>>>> 		<property name="alias" value="#{context.path}#{api.root.path}" />
>>>> 		<property name="httpService" ref="httpService" />
>>>> 		<property name="servlet" ref="camelServlet" />
>>>> 		<property name="servletName" value="RestApiServlet"/>
>>>> 		<property name="matchOnUriPrefix" value="true"/>
>>>> 	</bean> 
>>>> 
>>>> 	<restConfiguration component=“servlet" bindingMode="xml" contextPath="{{context.path}}{{api.root.path}}" 
>>>> 			port="{{port}}"
>>>> 			enableCORS="false"
>>>> 			clientRequestValidation="true">
>>>> 			<componentProperty key="matchOnUriPrefix" value="true"/>
>>>> 			<endpointProperty key="servletName" 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 <maggu2810@gmail.com <ma...@gmail.com>> 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 <https://lists.apache.org/thread.html/69182ee8feef88896f840efde48146053997119e820ef037853c1c9b@%3Cuser.karaf.apache.org%3E>
>>>>>> You also referenced to http://blog.nanthrax.net/?p=352 <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

Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
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 <al...@envieta.com> 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 <http://context.id/> property in the Camel Servlet.
> JB?
> 
> 
> 
>> On Jan 31, 2020, at 1:30 PM, Alex Soto <alex.soto@envieta.com <ma...@envieta.com>> 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 <https://github.com/ops4j/org.ops4j.pax.web/tree/master/samples/whiteboard-extended>  I made the following changes. 
>> 
>> In my blueprint:
>> 
>> 	<service interface="org.ops4j.pax.web.service.whiteboard.HttpContextMapping">
>> 		<service-properties>
>> 			<entry key="httpContext.id <http://httpcontext.id/>">
>> 		          <value>externalAPIContext</value>
>> 		      </entry>
>> 		</service-properties>
>> 		
>> 		<bean class="org.ops4j.pax.web.extender.whiteboard.runtime.DefaultHttpContextMapping">
>> 			<property name="httpContextId" value="externalAPIContext" />
>> 			<property name="path" value="#{context.path}#{api.root.path}" />
>> 			<property name="parameters">
>> 				<map>
>> 					<entry key="httpContext.virtualhosts" value="127.0.0.1"/>
>> 					<entry key="httpContext.connectors" value="externalAPIConnector"/>
>> 				</map>
>> 			</property>
>> 		</bean>
>> 	</service>
>> 	
>> 	<bean id="camelServlet" class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
>> 	
>> 	<reference id="httpService" interface="org.osgi.service.http.HttpService" />
>> 	<bean class="org.apache.camel.component.servlet.osgi.OsgiServletRegisterer"
>> 		init-method="register" 
>> 		destroy-method="unregister">
>> 		
>> 		<property name="alias" value="#{context.path}#{api.root.path}" />
>> 		<property name="httpService" ref="httpService" />
>> 		<property name="servlet" ref="camelServlet" />
>> 		<property name="servletName" value="ResponderRestApiServlet"/>
>> 		<property name="matchOnUriPrefix" value="true"/>
>> 	</bean>
>> 
>> 
>> In my jetty.xml:
>> 
>> 	<Call name="addConnector">
>> 		<Arg>
>> 			<New class="org.eclipse.jetty.server.ServerConnector">
>> 				<Arg name="server">
>> 					<Ref refid="Server" />
>> 				</Arg>
>> 				<Arg name="factories">
>> 					<Array type="org.eclipse.jetty.server.ConnectionFactory">
>> 						<Item>
>> 							<New class="org.eclipse.jetty.server.HttpConnectionFactory">
>> 								<Arg name="config">
>> 									<Ref refid="httpConfig" />
>> 								</Arg>
>> 							</New>
>> 						</Item>
>> 					</Array>
>> 				</Arg>
>> 				<Set name="host">
>> 					<Property name="jetty.host" default="127.0.0.1" />
>> 				</Set>
>> 				<Set name="port">
>> 					<Property name="jetty.port" default="8285" />
>> 				</Set>
>> 				<Set name="idleTimeout">
>> 					<Property name="http.timeout" default="30000" />
>> 				</Set>
>> 				<Set name="name">externalAPIConnector</Set>
>> 			</New>
>> 		</Arg>
>> 	</Call>
>> 
>> 
>> In my Camel Context:
>> 
>> 	<restConfiguration 
>> 		component="servlet"
>> 		bindingMode="xml" 
>> 		contextPath="{{context.path}}{{api.root.path}}" 
>> 		port="{{port}}"
>> 		enableCORS="false"
>> 		clientRequestValidation="true">
>> 
>> 		<componentProperty key="matchOnUriPrefix" value="true"/>
>> 		<endpointProperty key="servletName" value="ResponderRestApiServlet"/>
>> 		</restConfiguration>
>> 
>> 
>> But,  I am wondering if this correct, because in the example the Servlet is registered with service property httpContext.id <http://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 <http://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 <alex.soto@envieta.com <ma...@envieta.com>> 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:
>>> 
>>> 	<reference id="httpService" interface="org.osgi.service.http.HttpService" />
>>> 	<bean id="camelServlet" class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
>>> 	<bean class=“org.apache.camel.component.servlet.osgi.OsgiServletRegisterer" init-method="register" destroy-method="unregister”>
>>> 		<property name="alias" value="#{context.path}#{api.root.path}" />
>>> 		<property name="httpService" ref="httpService" />
>>> 		<property name="servlet" ref="camelServlet" />
>>> 		<property name="servletName" value="RestApiServlet"/>
>>> 		<property name="matchOnUriPrefix" value="true"/>
>>> 	</bean> 
>>> 
>>> 	<restConfiguration component=“servlet" bindingMode="xml" contextPath="{{context.path}}{{api.root.path}}" 
>>> 			port="{{port}}"
>>> 			enableCORS="false"
>>> 			clientRequestValidation="true">
>>> 			<componentProperty key="matchOnUriPrefix" value="true"/>
>>> 			<endpointProperty key="servletName" 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 <maggu2810@gmail.com <ma...@gmail.com>> 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 <https://lists.apache.org/thread.html/69182ee8feef88896f840efde48146053997119e820ef037853c1c9b@%3Cuser.karaf.apache.org%3E>
>>>>> You also referenced to http://blog.nanthrax.net/?p=352 <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

Posted by Alex Soto <al...@envieta.com>.
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 <http://context.id/> property in the Camel Servlet.
JB?



> On Jan 31, 2020, at 1:30 PM, Alex Soto <al...@envieta.com> 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 <https://github.com/ops4j/org.ops4j.pax.web/tree/master/samples/whiteboard-extended>  I made the following changes. 
> 
> In my blueprint:
> 
> 	<service interface="org.ops4j.pax.web.service.whiteboard.HttpContextMapping">
> 		<service-properties>
> 			<entry key="httpContext.id <http://httpcontext.id/>">
> 		          <value>externalAPIContext</value>
> 		      </entry>
> 		</service-properties>
> 		
> 		<bean class="org.ops4j.pax.web.extender.whiteboard.runtime.DefaultHttpContextMapping">
> 			<property name="httpContextId" value="externalAPIContext" />
> 			<property name="path" value="#{context.path}#{api.root.path}" />
> 			<property name="parameters">
> 				<map>
> 					<entry key="httpContext.virtualhosts" value="127.0.0.1"/>
> 					<entry key="httpContext.connectors" value="externalAPIConnector"/>
> 				</map>
> 			</property>
> 		</bean>
> 	</service>
> 	
> 	<bean id="camelServlet" class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
> 	
> 	<reference id="httpService" interface="org.osgi.service.http.HttpService" />
> 	<bean class="org.apache.camel.component.servlet.osgi.OsgiServletRegisterer"
> 		init-method="register" 
> 		destroy-method="unregister">
> 		
> 		<property name="alias" value="#{context.path}#{api.root.path}" />
> 		<property name="httpService" ref="httpService" />
> 		<property name="servlet" ref="camelServlet" />
> 		<property name="servletName" value="ResponderRestApiServlet"/>
> 		<property name="matchOnUriPrefix" value="true"/>
> 	</bean>
> 
> 
> In my jetty.xml:
> 
> 	<Call name="addConnector">
> 		<Arg>
> 			<New class="org.eclipse.jetty.server.ServerConnector">
> 				<Arg name="server">
> 					<Ref refid="Server" />
> 				</Arg>
> 				<Arg name="factories">
> 					<Array type="org.eclipse.jetty.server.ConnectionFactory">
> 						<Item>
> 							<New class="org.eclipse.jetty.server.HttpConnectionFactory">
> 								<Arg name="config">
> 									<Ref refid="httpConfig" />
> 								</Arg>
> 							</New>
> 						</Item>
> 					</Array>
> 				</Arg>
> 				<Set name="host">
> 					<Property name="jetty.host" default="127.0.0.1" />
> 				</Set>
> 				<Set name="port">
> 					<Property name="jetty.port" default="8285" />
> 				</Set>
> 				<Set name="idleTimeout">
> 					<Property name="http.timeout" default="30000" />
> 				</Set>
> 				<Set name="name">externalAPIConnector</Set>
> 			</New>
> 		</Arg>
> 	</Call>
> 
> 
> In my Camel Context:
> 
> 	<restConfiguration 
> 		component="servlet"
> 		bindingMode="xml" 
> 		contextPath="{{context.path}}{{api.root.path}}" 
> 		port="{{port}}"
> 		enableCORS="false"
> 		clientRequestValidation="true">
> 
> 		<componentProperty key="matchOnUriPrefix" value="true"/>
> 		<endpointProperty key="servletName" value="ResponderRestApiServlet"/>
> 		</restConfiguration>
> 
> 
> But,  I am wondering if this correct, because in the example the Servlet is registered with service property httpContext.id <http://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 <http://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 <alex.soto@envieta.com <ma...@envieta.com>> 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:
>> 
>> 	<reference id="httpService" interface="org.osgi.service.http.HttpService" />
>> 	<bean id="camelServlet" class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
>> 	<bean class=“org.apache.camel.component.servlet.osgi.OsgiServletRegisterer" init-method="register" destroy-method="unregister”>
>> 		<property name="alias" value="#{context.path}#{api.root.path}" />
>> 		<property name="httpService" ref="httpService" />
>> 		<property name="servlet" ref="camelServlet" />
>> 		<property name="servletName" value="RestApiServlet"/>
>> 		<property name="matchOnUriPrefix" value="true"/>
>> 	</bean> 
>> 
>> 	<restConfiguration component=“servlet" bindingMode="xml" contextPath="{{context.path}}{{api.root.path}}" 
>> 			port="{{port}}"
>> 			enableCORS="false"
>> 			clientRequestValidation="true">
>> 			<componentProperty key="matchOnUriPrefix" value="true"/>
>> 			<endpointProperty key="servletName" 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 <maggu2810@gmail.com <ma...@gmail.com>> 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 <https://lists.apache.org/thread.html/69182ee8feef88896f840efde48146053997119e820ef037853c1c9b@%3Cuser.karaf.apache.org%3E>
>>>> You also referenced to http://blog.nanthrax.net/?p=352 <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

Posted by Alex Soto <al...@envieta.com>.
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 <https://github.com/ops4j/org.ops4j.pax.web/tree/master/samples/whiteboard-extended>  I made the following changes. 

In my blueprint:

	<service interface="org.ops4j.pax.web.service.whiteboard.HttpContextMapping">
		<service-properties>
			<entry key="httpContext.id">
		          <value>externalAPIContext</value>
		      </entry>
		</service-properties>
		
		<bean class="org.ops4j.pax.web.extender.whiteboard.runtime.DefaultHttpContextMapping">
			<property name="httpContextId" value="externalAPIContext" />
			<property name="path" value="#{context.path}#{api.root.path}" />
			<property name="parameters">
				<map>
					<entry key="httpContext.virtualhosts" value="127.0.0.1"/>
					<entry key="httpContext.connectors" value="externalAPIConnector"/>
				</map>
			</property>
		</bean>
	</service>
	
	<bean id="camelServlet" class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
	
	<reference id="httpService" interface="org.osgi.service.http.HttpService" />
	<bean class="org.apache.camel.component.servlet.osgi.OsgiServletRegisterer"
		init-method="register" 
		destroy-method="unregister">
		
		<property name="alias" value="#{context.path}#{api.root.path}" />
		<property name="httpService" ref="httpService" />
		<property name="servlet" ref="camelServlet" />
		<property name="servletName" value="ResponderRestApiServlet"/>
		<property name="matchOnUriPrefix" value="true"/>
	</bean>


In my jetty.xml:

	<Call name="addConnector">
		<Arg>
			<New class="org.eclipse.jetty.server.ServerConnector">
				<Arg name="server">
					<Ref refid="Server" />
				</Arg>
				<Arg name="factories">
					<Array type="org.eclipse.jetty.server.ConnectionFactory">
						<Item>
							<New class="org.eclipse.jetty.server.HttpConnectionFactory">
								<Arg name="config">
									<Ref refid="httpConfig" />
								</Arg>
							</New>
						</Item>
					</Array>
				</Arg>
				<Set name="host">
					<Property name="jetty.host" default="127.0.0.1" />
				</Set>
				<Set name="port">
					<Property name="jetty.port" default="8285" />
				</Set>
				<Set name="idleTimeout">
					<Property name="http.timeout" default="30000" />
				</Set>
				<Set name="name">externalAPIConnector</Set>
			</New>
		</Arg>
	</Call>


In my Camel Context:

	<restConfiguration 
		component="servlet"
		bindingMode="xml" 
		contextPath="{{context.path}}{{api.root.path}}" 
		port="{{port}}"
		enableCORS="false"
		clientRequestValidation="true">

		<componentProperty key="matchOnUriPrefix" value="true"/>
		<endpointProperty key="servletName" value="ResponderRestApiServlet"/>
		</restConfiguration>


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 <al...@envieta.com> 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:
> 
> 	<reference id="httpService" interface="org.osgi.service.http.HttpService" />
> 	<bean id="camelServlet" class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
> 	<bean class=“org.apache.camel.component.servlet.osgi.OsgiServletRegisterer" init-method="register" destroy-method="unregister”>
> 		<property name="alias" value="#{context.path}#{api.root.path}" />
> 		<property name="httpService" ref="httpService" />
> 		<property name="servlet" ref="camelServlet" />
> 		<property name="servletName" value="RestApiServlet"/>
> 		<property name="matchOnUriPrefix" value="true"/>
> 	</bean> 
> 
> 	<restConfiguration component=“servlet" bindingMode="xml" contextPath="{{context.path}}{{api.root.path}}" 
> 			port="{{port}}"
> 			enableCORS="false"
> 			clientRequestValidation="true">
> 			<componentProperty key="matchOnUriPrefix" value="true"/>
> 			<endpointProperty key="servletName" 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 <maggu2810@gmail.com <ma...@gmail.com>> 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 <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

Posted by Alex Soto <al...@envieta.com>.
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:

	<reference id="httpService" interface="org.osgi.service.http.HttpService" />
	<bean id="camelServlet" class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
	<bean class=“org.apache.camel.component.servlet.osgi.OsgiServletRegisterer" init-method="register" destroy-method="unregister”>
		<property name="alias" value="#{context.path}#{api.root.path}" />
		<property name="httpService" ref="httpService" />
		<property name="servlet" ref="camelServlet" />
		<property name="servletName" value="RestApiServlet"/>
		<property name="matchOnUriPrefix" value="true"/>
	</bean> 

	<restConfiguration component=“servlet" bindingMode="xml" contextPath="{{context.path}}{{api.root.path}}" 
			port="{{port}}"
			enableCORS="false"
			clientRequestValidation="true">
			<componentProperty key="matchOnUriPrefix" value="true"/>
			<endpointProperty key="servletName" 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 <ma...@gmail.com> 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?


Re: Http Whiteboard - Pax-Web multiple instances

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
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é
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Http Whiteboard - Pax-Web multiple instances

Posted by Markus Rathgeb <ma...@gmail.com>.
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

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
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é
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Http Whiteboard - Pax-Web multiple instances

Posted by Markus Rathgeb <ma...@gmail.com>.
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).