OSGI - CDI / is it usable right now ? [Oct 2012]

拟墨画扇 提交于 2020-01-25 15:34:43

问题


I'm quite new to Java EE 6 and OSGI concept, and i'm quite excited about it...

The most exciting feature is the dynamic dependancy injection at execution time.

I've seen some really great presentation where the application is ajaxly updated when a bundle is activated or unactivated, i like that way of decoupling the application in modules and updated it at run time ...

Second though, i'm quite boring about XML configuration files, i think Java EE 6 with javax.inject and others annotations is a really good thing...

So, I'm quite ready to start using OSGI for my webapp but first i need some information..

I can't find a clear Status for the progress of the OSGI - CDI Integration in a Java EE Containter.

(gf-cdi-osgi-integration / osgi-cdi / osgi-cdi-api)

I think the question invoke weld-osgi too.

  1. Does the latest glassfish 3.1.2.2 support CDI annotation for OSGI like @OsgiService and @Publish ? or will it be release in a future release ?

(I've seen samples using @OsgiService and maven depenmdancy that seem to enable this annotation but nothing about @Publish for now...)

1bis - Does Jboss AS support that feature ? Which of theses Java EE container has the best integration with OSGI ?

  1. What is fighterfish (Oracle) and is it related to glassfish osgi ?

  2. So basically if i want to developp war with cdi and osgi now which env do i need

    (Server - Version - Plugins )

  3. Moreover which maven dependancy are required to be able to use @publish and @osgiservice

  4. And just to clarify something, can i use hibernate with OSGI in my project if i accept that hibernate lib are packed in my war / wab and will not be provided as bundle

    Same question for any others lib ...

Thanks for your time and explanation, btw i've already read lots of forum and blog https://github.com/tangyong/gf-cdi-osgi-integration for example , i just need a clear answer to my question :)


回答1:


A future version of JBoss AS7 (unfortunately I don't have a date) will include the new weld osgi (http://in.relation.to/Bloggers/NotOneTwoWeldReleases1110FinalAnd120Beta1) which will probably do what you want. As for GlassFish, I wouldn't expect to see a weld 1.2.x version in there anytime soon :(




回答2:


Glassfish already supports using Java EE annotations in OSGi bundles. The Document below shows what can already be done which I think is quite impressive. Among others @OsgiService is supported.

http://glassfish.java.net/public/GF-OSGi-Features.pdf




回答3:


Apache Karaf now also supports CDI by using the pax-cdi project.

In a mailing list thread on ops4j Harald Wellman describes how to use pax cdi on karaf. This worked fine for me. The upcoming karaf 3.0.0 will have pax cdi included in the enterprise feature so installation will then just be "feature:install cdi".

Start Apache Karaf 3.0.0.RC1

feature:repo-add mvn:org.ops4j.pax.cdi/pax-cdi-features/0.4.0/xml/features
install mvn:org.apache.xbean/xbean-bundleutils/3.12
feature:install pax-cdi-openwebbeans
install mvn:org.ops4j.pax.cdi.samples/pax-cdi-sample1/0.4.0
start org.ops4j.pax.cdi.sample1

So we can check if the example works:

services org.ops4j.pax.cdi.sample1

OPS4J Pax CDI Sample1 (153) provides:
------------------------------------
[org.ops4j.pax.cdi.sample1.impl.VanillaService,
org.ops4j.pax.cdi.sample1.IceCreamService]
[org.ops4j.pax.cdi.sample1.IceCreamService]
[org.ops4j.pax.cdi.spi.CdiContainer]


来源:https://stackoverflow.com/questions/12888325/osgi-cdi-is-it-usable-right-now-oct-2012

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!