geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r509958 - in /geronimo/server/trunk: configs/j2ee-deployer/ modules/geronimo-j2ee-builder/ modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/ modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee...
Date Wed, 21 Feb 2007 10:13:56 GMT
Author: djencks
Date: Wed Feb 21 02:13:55 2007
New Revision: 509958

URL: http://svn.apache.org/viewvc?view=rev&rev=509958
Log:
GERONIMO-2837 annotation processing first step

Added:
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/EJBAnnotationHelper.java   (with props)
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/ResourceAnnotationHelper.java   (with props)
Modified:
    geronimo/server/trunk/configs/j2ee-deployer/pom.xml
    geronimo/server/trunk/modules/geronimo-j2ee-builder/pom.xml
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/Module.java
    geronimo/server/trunk/modules/geronimo-jetty6-builder/pom.xml
    geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java
    geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java
    geronimo/server/trunk/modules/geronimo-tomcat6-builder/pom.xml
    geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java

Modified: geronimo/server/trunk/configs/j2ee-deployer/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/configs/j2ee-deployer/pom.xml?view=diff&rev=509958&r1=509957&r2=509958
==============================================================================
--- geronimo/server/trunk/configs/j2ee-deployer/pom.xml (original)
+++ geronimo/server/trunk/configs/j2ee-deployer/pom.xml Wed Feb 21 02:13:55 2007
@@ -6,9 +6,9 @@
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at
-  
+
   http://www.apache.org/licenses/LICENSE-2.0
-  
+
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,7 +21,7 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 
     <modelVersion>4.0.0</modelVersion>
-    
+
     <parent>
         <groupId>org.apache.geronimo.configs</groupId>
         <artifactId>configs</artifactId>
@@ -32,9 +32,9 @@
     <artifactId>j2ee-deployer</artifactId>
     <name>Geronimo Configs :: J2EE Deployer</name>
     <packaging>car</packaging>
-    
+
     <dependencies>
-    
+
         <dependency>
             <groupId>org.apache.geronimo.configs</groupId>
             <artifactId>geronimo-gbean-deployer</artifactId>
@@ -63,13 +63,13 @@
             <artifactId>geronimo-j2ee-schema</artifactId>
             <version>${version}</version>
         </dependency>
-        
+
         <dependency>
             <groupId>org.apache.geronimo.modules</groupId>
             <artifactId>geronimo-client</artifactId>
             <version>${version}</version>
         </dependency>
-        
+
         <dependency>
             <groupId>org.apache.geronimo.modules</groupId>
             <artifactId>geronimo-naming-builder</artifactId>
@@ -101,6 +101,12 @@
             <version>${version}</version>
         </dependency>
 
+        <dependency>
+            <groupId>org.apache.xbean</groupId>
+            <artifactId>xbean-finder</artifactId>
+            <scope>runtime</scope>
+        </dependency>
+
     </dependencies>
-    
+
 </project>

Modified: geronimo/server/trunk/modules/geronimo-j2ee-builder/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee-builder/pom.xml?view=diff&rev=509958&r1=509957&r2=509958
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee-builder/pom.xml (original)
+++ geronimo/server/trunk/modules/geronimo-j2ee-builder/pom.xml Wed Feb 21 02:13:55 2007
@@ -21,7 +21,7 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 
     <modelVersion>4.0.0</modelVersion>
-    
+
     <parent>
         <groupId>org.apache.geronimo.modules</groupId>
         <artifactId>modules</artifactId>
@@ -31,9 +31,9 @@
 
     <artifactId>geronimo-j2ee-builder</artifactId>
     <name>Geronimo :: J2EE :: Builder</name>
-    
+
     <dependencies>
-        
+
         <dependency>
             <groupId>${pom.groupId}</groupId>
             <artifactId>geronimo-j2ee-schema</artifactId>
@@ -51,9 +51,24 @@
             <artifactId>geronimo-service-builder</artifactId>
             <version>${version}</version>
         </dependency>
-        
+
+        <dependency>
+            <groupId>org.apache.xbean</groupId>
+            <artifactId>xbean-finder</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-annotation_1.0_spec</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>asm</groupId>
+            <artifactId>asm</artifactId>
+        </dependency>
+
     </dependencies>
-    
+
     <build>
         <plugins>
             <plugin>
@@ -68,7 +83,7 @@
                         </goals>
                         <configuration>
                             <outputDirectory>${project.build.directory}</outputDirectory>
-                            
+
                             <artifactItems>
                                 <artifactItem>
                                     <groupId>org.apache.geronimo.testsupport</groupId>
@@ -77,7 +92,7 @@
                                     <type>ear</type>
                                     <destFileName>test-ear-j2ee_1.3.ear</destFileName>
                                 </artifactItem>
-                                
+
                                 <artifactItem>
                                     <groupId>org.apache.geronimo.testsupport</groupId>
                                     <artifactId>test-ear-j2ee_1.3</artifactId>
@@ -88,7 +103,7 @@
                                     -->
                                     <destFileName>test-ear-j2ee_1.3-naked.ear</destFileName>
                                 </artifactItem>
-                                
+
                                 <artifactItem>
                                     <groupId>org.apache.geronimo.testsupport</groupId>
                                     <artifactId>test-ear-j2ee_1.4</artifactId>
@@ -96,7 +111,7 @@
                                     <type>ear</type>
                                     <destFileName>test-ear-j2ee_1.4.ear</destFileName>
                                 </artifactItem>
-                                
+
                                 <artifactItem>
                                     <groupId>org.apache.geronimo.testsupport</groupId>
                                     <artifactId>test-ear-j2ee_1.4</artifactId>
@@ -115,7 +130,7 @@
                                     <type>ear</type>
                                     <destFileName>test-ear-javaee_5.ear</destFileName>
                                 </artifactItem>
-                                
+
                                 <artifactItem>
                                     <groupId>org.apache.geronimo.testsupport</groupId>
                                     <artifactId>test-ear-javaee_5</artifactId>
@@ -131,7 +146,7 @@
                     </execution>
                 </executions>
             </plugin>
-            
+
             <plugin>
                 <artifactId>maven-antrun-plugin</artifactId>
                 <executions>
@@ -150,7 +165,7 @@
                                 <mkdir dir="${project.build.directory}/test-ear-javaee_5-unpacked.ear"/>
                                 <unzip src="${project.build.directory}/test-ear-javaee_5.ear"
                                     dest="${project.build.directory}/test-ear-javaee_5-unpacked.ear"/>
-                                
+
                                 <mkdir dir="${project.build.directory}/test-ear-javaee_5-naked-unpacked.ear"/>
                                 <unzip src="${project.build.directory}/test-ear-javaee_5-naked.ear"
                                     dest="${project.build.directory}/test-ear-javaee_5-naked-unpacked.ear"/>
@@ -159,14 +174,14 @@
                                 <mkdir dir="${project.build.directory}/test-ear-j2ee_1.4-unpacked.ear"/>
                                 <unzip src="${project.build.directory}/test-ear-j2ee_1.4.ear"
                                     dest="${project.build.directory}/test-ear-j2ee_1.4-unpacked.ear"/>
-                                
+
                                 <mkdir dir="${project.build.directory}/test-ear-javaee_5-naked-unpacked.ear"/>
                                 <unzip src="${project.build.directory}/test-ear-j2ee_1.4-naked.ear"
                                     dest="${project.build.directory}/test-ear-j2ee_1.4-naked-unpacked.ear"/>
                             </tasks>
                         </configuration>
                     </execution>
-                    
+
                     <!--
                     HACK: Copy the generated XmlBeans bits for clover
                     -->
@@ -189,7 +204,7 @@
                     </execution>
                 </executions>
             </plugin>
-            
+
             <plugin>
                 <groupId>org.codehaus.mojo</groupId>
                 <artifactId>xmlbeans-maven-plugin</artifactId>

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=509958&r1=509957&r2=509958
==============================================================================
--- 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 Wed Feb 21 02:13:55 2007
@@ -39,13 +39,14 @@
     private final JarFile moduleFile;
     private final String targetPath;
     private final URI targetPathURI;
-    private final XmlObject specDD;
     private final XmlObject vendorDD;
-    private final String originalSpecDD;
     private final String namespace;
 
     private EARContext earContext;
     private EARContext rootEarContext;
+    private XmlObject specDD;
+    private String originalSpecDD;
+
     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) {
@@ -162,5 +163,13 @@
 
     public Map getSharedContext() {
         return sharedContext;
+    }
+
+    public void setSpecDD(XmlObject specDD) {
+        this.specDD = specDD;
+    }
+
+    public void setOriginalSpecDD(String originalSpecDD) {
+        this.originalSpecDD = originalSpecDD;
     }
 }

