On Aug 18, 2009, at 1:19 AM, Gurkan Erdogdu wrote:

Scanning code is

https://svn.apache.org/repos/asf/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ee/deployer/WarMetaDataDiscoveryImpl.java

Listener code;
https://svn.apache.org/repos/asf/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationListener.java

Some explanation :

Context initialized method calls
https://svn.apache.org/repos/asf/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebBeansLifeCycle.java
instance's *"applicationStarted"* method.This method gets discovery class
instance and call its "init" and "scan" methods respectively.

this.discovery = ServiceLoader.getService(MetaDataDiscoveryService.class);

  this.discovery.init(event.getServletContext());

  this.discovery.scan();

After that it calls,
https://svn.apache.org/repos/asf/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContainerDeployer.java
"deploy" method to deploy all classes.

deployer.deploy(this.discovery);

WebBeansContainerDeployer "deploy" method calls "deployFromClassPath" method to resolve "Managed Beans" and "EJB Beans". It gets all scanned classes via
given scanner.

protected void deployFromClassPath(MetaDataDiscoveryService scanner)
throws ClassNotFoundException

I had a look at the boot/scan code. The boot process and scanning abstraction uses servlet apis. For Geronimo and OpenEJB, we'll need to scan all EE injectable classes at deploy time at the same time we scan servlets, filters, listeners, and JSF managed beans. Bottom line is that there is no "webapp" at the moment we do scanning, so any code that leverages servlet apis for scanning is not workable -- at least in the Geronimo/OpenEJB sense.

For Servlets and JSF, we actually read the web.xml and faces- config.xml files so that we can discover all the classes we need to scan. We then process all the Java EE ref types (@Resource, @EJB, @PersistenceUnit, @PersistenceContext, @WebServiceRef, etc.) found in those classes and fill out the web.xml adding every ref as a <resource- ref>, <ejb-ref>, etc. so that the descriptor data represents a complete list of the things we need to build and link into JNDI when the webapp is eventually created. All this is done in our AnnotationDeployer class. All the metadata we use to do injection at runtime is only possible because of the work done in that class. Attempting to inject into something at runtime which hasn't gone through scanning in the AnnotationDeployer is not possible with our code. Geronimo has a class similar to AnnotationDeployer with identical scanning requirements.

That's how things work from a high level at least. Not sure on the next step forward just yet. It'll definitely involved finding a way to get the 299 managed bean classes scanned like we do for servlets, jsf, etc.

-David


Reply via email to