Re: Using SpringMVC in Karaf 4.2.6

2019-11-08 Thread Jean-Baptiste Onofré
Hi Duan,

Karaf doesn't gave up Spring, it's still available.

In your bundle, you can still use Spring MVC DispatcherServlet, wiring, etc.

Spring DM is also still available but you have to use old Spring
version: it's not due to Karaf, it's Spring that doesn't maintain Spring
DM anymore.
So, my advice was more to replace Spring DM.

Without some details about your use of Spring MVC and the way you
package it in your bundles, I can only do suggestion.
Don't hesitate to ping me with some details.

Regards
JB

On 09/11/2019 04:27, duan2ping wrote:
> Hi JB
> 
> 
> Because karaf gave up Spring, I can only use Servlet to develop web
> applications in OSGi. So, I need to do a lot of work to implement a wrapper
> similar to the SpringMVC framework. 
> 
> Is there any other good advice, or can subsequent versions of Karaf provide
> a framework that can replace SpringMVC instead of using the original
> servlet?
> 
> 
> Regards
> duan
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
> 

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


Re: Using SpringMVC in Karaf 4.2.6

2019-11-08 Thread duan2ping
Hi JB


Because karaf gave up Spring, I can only use Servlet to develop web
applications in OSGi. So, I need to do a lot of work to implement a wrapper
similar to the SpringMVC framework. 

Is there any other good advice, or can subsequent versions of Karaf provide
a framework that can replace SpringMVC instead of using the original
servlet?


Regards
duan



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html


propertyFileEdits notes

2019-11-08 Thread Christian Lutz
Hello,
 
