dev@glassfish.java.net

[Glassfish CDI/OSGi Integration]About _at_Publish Feature

From: Tang Yong <tangyong_at_cn.fujitsu.com>
Date: Wed, 01 Aug 2012 12:46:00 +0900

Hi Sahoo, Siva, Hong

Now, A plain OSGi bundle can use @Publish annotation to
register service into OSGi world not using BundleActivator.
Taking a stockquote-cdi as a example, user can use the following way
to publish a osgi service which can be consumed by a servlet of WAB

@Publish
public class SimpleStockQuoteServiceImpl implements StockQuoteService{
...
}

then, he/she can use "deploy --type=osgi XXX" to publish the service.

ToDo: I will implment the service's publishing on bundle's start rather
than on deployment.

I have the basic prototype of the feature although still having
some problems needed to resolve.

The prototype is on https://github.com/tangyong/gf-cdi-osgi-integration

Let me to say integration idea.

1) getting WeldSniffer if current plain bundle contains beans.xml on
deploying

I modified the ApplicationLifecycle.prepareSniffersForOSGiDeployment
method to get WeldSniffer.

2) adding @Publish Qualifier into osgi-cdi-api module

I evaluated WELD/OSGi project and OSGi RFP 146, and decided to use
@Publish Qualifier.

ToDo: lately, maybe add some additional properties into @Publish

3) Making Weld can deploy plain bundle(jar) as BeanDeploymentArchiveImpl
not only for JavaEE application.

The critical point is that making Weld can load the plain bundle(jar)
classes and resources, so, I modified
BeanDeploymentArchiveImpl.getClassLoader() method.

4) letting Weld BeanManager to discovery bean classes with @Publish

Adding the discovering logic into OSGiServiceExtension.afterProcessBean
method on osgi-cdi module, and then, registering service into OSGi world.

If you having time, please discuss and review it.

I will continue to improve the prototype and resolve some problems, and
implement other features such as event integration between osgi and cdi.

--Best Regard!
--Tang