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 <[email protected]> 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 <[email protected] >> <mailto:[email protected]>> 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 <[email protected] >>> <mailto:[email protected]>> 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 <[email protected] >>>> <mailto:[email protected]>> 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 <[email protected] >>>>> <mailto:[email protected]>> 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 <[email protected] >>>>>> <mailto:[email protected]>> 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? >>>>> >>>> >>> >> >