Added: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/EJBAnnotationHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/EJBAnnotationHelper.java?view=auto&rev=509958
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/EJBAnnotationHelper.java (added)
+++ geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/EJBAnnotationHelper.java Wed Feb 21 02:13:55 2007
@@ -0,0 +1,476 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.j2ee.deployment.annotation;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.ejb.EJB;
+import javax.ejb.EJBs;
+import javax.ejb.EJBHome;
+import javax.ejb.EJBLocalHome;
+import javax.ejb.Local;
+import javax.ejb.Remote;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
+import org.apache.geronimo.xbeans.javaee.DescriptionType;
+import org.apache.geronimo.xbeans.javaee.FullyQualifiedClassType;
+import org.apache.geronimo.xbeans.javaee.JavaIdentifierType;
+import org.apache.geronimo.xbeans.javaee.EjbLinkType;
+import org.apache.geronimo.xbeans.javaee.EjbLocalRefType;
+import org.apache.geronimo.xbeans.javaee.EjbRefNameType;
+import org.apache.geronimo.xbeans.javaee.EjbRefType;
+import org.apache.geronimo.xbeans.javaee.InjectionTargetType;
+import org.apache.geronimo.xbeans.javaee.LocalType;
+import org.apache.geronimo.xbeans.javaee.RemoteType;
+import org.apache.geronimo.xbeans.javaee.WebAppType;
+import org.apache.geronimo.xbeans.javaee.XsdStringType;
+import org.apache.xbean.finder.ClassFinder;
+
+/**
+ * Static helper class used to encapsulate all the functions related to the translation of
+ *
+ * @EJB and @EBJs annotations to deployment descriptor tags. The EJBAnnotationHelper class can be
+ * used as part of the deployment of a module into the Geronimo server. It performs the following
+ * major functions:
+ *
+ * <ol>
+ *      <li>Translates annotations into corresponding deployment descriptor elements (so that the
+ *      actual deployment descriptor in the module can be updated or even created if necessary)
+ * </ol>
+ *
+ * <p><strong>Note(s):</strong>
+ * <ul>
+ *      <li>The user is responsible for invoking change to metadata-complete
+ *      <li>This helper class will validate any changes it makes to the deployment descriptor. An
+ *      exception will be thrown if it fails to parse
+ * </ul>
+ *
+ * <p><strong>Remaining ToDo(s):</strong>
+ * <ul>
+ *      <li>How to determine Session/Entity remote/local for @EJB
+ * </ul>
+ *
+ * @version $Rev$ $Date$
+ * @since 02-2007
+ */
+public final class EJBAnnotationHelper {
+
+    // Private instance variables
+    private static final Log log = LogFactory.getLog( EJBAnnotationHelper.class );
+
+    // Private constructor to prevent instantiation
+    private EJBAnnotationHelper() {
+    }
+
+
+    /**
+     * Determine if there are any @EJB, @EJBs annotations present
+     *
+     * @return true or false
+     */
+    public static boolean annotationsPresent( ClassFinder classFinder ) {
+        if ( classFinder.isAnnotationPresent(EJB.class) ) return true;
+        if ( classFinder.isAnnotationPresent(EJBs.class) ) return true;
+        return false;
+    }
+
+
+    /**
+     * Process the @EJB, @EJBs annotations
+     *
+     * @return Updated deployment descriptor
+     * @exception Exception if parsing or validation error
+     */
+    public static WebAppType processAnnotations( WebAppType webApp, ClassFinder classFinder ) throws Exception {
+        processEJBs( webApp,classFinder );
+        processEJB( webApp,classFinder );
+        return webApp;
+    }
+
+
+    /**
+     * Process @EJB annotations
+     *
+     * @param webApp
+     * @param classFinder
+     * @exception Exception
+     */
+    private static void processEJB( WebAppType webApp, ClassFinder classFinder ) throws Exception {
+        log.debug( "processEJB(): Entry" );
+
+        // Save the EJB lists
+        List<Class>  classesWithEJB = classFinder.findAnnotatedClasses( EJB.class );
+        List<Method> methodsWithEJB = classFinder.findAnnotatedMethods( EJB.class );
+        List<Field>  fieldsWithEJB  = classFinder.findAnnotatedFields ( EJB.class );
+
+        // Class-level EJB
+        for ( Class cls : classesWithEJB ) {
+            EJB ejb = (EJB)cls.getAnnotation( EJB.class );
+            if ( ejb != null ) {
+                addEJB( webApp, ejb, cls, null, null );
+            }
+        }
+
+        // Method-level EJB
+        for ( Method method : methodsWithEJB ) {
+            EJB ejb = (EJB)method.getAnnotation( EJB.class );
+            if ( ejb != null ) {
+                addEJB( webApp, ejb, null, method, null );
+            }
+        }
+
+        // Field-level EJB
+        for ( Field field : fieldsWithEJB ) {
+            EJB ejb = (EJB)field.getAnnotation( EJB.class );
+            if ( ejb != null ) {
+                addEJB( webApp, ejb, null, null, field );
+            }
+        }
+
+        // Validate deployment descriptor to ensure it's still okay
+        validateDD( webApp );
+
+        log.debug( "processEJB(): Exit: webApp: " + webApp.toString() );
+    }
+
+
+    /**
+     * Process @EJBs annotations
+     *
+     * @param webApp
+     * @param classFinder
+     * @exception Exception
+     */
+    private static void processEJBs( WebAppType webApp, ClassFinder classFinder ) throws Exception {
+        log.debug( "processEJBs(): Entry" );
+
+        // Save the EJBs list
+        List<Class> classesWithEJBs = classFinder.findAnnotatedClasses( EJBs.class );
+
+        // Class-level EJBs
+        List<EJB> ejbList = new ArrayList<EJB>();
+        for ( Class cls : classesWithEJBs ) {
+            EJBs ejbs = (EJBs) cls.getAnnotation( EJBs.class );
+            if ( ejbs != null ) {
+                ejbList.addAll( Arrays.asList(ejbs.value()) );
+            }
+            for ( EJB ejb : ejbList ) {
+                addEJB( webApp, ejb, cls, null, null );
+            }
+            ejbList.clear();
+        }
+
+        log.debug( "processEJBs(): Exit" );
+    }
+
+
+    /**
+     * Add @EJB and @EJBs annotations to the deployment descriptor. XMLBeans are used to read and
+     * manipulate the deployment descriptor as necessary. The EJB annotation(s) will be converted to
+     * one of the following deployment descriptors:
+     *
+     * <ol>
+     *      <li><ejb-ref>
+     *      <li><ejb-local-ref>
+     * </ol>
+     *
+     * <p><strong>Note(s):</strong>
+     * <ul>
+     *      <li>The deployment descriptor is the authoritative source so this method ensures that
+     *      existing elements in it are not overwritten by annoations
+     * </ul>
+     *
+     * @param webApp
+     * @param annotation @EJB annotation
+     * @param cls        Class name with the @EJB annoation
+     * @param method     Method name with the @EJB annoation
+     * @param field      Field name with the @EJB annoation
+     */
+    private static void addEJB( WebAppType webApp, EJB annotation, Class cls, Method method, Field field ) {
+        log.debug( "addEJB( " + webApp.toString() + ","          + '\n' +
+                  annotation.name() + ","                       + '\n' +
+                  (cls!=null?cls.getName():null) + ","          + '\n' +
+                  (method!=null?method.getName():null) + ","    + '\n' +
+                  (field!=null?field.getName():null) + " ): Entry" );
+
+        // First determine if the interface is "Local" or "Remote"
+        boolean localFlag = true;
+        Class interfce = annotation.beanInterface();
+        if ( interfce.equals(Object.class) ) {
+            if ( method != null ) {
+                interfce = method.getParameterTypes()[0];
+            }
+            else if ( field != null ) {
+                interfce = field.getType();
+            }
+            else {
+                interfce = null;
+            }
+        }
+
+        // Just in case local and/or remote homes are still being implemented (even though
+        // they are optional in EJB 3.0)
+        if ( interfce != null && !interfce.equals(Object.class) ) {
+            if ( EJBHome.class.isAssignableFrom(interfce) ) {
+                localFlag = false;
+            }
+            else if ( EJBLocalHome.class.isAssignableFrom(interfce) ) {
+                localFlag = true;
+            }
+            else {
+                if ( interfce.getAnnotation(Local.class) != null ) {
+                    localFlag = true;
+                }
+                else if ( interfce.getAnnotation(Remote.class) != null ) {
+                    localFlag = false;
+                }
+            }
+        }
+
+        if ( localFlag ) {
+
+            // <ejb-local-ref>
+            String localRefName = annotation.name();
+            if ( localRefName.equals("") ) {
+                if ( method != null ) {
+                    localRefName = method.getDeclaringClass().getName() + "/" + method.getName().substring(3);  // method should start with "set"
+                }
+                else if ( field != null ) {
+                    localRefName = field.getDeclaringClass().getName() + "/" + field.getName();
+                }
+            }
+
+            boolean exists = false;
+            EjbLocalRefType[] ejbLocalRefEntries = webApp.getEjbLocalRefArray();
+            for ( EjbLocalRefType ejbLocalRefEntry : ejbLocalRefEntries ) {
+                if ( ejbLocalRefEntry.getEjbRefName().equals( localRefName ) ) {
+                    exists = true;
+                    break;
+                }
+            }
+            if ( !exists ) {
+                try {
+
+                    // Doesn't exist in deployment descriptor -- add new
+                    EjbLocalRefType ejbLocalRef = webApp.addNewEjbLocalRef();
+
+                    //------------------------------------------------------------------------------
+                    // <ejb-local-ref> required elements:
+                    //------------------------------------------------------------------------------
+
+                    // ejb-ref-name
+                    EjbRefNameType ejbRefName = EjbRefNameType.Factory.newInstance();
+                    ejbRefName.setStringValue( localRefName );
+                    ejbLocalRef.setEjbRefName( ejbRefName );
+
+                    //------------------------------------------------------------------------------
+                    // <ejb-local-ref> optional elements:
+                    //------------------------------------------------------------------------------
+
+                    // local
+                    String localAnnotation = interfce.getName();
+                    if ( localAnnotation.length() > 0 ) {
+                        LocalType local = LocalType.Factory.newInstance();
+                        local.setStringValue( localAnnotation );
+                        ejbLocalRef.setLocal( local );
+                    }
+
+                    // ejb-link
+                    String beanName = annotation.beanName();
+                    if ( beanName.length() > 0 ) {
+                        EjbLinkType ejbLink = EjbLinkType.Factory.newInstance();
+                        ejbLink.setStringValue( beanName );
+                        ejbLocalRef.setEjbLink( ejbLink );
+                    }
+
+                    // mappedName
+                    String mappdedNameAnnotation = annotation.mappedName();
+                    if ( mappdedNameAnnotation.length() > 0 ) {
+                        XsdStringType mappedName = XsdStringType.Factory.newInstance();
+                        mappedName.setStringValue( mappdedNameAnnotation );
+                        ejbLocalRef.setMappedName( mappedName );
+                    }
+
+                    // description
+                    String descriptionAnnotation = annotation.description();
+                    if ( descriptionAnnotation.length() > 0 ) {
+                        DescriptionType description = DescriptionType.Factory.newInstance();
+                        description.setStringValue( descriptionAnnotation );
+                        int arraySize = ejbLocalRef.sizeOfDescriptionArray();
+                        ejbLocalRef.insertNewDescription( arraySize );
+                        ejbLocalRef.setDescriptionArray( arraySize,description );
+                    }
+
+                    // injectionTarget
+                    InjectionTargetType injectionTarget = InjectionTargetType.Factory.newInstance();
+                    FullyQualifiedClassType qualifiedClass = FullyQualifiedClassType.Factory.newInstance();
+                    JavaIdentifierType javaType = JavaIdentifierType.Factory.newInstance();
+                    if ( method != null ) {
+                        qualifiedClass.setStringValue( method.getDeclaringClass().getName() );
+                        javaType.setStringValue( method.getName().substring(3) );   // method should start with "set"
+                        injectionTarget.setInjectionTargetClass( qualifiedClass );
+                        injectionTarget.setInjectionTargetName( javaType );
+                        int arraySize = ejbLocalRef.sizeOfInjectionTargetArray();
+                        ejbLocalRef.insertNewInjectionTarget( arraySize );
+                        ejbLocalRef.setInjectionTargetArray( arraySize,injectionTarget );
+                    }
+                    else if ( field !=null ) {
+                        qualifiedClass.setStringValue( field.getDeclaringClass().getName() );
+                        javaType.setStringValue( field.getName() );
+                        injectionTarget.setInjectionTargetClass( qualifiedClass );
+                        injectionTarget.setInjectionTargetName( javaType );
+                        int arraySize = ejbLocalRef.sizeOfInjectionTargetArray();
+                        ejbLocalRef.insertNewInjectionTarget( arraySize );
+                        ejbLocalRef.setInjectionTargetArray( arraySize,injectionTarget );
+                    }
+
+                }
+                catch ( Exception anyException ) {
+                    log.debug( "EJBAnnotationHelper: Exception caught while processing <ejb-local-ref>" );
+                    anyException.printStackTrace();
+                }
+            }
+        }                                                                           // end if local
+        else {                                                                      // else remote
+
+            // <ejb-ref>
+            String remoteRefName = annotation.name();
+            if ( remoteRefName.equals("") ) {
+                if ( method != null ) {
+                    remoteRefName = method.getDeclaringClass().getName() + "/" + method.getName().substring(3); // method should start with "set"
+                }
+                else if ( field != null ) {
+                    remoteRefName = field.getDeclaringClass().getName() + "/" + field.getName();
+                }
+            }
+
+            boolean exists = false;
+            EjbRefType[] ejbRefEntries = webApp.getEjbRefArray();
+            for ( EjbRefType ejbRefEntry : ejbRefEntries ) {
+                if ( ejbRefEntry.getEjbRefName().equals( remoteRefName ) ) {
+                    exists = true;
+                    break;
+                }
+            }
+            if ( !exists ) {
+                try {
+
+                    // Doesn't exist in deployment descriptor -- add new
+                    EjbRefType ejbRef = webApp.addNewEjbRef();
+
+                    //------------------------------------------------------------------------------
+                    // <ejb-ref> required elements:
+                    //------------------------------------------------------------------------------
+
+                    // ejb-ref-name
+                    EjbRefNameType ejbRefName = EjbRefNameType.Factory.newInstance();
+                    ejbRefName.setStringValue( remoteRefName );
+                    ejbRef.setEjbRefName( ejbRefName );
+
+                    //------------------------------------------------------------------------------
+                    // <ejb-ref> optional elements:
+                    //------------------------------------------------------------------------------
+
+                    // remote
+                    String remoteAnnotation = interfce.getName();
+                    if ( remoteAnnotation.length() > 0 ) {
+                        RemoteType remote = RemoteType.Factory.newInstance();
+                        remote.setStringValue( remoteAnnotation );
+                        ejbRef.setRemote( remote );
+                    }
+
+                    // ejb-link
+                    String beanName = annotation.beanName();
+                    if ( beanName.length() > 0 ) {
+                        EjbLinkType ejbLink = EjbLinkType.Factory.newInstance();
+                        ejbLink.setStringValue( beanName );
+                        ejbRef.setEjbLink( ejbLink );
+                    }
+
+                    // mappedName
+                    String mappdedNameAnnotation = annotation.mappedName();
+                    if ( mappdedNameAnnotation.length() > 0 ) {
+                        XsdStringType mappedName = XsdStringType.Factory.newInstance();
+                        mappedName.setStringValue( mappdedNameAnnotation );
+                        ejbRef.setMappedName( mappedName );
+                    }
+
+                    // description
+                    String descriptionAnnotation = annotation.description();
+                    if ( descriptionAnnotation.length() > 0 ) {
+                        DescriptionType description = DescriptionType.Factory.newInstance();
+                        description.setStringValue( descriptionAnnotation );
+                        int arraySize = ejbRef.sizeOfDescriptionArray();
+                        ejbRef.insertNewDescription( arraySize );
+                        ejbRef.setDescriptionArray( arraySize,description );
+                    }
+
+                    // injectionTarget
+                    InjectionTargetType injectionTarget = InjectionTargetType.Factory.newInstance();
+                    FullyQualifiedClassType qualifiedClass = FullyQualifiedClassType.Factory.newInstance();
+                    JavaIdentifierType javaType = JavaIdentifierType.Factory.newInstance();
+                    if ( method != null ) {
+                        qualifiedClass.setStringValue( method.getDeclaringClass().getName() );
+                        javaType.setStringValue( method.getName().substring(3) );   // method should start with "set"
+                        injectionTarget.setInjectionTargetClass( qualifiedClass );
+                        injectionTarget.setInjectionTargetName( javaType );
+                        int arraySize = ejbRef.sizeOfInjectionTargetArray();
+                        ejbRef.insertNewInjectionTarget( arraySize );
+                        ejbRef.setInjectionTargetArray( arraySize, injectionTarget );
+                    }
+                    else if ( field !=null ) {
+                        qualifiedClass.setStringValue( field.getDeclaringClass().getName() );
+                        javaType.setStringValue( field.getName() );
+                        injectionTarget.setInjectionTargetClass( qualifiedClass );
+                        injectionTarget.setInjectionTargetName( javaType );
+                        int arraySize = ejbRef.sizeOfInjectionTargetArray();
+                        ejbRef.insertNewInjectionTarget( arraySize );
+                        ejbRef.setInjectionTargetArray( arraySize, injectionTarget );
+                    }
+
+                }
+                catch ( Exception anyException ) {
+                    log.debug( "EJBAnnotationHelper: Exception caught while <processing ejb-ref>" );
+                    anyException.printStackTrace();
+                }
+            }
+        }
+        log.debug( "addEJB(): Exit" );
+    }
+
+
+    /**
+     * Validate deployment descriptor
+     *
+     * @param webApp
+     * @exception Exception  thrown if deployment descriptor cannot be parsed
+     */
+    private static void validateDD( WebAppType webApp ) throws Exception {
+        log.debug( "validateDD( " + webApp.toString() + " ): Entry" );
+
+        XmlBeansUtil.parse( webApp.toString() );
+
+        log.debug( "validateDD(): Exit" );
+    }
+}

