geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r515016 - in /geronimo/server/trunk/modules: geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/ geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/ geronimo-j2ee-builder/src/main/java/or...
Date Tue, 06 Mar 2007 08:16:37 GMT
Author: djencks
Date: Tue Mar  6 00:16:35 2007
New Revision: 515016

URL: http://svn.apache.org/viewvc?view=rev&rev=515016
Log:
GERONIMO-2934 Create ClassFinder in module builders.  This almost certainly has bugs

Modified:
    geronimo/server/trunk/modules/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
    geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/AdminObjectRefBuilder.java
    geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/ResourceRefBuilder.java
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/Module.java
    geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java
    geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java
    geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/SwitchingServiceRefBuilder.java
    geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbDeploymentBuilder.java
    geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java
    geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java
    geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceContextRefBuilder.java
    geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitRefBuilder.java
    geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
    geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java

Modified: geronimo/server/trunk/modules/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java?view=diff&rev=515016&r1=515015&r2=515016
==============================================================================
--- geronimo/server/trunk/modules/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java Tue Mar  6 00:16:35 2007
@@ -86,9 +86,11 @@
 import org.apache.geronimo.xbeans.geronimo.naming.GerAbstractNamingEntryDocument;
 import org.apache.geronimo.xbeans.javaee.ApplicationClientDocument;
 import org.apache.geronimo.xbeans.javaee.ApplicationClientType;
