reta / jax-rs-2.0-cdi

Apache CXF 3.0 and CDI 1.1
Apache License 2.0
2 stars 5 forks source link

Alternative for CXF-CDI integration #1

Open Tcharl opened 10 years ago

Tcharl commented 10 years ago

Hi,

I made a CDI portable extension for CXF in my project: you just have to annotate your service implementation with @CXFEndpoint (providers={classes}) It's actually working with Karaf Please take a look at the links below, and feel free to ask me to make a contribution/contribute to CXF:

Regards, Charlie Mordant

reta commented 10 years ago

Hi Charlie,

Thanks a lot for sharing your implementation. It would be very helpful to have an OSGi support for this feature as well. Thanks a bunch, I will try to look through the code asap!

Best Regards, Andriy Redko

Tcharl commented 10 years ago

Hi Reta,

My implementation was made to work with OSGI (my project is karaf-runtime based). One of the thing that doesn't makes it working on a SE environment is that I register interceptors and providers via OSGI services. It's relatively easy to port to SE changing this registration mechanism with conventional DI.

I use Weld 2 and Pax-CDI as OSGi CDI engine

Best Regards

reta commented 10 years ago

Hi Charlie,

My apologies for being silent, very busy weeks. I have look through your implementation and, as you may expect, the approaches you and CXF have taken are very similar. I would like to ask if you might have time to review the current CXF + CDI integration and try to apply it within your project and OSGi environment to figure out what is missing and how it could be improved / extended. From my side, I would be very happy to provide the necessary support to you if you need any (you seem to be the expert in this area). It would be much appreciated, does it sound feasible to you?

Thank you very much. Best Regards, Andriy Redko

Tcharl commented 10 years ago

Hi Andriy,

I can always try :). I made some CXF-web-cdi that were disabled 'cause I didn't have the time to understand well the interaction between the three fwks (Servlet3, CDI, CXF) but I can rework a little on them and try to make them running into Karaf. I'm a little busy too at the moment (I'm trying to reimplement EMF with some friends, maintains/improve my fwk plus have a book review, without considering my job :S). But When I will be a little more available, I'll look at it.

But I think we've a different approach between my fwk and CXF way of doing: with the cxf one, you've to make an Application then injecting all your services onto it. But with my solution, the service implementation registers itself as a REST server with the help of the @CXFEndpoint annotation (that is computed by a CDI portable extension).

Best Regards

2014-06-16 16:16 GMT+02:00 Andriy Redko notifications@github.com:

Hi Charlie,

My apologies for being silent, very busy weeks. I have look through your implementation and, as you may expect, the approaches you and CXF have taken are very similar. I would like to ask if you might have time to review the current CXF + CDI integration and try to apply it within your project and OSGi environment to figure out what is missing and how it could be improved / extended. From my side, I would be very happy to provide the necessary support to you if you need any (you seem to be the expert in this area). It would be much appreciated, does it sound feasible to you?

Thank you very much. Best Regards, Andriy Redko

— Reply to this email directly or view it on GitHub https://github.com/reta/jax-rs-2.0-cdi/issues/1#issuecomment-46183390.

Charlie Mordant

Full OSGI/EE stack made with Karaf: https://github.com/OsgiliathEnterprise/net.osgiliath.parent

reta commented 10 years ago

Hi Charlie,

Thank you very much. Whenever you have time, please lead it :-) I am willing to assist you any time with any question/advice/implementation I may help with.

With respect to your comments, the approach CXF has taken is outlined in JAX-RS 2.0 (JSR-339), section 10.2.3 Context and Dependency Injection (CDI). Your approach is very valid and works well but CXF is targeting the compliance with the spec and it's a limiting factor. We have to look for a ways to follow it first. But it might just not be possible, as OSGi stays aside from any JSRs.

Thank you very much.

Best Regards, Andriy Redko

Tcharl commented 10 years ago

We've to launch the 'Adopt an OSR' movment ;). OSGI is a JSR itself (JSR 277) and have some subjacent spec (configadmin, events,...), but IMO have lack of some Java standard customizations (Messaging, Security, Services). That's why I'm doing Osgiliath which is JEE like with some OSGI steroided bundles. So I'll try to make an JSR-339 OSGI ready sample ;).