Propchange: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/EJBAnnotationHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/EJBAnnotationHelper.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/EJBAnnotationHelper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/ResourceAnnotationHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/ResourceAnnotationHelper.java?view=auto&rev=509958
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/ResourceAnnotationHelper.java (added)
+++ geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/ResourceAnnotationHelper.java Wed Feb 21 02:13:55 2007
@@ -0,0 +1,742 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.j2ee.deployment.annotation;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.List;
+import javax.annotation.Generated;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.annotation.Resource;
+import javax.annotation.Resources;
+import javax.annotation.security.DeclareRoles;
+import javax.annotation.security.DenyAll;
+import javax.annotation.security.PermitAll;
+import javax.annotation.security.RolesAllowed;
+import javax.annotation.security.RunAs;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.j2ee.deployment.Module;
+import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
+import org.apache.geronimo.xbeans.javaee.DescriptionType;
+import org.apache.geronimo.xbeans.javaee.EnvEntryType;
+import org.apache.geronimo.xbeans.javaee.EnvEntryTypeValuesType;
+import org.apache.geronimo.xbeans.javaee.FullyQualifiedClassType;
+import org.apache.geronimo.xbeans.javaee.InjectionTargetType;
+import org.apache.geronimo.xbeans.javaee.JavaIdentifierType;
+import org.apache.geronimo.xbeans.javaee.JndiNameType;
+import org.apache.geronimo.xbeans.javaee.ListenerType;
+import org.apache.geronimo.xbeans.javaee.MessageDestinationRefType;
+import org.apache.geronimo.xbeans.javaee.MessageDestinationTypeType;
+import org.apache.geronimo.xbeans.javaee.ServiceRefType;
+import org.apache.geronimo.xbeans.javaee.ServletType;
+import org.apache.geronimo.xbeans.javaee.ResourceEnvRefType;
+import org.apache.geronimo.xbeans.javaee.ResourceRefType;
+import org.apache.geronimo.xbeans.javaee.ResAuthType;
+import org.apache.geronimo.xbeans.javaee.ResSharingScopeType;
+import org.apache.geronimo.xbeans.javaee.WebAppType;
+import org.apache.geronimo.xbeans.javaee.XsdAnyURIType;
+import org.apache.geronimo.xbeans.javaee.XsdStringType;
+import org.apache.xbean.finder.ClassFinder;
+
+
+/**
+ * Static helper class used to encapsulate all the functions related to the translation of
+ *
+ * @EJB and @EBJs annotations to deployment descriptor tags. The ResourceAnnotationHelper class can be
+ * used as part of the deployment of a module into the Geronimo server. It performs the following
+ * major functions:
+ *
+ * <ol>
+ *      <li>Translates annotations into corresponding deployment descriptor elements (so that the
+ *      actual deployment descriptor in the module can be updated or even created if necessary)
+ * </ol>
+ *
+ * <p><strong>Note(s):</strong>
+ * <ul>
+ *      <li>The user is responsible for invoking change to metadata-complete
+ *      <li>This helper class will validate any changes it makes to the deployment descriptor. An
+ *      exception will be thrown if it fails to parse
+ * </ul>
+ *
+ * <p><strong>Remaining ToDo(s):</strong>
+ * <ul>
+ *      <li>How to determine Session/Entity remote/local for @EJB
+ * </ul>
+ *
+ * @version $Rev$ $Date$
+ * @since 02-2007
+ */
+public final class ResourceAnnotationHelper {
+
+    // Private instance variables
+    private static final Log log = LogFactory.getLog( ResourceAnnotationHelper.class );
+
+    // Private constructor to prevent instantiation
+    private ResourceAnnotationHelper() {
+    }
+
+
+    /**
+     * Determine if there are any Resource annotations present
+     *
+     * @return true or false
+     */
+    public static boolean annotationsPresent( ClassFinder classFinder ) {
+        if ( classFinder.isAnnotationPresent(Resource.class) ) return true;
+        if ( classFinder.isAnnotationPresent(Resources.class) ) return true;
+        return false;
+    }
+
+    /**
+     * Process the Resource set of annotations
+     *
+     * @return Updated deployment descriptor
+     * @exception Exception if parsing or validation error
+     */
+    public static WebAppType processAnnotations( WebAppType webApp, ClassFinder classFinder ) throws Exception {
+        processResources( webApp,classFinder );
+        processResource( webApp,classFinder );
+        return webApp;
+    }
+
+
+    /**
+     *  Process @Resource annotations
+     *
+     * @return
+     * @exception Exception
+     */
+    private static void processResource( WebAppType webApp, ClassFinder classFinder ) throws Exception {
+        log.debug( "processResource(): Entry: webApp: " + webApp.toString() );
+
+        //-----------------------------
+        // Save the Resource lists
+        //-----------------------------
+        List<Class>  classeswithResource = classFinder.findAnnotatedClasses( Resource.class );
+        List<Method> methodswithResource = classFinder.findAnnotatedMethods( Resource.class );
+        List<Field>  fieldswithResource  = classFinder.findAnnotatedFields ( Resource.class );
+
+        //--------------------------
+        // Class-level Resource
+        //--------------------------
+        for ( Class cls : classeswithResource ) {
+            Resource resource = (Resource)cls.getAnnotation( Resource.class );
+            if ( resource != null ) {
+                addResource( webApp, resource, cls, null, null );
+            }
+        }
+
+        //---------------------------
+        // Method-level Resource
+        //---------------------------
+        for ( Method method : methodswithResource ) {
+            Resource resource = (Resource)method.getAnnotation( Resource.class );
+            if ( resource != null ) {
+                addResource( webApp, resource, null, method, null );
+            }
+        }
+
+        //--------------------------
+        // Field-level Resource
+        //--------------------------
+        for ( Field field : fieldswithResource ) {
+            Resource resource = (Resource)field.getAnnotation( Resource.class );
+            if ( resource != null ) {
+                addResource( webApp, resource, null, null, field );
+            }
+        }
+
+        //--------------------------------------------------------------
+        // Validate deployment descriptor to ensure it's still okay
+        //--------------------------------------------------------------
+        validateDD( webApp );
+
+        log.debug( "processResource(): Exit: webApp: " + webApp.toString() );
+    }
+
+
+
+    /**
+     *  Process @Resources annotations
+     */
+    private static void processResources( WebAppType webApp, ClassFinder classFinder ) throws Exception {
+        log.debug( "processResources(): Entry" );
+
+        //-----------------------------
+        // Save the Resources list
+        //-----------------------------
+        List<Class> classeswithResources = classFinder.findAnnotatedClasses( Resources.class );
+
+        //---------------------------
+        // Class-level Resources
+        //---------------------------
+        List<Resource> ResourceList = new ArrayList<Resource>();
+        for ( Class cls : classeswithResources ) {
+            Resources resources = (Resources) cls.getAnnotation( Resources.class );
+            if ( resources != null ) {
+                ResourceList.addAll( Arrays.asList(resources.value()) );
+            }
+            for ( Resource resource : ResourceList ) {
+                addResource( webApp, resource, cls, null, null );
+            }
+            ResourceList.clear();
+        }
+
+        log.debug( "processResources(): Exit" );
+    }
+
+
+
+    /**
+     * Add @Resource and @Resources annotations to the deployment descriptor. XMLBeans are used to read and
+     * manipulate the deployment descriptor as necessary. The Resource annotation(s) will be converted to
+     * one of the following deployment descriptors:
+     *
+     * <ol>
+     *      <li><env-entry> -- Used to declare an application's environment entry
+     *      <li><service-ref> -- Declares a reference to a Web service
+     *      <li><resource-ref> -- Contains a declaration of a Deployment Component's reference to an
+     *      external resource
+     *      <li><message-destination-ref> -- Contains a declaration of Deployment Component's
+     *      reference to a message destination associated with a resource in Deployment Component's
+     *      environment
+     *      <li><resource-env-ref> -- Contains a declaration of a Deployment Component's reference to
+     *      an administered object associated with a resource in the Deployment Component's
+     *      environment
+     * </ol>
+     *
+     * <p><strong>Note(s):</strong>
+     * <ul>
+     *      <li>The deployment descriptor is the authoritative source so this method ensures that
+     *      existing elements in it are not overwritten by annoations
+     * </ul>
+     *
+     * @param annotation @Resource annotation
+     * @param cls        Class name with the @Resource annoation
+     * @param method     Method name with the @Resource annoation
+     * @param field      Field name with the @Resource annoation
+     */
+    private static void addResource( WebAppType webApp, Resource annotation, Class cls, Method method, Field field ) {
+        log.debug( "addResource( " + webApp.toString() + ","     + '\n' +
+                  annotation.name() + ","                       + '\n' +
+                  (cls!=null?cls.getName():null) + ","          + '\n' +
+                  (method!=null?method.getName():null) + ","    + '\n' +
+                  (field!=null?field.getName():null) + " ): Entry" );
+
+        //------------------------------------------------------------------------------------------
+        // Resource name:
+        // -- When annotation is applied on a class:    name must be provided (cannot be inferred)
+        // -- When annotation is applied on a method:   name is JavaBeans property name qualified by
+        //                                              the class (or as provided on the annotation)
+        // -- When annotation is applied on a field:    name is the field name qualified by the class
+        //                                              (or as provided on the annotation)
+        //------------------------------------------------------------------------------------------
+        String resourceName = annotation.name();
+        if ( resourceName.equals("") ) {
+            if ( method != null ) {
+                StringBuilder stringBuilder = new StringBuilder( method.getName().substring(3) );
+                stringBuilder.setCharAt( 0,Character.toLowerCase(stringBuilder.charAt(0)) );
+                resourceName = method.getDeclaringClass().getName() + "/" + stringBuilder.toString();
+            }
+            else if ( field != null ) {
+                resourceName = field.getDeclaringClass().getName() + "/" + field.getName();
+            }
+        }
+
+        //------------------------------------------------------------------------------------------
+        // Resource type:
+        // -- When annotation is applied on a class:    type must be provided (cannot be inferred)
+        // -- When annotation is applied on a method:   type is the JavaBeans property type (or as
+        //                                              provided on the annotation)
+        // -- When annotation is applied on a field:    type is the field type (or as provided on the
+        //                                              annotation)
+        //------------------------------------------------------------------------------------------
+        String resourceType = annotation.name();
+        if ( resourceType.equals("") ) {
+            if ( method != null ) {
+                resourceType = method.getParameterTypes()[0].getCanonicalName();
+            }
+            else if ( field != null ) {
+                resourceType = field.getType().toString();
+            }
+        }
+
+        //------------------------------------------------------------------------------------------
+        // Method name (for setter-based injection) must follow JavaBeans conventions:
+        // -- Must start with "set"
+        // -- Have one parameter
+        // -- Return void
+        //------------------------------------------------------------------------------------------
+        String injectionJavaType = "";
+        String injectionClass  = null;
+        if ( method != null ) {
+            injectionJavaType = method.getName().substring(3);
+            StringBuilder stringBuilder = new StringBuilder( injectionJavaType );
+            stringBuilder.setCharAt( 0,Character.toLowerCase(stringBuilder.charAt(0)) );
+            injectionJavaType = stringBuilder.toString();
+            injectionClass = method.getDeclaringClass().getName();
+        }
+        else if ( field != null ) {
+            injectionJavaType = field.getName();
+            injectionClass = field.getDeclaringClass().getName();
+        }
+
+        //------------------------------------------------------------------------------------------
+        // 1. <env-entry>
+        //------------------------------------------------------------------------------------------
+        if ( annotation.type().getCanonicalName().equals( "java.lang.String" )      ||
+             annotation.type().getCanonicalName().equals( "java.lang.Character" )   ||
+             annotation.type().getCanonicalName().equals( "java.lang.Integer" )     ||
+             annotation.type().getCanonicalName().equals( "java.lang.Boolean" )     ||
+             annotation.type().getCanonicalName().equals( "java.lang.Double" )      ||
+             annotation.type().getCanonicalName().equals( "java.lang.Byte" )        ||
+             annotation.type().getCanonicalName().equals( "java.lang.Short" )       ||
+             annotation.type().getCanonicalName().equals( "java.lang.Long" )        ||
+             annotation.type().getCanonicalName().equals( "java.lang.Float" ) ) {
+
+            boolean exists = false;
+            EnvEntryType[] envEntries = webApp.getEnvEntryArray();
+            for ( EnvEntryType envEntry : envEntries ) {
+                if ( envEntry.getEnvEntryName().equals(resourceName) ) {
+                    exists = true;
+                    break;
+                }
+            }
+            if ( !exists ) {
+                try {
+
+                    // Doesn't exist in deployment descriptor -- add new
+                    EnvEntryType envEntry = webApp.addNewEnvEntry();
+
+                    //------------------------------------------------------------------------------
+                    // <env-entry> required elements:
+                    //------------------------------------------------------------------------------
+
+                    // env-entry-name
+                    JndiNameType envEntryName = JndiNameType.Factory.newInstance();
+                    envEntryName.setStringValue( resourceName );
+                    envEntry.setEnvEntryName( envEntryName );
+
+                    if ( !resourceType.equals("") ) {
+                        // env-entry-type
+                        EnvEntryTypeValuesType envEntryType = EnvEntryTypeValuesType.Factory.newInstance();
+                        envEntryType.setStringValue( resourceType );
+                        envEntry.setEnvEntryType( envEntryType );
+                    }
+                    else if ( !injectionJavaType.equals("") ) {
+                        // injectionTarget
+                        InjectionTargetType injectionTarget = InjectionTargetType.Factory.newInstance();
+                        FullyQualifiedClassType qualifiedClass = FullyQualifiedClassType.Factory.newInstance();
+                        JavaIdentifierType javaType = JavaIdentifierType.Factory.newInstance();
+                        qualifiedClass.setStringValue( injectionClass );
+                        javaType.setStringValue( injectionJavaType );
+                        injectionTarget.setInjectionTargetClass( qualifiedClass );
+                        injectionTarget.setInjectionTargetName( javaType );
+                        int arraySize = envEntry.sizeOfInjectionTargetArray();
+                        envEntry.insertNewInjectionTarget( arraySize );
+                        envEntry.setInjectionTargetArray( arraySize, injectionTarget );
+                    }
+
+                    // env-entry-value
+                    XsdStringType value = XsdStringType.Factory.newInstance();
+                    value.setStringValue( annotation.mappedName() );
+                    envEntry.setEnvEntryValue( value);
+
+                    //------------------------------------------------------------------------------
+                    // <env-entry> optional elements:
+                    //------------------------------------------------------------------------------
+
+                    // description
+                    String descriptionAnnotation = annotation.description();
+                    if ( descriptionAnnotation.length() > 0 ) {
+                        DescriptionType description = DescriptionType.Factory.newInstance();
+                        description.setStringValue( descriptionAnnotation );
+                        int arraySize = envEntry.sizeOfDescriptionArray();
+                        envEntry.insertNewDescription( arraySize );
+                        envEntry.setDescriptionArray( arraySize,description );
+                    }
+
+                }
+                catch ( Exception anyException ) {
+                    log.debug( "ResourceAnnotationHelper: Exception caught while processing <env-entry>" );
+                    anyException.printStackTrace();
+                }
+            }
+        }
+
+        //------------------------------------------------------------------------------------------
+        // 2. <service-ref>
+        //------------------------------------------------------------------------------------------
+        else if ( annotation.type().getCanonicalName().equals("javax.xml.rpc.Service") ) {
+
+            boolean exists = false;
+            ServiceRefType[] serviceRefs = webApp.getServiceRefArray();
+            for ( ServiceRefType serviceRef : serviceRefs ) {
+                if ( serviceRef.getServiceRefName().equals(resourceName) ) {
+                    exists = true;
+                    break;
+                }
+            }
+            if ( !exists ) {
+                try {
+
+                    // Doesn't exist in deployment descriptor -- add new
+                    ServiceRefType serviceRef = webApp.addNewServiceRef();
+
+                    //------------------------------------------------------------------------------
+                    // <service-ref> required elements:
+                    //------------------------------------------------------------------------------
+
+                    // service-ref-name
+                    JndiNameType serviceRefName = JndiNameType.Factory.newInstance();
+                    serviceRefName.setStringValue( resourceName );
+                    serviceRef.setServiceRefName( serviceRefName );
+
+                    if ( !resourceType.equals("") ) {
+                        // service-ref-type
+                        FullyQualifiedClassType qualifiedClass = FullyQualifiedClassType.Factory.newInstance();
+                        qualifiedClass.setStringValue( resourceType );
+                        serviceRef.setServiceInterface( qualifiedClass );
+                    }
+                    else if ( !injectionJavaType.equals("") ) {
+                        // injectionTarget
+                        InjectionTargetType injectionTarget = InjectionTargetType.Factory.newInstance();
+                        FullyQualifiedClassType qualifiedClass = FullyQualifiedClassType.Factory.newInstance();
+                        JavaIdentifierType javaType = JavaIdentifierType.Factory.newInstance();
+                        qualifiedClass.setStringValue( injectionClass );
+                        javaType.setStringValue( injectionJavaType );
+                        injectionTarget.setInjectionTargetClass( qualifiedClass );
+                        injectionTarget.setInjectionTargetName( javaType );
+                        int arraySize = serviceRef.sizeOfInjectionTargetArray();
+                        serviceRef.insertNewInjectionTarget( arraySize );
+                        serviceRef.setInjectionTargetArray( arraySize, injectionTarget );
+                    }
+
+                    //------------------------------------------------------------------------------
+                    // <service-ref> optional elements:
+                    //------------------------------------------------------------------------------
+
+                    // description
+                    String descriptionAnnotation = annotation.description();
+                    if ( descriptionAnnotation.length() > 0 ) {
+                        DescriptionType description = DescriptionType.Factory.newInstance();
+                        description.setStringValue( descriptionAnnotation );
+                        int arraySize = serviceRef.sizeOfDescriptionArray();
+                        serviceRef.insertNewDescription( arraySize );
+                        serviceRef.setDescriptionArray( arraySize,description );
+                    }
+
+                    // WSDL document location
+                    String documentAnnotation = annotation.mappedName();
+                    if ( documentAnnotation.length() > 0 ) {
+                        XsdAnyURIType wsdlFile = XsdAnyURIType.Factory.newInstance();
+                        wsdlFile.setStringValue( annotation.mappedName() );
+                        serviceRef.setWsdlFile( wsdlFile );
+                    }
+
+                }
+                catch ( Exception anyException ) {
+                    log.debug( "ResourceAnnotationHelper: Exception caught while processing <service-ref>" );
+                    anyException.printStackTrace();
+                }
+            }
+        }
+
+        //------------------------------------------------------------------------------------------
+        // 3. <resource-ref>
+        //------------------------------------------------------------------------------------------
+        else if ( annotation.type().getCanonicalName().equals("javax.sql.DataSource")                   ||
+                  annotation.type().getCanonicalName().equals("javax.jms.ConnectionFactory")            ||
+                  annotation.type().getCanonicalName().equals("javax.jms.QueueConnectionFactory")       ||
+                  annotation.type().getCanonicalName().equals("javax.jms.TopicConnectionFactory")       ||
+                  annotation.type().getCanonicalName().equals("javax.mail.Session")                     ||
+                  annotation.type().getCanonicalName().equals("java.net.URL")                           ||
+                  annotation.type().getCanonicalName().equals("javax.resource.cci.ConnectionFactory")   ||
+                  annotation.type().getCanonicalName().equals("org.omg.CORBA_2_3.ORB")                  ||
+                  annotation.type().getCanonicalName().endsWith("ConnectionFactory") ) {
+
+            boolean exists = false;
+            ResourceRefType[] resourceRefs = webApp.getResourceRefArray();
+            for ( ResourceRefType resourceRef : resourceRefs ) {
+                if ( resourceRef.getResRefName().equals(resourceName) ) {
+                    exists = true;
+                    break;
+                }
+            }
+            if ( !exists ) {
+                try {
+
+                    // Doesn't exist in deployment descriptor -- add new
+                    ResourceRefType resourceRef = webApp.addNewResourceRef();
+
+                    //------------------------------------------------------------------------------
+                    // <resource-ref> required elements:
+                    //------------------------------------------------------------------------------
+
+                    // resource-ref-name
+                    JndiNameType resourceRefName = JndiNameType.Factory.newInstance();
+                    resourceRefName.setStringValue( resourceName );
+                    resourceRef.setResRefName( resourceRefName );
+
+                    if ( !resourceType.equals("") ) {
+                        // resource-ref-type
+                        FullyQualifiedClassType qualifiedClass = FullyQualifiedClassType.Factory.newInstance();
+                        qualifiedClass.setStringValue( resourceType );
+                        resourceRef.setResType( qualifiedClass );
+                    }
+                    else if ( !injectionJavaType.equals("") ) {
+                        // injectionTarget
+                        InjectionTargetType injectionTarget = InjectionTargetType.Factory.newInstance();
+                        FullyQualifiedClassType qualifiedClass = FullyQualifiedClassType.Factory.newInstance();
+                        JavaIdentifierType javaType = JavaIdentifierType.Factory.newInstance();
+                        qualifiedClass.setStringValue( injectionClass );
+                        javaType.setStringValue( injectionJavaType );
+                        injectionTarget.setInjectionTargetClass( qualifiedClass );
+                        injectionTarget.setInjectionTargetName( javaType );
+                        int arraySize = resourceRef.sizeOfInjectionTargetArray();
+                        resourceRef.insertNewInjectionTarget( arraySize );
+                        resourceRef.setInjectionTargetArray( arraySize, injectionTarget );
+                    }
+
+                    //------------------------------------------------------------------------------
+                    // <resource-ref> optional elements:
+                    //------------------------------------------------------------------------------
+
+                    // description
+                    String descriptionAnnotation = annotation.description();
+                    if ( descriptionAnnotation.length() > 0 ) {
+                        DescriptionType description = DescriptionType.Factory.newInstance();
+                        description.setStringValue( descriptionAnnotation );
+                        int arraySize = resourceRef.sizeOfDescriptionArray();
+                        resourceRef.insertNewDescription( arraySize );
+                        resourceRef.setDescriptionArray( arraySize,description );
+                    }
+
+                    // authentication
+                    ResAuthType resAuth = ResAuthType.Factory.newInstance();
+                    if ( annotation.authenticationType() == Resource.AuthenticationType.CONTAINER ) {
+                        resAuth.setStringValue( "Container" );
+                    }
+                    else if ( annotation.authenticationType() == Resource.AuthenticationType.APPLICATION ) {
+                        resAuth.setStringValue( "Application" );
+                    }
+                    resourceRef.setResAuth( resAuth );
+
+                    // sharing scope
+                    ResSharingScopeType resScope = ResSharingScopeType.Factory.newInstance();
+                    resScope.setStringValue( annotation.shareable() ? "Shareable" : "Unshareable" );
+                    resourceRef.setResSharingScope( resScope );
+
+                    // mappedName
+                    String mappdedNameAnnotation = annotation.mappedName();
+                    if ( mappdedNameAnnotation.length() > 0 ) {
+                        XsdStringType mappedName = XsdStringType.Factory.newInstance();
+                        mappedName.setStringValue( mappdedNameAnnotation );
+                        resourceRef.setMappedName( mappedName );
+                    }
+
+                }
+                catch ( Exception anyException ) {
+                    log.debug( "ResourceAnnotationHelper: Exception caught while processing <resource-ref>" );
+                    anyException.printStackTrace();
+                }
+            }
+        }
+
+        //------------------------------------------------------------------------------------------
+        // 4. <message-destination-ref>
+        //------------------------------------------------------------------------------------------
+        else if ( annotation.type().getCanonicalName().equals("javax.jms.Queue")    ||
+                  annotation.type().getCanonicalName().equals("javax.jms.Topic") ) {
+
+            boolean exists = false;
+            MessageDestinationRefType[] messageDestinationRefs = webApp.getMessageDestinationRefArray();
+            for ( MessageDestinationRefType messageDestinationRef : messageDestinationRefs ) {
+                if ( messageDestinationRef.getMessageDestinationRefName().equals(resourceName) ) {
+                    exists = true;
+                    break;
+                }
+            }
+            if ( !exists ) {
+                try {
+
+                    // Doesn't exist in deployment descriptor -- add new
+                    MessageDestinationRefType messageDestinationRef = webApp.addNewMessageDestinationRef();
+
+                    //------------------------------------------------------------------------------
+                    // <message-destination-ref> required elements:
+                    //------------------------------------------------------------------------------
+
+                    // message-destination-ref-name
+                    JndiNameType messageDestinationRefName = JndiNameType.Factory.newInstance();
+                    messageDestinationRefName.setStringValue( resourceName );
+                    messageDestinationRef.setMessageDestinationRefName( messageDestinationRefName );
+
+                    if ( !resourceType.equals("") ) {
+                        // message-destination-ref-type
+                        MessageDestinationTypeType msgDestType = MessageDestinationTypeType.Factory.newInstance();
+                        msgDestType.setStringValue( resourceType );
+                        messageDestinationRef.setMessageDestinationType( msgDestType );
+                    }
+                    else if ( !injectionJavaType.equals("") ) {
+                        // injectionTarget
+                        InjectionTargetType injectionTarget = InjectionTargetType.Factory.newInstance();
+                        FullyQualifiedClassType qualifiedClass = FullyQualifiedClassType.Factory.newInstance();
+                        JavaIdentifierType javaType = JavaIdentifierType.Factory.newInstance();
+                        qualifiedClass.setStringValue( injectionClass );
+                        javaType.setStringValue( injectionJavaType );
+                        injectionTarget.setInjectionTargetClass( qualifiedClass );
+                        injectionTarget.setInjectionTargetName( javaType );
+                        int arraySize = messageDestinationRef.sizeOfInjectionTargetArray();
+                        messageDestinationRef.insertNewInjectionTarget( arraySize );
+                        messageDestinationRef.setInjectionTargetArray( arraySize, injectionTarget );
+                    }
+
+                    //------------------------------------------------------------------------------
+                    // <message-destination-ref> optional elements:
+                    //------------------------------------------------------------------------------
+
+                    // description
+                    String descriptionAnnotation = annotation.description();
+                    if ( descriptionAnnotation.length() > 0 ) {
+                        DescriptionType description = DescriptionType.Factory.newInstance();
+                        description.setStringValue( descriptionAnnotation );
+                        int arraySize = messageDestinationRef.sizeOfDescriptionArray();
+                        messageDestinationRef.insertNewDescription( arraySize );
+                        messageDestinationRef.setDescriptionArray( arraySize,description );
+                    }
+
+                    // mappedName
+                    String mappdedNameAnnotation = annotation.mappedName();
+                    if ( mappdedNameAnnotation.length() > 0 ) {
+                        XsdStringType mappedName = XsdStringType.Factory.newInstance();
+                        mappedName.setStringValue( mappdedNameAnnotation );
+                        messageDestinationRef.setMappedName( mappedName );
+                    }
+
+                }
+                catch ( Exception anyException ) {
+                    log.debug( "ResourceAnnotationHelper: Exception caught while processing <message-destination-ref>" );
+                    anyException.printStackTrace();
+                }
+            }
+        }
+
+        //------------------------------------------------------------------------------------------
+        // 5. Everything else must be a <resource-env-ref>
+        //------------------------------------------------------------------------------------------
+        else if ( annotation.type().getCanonicalName().equals("javax.resource.cci.InteractionSpec") ||
+                  annotation.type().getCanonicalName().equals("javax.transaction.UserTransaction")  || true ) {
+
+            boolean exists = false;
+            ResourceEnvRefType[] resourceEnvRefs = webApp.getResourceEnvRefArray();
+            for ( ResourceEnvRefType resourceEnvRef : resourceEnvRefs ) {
+                if ( resourceEnvRef.getResourceEnvRefName().equals(resourceName) ) {
+                    exists = true;
+                    break;
+                }
+            }
+            if ( !exists ) {
+                try {
+
+                    // Doesn't exist in deployment descriptor -- add new
+                    ResourceEnvRefType resourceEnvRef = webApp.addNewResourceEnvRef();
+
+                    //------------------------------------------------------------------------------
+                    // <resource-env-ref> required elements:
+                    //------------------------------------------------------------------------------
+
+                    // resource-env-ref-name
+                    JndiNameType resourceEnvRefName = JndiNameType.Factory.newInstance();
+                    resourceEnvRefName.setStringValue( resourceName );
+                    resourceEnvRef.setResourceEnvRefName( resourceEnvRefName );
+
+                    if ( !resourceType.equals("") ) {
+                        // resource-env-ref-type
+                        FullyQualifiedClassType classType = FullyQualifiedClassType.Factory.newInstance();
+                        classType.setStringValue( resourceType );
+                        resourceEnvRef.setResourceEnvRefType( classType );
+                    }
+                    else if ( !injectionJavaType.equals("") ) {
+                        // injectionTarget
+                        InjectionTargetType injectionTarget = InjectionTargetType.Factory.newInstance();
+                        FullyQualifiedClassType qualifiedClass = FullyQualifiedClassType.Factory.newInstance();
+                        JavaIdentifierType javaType = JavaIdentifierType.Factory.newInstance();
+                        qualifiedClass.setStringValue( injectionClass );
+                        javaType.setStringValue( injectionJavaType );
+                        injectionTarget.setInjectionTargetClass( qualifiedClass );
+                        injectionTarget.setInjectionTargetName( javaType );
+                        int arraySize = resourceEnvRef.sizeOfInjectionTargetArray();
+                        resourceEnvRef.insertNewInjectionTarget( arraySize );
+                        resourceEnvRef.setInjectionTargetArray( arraySize, injectionTarget );
+                    }
+
+                    //------------------------------------------------------------------------------
+                    // <resource-env-ref> optional elements:
+                    //------------------------------------------------------------------------------
+
+                    // description
+                    String descriptionAnnotation = annotation.description();
+                    if ( descriptionAnnotation.length() > 0 ) {
+                        DescriptionType description = DescriptionType.Factory.newInstance();
+                        description.setStringValue( descriptionAnnotation );
+                        int arraySize = resourceEnvRef.sizeOfDescriptionArray();
+                        resourceEnvRef.insertNewDescription( arraySize );
+                        resourceEnvRef.setDescriptionArray( arraySize,description );
+                    }
+
+                    // mappedName
+                    String mappdedNameAnnotation = annotation.mappedName();
+                    if ( mappdedNameAnnotation.length() > 0 ) {
+                        XsdStringType mappedName = XsdStringType.Factory.newInstance();
+                        mappedName.setStringValue( mappdedNameAnnotation );
+                        resourceEnvRef.setMappedName( mappedName );
+                    }
+
+                }
+                catch ( Exception anyException ) {
+                    log.debug( "ResourceAnnotationHelper: Exception caught while processing <resource-env-ref>" );
+                    anyException.printStackTrace();
+                }
+            }
+        }
+        log.debug( "addResource(): Exit" );
+    }
+
+
+    /**
+     * Validate deployment descriptor
+     *
+     * @param webApp
+     * @exception Exception  thrown if deployment descriptor cannot be parsed
+     */
+    private static void validateDD( WebAppType webApp ) throws Exception {
+        log.debug( "validateDD( " + webApp.toString() + " ): Entry" );
+
+        XmlBeansUtil.parse( webApp.toString() );
+
+        log.debug( "validateDD(): Exit" );
+    }
+}