+import org.apache.geronimo.xbeans.javaee.FullyQualifiedClassType;
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
+import org.apache.xbean.finder.ClassFinder;
 
 
 /**
@@ -529,7 +531,7 @@
             if (!module.isStandAlone()) {
                 appClientModuleGBeanData.setReferencePattern("J2EEApplication", earContext.getModuleName());
             }
-            appClientModuleGBeanData.setAttribute("deploymentDescriptor", appClientModule.getOriginalSpecDD());
+// below    appClientModuleGBeanData.setAttribute("deploymentDescriptor", appClientModule.getOriginalSpecDD());
 
         } catch (Exception e) {
             throw new DeploymentException("Unable to initialize AppClientModule GBean", e);
@@ -586,7 +588,22 @@
                     buildingContext.put(NamingBuilder.GBEAN_NAME_KEY, jndiContextName);
                     Configuration localConfiguration = appClientDeploymentContext.getConfiguration();
                     Configuration remoteConfiguration = earContext.getConfiguration();
+
+                    if (!appClient.getMetadataComplete()) {
+                        // Create a classfinder and populate it for the naming builder(s). The absence of a
+                        // classFinder in the module will convey whether metadata-complete is set
+                        // (or not)
+                        appClientModule.setClassFinder(createAppClientClassFinder(appClient, appClientModule));
+                    }
+
                     namingBuilders.buildNaming(appClient, geronimoAppClient, localConfiguration, remoteConfiguration, appClientModule, buildingContext);
+
+                    if (!appClient.getMetadataComplete()) {
+                        appClient.setMetadataComplete(true);
+                        module.setOriginalSpecDD(module.getSpecDD().toString());
+                    }
+
+                    appClientModuleGBeanData.setAttribute("deploymentDescriptor", appClientModule.getOriginalSpecDD());
                     injectionsMap = NamingBuilder.INJECTION_KEY.get(buildingContext);
                     jndiContextGBeanData.setAttribute("context", NamingBuilder.JNDI_KEY.get(buildingContext));
                 } catch (DeploymentException e) {
@@ -662,6 +679,46 @@
             }
             throw new Error(e);
         }
+    }
+
+
+    private ClassFinder createAppClientClassFinder(ApplicationClientType appClient, AppClientModule appClientModule) throws DeploymentException {
+
+        //------------------------------------------------------------------------------------
+        // Find the list of classes from the application-client.xml we want to search for
+        // annotations in
+        //------------------------------------------------------------------------------------
+        List<Class> classes = new ArrayList<Class>();
+
+        // Get the classloader from the module's EARContext
+        ClassLoader classLoader = appClientModule.getEarContext().getClassLoader();
+
+        // Get the main class from the module
+        //TODO the main class is specified in the manifest
+        String mainClass = appClientModule.getMainClassName();
+        Class<?> mainClas;
+        try {
+            mainClas = classLoader.loadClass(mainClass);
+        }
+        catch (ClassNotFoundException e) {
+            throw new DeploymentException("AppClientModuleBuilder: Could not load main class: " + mainClass);
+        }
+        classes.add(mainClas);
+
+        // Get the callback-handler from the deployment descriptor
+        if (appClient.isSetCallbackHandler()) {
+            FullyQualifiedClassType cls = appClient.getCallbackHandler();
+            Class<?> clas;
+            try {
+                clas = classLoader.loadClass(cls.getStringValue().trim());
+            }
+            catch (ClassNotFoundException e) {
+                throw new DeploymentException("AppClientModuleBuilder: Could not load callback-handler class: " + cls.getStringValue());
+            }
+            classes.add(clas);
+        }
+
+        return new ClassFinder(classes);
     }
 
     public String getSchemaNamespace() {

Modified: geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/AdminObjectRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/AdminObjectRefBuilder.java?view=diff&rev=515016&r1=515015&r2=515016
==============================================================================
--- geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/AdminObjectRefBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/AdminObjectRefBuilder.java Tue Mar  6 00:16:35 2007
@@ -24,12 +24,15 @@
 import javax.naming.Reference;
 import javax.xml.namespace.QName;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.common.UnresolvedReferenceException;
 import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.j2ee.deployment.Module;
+import org.apache.geronimo.j2ee.deployment.annotation.ResourceAnnotationHelper;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.config.Configuration;
@@ -52,6 +55,7 @@
  * @version $Rev$ $Date$
  */
 public class AdminObjectRefBuilder extends AbstractNamingBuilder {
+    private final static Log log = LogFactory.getLog(AdminObjectRefBuilder.class);
     private  final QNameSet adminOjbectRefQNameSet;
     private final QNameSet messageDestinationQNameSet;
     private final QNameSet messageDestinationRefQNameSet;
@@ -96,6 +100,12 @@
 
 
     public void buildNaming(XmlObject specDD, XmlObject plan, Configuration localConfiguration, Configuration remoteConfiguration, Module module, Map componentContext) throws DeploymentException {
+
+        // Discover and process any @Resource annotations (if !metadata-complete)
+        if ((module != null) && (module.getClassFinder() != null)) {
+            processAnnotations(module);
+        }
+
         List<ResourceEnvRefType> resourceEnvRefsUntyped = convert(specDD.selectChildren(adminOjbectRefQNameSet), JEE_CONVERTER, ResourceEnvRefType.class, ResourceEnvRefType.type);
         ClassLoader cl = module.getEarContext().getClassLoader();
         XmlObject[] gerResourceEnvRefsUntyped = plan == null? NO_REFS: plan.selectChildren(GER_ADMIN_OBJECT_REF_QNAME_SET);
@@ -238,6 +248,20 @@
             containerId = buildAbstractNameQuery(patternType, NameFactory.JCA_ADMIN_OBJECT, NameFactory.RESOURCE_ADAPTER_MODULE, null);
         }
         return containerId;
+    }
+
+    private void processAnnotations(Module module) throws DeploymentException {
+
+        // Process all the annotations for this naming builder type
+        if (ResourceAnnotationHelper.annotationsPresent(module.getClassFinder())) {
+            try {
+                ResourceAnnotationHelper.processAnnotations(module.getAnnotatedApp(), module.getClassFinder());
+            }
+            catch (Exception e) {
+                log.warn("Unable to process @Resource annotations for module" +
+                module.getName(), e);
+            }
+        }
     }
 
     private static Map<String, XmlObject> mapResourceEnvRefs(XmlObject[] refs) {

Modified: geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/ResourceRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/ResourceRefBuilder.java?view=diff&rev=515016&r1=515015&r2=515016
==============================================================================
--- geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/ResourceRefBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/ResourceRefBuilder.java Tue Mar  6 00:16:35 2007
@@ -29,12 +29,15 @@
 import javax.naming.Reference;
 import javax.xml.namespace.QName;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.common.UnresolvedReferenceException;
 import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.j2ee.deployment.Module;
+import org.apache.geronimo.j2ee.deployment.annotation.ResourceAnnotationHelper;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.config.Configuration;
@@ -54,6 +57,9 @@
  * @version $Rev$ $Date$
  */
 public class ResourceRefBuilder extends AbstractNamingBuilder implements ResourceEnvironmentSetter {
+
+    private static final Log log = LogFactory.getLog(ResourceRefBuilder.class);
+
     private static final QName GER_RESOURCE_REF_QNAME = GerResourceRefDocument.type.getDocumentElementName();
     private static final QNameSet GER_RESOURCE_REF_QNAME_SET = QNameSet.singleton(GER_RESOURCE_REF_QNAME);
 
@@ -73,6 +79,12 @@
     }
 
     public void buildNaming(XmlObject specDD, XmlObject plan, Configuration localConfiguration, Configuration remoteConfiguration, Module module, Map componentContext) throws DeploymentException {
+
+        // Discover and process any @Resource annotations (if !metadata-complete)
+        if ((module != null) && (module.getClassFinder() != null)) {
+            processAnnotations(module);
+        }
+
         List<ResourceRefType> resourceRefsUntyped = convert(specDD.selectChildren(resourceRefQNameSet), J2EE_CONVERTER, ResourceRefType.class, ResourceRefType.type);
         XmlObject[] gerResourceRefsUntyped = plan == null? NO_REFS: plan.selectChildren(GER_RESOURCE_REF_QNAME_SET);
         Map refMap = mapResourceRefs(gerResourceRefsUntyped);
@@ -200,6 +212,20 @@
             containerId = buildAbstractNameQuery(patternType, type, NameFactory.RESOURCE_ADAPTER_MODULE, null);
         }
         return containerId;
+    }
+
+
+    private void processAnnotations(Module module) throws DeploymentException {
+
+        // Process all the annotations for this naming builder type
+        if (ResourceAnnotationHelper.annotationsPresent(module.getClassFinder())) {
+            try {
+                ResourceAnnotationHelper.processAnnotations(module.getAnnotatedApp(), module.getClassFinder());
+            }
+            catch (Exception e) {
+                log.warn("Unable to process @Resource annotations for module" + module.getName(), e);
+            }
+        }
     }
 
     public QNameSet getSpecQNameSet() {

Modified: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/Module.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/Module.java?view=diff&rev=515016&r1=515015&r2=515016
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/Module.java (original)
+++ geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/Module.java Tue Mar  6 00:16:35 2007
@@ -26,6 +26,7 @@
 import org.apache.geronimo.deployment.util.DeploymentUtil;
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.j2ee.deployment.annotation.AnnotatedApp;
+import org.apache.xbean.finder.ClassFinder;
 
 /**
  * @version $Rev$ $Date$
@@ -48,10 +49,11 @@
     private XmlObject specDD;
     private String originalSpecDD;
     private AnnotatedApp annotatedApp;
+    private ClassFinder classFinder;
 
     protected final Map sharedContext;
 
-    protected Module(boolean standAlone, AbstractName moduleName, Environment environment, JarFile moduleFile, String targetPath, XmlObject specDD, XmlObject vendorDD, String originalSpecDD, String namespace, Map sharedContext, AnnotatedApp annotatedApp) {
+    protected Module(boolean standAlone, AbstractName moduleName, Environment environment, JarFile moduleFile, String targetPath, XmlObject specDD, XmlObject vendorDD, String originalSpecDD, String namespace, Map sharedContext, AnnotatedApp annotatedApp ) {
         assert targetPath != null: "targetPath is null";
         assert moduleName != null: "moduleName is null";
 
@@ -76,6 +78,7 @@
         targetPathURI = URI.create(targetPath + "/");
         this.sharedContext = sharedContext;
         this.annotatedApp = annotatedApp;
+        this.classFinder = classFinder;
     }
 
     public abstract ConfigurationModuleType getType();
@@ -182,5 +185,13 @@
 
     public void setAnnotatedApp(AnnotatedApp annotatedApp) {
         this.annotatedApp = annotatedApp;
+    }
+
+    public ClassFinder getClassFinder() {
+        return classFinder;
+    }
+
+    public void setClassFinder(ClassFinder classFinder) {
+        this.classFinder = classFinder;
     }
 }

Modified: geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java?view=diff&rev=515016&r1=515015&r2=515016
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java Tue Mar  6 00:16:35 2007
@@ -112,13 +112,13 @@
 import org.apache.geronimo.xbeans.javaee.WebAppDocument;
 import org.apache.geronimo.xbeans.javaee.WebAppType;
 import org.apache.geronimo.xbeans.javaee.WelcomeFileListType;
+import org.apache.xbean.finder.ClassFinder;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 import org.mortbay.jetty.security.BasicAuthenticator;
 import org.mortbay.jetty.security.ClientCertAuthenticator;
 import org.mortbay.jetty.security.DigestAuthenticator;
 import org.mortbay.jetty.security.FormAuthenticator;
-import org.apache.geronimo.j2ee.deployment.annotation.AnnotatedWebApp;
 
 
 /**
@@ -330,7 +330,20 @@
         Map buildingContext = new HashMap();
         buildingContext.put(NamingBuilder.GBEAN_NAME_KEY, moduleName);
         Configuration earConfiguration = earContext.getConfiguration();
+
+        if (!webApp.getMetadataComplete()) {
+            // Create a classfinder and populate it for the naming builder(s). The absence of a
+            // classFinder in the module will convey whether metadata-complete is set (or not)
+            webModule.setClassFinder(createWebAppClassFinder(webApp, webModule));
+        }
+
         getNamingBuilders().buildNaming(webApp, jettyWebApp, earConfiguration, earConfiguration, (Module) webModule, buildingContext);
+
+        if (!webApp.getMetadataComplete()) {
+            webApp.setMetadataComplete(true);
+            module.setOriginalSpecDD(module.getSpecDD().toString());
+        }
+
         Map compContext = NamingBuilder.JNDI_KEY.get(buildingContext);
         Map<String, List<Injection>> injections = NamingBuilder.INJECTION_KEY.get(buildingContext);
         Map<String, Holder> holders = new HashMap<String, Holder> ();

Modified: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java?view=diff&rev=515016&r1=515015&r2=515016
==============================================================================
--- geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java Tue Mar  6 00:16:35 2007
@@ -22,10 +22,13 @@
 
 import javax.xml.namespace.QName;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.j2ee.deployment.annotation.ResourceAnnotationHelper;
 import org.apache.geronimo.j2ee.deployment.Module;
 import org.apache.geronimo.j2ee.deployment.NamingBuilder;
 import org.apache.geronimo.kernel.config.Configuration;
@@ -41,6 +44,8 @@
  */
 public class EnvironmentEntryBuilder extends AbstractNamingBuilder {
 
+    private static final Log log = LogFactory.getLog(EnvironmentEntryBuilder.class);
+
     private final QNameSet envEntryQNameSet;
 
     public EnvironmentEntryBuilder(String[] eeNamespaces) {
@@ -53,6 +58,12 @@
     }
 
     public void buildNaming(XmlObject specDD, XmlObject plan, Configuration localConfiguration, Configuration remoteConfiguration, Module module, Map componentContext) throws DeploymentException {
+
+        // Discover and process any @Resource annotations (if !metadata-complete)
+        if ((module != null) && (module.getClassFinder() != null)) {
+            processAnnotations(module);
+        }
+
         List<EnvEntryType> envEntriesUntyped = convert(specDD.selectChildren(envEntryQNameSet), JEE_CONVERTER, EnvEntryType.class, EnvEntryType.type);
         for (EnvEntryType envEntry: envEntriesUntyped) {
             String name = envEntry.getEnvEntryName().getStringValue().trim();
@@ -94,6 +105,19 @@
             }
         }
 
+    }
+
+    private void processAnnotations(Module module) throws DeploymentException {
+
+        // Process all the annotations for this naming builder type
+        if (ResourceAnnotationHelper.annotationsPresent(module.getClassFinder())) {
+            try {
+                ResourceAnnotationHelper.processAnnotations(module.getAnnotatedApp(), module.getClassFinder());
+            }
+            catch (Exception e) {
+                log.warn("Unable to process @Resource annotations for module" + module.getName(), e);
+            }
+        }
     }
 
     public QNameSet getSpecQNameSet() {

Modified: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/SwitchingServiceRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/SwitchingServiceRefBuilder.java?view=diff&rev=515016&r1=515015&r2=515016
==============================================================================
--- geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/SwitchingServiceRefBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/SwitchingServiceRefBuilder.java Tue Mar  6 00:16:35 2007
@@ -17,7 +17,6 @@
 
 package org.apache.geronimo.naming.deployment;
 
-import java.io.IOException;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
@@ -30,7 +29,6 @@
 import org.apache.geronimo.deployment.service.EnvironmentBuilder;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.j2ee.deployment.annotation.AnnotatedApp;
 import org.apache.geronimo.j2ee.deployment.annotation.WebServiceRefAnnotationHelper;
 import org.apache.geronimo.j2ee.deployment.Module;
 import org.apache.geronimo.j2ee.deployment.WebModule;
@@ -42,7 +40,6 @@
 import org.apache.geronimo.xbeans.geronimo.naming.GerServiceRefDocument;
 import org.apache.geronimo.xbeans.geronimo.naming.GerServiceRefType;
 import org.apache.geronimo.xbeans.javaee.ServiceRefType;
-import org.apache.geronimo.xbeans.javaee.WebAppType;
 import org.apache.xbean.finder.ClassFinder;
 import org.apache.xbean.finder.UrlSet;
 import org.apache.xmlbeans.QNameSet;
@@ -92,19 +89,9 @@
                             Module module,
                             Map componentContext) throws DeploymentException {
 
-        if ( module instanceof WebModule ) {
-            //TODO determine if its metdatacomplete by presence of ClassFinder in module
-            //This will let this code work on any dd type.
-            WebAppType webApp = (WebAppType) specDD;
-            if (!webApp.getMetadataComplete()) {
-
-                // Discover and process any @WebServiceRef annotations
-                processAnnotations(module);
-
-                // Update both versions of specDD in module
-                module.setSpecDD(webApp);
-                module.setOriginalSpecDD(webApp.toString());
-            }
+        // Discover and process any @WebServiceRef annotations (if !metadata-complete)
+        if ((module != null) && (module.getClassFinder() != null)) {
+            processAnnotations(module);
         }
 
         ClassLoader cl = module.getEarContext().getClassLoader();
@@ -204,38 +191,14 @@
 
     private void processAnnotations(Module module) throws DeploymentException {
 
-        // Find all the annotated classes via ClassFinder
-        try {
-            ClassLoader classLoader = module.getEarContext().getClassLoader();
-            UrlSet urlSet = new UrlSet(classLoader);
-            if (classLoader instanceof MultiParentClassLoader) {
-                MultiParentClassLoader multiParentClassLoader = (MultiParentClassLoader) classLoader;
-                for (ClassLoader parent : multiParentClassLoader.getParents()) {
-                    if (parent != null) {
-                        urlSet = urlSet.exclude(parent);
-                    }
-                }
-            } else {
-                ClassLoader parent = classLoader.getParent();
-                if (parent != null) {
-                    urlSet = urlSet.exclude(parent);
-                }
+        // Process all the annotations for this naming builder type
+        if (WebServiceRefAnnotationHelper.annotationsPresent(module.getClassFinder())) {
+            try {
+                WebServiceRefAnnotationHelper.processAnnotations(module.getAnnotatedApp(), module.getClassFinder());
             }
-            ClassFinder finder = new ClassFinder(classLoader, urlSet.getUrls());
-
-            // Process all the annotations for this naming builder type
-            if (WebServiceRefAnnotationHelper.annotationsPresent(finder)) {
-                try {
-                    WebServiceRefAnnotationHelper.processAnnotations(module.getAnnotatedApp(), finder);
-                }
-                catch (Exception e) {
-                    log.warn("Unable to process @WebServiceRef annotations for web module" + module.getName(), e);
-                }
+            catch (Exception e) {
+                log.warn("Unable to process @WebServiceRef annotations for module" + module.getName(), e);
             }
-
-        } catch (IOException e) {
-            // ignored... we tried
-            log.warn("Unable to process @WebServiceRef annotations for web module" + module.getName(), e);
         }
     }
 

Modified: geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbDeploymentBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbDeploymentBuilder.java?view=diff&rev=515016&r1=515015&r2=515016
==============================================================================
--- geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbDeploymentBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbDeploymentBuilder.java Tue Mar  6 00:16:35 2007
@@ -18,7 +18,9 @@
 package org.apache.geronimo.openejb.deployment;
 
 import java.security.Permissions;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
 import java.util.Collections;
@@ -59,6 +61,7 @@
 import org.apache.geronimo.openejb.MessageDrivenDeploymentGBean;
 import org.apache.geronimo.openejb.OpenEjbSystem;
 import org.apache.geronimo.connector.outbound.connectiontracking.TrackedConnectionAssociator;
+import org.apache.xbean.finder.ClassFinder;
 import org.apache.xmlbeans.XmlObject;
 
 /**
@@ -220,7 +223,15 @@
         //
         // XMLBeans types must be use because Geronimo naming building is coupled via XMLBeans objects
         //
+
         EjbJarType ejbJarType = (EjbJarType) ejbModule.getSpecDD();
+
+        if (!ejbJarType.getMetadataComplete()) {
+            // Create a classfinder and populate it for the naming builder(s). The absence of a
+            // classFinder in the module will convey whether metadata-complete is set (or not)
+            ejbModule.setClassFinder(createEjbJarClassFinder(ejbJarType, ejbModule));
+        }
+
         EnterpriseBeansType enterpriseBeans = ejbJarType.getEnterpriseBeans();
         if (enterpriseBeans != null) {
             for (SessionBeanType xmlbeansEjb : enterpriseBeans.getSessionArray()) {
@@ -243,6 +254,11 @@
             }
 
         }
+
+        if (!ejbJarType.getMetadataComplete()) {
+            ejbJarType.setMetadataComplete(true);
+            ejbModule.setOriginalSpecDD(ejbModule.getSpecDD().toString());
+        }
     }
 
     private void addEnc(GBeanData gbean, XmlObject xmlbeansEjb, ResourceRefType[] resourceRefs) throws DeploymentException {
@@ -276,6 +292,21 @@
 
         GBeanResourceEnvironmentBuilder refBuilder = new GBeanResourceEnvironmentBuilder(gbean);
         resourceEnvironmentSetter.setResourceEnvironment(refBuilder, resourceRefs, gerResourceRefs);
+    }
+
+    private ClassFinder createEjbJarClassFinder( EjbJarType ejbJarType, EjbModule ejbModule) throws DeploymentException {
+
+        //----------------------------------------------------------------------------------------
+        // Find the list of classes from the ejb-jar.xml we want to search for annotations in
+        //----------------------------------------------------------------------------------------
+        List<Class> classes = new ArrayList<Class>();
+
+        // Get the classloader from the module's EARContext
+        ClassLoader classLoader = ejbModule.getEarContext().getClassLoader();
+
+        // TODO Openejb has the classfinder we need, we just have to get it from them.
+
+        return new ClassFinder(classes);
     }
 
     private GBeanData getEjbGBean(String ejbName) throws DeploymentException {

Modified: geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java?view=diff&rev=515016&r1=515015&r2=515016
==============================================================================
--- geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java Tue Mar  6 00:16:35 2007
@@ -525,6 +525,9 @@
         EjbModule ejbModule = (EjbModule) module;
         EjbDeploymentBuilder ejbDeploymentBuilder = ejbModule.getEjbBuilder();
 
+        // add enc
+        ejbDeploymentBuilder.buildEnc();
+
         // Add JSR77 EJBModule GBean
         GBeanData ejbModuleGBeanData = new GBeanData(ejbModule.getModuleName(), EjbModuleImplGBean.GBEAN_INFO);
         try {
@@ -550,9 +553,6 @@
 
         // add a depdendency on the ejb module object
         ejbDeploymentBuilder.addEjbModuleDependency(ejbModuleGBeanData.getAbstractName());
-
-        // add enc
-        ejbDeploymentBuilder.buildEnc();
 
         // add the Jacc permissions to the ear
         ComponentPermissions componentPermissions = ejbDeploymentBuilder.buildComponentPermissions();

Modified: geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java?view=diff&rev=515016&r1=515015&r2=515016
==============================================================================
--- geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java Tue Mar  6 00:16:35 2007
@@ -40,7 +40,6 @@
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.j2ee.deployment.Module;
 import org.apache.geronimo.j2ee.deployment.WebModule;
-import org.apache.geronimo.j2ee.deployment.annotation.AnnotatedApp;
 import org.apache.geronimo.j2ee.deployment.annotation.EJBAnnotationHelper;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.config.Configuration;
@@ -107,23 +106,12 @@
     public void buildNaming(XmlObject specDD, XmlObject plan, Configuration localConfiguration, Configuration remoteConfiguration, Module module, Map componentContext) throws DeploymentException {
         JndiConsumer consumer = createJndiConsumer(specDD, componentContext);
 
-        if ( module instanceof WebModule ) {
-            WebAppType webApp = (WebAppType) module.getSpecDD();
-            if (!webApp.getMetadataComplete()) {
-
-                // Discover and process any EJB annotations
-                processAnnotations(module);
-
-                // Set metadata complete
-                webApp.setMetadataComplete(true);
-
-                // Update both versions of specDD in module
-                module.setSpecDD(webApp);
-                module.setOriginalSpecDD(webApp.toString());
+        // Discover and process any @EJB annotations (if !metadata-complete)
+        if ((module != null) && (module.getClassFinder() != null)) {
+            processAnnotations(module);
 
-                // Augment the JndiConsumer with any discovered annotations
-                augmentJndiConsumer(module, consumer, componentContext);
-            }
+            // Augment the JndiConsumer with any discovered annotations
+            augmentJndiConsumer(module, consumer, componentContext);
         }
 
 //      processWebEjbAnnotations(module, consumer);
@@ -267,42 +255,14 @@
 
     private void processAnnotations(Module module) throws DeploymentException {
 
-        //----------------------------------------------------
-        // Find all the annotated classes via ClassFinder
-        //----------------------------------------------------
-        try {
-            ClassLoader classLoader = module.getEarContext().getClassLoader();
-            UrlSet urlSet = new UrlSet(classLoader);
-            if (classLoader instanceof MultiParentClassLoader) {
-                MultiParentClassLoader multiParentClassLoader = (MultiParentClassLoader) classLoader;
-                for (ClassLoader parent : multiParentClassLoader.getParents()) {
-                    if (parent != null) {
-                        urlSet = urlSet.exclude(parent);
-                    }
-                }
-            } else {
-                ClassLoader parent = classLoader.getParent();
-                if (parent != null) {
-                    urlSet = urlSet.exclude(parent);
-                }
+        // Process all the annotations for this naming builder type
+        if (EJBAnnotationHelper.annotationsPresent(module.getClassFinder())) {
+            try {
+                EJBAnnotationHelper.processAnnotations(module.getAnnotatedApp(), module.getClassFinder());
             }
-            ClassFinder finder = new ClassFinder(classLoader, urlSet.getUrls());
-
-            //----------------------------------------------------------------------
-            // Finally process all the annotations for this naming builder type
-            //----------------------------------------------------------------------
-            if (EJBAnnotationHelper.annotationsPresent(finder)) {
-                try {
-                    EJBAnnotationHelper.processAnnotations(module.getAnnotatedApp(), finder);
-                }
-                catch (Exception e) {
-                    log.warn("Unable to process @EJB annotations for web module" + module.getName(), e);
-                }
+            catch (Exception e) {
+                log.warn("Unable to process @EJB annotations for module" + module.getName(), e);
             }
-
-        } catch (IOException e) {
-            // ignored... we tried
-            log.warn("Unable to process @EJB annotations for web module" + module.getName(), e);
         }
     }
 
@@ -313,132 +273,139 @@
         //------------------------------------------
 
         EjbRefType[] ejbRefs = module.getAnnotatedApp().getEjbRefArray();
-        for ( EjbRefType xmlbeansRef : ejbRefs ) {
+        if (ejbRefs != null) {
+            for ( EjbRefType xmlbeansRef : ejbRefs ) {
 
-            // create the ejb-ref
-            EjbRef ref = new EjbRef();
-            consumer.getEjbRef().add(ref);
+                // create the ejb-ref
+                EjbRef ref = new EjbRef();
+                consumer.getEjbRef().add(ref);
 
-            // ejb-ref-name
-            String refName = getStringValue(xmlbeansRef.getEjbRefName());
-            ref.setEjbRefName(refName);
+                // ejb-ref-name
+                String refName = getStringValue(xmlbeansRef.getEjbRefName());
+                ref.setEjbRefName(refName);
 
-            // ejb-ref-type
-            String refType = getStringValue(xmlbeansRef.getEjbRefType());
-            if ("SESSION".equalsIgnoreCase(refType)) {
-                ref.setEjbRefType(org.apache.openejb.jee.EjbRefType.SESSION);
-            } else if ("ENTITY".equalsIgnoreCase(refType)) {
-                ref.setEjbRefType(org.apache.openejb.jee.EjbRefType.ENTITY);
-            }
+                // ejb-ref-type
+                String refType = getStringValue(xmlbeansRef.getEjbRefType());
+                if ("SESSION".equalsIgnoreCase(refType)) {
+                    ref.setEjbRefType(org.apache.openejb.jee.EjbRefType.SESSION);
+                }
+                else if ("ENTITY".equalsIgnoreCase(refType)) {
+                    ref.setEjbRefType(org.apache.openejb.jee.EjbRefType.ENTITY);
+                }
 
-            // home
-            ref.setHome(getStringValue(xmlbeansRef.getHome()));
+                // home
+                ref.setHome(getStringValue(xmlbeansRef.getHome()));
 
-            // remote
-            ref.setRemote(getStringValue(xmlbeansRef.getRemote()));
+                // remote
+                ref.setRemote(getStringValue(xmlbeansRef.getRemote()));
 
-            // ejb-link
-            ref.setEjbLink(getStringValue(xmlbeansRef.getEjbLink()));
+                // ejb-link
+                ref.setEjbLink(getStringValue(xmlbeansRef.getEjbLink()));
 
-            // mapped-name
-            ref.setMappedName(getStringValue(xmlbeansRef.getMappedName()));
+                // mapped-name
+                ref.setMappedName(getStringValue(xmlbeansRef.getMappedName()));
 
-            // openejb handling of injection-targets
-            if (xmlbeansRef.getInjectionTargetArray() != null) {
-                for (InjectionTargetType injectionTargetType : xmlbeansRef.getInjectionTargetArray()) {
-                    InjectionTarget injectionTarget = new InjectionTarget();
-                    injectionTarget.setInjectionTargetClass(getStringValue(injectionTargetType.getInjectionTargetClass()));
-                    injectionTarget.setInjectionTargetName(getStringValue(injectionTargetType.getInjectionTargetName()));
-                    ref.getInjectionTarget().add(injectionTarget);
+                // openejb handling of injection-targets
+                if (xmlbeansRef.getInjectionTargetArray() != null) {
+                    for (InjectionTargetType injectionTargetType : xmlbeansRef.getInjectionTargetArray()) {
+                        InjectionTarget injectionTarget = new InjectionTarget();
+                        injectionTarget.setInjectionTargetClass(getStringValue(injectionTargetType.getInjectionTargetClass()));
+                        injectionTarget.setInjectionTargetName(getStringValue(injectionTargetType.getInjectionTargetName()));
+                        ref.getInjectionTarget().add(injectionTarget);
+                    }
                 }
+                //geronimo's handling of injection-target
+                addInjections(refName, xmlbeansRef.getInjectionTargetArray(), componentContext);
             }
-            //geronimo's handling of injection-target
-            addInjections(refName, xmlbeansRef.getInjectionTargetArray(), componentContext);
         }
 
         EjbLocalRefType[] ejbLocalRefs = module.getAnnotatedApp().getEjbLocalRefArray();
-        for ( EjbLocalRefType xmlbeansRef : ejbLocalRefs ) {
+        if (ejbLocalRefs != null) {
+            for ( EjbLocalRefType xmlbeansRef : ejbLocalRefs ) {
 
-            // create the ejb-ref
-            EjbLocalRef ref = new EjbLocalRef();
-            consumer.getEjbLocalRef().add(ref);
+                // create the ejb-ref
+                EjbLocalRef ref = new EjbLocalRef();
+                consumer.getEjbLocalRef().add(ref);
 
-            // ejb-ref-name
-            String refName = getStringValue(xmlbeansRef.getEjbRefName());
-            ref.setEjbRefName(refName);
+                // ejb-ref-name
+                String refName = getStringValue(xmlbeansRef.getEjbRefName());
+                ref.setEjbRefName(refName);
 
-            // ejb-ref-type
-            String refType = getStringValue(xmlbeansRef.getEjbRefType());
-            if ("SESSION".equalsIgnoreCase(refType)) {
-                ref.setEjbRefType(org.apache.openejb.jee.EjbRefType.SESSION);
-            } else if ("ENTITY".equalsIgnoreCase(refType)) {
-                ref.setEjbRefType(org.apache.openejb.jee.EjbRefType.ENTITY);
-            }
+                // ejb-ref-type
+                String refType = getStringValue(xmlbeansRef.getEjbRefType());
+                if ("SESSION".equalsIgnoreCase(refType)) {
+                    ref.setEjbRefType(org.apache.openejb.jee.EjbRefType.SESSION);
+                }
+                else if ("ENTITY".equalsIgnoreCase(refType)) {
+                    ref.setEjbRefType(org.apache.openejb.jee.EjbRefType.ENTITY);
+                }
 
-            // home
-            ref.setLocalHome(getStringValue(xmlbeansRef.getLocalHome()));
+                // home
+                ref.setLocalHome(getStringValue(xmlbeansRef.getLocalHome()));
 
-            // remote
-            ref.setLocal(getStringValue(xmlbeansRef.getLocal()));
+                // remote
+                ref.setLocal(getStringValue(xmlbeansRef.getLocal()));
 
-            // ejb-link
-            ref.setEjbLink(getStringValue(xmlbeansRef.getEjbLink()));
+                // ejb-link
+                ref.setEjbLink(getStringValue(xmlbeansRef.getEjbLink()));
 
-            // mapped-name
-            ref.setMappedName(getStringValue(xmlbeansRef.getMappedName()));
+                // mapped-name
+                ref.setMappedName(getStringValue(xmlbeansRef.getMappedName()));
 
-            // openejb handling of injection-targets
-            if (xmlbeansRef.getInjectionTargetArray() != null) {
-                for (InjectionTargetType injectionTargetType : xmlbeansRef.getInjectionTargetArray()) {
-                    InjectionTarget injectionTarget = new InjectionTarget();
-                    injectionTarget.setInjectionTargetClass(getStringValue(injectionTargetType.getInjectionTargetClass()));
-                    injectionTarget.setInjectionTargetName(getStringValue(injectionTargetType.getInjectionTargetName()));
-                    ref.getInjectionTarget().add(injectionTarget);
+                // openejb handling of injection-targets
+                if (xmlbeansRef.getInjectionTargetArray() != null) {
+                    for (InjectionTargetType injectionTargetType : xmlbeansRef.getInjectionTargetArray()) {
+                        InjectionTarget injectionTarget = new InjectionTarget();
+                        injectionTarget.setInjectionTargetClass(getStringValue(injectionTargetType.getInjectionTargetClass()));
+                        injectionTarget.setInjectionTargetName(getStringValue(injectionTargetType.getInjectionTargetName()));
+                        ref.getInjectionTarget().add(injectionTarget);
+                    }
                 }
+                //geronimo's handling of injection-target
+                addInjections(refName, xmlbeansRef.getInjectionTargetArray(), componentContext);
             }
-            //geronimo's handling of injection-target
-            addInjections(refName, xmlbeansRef.getInjectionTargetArray(), componentContext);
         }
 
         List<EjbRefType> ambiguous = module.getAnnotatedApp().getAmbiguousEjbRefs();
-        for ( EjbRefType xmlbeansRef : ambiguous ) {
-
-            // create the ejb-ref
-            EjbRef ref = new EjbRef();
-            consumer.getEjbRef().add(ref);
-
-            // ejb-ref-name
-            String refName = getStringValue(xmlbeansRef.getEjbRefName());
-            ref.setEjbRefName(refName);
-
-            // ejb-ref-type
-            ref.setRefType(EjbRef.Type.UNKNOWN);
-
-            // home
-            ref.setHome(getStringValue(xmlbeansRef.getHome()));
+        if (ambiguous != null) {
+            for ( EjbRefType xmlbeansRef : ambiguous ) {
 
-            // remote
-            ref.setRemote(getStringValue(xmlbeansRef.getRemote()));
-
-            // ejb-link
-            ref.setEjbLink(getStringValue(xmlbeansRef.getEjbLink()));
-
-            // mapped-name
-            ref.setMappedName(getStringValue(xmlbeansRef.getMappedName()));
-
-            // openejb handling of injection-targets
-            if (xmlbeansRef.getInjectionTargetArray() != null) {
-                for (InjectionTargetType injectionTargetType : xmlbeansRef.getInjectionTargetArray()) {
-                    InjectionTarget injectionTarget = new InjectionTarget();
-                    injectionTarget.setInjectionTargetClass(getStringValue(injectionTargetType.getInjectionTargetClass()));
-                    injectionTarget.setInjectionTargetName(getStringValue(injectionTargetType.getInjectionTargetName()));
-                    ref.getInjectionTarget().add(injectionTarget);
+                // create the ejb-ref
+                EjbRef ref = new EjbRef();
+                consumer.getEjbRef().add(ref);
+
+                // ejb-ref-name
+                String refName = getStringValue(xmlbeansRef.getEjbRefName());
+                ref.setEjbRefName(refName);
+
+                // ejb-ref-type
+                ref.setRefType(EjbRef.Type.UNKNOWN);
+
+                // home
+                ref.setHome(getStringValue(xmlbeansRef.getHome()));
+
+                // remote
+                ref.setRemote(getStringValue(xmlbeansRef.getRemote()));
+
+                // ejb-link
+                ref.setEjbLink(getStringValue(xmlbeansRef.getEjbLink()));
+
+                // mapped-name
+                ref.setMappedName(getStringValue(xmlbeansRef.getMappedName()));
+
+                // openejb handling of injection-targets
+                if (xmlbeansRef.getInjectionTargetArray() != null) {
+                    for (InjectionTargetType injectionTargetType : xmlbeansRef.getInjectionTargetArray()) {
+                        InjectionTarget injectionTarget = new InjectionTarget();
+                        injectionTarget.setInjectionTargetClass(getStringValue(injectionTargetType.getInjectionTargetClass()));
+                        injectionTarget.setInjectionTargetName(getStringValue(injectionTargetType.getInjectionTargetName()));
+                        ref.getInjectionTarget().add(injectionTarget);
+                    }
                 }
+                //geronimo's handling of injection-target
+                addInjections(refName, xmlbeansRef.getInjectionTargetArray(), componentContext);
             }
-            //geronimo's handling of injection-target
-            addInjections(refName, xmlbeansRef.getInjectionTargetArray(), componentContext);
         }
-
     }
 
     private void processWebEjbAnnotations(Module module, JndiConsumer consumer) throws DeploymentException {
@@ -474,7 +441,7 @@
 
             } catch (IOException e) {
                 // ignored... we tried
-                log.warn("Unable to process @EJB annotations for web module" + module.getName(), e);
+                log.warn("Unable to process @EJB annotations web module" + module.getName(), e);
             }
         }
     }

Modified: geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceContextRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceContextRefBuilder.java?view=diff&rev=515016&r1=515015&r2=515016
==============================================================================
--- geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceContextRefBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceContextRefBuilder.java Tue Mar  6 00:16:35 2007
@@ -71,6 +71,12 @@
     }
 
     public void buildNaming(XmlObject specDD, XmlObject plan, Configuration localConfiguration, Configuration remoteConfiguration, Module module, Map componentContext) throws DeploymentException {
+
+        // Discover and process any @PersistenceContextRef annotations (if !metadata-complete)
+        if ((module != null) && (module.getClassFinder() != null)) {
+            processAnnotations(module);
+        }
+
         List<PersistenceContextRefType> specPersistenceContextRefsUntyped = convert(specDD.selectChildren(PERSISTENCE_CONTEXT_REF_QNAME_SET), JEE_CONVERTER, PersistenceContextRefType.class, PersistenceContextRefType.type);
         Map<String, GerPersistenceContextRefType> gerPersistenceContextRefsUntyped = getGerPersistenceContextRefs(plan);
         for (PersistenceContextRefType persistenceContextRef : specPersistenceContextRefsUntyped) {
@@ -166,6 +172,21 @@
             persistenceUnitNameQuery = buildAbstractNameQuery(gbeanLocator, null, null, PERSISTENCE_UNIT_INTERFACE_TYPES);
         }
         return persistenceUnitNameQuery;
+    }
+
+    private void processAnnotations(Module module) throws DeploymentException {
+
+        // Process all the annotations for this naming builder type
+//      if (PersistenceContextRefAnnotationHelper.annotationsPresent(module.getClassFinder()))
+//              { try {
+//              PersistenceContextRefAnnotationHelper.processAnnotations(module.getAnnotatedApp(),
+//              module.getClassFinder());
+//          }
+//          catch (Exception e) {
+//              log.warn("Unable to process @PersistenceContextRef annotations for module" +
+//              module.getName(), e);
+//          }
+//      }
     }
 
     public QNameSet getSpecQNameSet() {

Modified: geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitRefBuilder.java?view=diff&rev=515016&r1=515015&r2=515016
==============================================================================
--- geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitRefBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitRefBuilder.java Tue Mar  6 00:16:35 2007
@@ -73,6 +73,12 @@
     }
 
     public void buildNaming(XmlObject specDD, XmlObject plan, Configuration localConfiguration, Configuration remoteConfiguration, Module module, Map componentContext) throws DeploymentException {
+
+        // Discover and process any @PersistenceUnitRef annotations (if !metadata-complete)
+        if ((module != null) && (module.getClassFinder() != null)) {
+            processAnnotations(module);
+        }
+
         List<PersistenceUnitRefType> specPersistenceUnitRefsUntyped = convert(specDD.selectChildren(PersistenceUnitRefBuilder.PERSISTENCE_UNIT_REF_QNAME_SET), JEE_CONVERTER, PersistenceUnitRefType.class, PersistenceUnitRefType.type);
         Map<String, GerPersistenceUnitRefType> gerPersistenceUnitRefsUntyped = getGerPersistenceUnitRefs(plan);
         for (PersistenceUnitRefType PersistenceUnitRef: specPersistenceUnitRefsUntyped) {
@@ -119,6 +125,21 @@
             NamingBuilder.JNDI_KEY.get(componentContext).put(ENV + PersistenceUnitRefName, reference);
 
         }
+    }
+
+    private void processAnnotations(Module module) throws DeploymentException {
+
+        // Process all the annotations for this naming builder type
+//      if (PersistenceUnitRefAnnotationHelper.annotationsPresent(module.getClassFinder())) {
+//          try {
+//              PersistenceUnitRefAnnotationHelper.processAnnotations(module.getAnnotatedApp(),
+//              module.getClassFinder());
+//          }
+//          catch (Exception e) {
+//              log.warn("Unable to process @PersistenceUnitRef annotations for module" +
+//              module.getName(), e);
+//          }
+//      }
     }
 
     private AbstractNameQuery findPersistenceUnit(GerPersistenceUnitRefType gerPersistenceUnitRef) {

Modified: geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java?view=diff&rev=515016&r1=515015&r2=515016
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java Tue Mar  6 00:16:35 2007
@@ -86,6 +86,7 @@
 import org.apache.geronimo.xbeans.javaee.WebAppType;
 import org.apache.geronimo.xbeans.javaee.ServletMappingType;
 import org.apache.geronimo.xbeans.javaee.impl.WebAppDocumentImpl;
+import org.apache.xbean.finder.ClassFinder;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlOptions;
@@ -319,7 +320,6 @@
                 webModuleData.setReferencePattern("J2EEApplication", earContext.getModuleName());
             }
 
-            webModuleData.setAttribute("deploymentDescriptor", module.getOriginalSpecDD());
             Set securityRoles = collectRoleNames(webApp);
             Map rolePermissions = new HashMap();
 
@@ -335,7 +335,21 @@
             Map buildingContext = new HashMap();
             buildingContext.put(NamingBuilder.GBEAN_NAME_KEY, moduleName);
             Configuration earConfiguration = earContext.getConfiguration();
+
+            if (!webApp.getMetadataComplete()) {
+                // Create a classfinder and populate it for the naming builder(s). The absence of a
+                // classFinder in the module will convey whether metadata-complete is set (or not)
+                webModule.setClassFinder(createWebAppClassFinder(webApp, webModule));
+            }
+
             getNamingBuilders().buildNaming(webApp, tomcatWebApp, earConfiguration, earConfiguration, webModule, buildingContext);
+
+            if (!webApp.getMetadataComplete()) {
+                webApp.setMetadataComplete(true);
+                module.setOriginalSpecDD(module.getSpecDD().toString());
+            }
+            webModuleData.setAttribute("deploymentDescriptor", module.getOriginalSpecDD());
+
             Map compContext = NamingBuilder.JNDI_KEY.get(buildingContext);
 
             webModuleData.setAttribute("componentContext", compContext);

Modified: geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java?view=diff&rev=515016&r1=515015&r2=515016
==============================================================================
--- geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java Tue Mar  6 00:16:35 2007
@@ -60,8 +60,6 @@
 import org.apache.geronimo.j2ee.deployment.NamingBuilder;
 import org.apache.geronimo.j2ee.deployment.WebModule;
 import org.apache.geronimo.j2ee.deployment.WebServiceBuilder;
-import org.apache.geronimo.j2ee.deployment.annotation.EJBAnnotationHelper;
-import org.apache.geronimo.j2ee.deployment.annotation.ResourceAnnotationHelper;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.Naming;
@@ -76,6 +74,8 @@
 import org.apache.geronimo.security.util.HTTPMethods;
 import org.apache.geronimo.security.util.URLPattern;
 import org.apache.geronimo.xbeans.geronimo.j2ee.GerSecurityDocument;
+import org.apache.geronimo.xbeans.javaee.EjbLocalRefType;
+import org.apache.geronimo.xbeans.javaee.EjbRefType;
 import org.apache.geronimo.xbeans.javaee.FilterMappingType;
 import org.apache.geronimo.xbeans.javaee.FilterType;
 import org.apache.geronimo.xbeans.javaee.FullyQualifiedClassType;
@@ -694,36 +694,36 @@
         serviceBuilders.build(gerWebApp, earContext, module.getEarContext());
     }
 
-    protected void makeMetadataComplete(WebAppType webApp, Module module) throws DeploymentException {
-        if (!webApp.getMetadataComplete()) {
-            processAnnotations(webApp, module);
-            webApp.setMetadataComplete(true);
-            module.setSpecDD(webApp);
-            module.setOriginalSpecDD(webApp.toString());
-        }
-    }
-
-    private void processAnnotations(WebAppType webApp, Module module) throws DeploymentException {
-
-        //--------------------------------------------------------------------------------------
-        // First find the list of classes from the WAR we want to search for annotations in
-        //--------------------------------------------------------------------------------------
+//  protected void makeMetadataComplete(WebAppType webApp, Module module) throws DeploymentException
+//      { if (!webApp.getMetadataComplete()) {
+//          processAnnotations(webApp, module);
+//          webApp.setMetadataComplete(true);
+//          module.setSpecDD(webApp);
+//          module.setOriginalSpecDD(webApp.toString());
+//      }
+//  }
+
+    protected ClassFinder createWebAppClassFinder(WebAppType webApp, WebModule webModule) throws DeploymentException {
+
+        //------------------------------------------------------------------------------------
+        // Find the list of classes from the web.xml we want to search for annotations in
+        //------------------------------------------------------------------------------------
         List<Class> classes = new ArrayList<Class>();
 
         // Get the classloader from the module's EARContext
-        ClassLoader classLoader = module.getEarContext().getClassLoader();
+        ClassLoader classLoader = webModule.getEarContext().getClassLoader();
 
         // Get all the servlets from the deployment descriptor
         ServletType[] servlets = webApp.getServletArray();
         for (ServletType servlet : servlets) {
             FullyQualifiedClassType cls = servlet.getServletClass();
-            if (cls != null) { //don't try this for jsps
+            if (cls != null) {                              // Don't try this for JSPs
                 Class<?> clas;
                 try {
                     clas = classLoader.loadClass(cls.getStringValue());
                 }
                 catch (ClassNotFoundException e) {
-                    throw new DeploymentException("WebModuleBuilder: Could not load servlet class: " + cls.getStringValue());
+                    throw new DeploymentException("AbstractWebModuleBuilder: Could not load servlet class: " + cls.getStringValue());
                 }
                 classes.add(clas);
             }
@@ -738,7 +738,7 @@
                 clas = classLoader.loadClass(cls.getStringValue());
             }
             catch (ClassNotFoundException e) {
-                throw new DeploymentException("WebModuleBuilder: Could not load listener class: " + cls.getStringValue());
+                throw new DeploymentException("AbstractWebModuleBuilder: Could not load listener class: " + cls.getStringValue());
             }
             classes.add(clas);
         }
@@ -752,57 +752,12 @@
                 clas = classLoader.loadClass(cls.getStringValue());
             }
             catch (ClassNotFoundException e) {
-                throw new DeploymentException("WebModuleBuilder: Could not load filter class: " + cls.getStringValue());
+                throw new DeploymentException("AbstractWebModuleBuilder: Could not load filter class: " + cls.getStringValue());
             }
             classes.add(clas);
         }
 
-        if (classes.size() > 0) {
-
-            //----------------------------------------------------
-            // Find all the annotated classes via ClassFinder
-            //----------------------------------------------------
-            ClassFinder classFinder = new ClassFinder(classes);
-
-            //--------------------------------------------------------------
-            // Finally process all the annotations for this module type
-            //--------------------------------------------------------------
-
-            // <ejb-ref>
-            // <ejb-local-ref>
-            if (EJBAnnotationHelper.annotationsPresent(classFinder)) {
-                try {
-                    ClassFinder ejbFinder = new ClassFinder(classLoader);
-//                  webApp = EJBAnnotationHelper.processAnnotations(webApp, classFinder, ejbFinder);
-                }
-                catch (Exception e) {
-                    throw new DeploymentException("TomcatModuleBuilder: Error processing @EJB(s) annotations", e);
-                }
-            }
-
-            // <env-entry>
-            // <message-destination>
-            // <message-destination-ref>
-            // <resource-env-ref>
-            // <resource-ref>
-            // <service-ref>
-            if (ResourceAnnotationHelper.annotationsPresent(classFinder)) {
-                try {
-//                  ResourceAnnotationHelper.processAnnotations(webApp, classFinder);
-                }
-                catch (Exception e) {
-                    throw new DeploymentException("TomcatModuleBuilder: Error processing @Resource(s) annotations", e);
-                }
-            }
-
-            /*  TODO
-               <security-role-ref>
-               <post-construct>
-               <pre-destroy>
-               <persistence-context-ref>
-               <persistence-unit-ref>
-            */
-        }
+        return new ClassFinder(classes);
     }
 
     class UncheckedItem {



Mime
View raw message