2014-06-16 19:06 GMT+02:00 Andriy Redko notifications@github.com:

Hi Charlie,

Thank you very much. Whenever you have time, please lead it :-) I am willing to assist you any time with any question/advice/implementation I may help with.

With respect to your comments, the approach CXF has taken is outlined in JAX-RS 2.0 (JSR-339), section 10.2.3 Context and Dependency Injection (CDI). Your approach is very valid and works well but CXF is targeting the compliance with the spec and it's a limiting factor. We have to look for a ways to follow it first. But it might just not be possible, as OSGi stays aside from any JSRs.

Thank you very much.

Best Regards, Andriy Redko

— Reply to this email directly or view it on GitHub https://github.com/reta/jax-rs-2.0-cdi/issues/1#issuecomment-46205823.

Charlie Mordant

Full OSGI/EE stack made with Karaf: https://github.com/OsgiliathEnterprise/net.osgiliath.parent

reta commented 10 years ago

:-) Very right, sounds like a great idea by the way. And you have done a really awesome job so far. Thanks a lot again!

Best Regards, Andriy Redko

Tcharl commented 10 years ago

Hi Andriy,

Looks like cdi-web-weld isn't compatible with Servlet3 WebInitParam (at least pax-web servlet3 support) :(.

As I'm not a Servlet expert, I've no solution for the moment. I made all the OSGI linkage, so if you want, you can fork and test: https://github.com/OsgiliathEnterprise/net.osgiliath.parent/tree/master/net.osgiliath.framework/net.osgiliath.features.karaf-features/net.osgiliath.features.karaf-features.itests/net.osgiliath.features.karaf-features.itests.jaxrs.web.cdi

At first, you've to mvn clean install the parent (and take a coffee break). It will fail for ui module (if you don't have firefox, npm and some third party node modules) but you can test this integration without (just uncomment the @Ignore to make it fail).

I will try again at the next Karaf release (and the new Pax-web release).

Best regards, and thank you for this discussion (and hope it will continue :))

2014-06-16 23:56 GMT+02:00 Andriy Redko notifications@github.com:

:-) Very right, sounds like a great idea by the way. And you have done a really awesome job so far. Thanks a lot again!

Best Regards, Andriy Redko

— Reply to this email directly or view it on GitHub https://github.com/reta/jax-rs-2.0-cdi/issues/1#issuecomment-46243414.

Charlie Mordant

Full OSGI/EE stack made with Karaf: https://github.com/OsgiliathEnterprise/net.osgiliath.parent

reta commented 10 years ago

Hi Charlie,

Thank you very much for your time and effort, it is very appreciated. I have forked your implementation and will try to play with it this week, hope to find some breakthrough. Thank you!

Best Regards, Andriy Redko

reta commented 10 years ago

Hi Charlie,

Thanks a again for spending time on this. I think the problem is related to Jetty 8.x. I tried to switch to Jetty 9.x and although I haven't succeeded to make test green, I was able to move couple of steps further. I reached the same conclusions as you and I am agree with you that pax-web-api 4.0 should give us a breakthrough. We probably have to wait a bit, what do you think?

Thanks a lot.

Best Regards, Andriy Redko

Tcharl commented 10 years ago

Hi Andriy,

Nice diagnostic :). The Karaf release with pax-web 4 will not be in a long time as their next Objective is to support Java 8 and pax-Web4 is the only branch that handles it ;).

Let see in a couple of weeks so...

Thank a lot too!

2014-06-26 15:05 GMT+02:00 Andriy Redko notifications@github.com:

Hi Charlie,

Thanks a again for spending time on this. I think the problem is related to Jetty 8.x. I tried to switch to Jetty 9.x and although I haven't succeeded to make test green, I was able to move couple of steps further. I reached the same conclusions as you and I am agree with you that pax-web-api 4.0 should give us a breakthrough. We probably have to wait a bit, what do you think?

Thanks a lot.

Best Regards, Andriy Redko

— Reply to this email directly or view it on GitHub https://github.com/reta/jax-rs-2.0-cdi/issues/1#issuecomment-47222601.

Charlie Mordant

Full OSGI/EE stack made with Karaf: https://github.com/OsgiliathEnterprise/net.osgiliath.parent