I went ahead to commit the changes to trunk at rev.1196032. Think that we may still consider more for webbeans integration in the future.

2011/10/29 Ivan <xhhsld@gmail.com>
Also, after the changes, OpenWebBeans plugin will dependent on OpenEJB plugin, and web application will not explicitly dependent on the OpenWebBeans plugin.
Another problem is that, web application bundle still import OpenWebBeans packages, it is caused by some NamingBuilder, I have opened another JIRA to track this, and think that it should not a problem after more OSGi-friendly changes to Geronimo.


2011/10/29 Ivan <xhhsld@gmail.com>
Hi, devs, in the last week, I am trying to decouple the OpenWebBeans from web container, and would like to list some major change points, will appreciate any comment.

Generally speaking, there are three points required to do :
1. Remove the OpenWebBeans hard references from the Holder class in the geronimo-j2ee module. The Holder class is used to create those managed classes, like servlet, filter, etc. Now the solution is to introduce a interceptor interface, like :
  
public static interface Interceptor {

        public void instancerCreated(InvocationContext context) throws InterceptorException;

        public void instanceDestoryed(InvocationContext context) throws InterceptorException;

        public void postConstructInvoked(InvocationContext context) throws InterceptorException;
}

With this, other technology could register their own interceptors to the Holder instance to populate the created instance.

2. Thread aware WebBeansContext
The same solution with JSF plugin is used, now we keep a thread-aware web application name. Considering to the GeronimoSingletonService is used globally, I added an extra field below. While the getContext method is invoked, it will firstly check whether there is WebBeansContext attached with the current thread, then it will check whether there is one found based on the web application name.
private SingletonService<WebBeansContext> webApplicationSingletonService;

3. OpenWeBeans initialization
This is a tricky thing, in the past, we initialize it in the related webAppContext, with that, it would make sure the WebBeansContext is initialized before any managed instances are created, including the ServletContextListener.
Now I created a WebModuleListener, which is internally used by Geronimo, it is similar with the ServletContextListener, but this listener will be called after the ServletContext is created and before any managed instances are created.

A patch is attached the JIRA below, I have run some cases, including parts of Java EE TCK cases and all the JCDI cases, the results looked fine.
https://issues.apache.org/jira/browse/GERONIMO-6204
--
Ivan



--
Ivan



--
Ivan