Propchange: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/ResourceAnnotationHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/ResourceAnnotationHelper.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/ResourceAnnotationHelper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/modules/geronimo-jetty6-builder/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6-builder/pom.xml?view=diff&rev=509958&r1=509957&r2=509958
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6-builder/pom.xml (original)
+++ geronimo/server/trunk/modules/geronimo-jetty6-builder/pom.xml Wed Feb 21 02:13:55 2007
@@ -44,6 +44,13 @@
             <artifactId>geronimo-jetty6</artifactId>
             <version>${version}</version>
         </dependency>
+        
+        <dependency>
+            <!-- TODO remove this WTF??? why isn't this picked up from geronimo-web-2.5-builder? -->
+            <groupId>asm</groupId>
+            <artifactId>asm</artifactId>
+        </dependency>
+
     </dependencies>
     
     <build>

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=509958&r1=509957&r2=509958
==============================================================================
--- 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 Wed Feb 21 02:13:55 2007
@@ -301,15 +301,7 @@
 
     public void initContext(EARContext earContext, Module module, ClassLoader cl) throws DeploymentException {
         WebAppType webApp = (WebAppType) module.getSpecDD();
-//        MessageDestinationType[] messageDestinations = webApp.getMessageDestinationArray();
         JettyWebAppType gerWebApp = (JettyWebAppType) module.getVendorDD();
-//        GerMessageDestinationType[] gerMessageDestinations = gerWebApp.getMessageDestinationArray();
-
-//        ENCConfigBuilder.registerMessageDestinations(earContext, module.getName(), messageDestinations, gerMessageDestinations);
-        if ((webApp.getSecurityConstraintArray().length > 0 || webApp.getSecurityRoleArray().length > 0) &&
-                !gerWebApp.isSetSecurityRealmName()) {
-            throw new DeploymentException("web.xml for web app " + module.getName() + " includes security elements but Geronimo deployment plan is not provided or does not contain <security-realm-name> element necessary to configure security accordingly.");
-        }
         boolean hasSecurityRealmName = gerWebApp.isSetSecurityRealmName();
         buildSubstitutionGroups(gerWebApp, hasSecurityRealmName, module, earContext);
     }

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=509958&r1=509957&r2=509958
==============================================================================
--- 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 Wed Feb 21 02:13:55 2007
@@ -102,7 +102,7 @@
 
     public void buildNaming(XmlObject specDD, XmlObject plan, Configuration localConfiguration, Configuration remoteConfiguration, Module module, Map componentContext) throws DeploymentException {
         JndiConsumer consumer = createJndiConsumer(specDD);
-        processWebEjbAnnotations(module, consumer);
+//      processWebEjbAnnotations(module, consumer);
 
         Map<String, Object> map = null;
         try {

Modified: geronimo/server/trunk/modules/geronimo-tomcat6-builder/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6-builder/pom.xml?view=diff&rev=509958&r1=509957&r2=509958
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6-builder/pom.xml (original)
+++ geronimo/server/trunk/modules/geronimo-tomcat6-builder/pom.xml Wed Feb 21 02:13:55 2007
@@ -31,9 +31,9 @@
 
     <artifactId>geronimo-tomcat6-builder</artifactId>
     <name>Geronimo :: Tomcat :: Builder</name>
-    
+
     <dependencies>
-        
+
         <dependency>
             <groupId>${pom.groupId}</groupId>
             <artifactId>geronimo-naming-builder</artifactId>
@@ -69,7 +69,7 @@
             <artifactId>geronimo-web-2.5-builder</artifactId>
             <version>${version}</version>
         </dependency>
-        
+
         <dependency>
             <groupId>xmlbeans</groupId>
             <artifactId>xbean</artifactId>
@@ -79,7 +79,7 @@
             <groupId>stax</groupId>
             <artifactId>stax-api</artifactId>
         </dependency>
-        
+
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-annotation_1.0_spec</artifactId>
@@ -116,9 +116,14 @@
             <scope>test</scope>
         </dependency>
 
-        
+        <dependency>
+            <!-- TODO remove this WTF??? why isn't this picked up from geronimo-web-2.5-builder? -->
+            <groupId>asm</groupId>
+            <artifactId>asm</artifactId>
+        </dependency>
+
     </dependencies>
-    
+
     <build>
         <plugins>
             <plugin>
@@ -144,7 +149,7 @@
                     <sourceSchemas>geronimo-tomcat-1.2.xsd,geronimo-tomcat-config-1.0.xsd</sourceSchemas>
                 </configuration>
             </plugin>
-            
+
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-dependency-plugin</artifactId>
@@ -171,11 +176,11 @@
                     </execution>
                 </executions>
             </plugin>
-            
+
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-antrun-plugin</artifactId>
-                
+
                 <executions>
                     <!--
                     HACK: Copy the generated XmlBeans bits for clover
@@ -197,7 +202,7 @@
                             </tasks>
                         </configuration>
                     </execution>
-                    
+
                     <execution>
                         <id>setup-test-environment</id>
                         <phase>process-test-resources</phase>

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=509958&r1=509957&r2=509958
==============================================================================
--- 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 Wed Feb 21 02:13:55 2007
@@ -72,8 +72,8 @@
 import org.apache.geronimo.tomcat.TomcatWebAppContext;
 import org.apache.geronimo.tomcat.ValveGBean;
 import org.apache.geronimo.tomcat.util.SecurityHolder;
-import org.apache.geronimo.web25.deployment.AbstractWebModuleBuilder;
 import org.apache.geronimo.web.deployment.GenericToSpecificPlanConverter;
+import org.apache.geronimo.web25.deployment.AbstractWebModuleBuilder;
 import org.apache.geronimo.xbeans.geronimo.web.tomcat.TomcatWebAppDocument;
 import org.apache.geronimo.xbeans.geronimo.web.tomcat.TomcatWebAppType;
 import org.apache.geronimo.xbeans.geronimo.web.tomcat.config.GerTomcatDocument;
@@ -83,7 +83,6 @@
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 
-
 /**
  * @version $Rev:385659 $ $Date$
  */
@@ -111,9 +110,9 @@
     }
 
     protected Module createModule(Object plan, JarFile moduleFile, String targetPath, URL specDDUrl, boolean standAlone, String contextRoot, AbstractName earName, Naming naming, ModuleIDBuilder idBuilder) throws DeploymentException {
-        assert moduleFile != null: "moduleFile is null";
-        assert targetPath != null: "targetPath is null";
-        assert !targetPath.endsWith("/"): "targetPath must not end with a '/'";
+        assert moduleFile != null : "moduleFile is null";
+        assert targetPath != null : "targetPath is null";
+        assert !targetPath.endsWith("/") : "targetPath must not end with a '/'";
 
         // parse the spec dd
         String specDD = null;
@@ -126,22 +125,22 @@
             // read in the entire specDD as a string, we need this for getDeploymentDescriptor
             // on the J2ee management object
             specDD = DeploymentUtil.readAll(specDDUrl);
-            
+
             // we found web.xml, if it won't parse that's an error.
             XmlObject parsed = XmlBeansUtil.parse(specDD);
             WebAppDocument webAppDoc = convertToServletSchema(parsed);
             webApp = webAppDoc.getWebApp();
             check(webApp);
         } catch (XmlException e) {
-        	// Output the target path in the error to make it clearer to the user which webapp
+            // Output the target path in the error to make it clearer to the user which webapp
             // has the problem.  The targetPath is used, as moduleFile may have an unhelpful
             // value such as C:\geronimo-1.1\var\temp\geronimo-deploymentUtil22826.tmpdir
             throw new DeploymentException("Error parsing web.xml for " + targetPath, e);
         } catch (Exception e) {
-        	if(!moduleFile.getName().endsWith(".war")) {
-        		//not for us
-        		return null;
-        	} 
+            if (!moduleFile.getName().endsWith(".war")) {
+                //not for us
+                return null;
+            }
             //else ignore as jee5 allows optional spec dd for .war's
         }
 
@@ -161,20 +160,18 @@
         EnvironmentType environmentType = tomcatWebApp.getEnvironment();
         Environment environment = EnvironmentBuilder.buildEnvironment(environmentType, defaultEnvironment);
 
-        getNamingBuilders().buildEnvironment(webApp, tomcatWebApp, environment);
-
         // Note: logic elsewhere depends on the default artifact ID being the file name less extension (ConfigIDExtractor)
         String warName = "";
         File temp = new File(moduleFile.getName());
-        if(temp.isFile()) {
+        if (temp.isFile()) {
             warName = temp.getName();
-            if(warName.lastIndexOf('.') > -1) {
+            if (warName.lastIndexOf('.') > -1) {
                 warName = warName.substring(0, warName.lastIndexOf('.'));
             }
         } else {
             try {
                 warName = temp.getCanonicalFile().getName();
-                if(warName.equals("")) {
+                if (warName.equals("")) {
                     // Root directory
                     warName = "$root-dir$";
                 }
@@ -241,7 +238,7 @@
 
     private TomcatWebAppType createDefaultPlan(String path) {
         TomcatWebAppType tomcatWebApp = TomcatWebAppType.Factory.newInstance();
-        if (path!=null && !path.startsWith("/")) {
+        if (path != null && !path.startsWith("/")) {
             tomcatWebApp.setContextRoot("/" + path);
         } else {
             tomcatWebApp.setContextRoot(path);
@@ -251,17 +248,7 @@
 
 
     public void initContext(EARContext earContext, Module module, ClassLoader cl) throws DeploymentException {
-        WebAppType webApp = (WebAppType) module.getSpecDD();
-//        MessageDestinationType[] messageDestinations = webApp.getMessageDestinationArray();
         TomcatWebAppType gerWebApp = (TomcatWebAppType) module.getVendorDD();
-//        GerMessageDestinationType[] gerMessageDestinations = gerWebApp.getMessageDestinationArray();
-
-//        ENCConfigBuilder.registerMessageDestinations(earContext, module.getName(), messageDestinations, gerMessageDestinations);
-        getNamingBuilders().initContext(webApp, gerWebApp, module.getEarContext().getConfiguration(), earContext.getConfiguration(), module);
-        if ((webApp.getSecurityConstraintArray().length > 0 || webApp.getSecurityRoleArray().length > 0) &&
-                !gerWebApp.isSetSecurityRealmName()) {
-            throw new DeploymentException("web.xml for web app " + module.getName() + " includes security elements but Geronimo deployment plan is not provided or does not contain <security-realm-name> element necessary to configure security accordingly.");
-        }
         boolean hasSecurityRealmName = gerWebApp.isSetSecurityRealmName();
         buildSubstitutionGroups(gerWebApp, hasSecurityRealmName, module, earContext);
     }



Mime
View raw message