I tried to set set the serviceRequirements=disable with the karaf-maven-plugin.
As mentioned here 
(http://karaf.922171.n3.nabble.com/How-do-i-change-a-single-line-in-a-custom-distro-file-td4053462.html)
 I am able todo this with the assembly-property-edits.xml file.
 
Three points to note:
1. There is an open issue (https://issues.apache.org/jira/browse/KARAF-4223) 
because of the missing documentation. Where should the documentation be 
defined. If it is easy a can create a pull request.
2. The xmlns url is invalid because it doesn't exist 
http://karaf.apache.org/tools/property-edits/1.0.0 and it is inconsistent 
compared to the other xmlns it should be something like
http://karaf.apache.org/xmlns/tools/property-edits/v1.0.0
3. The format of the file will be changed and the format isn't preserved. If we 
could use Apache Commons Configurations 
(http://commons.apache.org/proper/commons-configuration/index.html) it should 
be possible to preserve the format. What do you think?
 
kind regards
christian



Re: Karaf pax.web 2 Servlets 2 ports

2019-11-08 Thread Jean-Baptiste Onofré
That's similar indeed.

Let's add a full example (and eventually improvement on Pax Web).

Regards
JB

On 08/11/2019 10:50, Markus Rathgeb wrote:
> 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.
> 

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


Re: Karaf pax.web 2 Servlets 2 ports

2019-11-08 Thread Markus Rathgeb
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.


Re: Aries jax-rs whiteboard

2019-11-08 Thread Tim Ward
Hi,

Yes, you can absolutely inject things using @Context (this is the only way to 
do server sent events, so it’s not optional for any implementation). It’s 
recommended that you inject into resource methods, rather than into fields, 
unless you make your service prototype scope. This is to avoid any potential 
threading mismatch if you inject invocation scoped objects (e.g. an incoming 
HttpServletRequest) and get two http calls at the same time.

Tim

> On 7 Nov 2019, at 16:24, Matthias Leinweber  
> wrote:
> 
> Great. Thank you very much.
> 
> I dont want to add CXF or Jersey. thank to your answer I have come up with 
> the idea myself to inject the  @Context HttpServletRequest into the JaxRS 
> code. To mix in this: 
> https://osgi.org/specification/osgi.cmpn/7.0.0/service.http.whiteboard.html#d0e120961
>  
> 
> I didn't test it yet but does it work? I don't see that the aries JaxRs 
> whiteboard impl somewhere defined 
> osgi.http.whiteboard.servlet.multipart.enabled=true
> 
> Best regards,
> Matthias
> 
> Am Do., 7. Nov. 2019 um 15:38 Uhr schrieb Tim Ward  >:
> Hi Matthias
> 
>> I was a bit confused about how you could add a Servelt to the 
>> JaxRsWhiteboard instead of the HttpWhiteboard for Multi-Part file uploads.
> 
> I hope it’s now clear that the JAX-RS whiteboard does not support Servlets. 
> You can either:
> Register a servlet with the Http Whiteboard and find a place to put the file
> Handle the multipart file upload using JAX-RS
> 
> If the file upload is only needed by your JAX-RS components then I would 
> recommend just using JAX-RS rather than a servlet.
> 
>> * So a JaxRsResource can but most not belong to an application?
> 
> A JAX-RS Whiteboard resource is just a “bare” resource in the service 
> registry. In the most common case the resource service that you register will 
> bind to the “default” application provided by the JAX-RS Whiteboard. There is 
> no need to deploy a custom whiteboard application for resources to be hosted 
> by the JAX-RS whiteboard.
> 
>> * It's fine to put all your Resources into the same JaxRsWhiteboard even if 
>> you could separate them?
> 
> Yes. This will work fine. All the resources (by default) will get hosted in 
> the default application. If you do want to provide some isolation between the 
> resources (e.g. if you need differently configured JSON providers for 
> different resources) then you can still do this with a single 
> JAX-RSWhiteboard, but you will need to provide separate Applications for the 
> resources and extensions. This is because applications within the whiteboard 
> *are* isolated from each other, and can have different sets of resources and 
> extensions.
> 
> In general, however, you’re pretty safe just registering all the resources 
> and extensions that you need directly with the whiteboard using the default 
> application.
> 
> All the best,
> 
> Tim
> 
> 
>> On 7 Nov 2019, at 12:54, Matthias Leinweber > > wrote:
>> 
>> Hello Tim,
>> 
>> thanks for your reply. I get the JaxRS Application thing wrong. I thought 
>> that an application and a JaxRsResource is/can be the same. But obviously, 
>> if you read the documentation correct, then not.
>> Then it also makes sense to inject the Application with @Context Applicaiton 
>> app into a method.
>> I had also a misunderstanding with http and jaxrs whiteboard. I was a bit 
>> confused about how you could add a Servelt to the JaxRsWhiteboard instead of 
>> the HttpWhiteboard for Multi-Part file uploads.
>> I think the default app and the configuration of the default jaxrs 
>> whiteboard caused some confusion for me.
>> 
>> * So a JaxRsResource can but most not belong to an application?
>> * It's fine to put all your Resources into the same JaxRsWhiteboard even if 
>> you could separate them?
>> 
>> right? then I think, I understood the thing and i like it :)
>> 
>> Best regards
>> Matthias
>> 
>> Am Do., 7. Nov. 2019 um 13:24 Uhr schrieb Tim Ward > >:
>>> in OSGI 6 I think we should be able to use
>>> @Component(property = {"osgi.jaxrs.name =myApp", 
>>> "osgi.jaxrs.application.base=/foo"}, service = A.class)
>>> class...
>>> That does not work or did I misunderstood something?
>> 
>> If you want to register an application with the whiteboard then you must 
>> register it as a javax.ws.rs .core.Application in the 
>> service registry. This is outlined at 
>> https://osgi.org/specification/osgi.cmpou 
>> cann/7.0.0/service.jaxrs.html#service.jaxrs.application.services 
>> 
>> 
>>> Second how do i create additional Servlets and how do I select them in a 
>>> resource?
>>> E.g. A configfile/servicepid
>>> org.apache.aries.jax.rs.whiteboard-bar.cfg
>>> 

Re: Karaf pax.web 2 Servlets 2 ports

2019-11-08 Thread Jean-Baptiste Onofré
OK,

I created https://issues.apache.org/jira/browse/KARAF-6515
for the tracking.

Regards
JB

On 08/11/2019 10:08, Paul Fraser wrote:
> Hi JB,
> 
> As usual, thanks for your very fast reply.
> 
> A full example would be most valuable. I will try and work through the
> blog and will let you know how I go.
> 
> Paul
> 
> On 8/11/2019 7:52 pm, Jean-Baptiste Onofré wrote:
>> Hi Paul,
>>
>> You can take a look on:
>>
>> http://blog.nanthrax.net/?p=352
>>
>> You can setup two connector in jetty.xml and then bind a servlet to
>> vhost. It doesn't use whiteboard, but you can define the vhost as
>> service property.
>>
>> I can also add a full example in Karaf if you think it makes sense.
>>
>> Regards
>> JB
>>
>> On 08/11/2019 09:43, Paul Fraser wrote:
>>> Hi,
>>>
>>> https://github.com/ops4j/org.ops4j.pax.web/tree/master/samples/whiteboard-extended
>>>
>>>
>>>
>>> has been offered as an example of serving on 2 ports, for example with
>>> the karaf jetty setup.
>>>
>>> How and where are the port values set?
>>>
>>> These examples are 3 years old, is there anything more recent (Karaf
>>> 4.2.6) and perhaps simpler ?
>>>
>>> Paul Fraser
>>>
>>>
>>>
> 

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


Re: Karaf pax.web 2 Servlets 2 ports

2019-11-08 Thread Paul Fraser

Hi JB,

As usual, thanks for your very fast reply.

A full example would be most valuable. I will try and work through the blog and will let you know 
how I go.


Paul

On 8/11/2019 7:52 pm, Jean-Baptiste Onofré wrote:

Hi Paul,

You can take a look on:

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

You can setup two connector in jetty.xml and then bind a servlet to
vhost. It doesn't use whiteboard, but you can define the vhost as
service property.

I can also add a full example in Karaf if you think it makes sense.

Regards
JB

On 08/11/2019 09:43, Paul Fraser wrote:

Hi,

https://github.com/ops4j/org.ops4j.pax.web/tree/master/samples/whiteboard-extended


has been offered as an example of serving on 2 ports, for example with
the karaf jetty setup.

How and where are the port values set?

These examples are 3 years old, is there anything more recent (Karaf
4.2.6) and perhaps simpler ?

Paul Fraser







Re: Using SpringMVC in Karaf 4.2.6

2019-11-08 Thread Jean-Baptiste Onofré
Hi,

I compared spring and blueprint. I don't know enough SpringMVC to compare.

Anyway, SpringMVC is one think Spring DM is nother one.
You also have the Spring extender in blueprint, so, it should be possible.

About the servlet, yes, you can deploy a servlet in different ways. You
have examples here:

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

Don't hesitate to ping me directly to figure it out.

Regards
JB

On 08/11/2019 09:50, duan2ping wrote:
> Hi JB
> 
> I tried to check out some information about using Blueprint, but there
> is nothing to gain.
> 
> If use blueprint and scr instead of spring, does web application development
> have a similar alternative to springmvc? 
> Or can you only use the original servlet method like the one below?
> 
> @OsgiServiceProvider(classes={Servlet.class})
> @Properties({@Property(name="alias", value="/tasklist")})
> @Singleton
> public class TaskListServlet extends HttpServlet {
> //..
> }
> 
> I am very confused now.
> How do I use Blueprint instead of Spring and SpringMVC to develop a Web
> Bundle correctly, is there a related reference solution?
> 
> Regards
> duan
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
> 

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


Re: Karaf pax.web 2 Servlets 2 ports

2019-11-08 Thread Jean-Baptiste Onofré
Hi Paul,

You can take a look on:

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

You can setup two connector in jetty.xml and then bind a servlet to
vhost. It doesn't use whiteboard, but you can define the vhost as
service property.

I can also add a full example in Karaf if you think it makes sense.

Regards
JB

On 08/11/2019 09:43, Paul Fraser wrote:
> Hi,
> 
> https://github.com/ops4j/org.ops4j.pax.web/tree/master/samples/whiteboard-extended
> 
> 
> has been offered as an example of serving on 2 ports, for example with
> the karaf jetty setup.
> 
> How and where are the port values set?
> 
> These examples are 3 years old, is there anything more recent (Karaf
> 4.2.6) and perhaps simpler ?
> 
> Paul Fraser
> 
> 
> 

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


Re: Using SpringMVC in Karaf 4.2.6

2019-11-08 Thread duan2ping
Hi JB

I tried to check out some information about using Blueprint, but there
is nothing to gain.

If use blueprint and scr instead of spring, does web application development
have a similar alternative to springmvc? 
Or can you only use the original servlet method like the one below?

@OsgiServiceProvider(classes={Servlet.class})
@Properties({@Property(name="alias", value="/tasklist")})
@Singleton
public class TaskListServlet extends HttpServlet {
//..
}

I am very confused now.
How do I use Blueprint instead of Spring and SpringMVC to develop a Web
Bundle correctly, is there a related reference solution?

Regards
duan



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html


Karaf pax.web 2 Servlets 2 ports

2019-11-08 Thread Paul Fraser

Hi,

https://github.com/ops4j/org.ops4j.pax.web/tree/master/samples/whiteboard-extended

has been offered as an example of serving on 2 ports, for example with the 
karaf jetty setup.

How and where are the port values set?

These examples are 3 years old, is there anything more recent (Karaf 4.2.6) and 
perhaps simpler ?

Paul Fraser