geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r525609 [1/3] - in /geronimo/server/trunk/modules: geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/ geronimo-connector-builder/src/test/java/org/apache/geronimo/connector/deployment/annotation/ geronimo-con...
Date Wed, 04 Apr 2007 21:20:05 GMT
Author: djencks
Date: Wed Apr  4 14:20:03 2007
New Revision: 525609

URL: http://svn.apache.org/viewvc?view=rev&rev=525609
Log:
GERONIMO-3022 A whole lot more annotation processing tests from Tim McConnell together with persistence context ref parameter handling and @Resource meaning service-ref

Added:
    geronimo/server/trunk/modules/geronimo-connector-builder/src/test/java/org/apache/geronimo/connector/deployment/annotation/
    geronimo/server/trunk/modules/geronimo-connector-builder/src/test/java/org/apache/geronimo/connector/deployment/annotation/AnnotationHelperTest.java   (with props)
    geronimo/server/trunk/modules/geronimo-connector-builder/src/test/java/org/apache/geronimo/connector/deployment/annotation/ResourceAnnotationTest.java   (with props)
    geronimo/server/trunk/modules/geronimo-connector-builder/src/test/resources/annotation/
    geronimo/server/trunk/modules/geronimo-connector-builder/src/test/resources/annotation/empty-web-src.xml   (with props)
    geronimo/server/trunk/modules/geronimo-connector-builder/src/test/resources/annotation/resource-ref-expected.xml   (with props)
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/annotation/
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotationHelperTest.java   (with props)
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/annotation/EJBAnnotationTest.java   (with props)
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/annotation/HandlerChainAnnotationTest.java   (with props)
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/annotation/PersistenceContextAnnotationTest.java   (with props)
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/annotation/PersistenceUnitAnnotationTest.java   (with props)
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/annotation/WebServiceRefAnnotationTest.java   (with props)
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/test/resources/annotation/
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/test/resources/annotation/ejb-expected.xml   (with props)
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/test/resources/annotation/empty-web-src.xml   (with props)
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/test/resources/annotation/handler-chain-expected.xml   (with props)
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/test/resources/annotation/handler-chain-src.xml   (with props)
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/test/resources/annotation/handlers1.xml   (with props)
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/test/resources/annotation/handlers2.xml   (with props)
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/test/resources/annotation/handlers3.xml   (with props)
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/test/resources/annotation/handlers4.xml   (with props)
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/test/resources/annotation/handlers5.xml   (with props)
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/test/resources/annotation/persistence-context-expected.xml   (with props)
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/test/resources/annotation/persistence-unit-expected.xml   (with props)
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/test/resources/annotation/webservice-ref-expected.xml   (with props)
    geronimo/server/trunk/modules/geronimo-naming-builder/src/test/java/org/apache/geronimo/naming/deployment/annotation/
    geronimo/server/trunk/modules/geronimo-naming-builder/src/test/java/org/apache/geronimo/naming/deployment/annotation/AnnotationHelperTest.java   (with props)
    geronimo/server/trunk/modules/geronimo-naming-builder/src/test/java/org/apache/geronimo/naming/deployment/annotation/ResourceAnnotationTest.java   (with props)
    geronimo/server/trunk/modules/geronimo-naming-builder/src/test/resources/
    geronimo/server/trunk/modules/geronimo-naming-builder/src/test/resources/annotation/
    geronimo/server/trunk/modules/geronimo-naming-builder/src/test/resources/annotation/empty-web-src.xml   (with props)
    geronimo/server/trunk/modules/geronimo-naming-builder/src/test/resources/annotation/env-entry-expected.xml   (with props)
    geronimo/server/trunk/modules/geronimo-naming-builder/src/test/resources/annotation/service-ref-expected.xml   (with props)
Modified:
    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/annotation/EJBAnnotationHelper.java
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/HandlerChainAnnotationHelper.java
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/PersistenceContextAnnotationHelper.java
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/ResourceAnnotationHelper.java
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/WebServiceRefAnnotationHelper.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

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=525609&r1=525608&r2=525609
==============================================================================
--- 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 Wed Apr  4 14:20:03 2007
@@ -286,7 +286,7 @@
         return GER_ADMIN_OBJECT_REF_QNAME_SET;
     }
 
-    static class AdminObjectRefProcessor extends ResourceAnnotationHelper.ResourceProcessor {
+    public static class AdminObjectRefProcessor extends ResourceAnnotationHelper.ResourceProcessor {
         private final Configuration localConfiguration;
         private final Map<String, GerResourceEnvRefType> refMap;
         private final Map<String, Map<String, GerMessageDestinationType>> messageDestinations;

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=525609&r1=525608&r2=525609
==============================================================================
--- 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 Wed Apr  4 14:20:03 2007
@@ -245,7 +245,7 @@
         return GER_RESOURCE_REF_QNAME_SET;
     }
 
-    static class ResourceRefProcessor extends ResourceAnnotationHelper.ResourceProcessor {
+    public static class ResourceRefProcessor extends ResourceAnnotationHelper.ResourceProcessor {
 
         public static final ResourceRefProcessor INSTANCE = new ResourceRefProcessor();
 
@@ -253,6 +253,12 @@
         }
 
         public boolean processResource(AnnotatedApp annotatedApp, Resource annotation, Class cls, Method method, Field field) {
+            log.debug("processResource( [annotatedApp] " + annotatedApp.toString() + "," + '\n' +
+                    "[annotation] " + annotation.toString() + "," + '\n' +
+                    "[cls] " + (cls != null ? cls.getName() : null) + "," + '\n' +
+                    "[method] " + (method != null ? method.getName() : null) + "," + '\n' +
+                    "[field] " + (field != null ? field.getName() : null) + " ): Entry");
+
             String resourceName = getResourceName(annotation, method, field);
             String resourceType = getResourceType(annotation, method, field);
             if (resourceType.equals("javax.sql.DataSource") ||
@@ -265,7 +271,7 @@
                     resourceType.equals("org.omg.CORBA_2_3.ORB") ||
                     resourceType.endsWith("ConnectionFactory")) {
 
-                log.debug("addResource(): <resource-ref> found");
+                log.debug("processResource(): <resource-ref> found");
 
                 boolean exists = false;
                 ResourceRefType[] resourceRefs = annotatedApp.getResourceRefArray();
@@ -284,7 +290,7 @@
                 if (!exists) {
                     try {
 
-                        log.debug("addResource(): Does not exist in DD: " + resourceName);
+                        log.debug("processResource(): Does not exist in DD: " + resourceName);
 
                         // Doesn't exist in deployment descriptor -- add new
                         ResourceRefType resourceRef = annotatedApp.addNewResourceRef();
@@ -296,13 +302,11 @@
                         // resource-ref-name
                         JndiNameType resourceRefName = resourceRef.addNewResRefName();
                         resourceRefName.setStringValue(resourceName);
-                        resourceRef.setResRefName(resourceRefName);
 
                         if (!resourceType.equals("")) {
                             // resource-ref-type
                             FullyQualifiedClassType qualifiedClass = resourceRef.addNewResType();
                             qualifiedClass.setStringValue(resourceType);
-                            resourceRef.setResType(qualifiedClass);
                         }
                         if (method != null || field != null) {
                             // injectionTarget
@@ -347,8 +351,7 @@
 
                     }
                     catch (Exception anyException) {
-                        log.debug("ResourceAnnotationHelper: Exception caught while processing <resource-ref>");
-                        anyException.printStackTrace();
+                        log.debug("ResourceRefBuilder: Exception caught while processing <resource-ref>");
                     }
                 }
                 return true;

Added: geronimo/server/trunk/modules/geronimo-connector-builder/src/test/java/org/apache/geronimo/connector/deployment/annotation/AnnotationHelperTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-connector-builder/src/test/java/org/apache/geronimo/connector/deployment/annotation/AnnotationHelperTest.java?view=auto&rev=525609
==============================================================================
--- geronimo/server/trunk/modules/geronimo-connector-builder/src/test/java/org/apache/geronimo/connector/deployment/annotation/AnnotationHelperTest.java (added)
+++ geronimo/server/trunk/modules/geronimo-connector-builder/src/test/java/org/apache/geronimo/connector/deployment/annotation/AnnotationHelperTest.java Wed Apr  4 14:20:03 2007
@@ -0,0 +1,93 @@
+/**
+ *  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.connector.deployment.annotation;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.annotation.Resource;
+import javax.annotation.Resources;
+
+import org.apache.geronimo.j2ee.deployment.annotation.ResourceAnnotationHelper;
+import org.apache.geronimo.connector.deployment.ResourceRefBuilder;
+import org.apache.geronimo.j2ee.deployment.annotation.AnnotatedWebApp;
+import org.apache.geronimo.testsupport.XmlBeansTestSupport;
+import org.apache.geronimo.xbeans.javaee.WebAppDocument;
+import org.apache.geronimo.xbeans.javaee.WebAppType;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xbean.finder.ClassFinder;
+import org.apache.xmlbeans.XmlOptions;
+
+/**
+ * Testcases for each of the various AnnotationHelper class
+ */
+public class AnnotationHelperTest extends XmlBeansTestSupport {
+
+    private Class[] classes = {ResourceAnnotationTest.class};
+
+    private ClassFinder classFinder = new ClassFinder(classes);
+    private ClassLoader classLoader = this.getClass().getClassLoader();
+    private XmlOptions options = new XmlOptions();
+
+    public void testResourceAnnotationHelper() throws Exception {
+
+        //-------------------------------------------------
+        // Ensure annotations are discovered correctly
+        //-------------------------------------------------
+        List<Class> annotatedClasses = classFinder.findAnnotatedClasses(Resources.class);
+        assertNotNull(annotatedClasses);
+        assertEquals(1, annotatedClasses.size());
+        assertTrue(annotatedClasses.contains(ResourceAnnotationTest.class));
+
+        List<Method> annotatedMethods = classFinder.findAnnotatedMethods(Resource.class);
+        assertNotNull(annotatedMethods);
+        assertEquals(2, annotatedMethods.size());
+        assertTrue(annotatedMethods.contains(ResourceAnnotationTest.class.getDeclaredMethod("setAnnotatedMethod1", new Class[]{String.class})));
+        assertTrue(annotatedMethods.contains(ResourceAnnotationTest.class.getDeclaredMethod("setAnnotatedMethod2", new Class[]{String.class})));
+
+        List<Field> annotatedFields = classFinder.findAnnotatedFields(Resource.class);
+        assertNotNull(annotatedFields);
+        assertEquals(2, annotatedFields.size());
+        assertTrue(annotatedFields.contains(ResourceAnnotationTest.class.getDeclaredField("annotatedField1")));
+        assertTrue(annotatedFields.contains(ResourceAnnotationTest.class.getDeclaredField("annotatedField2")));
+
+        //-------------------------------------------------
+        // Ensure annotations are processed correctly
+        //-------------------------------------------------
+        //
+        // 1. resource-ref
+        //
+        URL srcXML = classLoader.getResource("annotation/empty-web-src.xml");
+        XmlObject xmlObject = XmlObject.Factory.parse(srcXML, options);
+        WebAppDocument webAppDoc = (WebAppDocument) xmlObject.changeType(WebAppDocument.type);
+        WebAppType webApp = webAppDoc.getWebApp();
+        AnnotatedWebApp annotatedWebApp = new AnnotatedWebApp(webApp);
+        ResourceAnnotationHelper.processAnnotations(annotatedWebApp, classFinder, ResourceRefBuilder.ResourceRefProcessor.INSTANCE);
+        URL expectedXML = classLoader.getResource("annotation/resource-ref-expected.xml");
+        XmlObject expected = XmlObject.Factory.parse(expectedXML);
+        log.debug("[@Resource <resource-ref> Source XML] " + '\n' + webApp.toString() + '\n');
+        log.debug("[@Resource <resource-ref> Expected XML]" + '\n' + expected.toString() + '\n');
+        List problems = new ArrayList();
+        boolean ok = compareXmlObjects(webApp, expected, problems);
+        assertTrue("Differences: " + problems, ok);
+    }
+}

Propchange: geronimo/server/trunk/modules/geronimo-connector-builder/src/test/java/org/apache/geronimo/connector/deployment/annotation/AnnotationHelperTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-connector-builder/src/test/java/org/apache/geronimo/connector/deployment/annotation/AnnotationHelperTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/modules/geronimo-connector-builder/src/test/java/org/apache/geronimo/connector/deployment/annotation/AnnotationHelperTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/modules/geronimo-connector-builder/src/test/java/org/apache/geronimo/connector/deployment/annotation/ResourceAnnotationTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-connector-builder/src/test/java/org/apache/geronimo/connector/deployment/annotation/ResourceAnnotationTest.java?view=auto&rev=525609
==============================================================================
--- geronimo/server/trunk/modules/geronimo-connector-builder/src/test/java/org/apache/geronimo/connector/deployment/annotation/ResourceAnnotationTest.java (added)
+++ geronimo/server/trunk/modules/geronimo-connector-builder/src/test/java/org/apache/geronimo/connector/deployment/annotation/ResourceAnnotationTest.java Wed Apr  4 14:20:03 2007
@@ -0,0 +1,70 @@
+/**
+ * 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.connector.deployment.annotation;
+
+import javax.annotation.Resource;
+import javax.annotation.Resources;
+
+@Resources ({
+                @Resource(name = "Resource1",                   // 2. env-entry
+                          type = java.lang.String.class,
+                          authenticationType = Resource.AuthenticationType.APPLICATION,
+                          shareable = true,
+                          description = "description1",
+                          mappedName = "mappedName1"),
+                @Resource(name = "Resource2",                   // 3. service-ref
+                          type = javax.xml.ws.Service.class,
+                          authenticationType = Resource.AuthenticationType.APPLICATION)
+            })
+public class ResourceAnnotationTest {
+
+    @Resource(name = "Resource3",
+              type = java.lang.Object.class,
+              authenticationType = Resource.AuthenticationType.CONTAINER,
+              shareable = true,
+              mappedName = "mappedName3")
+    boolean annotatedField1;
+
+    @Resource(name = "Resource4",
+              type = javax.xml.ws.Service.class,                // 3. service-ref
+              shareable = false,
+              description = "description4",
+              mappedName = "mappedName4")
+    String annotatedField2;
+
+    //------------------------------------------------------------------------------------------
+    // Method name (for setter-based injection) must follow JavaBeans conventions:
+    // -- Must start with "set"
+    // -- Have one parameter
+    // -- Return void
+    //------------------------------------------------------------------------------------------
+    @Resource(name = "Resource5",                               // 1. resource-ref
+              type = javax.sql.DataSource.class,
+              authenticationType = Resource.AuthenticationType.CONTAINER,
+              description = "description5",
+              mappedName = "mappedName5")
+    public void setAnnotatedMethod1(String string) {
+    }
+
+    @Resource                                                   // 2. env-entry
+    public void setAnnotatedMethod2(String string) {
+    }
+
+}

Propchange: geronimo/server/trunk/modules/geronimo-connector-builder/src/test/java/org/apache/geronimo/connector/deployment/annotation/ResourceAnnotationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-connector-builder/src/test/java/org/apache/geronimo/connector/deployment/annotation/ResourceAnnotationTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/modules/geronimo-connector-builder/src/test/java/org/apache/geronimo/connector/deployment/annotation/ResourceAnnotationTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/modules/geronimo-connector-builder/src/test/resources/annotation/empty-web-src.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-connector-builder/src/test/resources/annotation/empty-web-src.xml?view=auto&rev=525609
==============================================================================
--- geronimo/server/trunk/modules/geronimo-connector-builder/src/test/resources/annotation/empty-web-src.xml (added)
+++ geronimo/server/trunk/modules/geronimo-connector-builder/src/test/resources/annotation/empty-web-src.xml Wed Apr  4 14:20:03 2007
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   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.
+-->
+
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+   version="2.5" >
+
+    <display-name>Empty web application</display-name>
+    <description>Empty web application</description>
+
+</web-app>

Propchange: geronimo/server/trunk/modules/geronimo-connector-builder/src/test/resources/annotation/empty-web-src.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-connector-builder/src/test/resources/annotation/empty-web-src.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/modules/geronimo-connector-builder/src/test/resources/annotation/empty-web-src.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: geronimo/server/trunk/modules/geronimo-connector-builder/src/test/resources/annotation/resource-ref-expected.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-connector-builder/src/test/resources/annotation/resource-ref-expected.xml?view=auto&rev=525609
==============================================================================
--- geronimo/server/trunk/modules/geronimo-connector-builder/src/test/resources/annotation/resource-ref-expected.xml (added)
+++ geronimo/server/trunk/modules/geronimo-connector-builder/src/test/resources/annotation/resource-ref-expected.xml Wed Apr  4 14:20:03 2007
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   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.
+-->
+
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+   version="2.5" >
+
+    <display-name>Empty web application</display-name>
+    <description>Empty web application</description>
+    <resource-ref>
+        <description>description5</description>
+        <res-ref-name>Resource5</res-ref-name>
+        <res-type>javax.sql.DataSource</res-type>
+        <res-auth>Container</res-auth>
+        <res-sharing-scope>Shareable</res-sharing-scope>
+        <mapped-name>mappedName5</mapped-name>
+        <injection-target>
+            <injection-target-class>org.apache.geronimo.j2ee.deployment.annotation.ResourceAnnotationTest</injection-target-class>
+            <injection-target-name>annotatedMethod1</injection-target-name>
+        </injection-target>
+    </resource-ref>
+
+</web-app>

Propchange: geronimo/server/trunk/modules/geronimo-connector-builder/src/test/resources/annotation/resource-ref-expected.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-connector-builder/src/test/resources/annotation/resource-ref-expected.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/modules/geronimo-connector-builder/src/test/resources/annotation/resource-ref-expected.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: 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=diff&rev=525609&r1=525608&r2=525609
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/EJBAnnotationHelper.java (original)
+++ geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/EJBAnnotationHelper.java Wed Apr  4 14:20:03 2007
@@ -207,11 +207,11 @@
      * @param field        Field name with the @EJB annoation
      */
     private static void addEJB(AnnotatedApp annotatedApp, EJB annotation, Class cls, Method method, Field field) {
-        log.debug("addEJB( " + annotatedApp.toString() + "," + '\n' +
-                annotation.name() + "," + '\n' +
-                (cls != null ? cls.getName() : null) + "," + '\n' +
-                (method != null ? method.getName() : null) + "," + '\n' +
-                (field != null ? field.getName() : null) + " ): Entry");
+        log.debug("addEJB( [annotatedApp] " + annotatedApp.toString() + "," + '\n' +
+                "[annotation] " + annotation.toString() + "," + '\n' +
+                "[cls] " + (cls != null ? cls.getName() : null) + "," + '\n' +
+                "[method] " + (method != null ? method.getName() : null) + "," + '\n' +
+                "[field] " + (field != null ? field.getName() : null) + " ): Entry");
 
         // First determine if the interface is "Local" or "Remote" (if we can--we may not be able to)
         boolean localFlag = false;
@@ -226,6 +226,7 @@
                 interfce = null;
             }
         }
+        log.debug("addEJB(): interfce: " + interfce);
 
         // Just in case local and/or remote homes are still being implemented (even though
         // they are optional in EJB 3.0)
@@ -242,6 +243,8 @@
                 }
             }
         }
+        log.debug("addEJB(): localFlag: " + localFlag);
+        log.debug("addEJB(): remoteFlag: " + remoteFlag);
 
         //------------------------------------------------------------------------------------------
         // 1. <ejb-local-ref>
@@ -289,11 +292,13 @@
                     //------------------------------------------------------------------------------
 
                     // local
-                    String localAnnotation = interfce.getName();
-                    if (!localAnnotation.equals("")) {
-                        LocalType local = ejbLocalRef.addNewLocal();
-                        local.setStringValue(localAnnotation);
-                        ejbLocalRef.setLocal(local);
+                    if (interfce != null) {
+                        String localAnnotation = interfce.getName();
+                        if (!localAnnotation.equals("")) {
+                            LocalType local = ejbLocalRef.addNewLocal();
+                            local.setStringValue(localAnnotation);
+                            ejbLocalRef.setLocal(local);
+                        }
                     }
 
                     // ejb-link
@@ -320,19 +325,22 @@
                     }
 
                     // injectionTarget
-                    InjectionTargetType injectionTarget = ejbLocalRef.addNewInjectionTarget();
-                    FullyQualifiedClassType qualifiedClass = injectionTarget.addNewInjectionTargetClass();
-                    JavaIdentifierType javaType = injectionTarget.addNewInjectionTargetName();
-                    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);
-                    } else if (field != null) {
-                        qualifiedClass.setStringValue(field.getDeclaringClass().getName());
-                        javaType.setStringValue(field.getName());
-                        injectionTarget.setInjectionTargetClass(qualifiedClass);
-                        injectionTarget.setInjectionTargetName(javaType);
+                    if (method != null || field != null) {                            // No class-level injection
+                        InjectionTargetType injectionTarget = ejbLocalRef.addNewInjectionTarget();
+                        FullyQualifiedClassType qualifiedClass = injectionTarget.addNewInjectionTargetClass();
+                        JavaIdentifierType javaType = injectionTarget.addNewInjectionTargetName();
+                        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);
+                        }
+                        else if (field != null) {
+                            qualifiedClass.setStringValue(field.getDeclaringClass().getName());
+                            javaType.setStringValue(field.getName());
+                            injectionTarget.setInjectionTargetClass(qualifiedClass);
+                            injectionTarget.setInjectionTargetName(javaType);
+                        }
                     }
 
                 }
@@ -389,11 +397,13 @@
                     //------------------------------------------------------------------------------
 
                     // remote
-                    String remoteAnnotation = interfce.getName();
-                    if (!remoteAnnotation.equals("")) {
-                        RemoteType remote = ejbRef.addNewRemote();
-                        remote.setStringValue(remoteAnnotation);
-                        ejbRef.setRemote(remote);
+                    if (interfce != null) {
+                        String remoteAnnotation = interfce.getName();
+                        if (!remoteAnnotation.equals("")) {
+                            RemoteType remote = ejbRef.addNewRemote();
+                            remote.setStringValue(remoteAnnotation);
+                            ejbRef.setRemote(remote);
+                        }
                     }
 
                     // ejb-link
@@ -420,19 +430,22 @@
                     }
 
                     // injectionTarget
-                    InjectionTargetType injectionTarget = ejbRef.addNewInjectionTarget();
-                    FullyQualifiedClassType qualifiedClass = injectionTarget.addNewInjectionTargetClass();
-                    JavaIdentifierType javaType = injectionTarget.addNewInjectionTargetName();
-                    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);
-                    } else if (field != null) {
-                        qualifiedClass.setStringValue(field.getDeclaringClass().getName());
-                        javaType.setStringValue(field.getName());
-                        injectionTarget.setInjectionTargetClass(qualifiedClass);
-                        injectionTarget.setInjectionTargetName(javaType);
+                    if (method != null || field != null) {                            // No class-level injection
+                        InjectionTargetType injectionTarget = ejbRef.addNewInjectionTarget();
+                        FullyQualifiedClassType qualifiedClass = injectionTarget.addNewInjectionTargetClass();
+                        JavaIdentifierType javaType = injectionTarget.addNewInjectionTargetName();
+                        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);
+                        }
+                        else if (field != null) {
+                            qualifiedClass.setStringValue(field.getDeclaringClass().getName());
+                            javaType.setStringValue(field.getName());
+                            injectionTarget.setInjectionTargetClass(qualifiedClass);
+                            injectionTarget.setInjectionTargetName(javaType);
+                        }
                     }
 
                 }
@@ -490,11 +503,13 @@
                     //------------------------------------------------------------------------------
 
                     // remote
-                    String remoteAnnotation = interfce.getName();
-                    if (!remoteAnnotation.equals("")) {
-                        RemoteType remote = ejbRef.addNewRemote();
-                        remote.setStringValue(remoteAnnotation);
-                        ejbRef.setRemote(remote);
+                    if (interfce != null) {
+                        String remoteAnnotation = interfce.getName();
+                        if (!remoteAnnotation.equals("")) {
+                            RemoteType remote = ejbRef.addNewRemote();
+                            remote.setStringValue(remoteAnnotation);
+                            ejbRef.setRemote(remote);
+                        }
                     }
 
                     // ejb-link
@@ -521,19 +536,22 @@
                     }
 
                     // injectionTarget
-                    InjectionTargetType injectionTarget = ejbRef.addNewInjectionTarget();
-                    FullyQualifiedClassType qualifiedClass = injectionTarget.addNewInjectionTargetClass();
-                    JavaIdentifierType javaType = injectionTarget.addNewInjectionTargetName();
-                    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);
-                    } else if (field != null) {
-                        qualifiedClass.setStringValue(field.getDeclaringClass().getName());
-                        javaType.setStringValue(field.getName());
-                        injectionTarget.setInjectionTargetClass(qualifiedClass);
-                        injectionTarget.setInjectionTargetName(javaType);
+                    if (method != null || field != null) {                            // No class-level injection
+                        InjectionTargetType injectionTarget = ejbRef.addNewInjectionTarget();
+                        FullyQualifiedClassType qualifiedClass = injectionTarget.addNewInjectionTargetClass();
+                        JavaIdentifierType javaType = injectionTarget.addNewInjectionTargetName();
+                        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);
+                        }
+                        else if (field != null) {
+                            qualifiedClass.setStringValue(field.getDeclaringClass().getName());
+                            javaType.setStringValue(field.getName());
+                            injectionTarget.setInjectionTargetClass(qualifiedClass);
+                            injectionTarget.setInjectionTargetName(javaType);
+                        }
                     }
 
                 }

Modified: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/HandlerChainAnnotationHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/HandlerChainAnnotationHelper.java?view=diff&rev=525609&r1=525608&r2=525609
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/HandlerChainAnnotationHelper.java (original)
+++ geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/HandlerChainAnnotationHelper.java Wed Apr  4 14:20:03 2007
@@ -61,11 +61,6 @@
  *      exception will be thrown if it fails to parse
  * </ul>
  *
- * <p><strong>Remaining ToDo(s):</strong>
- * <ul>
- *      <li>None
- * </ul>
- *
  * @version $Rev $Date
  * @since 03-2007
  */
@@ -103,21 +98,9 @@
     private static void processHandlerChain(AnnotatedApp annotatedApp, ClassFinder classFinder) throws DeploymentException {
         log.debug("processHandlerChain(): Entry: AnnotatedApp: " + annotatedApp.toString());
 
-//      List<Class> classeswithHandlerChain = classFinder.findAnnotatedClasses(HandlerChain.class);
         List<Method> methodswithHandlerChain = classFinder.findAnnotatedMethods(HandlerChain.class);
         List<Field> fieldswithHandlerChain = classFinder.findAnnotatedFields(HandlerChain.class);
 
-// TODO: GERONIMO-2956
-//       If we ultimately determine that handler chain annotations at a class-level do not need to be processed
-//       in conjunction with any other annotations, which seems likely at this point, then these comments can be
-//       removed
-// Class-level annotation
-//      for ( Class cls : classeswithHandlerChain ) {
-//          HandlerChain handlerChain = (HandlerChain) cls.getAnnotation(HandlerChain.class);
-//          if ( handlerChain != null ) {
-//              addHandlerChain(annotatedApp, handlerChain, cls, null, null);
-//          }
-//      }
 
         // Method-level annotation
         for ( Method method : methodswithHandlerChain ) {
@@ -165,10 +148,11 @@
      * @param field      Field name with the @HandlerChain annotation
      */
     private static void addHandlerChain(AnnotatedApp annotatedApp, final HandlerChain annotation, Class cls, Method method, Field field) {
-        log.debug("addHandlerChain( " + annotatedApp.toString() + "," + '\n' +
-                           (cls != null ? cls.getName() : null) + "," + '\n' +
-                           (method != null ? method.getName() : null) + "," + '\n' +
-                           (field != null ? field.getName() : null) + " ): Entry");
+        log.debug("addHandlerChain( [annotatedApp] " + annotatedApp.toString() + "," + '\n' +
+                "[annotation] " + annotation.toString() + "," + '\n' +
+                "[cls] " + (cls != null ? cls.getName() : null) + "," + '\n' +
+                "[method] " + (method != null ? method.getName() : null) + "," + '\n' +
+                "[field] " + (field != null ? field.getName() : null) + " ): Entry");
 
         //------------------------------------------------------------------------------------------
         // HandlerChain members:
@@ -290,7 +274,7 @@
             url = Thread.currentThread().getContextClassLoader().getResource(loc);
         }
 
-        log.debug("getURL(): Exit: url: " + url.toString() );
+        log.debug("getURL(): Exit: url: " + (url != null ? url.toString() : null) );
         return url;
     }
 

Modified: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/PersistenceContextAnnotationHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/PersistenceContextAnnotationHelper.java?view=diff&rev=525609&r1=525608&r2=525609
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/PersistenceContextAnnotationHelper.java (original)
+++ geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/PersistenceContextAnnotationHelper.java Wed Apr  4 14:20:03 2007
@@ -26,6 +26,7 @@
 import javax.persistence.PersistenceContext;
 import javax.persistence.PersistenceContexts;
 import javax.persistence.PersistenceContextType;
+import javax.persistence.PersistenceProperty;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -37,7 +38,7 @@
 import org.apache.geronimo.xbeans.javaee.PersistenceContextRefType;
 import org.apache.geronimo.xbeans.javaee.PersistenceContextTypeType;
 import org.apache.geronimo.xbeans.javaee.PropertyType;
-import org.apache.geronimo.xbeans.javaee.XsdAnyURIType;
+import org.apache.geronimo.xbeans.javaee.XsdStringType;
 import org.apache.xbean.finder.ClassFinder;
 
 
@@ -218,7 +219,7 @@
         }
         log.debug("addPersistenceContext(): PersistenceContextRefName: " + persistenceContextRefName);
 
-        // If there is already xml for the persistence unit ref, just add injection targets and return.
+        // If there is already xml for the persistence context ref, just add injection targets and return.
         PersistenceContextRefType[] persistenceContextRefs = annotatedApp.getPersistenceContextRefArray();
         for (PersistenceContextRefType persistenceContextRef : persistenceContextRefs) {
             if (persistenceContextRef.getPersistenceContextRefName().getStringValue().trim().equals(persistenceContextRefName)) {
@@ -263,6 +264,16 @@
             PersistenceContextTypeType persistenceContextType = persistenceContextRef.addNewPersistenceContextType();
             persistenceContextType.setStringValue("Extended");
             persistenceContextRef.setPersistenceContextType(persistenceContextType);
+        }
+
+        // persistence-context-properties
+        PersistenceProperty[] properties = annotation.properties();
+        for (PersistenceProperty property : properties) {
+            PropertyType propertyType = persistenceContextRef.addNewPersistenceProperty();
+            XsdStringType propertyName = propertyType.addNewName();
+            propertyName.setStringValue(property.name());
+            XsdStringType propertyValue = propertyType.addNewValue();
+            propertyValue.setStringValue(property.value());
         }
 
         // injection targets

Modified: 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=diff&rev=525609&r1=525608&r2=525609
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/ResourceAnnotationHelper.java (original)
+++ geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/ResourceAnnotationHelper.java Wed Apr  4 14:20:03 2007
@@ -210,520 +210,4 @@
         }
     }
 
-    /**
-     * 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:
-     * <p/>
-     * <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/>
-     * <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(AnnotatedApp annotatedApp, Resource annotation, Class cls, Method method, Field field) {
-        log.debug("addResource( " + annotatedApp.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();
-            }
-        }
-        log.debug("addResource(): resourceName: " + resourceName);
-
-        //------------------------------------------------------------------------------------------
-        // 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.type().getCanonicalName();
-        if (resourceType.equals("") || resourceType.equals(Object.class.getName())) {
-            if (method != null) {
-                resourceType = method.getParameterTypes()[0].getCanonicalName();
-            } else if (field != null) {
-                resourceType = field.getType().getName();
-            }
-        }
-        log.debug("addResource(): resourceType: " + resourceType);
-
-        //------------------------------------------------------------------------------------------
-        // 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();
-        }
-        log.debug("addResource(): injectionJavaType: " + injectionJavaType);
-        log.debug("addResource(): injectionClass   : " + injectionClass);
-
-        // 0. exclusions
-        //  WebServiceContext
-        if (resourceType.equals("javax.xml.ws.WebServiceContext")) {
-            return;
-        }
-
-        //------------------------------------------------------------------------------------------
-        // 1. <env-entry>
-        //------------------------------------------------------------------------------------------
-        if (resourceType.equals("java.lang.String") ||
-                resourceType.equals("java.lang.Character") ||
-                resourceType.equals("java.lang.Integer") ||
-                resourceType.equals("java.lang.Boolean") ||
-                resourceType.equals("java.lang.Double") ||
-                resourceType.equals("java.lang.Byte") ||
-                resourceType.equals("java.lang.Short") ||
-                resourceType.equals("java.lang.Long") ||
-                resourceType.equals("java.lang.Float")) {
-
-            log.debug("addResource(): <env-entry> found");
-
-            boolean exists = false;
-            EnvEntryType[] envEntries = annotatedApp.getEnvEntryArray();
-            for (EnvEntryType envEntry : envEntries) {
-                if (envEntry.getEnvEntryName().getStringValue().trim().equals(resourceName)) {
-                    exists = true;
-                    break;
-                }
-            }
-            if (!exists) {
-                try {
-
-                    log.debug("addResource(): Does not exist in DD: " + resourceName);
-
-                    // Doesn't exist in deployment descriptor -- add new
-                    EnvEntryType envEntry = annotatedApp.addNewEnvEntry();
-
-                    //------------------------------------------------------------------------------
-                    // <env-entry> required elements:
-                    //------------------------------------------------------------------------------
-
-                    // env-entry-name
-                    JndiNameType envEntryName = envEntry.addNewEnvEntryName();
-                    envEntryName.setStringValue(resourceName);
-
-                    if (!resourceType.equals("")) {
-                        // env-entry-type
-                        EnvEntryTypeValuesType envEntryType = envEntry.addNewEnvEntryType();
-                        envEntryType.setStringValue(resourceType);
-                    } else if (!injectionJavaType.equals("")) {
-                        // injectionTarget
-                        InjectionTargetType injectionTarget = envEntry.addNewInjectionTarget();
-                        configureInjectionTarget(injectionTarget, method, field);
-                    }
-
-                    // env-entry-value
-                    XsdStringType value = envEntry.addNewEnvEntryValue();
-                    value.setStringValue(annotation.mappedName());
-
-                    //------------------------------------------------------------------------------
-                    // <env-entry> optional elements:
-                    //------------------------------------------------------------------------------
-
-                    // description
-                    String descriptionAnnotation = annotation.description();
-                    if (!descriptionAnnotation.equals("")) {
-                        DescriptionType description = envEntry.addNewDescription();
-                        description.setStringValue(descriptionAnnotation);
-                    }
-
-                }
-                catch (Exception anyException) {
-                    log.debug("ResourceAnnotationHelper: Exception caught while processing <env-entry>");
-                }
-            }
-        }
-
-        //------------------------------------------------------------------------------------------
-        // 2. <service-ref>
-        //------------------------------------------------------------------------------------------
-        else if (resourceType.equals("javax.xml.rpc.Service")) {
-
-            log.debug("addResource(): <service-ref> found");
-
-            boolean exists = false;
-            ServiceRefType[] serviceRefs = annotatedApp.getServiceRefArray();
-            for (ServiceRefType serviceRef : serviceRefs) {
-                if (serviceRef.getServiceRefName().getStringValue().trim().equals(resourceName)) {
-                    exists = true;
-                    break;
-                }
-            }
-            if (!exists) {
-                try {
-
-                    log.debug("addResource(): Does not exist in DD: " + resourceName);
-
-                    // Doesn't exist in deployment descriptor -- add new
-                    ServiceRefType serviceRef = annotatedApp.addNewServiceRef();
-
-                    //------------------------------------------------------------------------------
-                    // <service-ref> required elements:
-                    //------------------------------------------------------------------------------
-
-                    // service-ref-name
-                    JndiNameType serviceRefName = serviceRef.addNewServiceRefName();
-                    serviceRefName.setStringValue(resourceName);
-
-                    if (!resourceType.equals("")) {
-                        // service-ref-type
-                        FullyQualifiedClassType qualifiedClass = serviceRef.addNewServiceInterface();
-                        qualifiedClass.setStringValue(resourceType);
-                        serviceRef.setServiceInterface(qualifiedClass);
-                    } else if (!injectionJavaType.equals("")) {
-                        // injectionTarget
-                        InjectionTargetType injectionTarget = serviceRef.addNewInjectionTarget();
-                        configureInjectionTarget(injectionTarget, method, field);
-                    }
-
-                    //------------------------------------------------------------------------------
-                    // <service-ref> optional elements:
-                    //------------------------------------------------------------------------------
-
-                    // description
-                    String descriptionAnnotation = annotation.description();
-                    if (!descriptionAnnotation.equals("")) {
-                        DescriptionType description = serviceRef.addNewDescription();
-                        description.setStringValue(descriptionAnnotation);
-                    }
-
-                    // WSDL document location
-                    String documentAnnotation = annotation.mappedName();
-                    if (!documentAnnotation.equals("")) {
-                        XsdAnyURIType wsdlFile = serviceRef.addNewWsdlFile();
-                        wsdlFile.setStringValue(documentAnnotation);
-                        serviceRef.setWsdlFile(wsdlFile);
-                    }
-
-                }
-                catch (Exception anyException) {
-                    log.debug("ResourceAnnotationHelper: Exception caught while processing <service-ref>");
-                    anyException.printStackTrace();
-                }
-            }
-        }
-
-        //------------------------------------------------------------------------------------------
-        // 3. <resource-ref>
-        //------------------------------------------------------------------------------------------
-        else if (resourceType.equals("javax.sql.DataSource") ||
-                resourceType.equals("javax.jms.ConnectionFactory") ||
-                resourceType.equals("javax.jms.QueueConnectionFactory") ||
-                resourceType.equals("javax.jms.TopicConnectionFactory") ||
-                resourceType.equals("javax.mail.Session") ||
-                resourceType.equals("java.net.URL") ||
-                resourceType.equals("javax.resource.cci.ConnectionFactory") ||
-                resourceType.equals("org.omg.CORBA_2_3.ORB") ||
-                resourceType.endsWith("ConnectionFactory")) {
-
-            log.debug("addResource(): <resource-ref> found");
-
-            boolean exists = false;
-            ResourceRefType[] resourceRefs = annotatedApp.getResourceRefArray();
-            for (ResourceRefType resourceRef : resourceRefs) {
-                if (resourceRef.getResRefName().getStringValue().trim().equals(resourceName)) {
-                    exists = true;
-                    break;
-                }
-            }
-            if (!exists) {
-                try {
-
-                    log.debug("addResource(): Does not exist in DD: " + resourceName);
-
-                    // Doesn't exist in deployment descriptor -- add new
-                    ResourceRefType resourceRef = annotatedApp.addNewResourceRef();
-
-                    //------------------------------------------------------------------------------
-                    // <resource-ref> required elements:
-                    //------------------------------------------------------------------------------
-
-                    // resource-ref-name
-                    JndiNameType resourceRefName = resourceRef.addNewResRefName();
-                    resourceRefName.setStringValue(resourceName);
-                    resourceRef.setResRefName(resourceRefName);
-
-                    if (!resourceType.equals("")) {
-                        // resource-ref-type
-                        FullyQualifiedClassType qualifiedClass = resourceRef.addNewResType();
-                        qualifiedClass.setStringValue(resourceType);
-                        resourceRef.setResType(qualifiedClass);
-                    } else if (!injectionJavaType.equals("")) {
-                        // injectionTarget
-                        InjectionTargetType injectionTarget = resourceRef.addNewInjectionTarget();
-                        configureInjectionTarget(injectionTarget, method, field);
-                    }
-
-                    //------------------------------------------------------------------------------
-                    // <resource-ref> optional elements:
-                    //------------------------------------------------------------------------------
-
-                    // description
-                    String descriptionAnnotation = annotation.description();
-                    if (!descriptionAnnotation.equals("")) {
-                        DescriptionType description = resourceRef.addNewDescription();
-                        description.setStringValue(descriptionAnnotation);
-                    }
-
-                    // authentication
-                    if (annotation.authenticationType() == Resource.AuthenticationType.CONTAINER) {
-                        ResAuthType resAuth = resourceRef.addNewResAuth();
-                        resAuth.setStringValue("Container");
-                        resourceRef.setResAuth(resAuth);
-                    } else if (annotation.authenticationType() == Resource.AuthenticationType.APPLICATION) {
-                        ResAuthType resAuth = resourceRef.addNewResAuth();
-                        resAuth.setStringValue("Application");
-                        resourceRef.setResAuth(resAuth);
-                    }
-
-                    // sharing scope
-                    ResSharingScopeType resScope = resourceRef.addNewResSharingScope();
-                    resScope.setStringValue(annotation.shareable() ? "Shareable" : "Unshareable");
-                    resourceRef.setResSharingScope(resScope);
-
-                    // mappedName
-                    String mappdedNameAnnotation = annotation.mappedName();
-                    if (!mappdedNameAnnotation.equals("")) {
-                        XsdStringType mappedName = resourceRef.addNewMappedName();
-                        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 (resourceType.equals("javax.jms.Queue") ||
-                resourceType.equals("javax.jms.Topic")) {
-
-            log.debug("addResource(): <message-destination-ref> found");
-
-            boolean exists = false;
-            MessageDestinationRefType[] messageDestinationRefs = annotatedApp.getMessageDestinationRefArray();
-            for (MessageDestinationRefType messageDestinationRef : messageDestinationRefs) {
-                if (messageDestinationRef.getMessageDestinationRefName().getStringValue().trim().equals(resourceName)) {
-                    exists = true;
-                    break;
-                }
-            }
-            if (!exists) {
-                try {
-
-                    log.debug("addResource(): Does not exist in DD: " + resourceName);
-
-                    // Doesn't exist in deployment descriptor -- add new
-                    MessageDestinationRefType messageDestinationRef = annotatedApp.addNewMessageDestinationRef();
-
-                    //------------------------------------------------------------------------------
-                    // <message-destination-ref> required elements:
-                    //------------------------------------------------------------------------------
-
-                    // message-destination-ref-name
-                    JndiNameType messageDestinationRefName = messageDestinationRef.addNewMessageDestinationRefName();
-                    messageDestinationRefName.setStringValue(resourceName);
-                    messageDestinationRef.setMessageDestinationRefName(messageDestinationRefName);
-
-                    if (!resourceType.equals("")) {
-                        // message-destination-ref-type
-                        MessageDestinationTypeType msgDestType = messageDestinationRef.addNewMessageDestinationType();
-                        msgDestType.setStringValue(resourceType);
-                        messageDestinationRef.setMessageDestinationType(msgDestType);
-                    } else if (!injectionJavaType.equals("")) {
-                        // injectionTarget
-                        InjectionTargetType injectionTarget = messageDestinationRef.addNewInjectionTarget();
-                        configureInjectionTarget(injectionTarget, method, field);
-                    }
-
-                    //------------------------------------------------------------------------------
-                    // <message-destination-ref> optional elements:
-                    //------------------------------------------------------------------------------
-
-                    // description
-                    String descriptionAnnotation = annotation.description();
-                    if (!descriptionAnnotation.equals("")) {
-                        DescriptionType description = messageDestinationRef.addNewDescription();
-                        description.setStringValue(descriptionAnnotation);
-                    }
-
-                    // mappedName
-                    String mappdedNameAnnotation = annotation.mappedName();
-                    if (!mappdedNameAnnotation.equals("")) {
-                        XsdStringType mappedName = messageDestinationRef.addNewMappedName();
-                        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) {
-
-            log.debug("addResource(): <resource-env-ref> found");
-
-            boolean exists = false;
-            ResourceEnvRefType[] resourceEnvRefs = annotatedApp.getResourceEnvRefArray();
-            for (ResourceEnvRefType resourceEnvRef : resourceEnvRefs) {
-                if (resourceEnvRef.getResourceEnvRefName().getStringValue().trim().equals(resourceName)) {
-                    exists = true;
-                    break;
-                }
-            }
-            if (!exists) {
-                try {
-
-                    log.debug("addResource(): Does not exist in DD: " + resourceName);
-
-                    // Doesn't exist in deployment descriptor -- add new
-                    ResourceEnvRefType resourceEnvRef = annotatedApp.addNewResourceEnvRef();
-
-                    //------------------------------------------------------------------------------
-                    // <resource-env-ref> required elements:
-                    //------------------------------------------------------------------------------
-
-                    // resource-env-ref-name
-                    JndiNameType resourceEnvRefName = resourceEnvRef.addNewResourceEnvRefName();
-                    resourceEnvRefName.setStringValue(resourceName);
-                    resourceEnvRef.setResourceEnvRefName(resourceEnvRefName);
-
-                    if (!resourceType.equals("")) {
-                        // resource-env-ref-type
-                        FullyQualifiedClassType qualifiedClass = resourceEnvRef.addNewResourceEnvRefType();
-                        qualifiedClass.setStringValue(resourceType);
-                        resourceEnvRef.setResourceEnvRefType(qualifiedClass);
-                    } else if (!injectionJavaType.equals("")) {
-                        // injectionTarget
-                        InjectionTargetType injectionTarget = resourceEnvRef.addNewInjectionTarget();
-                        configureInjectionTarget(injectionTarget, method, field);
-                    }
-
-                    //------------------------------------------------------------------------------
-                    // <resource-env-ref> optional elements:
-                    //------------------------------------------------------------------------------
-
-                    // description
-                    String descriptionAnnotation = annotation.description();
-                    if (!descriptionAnnotation.equals("")) {
-                        DescriptionType description = resourceEnvRef.addNewDescription();
-                        description.setStringValue(descriptionAnnotation);
-                    }
-
-                    // mappedName
-                    String mappdedNameAnnotation = annotation.mappedName();
-                    if (!mappdedNameAnnotation.equals("")) {
-                        XsdStringType mappedName = resourceEnvRef.addNewMappedName();
-                        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");
-    }
-      */
-
-    /**
-     * Configure Injection Target
-     *
-     * @param injectionTarget
-     * @param method
-     * @param field
-     */
-    /*
-    private static void configureInjectionTarget(InjectionTargetType injectionTarget, Method method, Field field) {
-        log.debug("configureInjectionTarget(): Entry");
-
-        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();
-        }
-        FullyQualifiedClassType qualifiedClass = injectionTarget.addNewInjectionTargetClass();
-        JavaIdentifierType javaType = injectionTarget.addNewInjectionTargetName();
-        qualifiedClass.setStringValue(injectionClass);
-        javaType.setStringValue(injectionJavaType);
-        injectionTarget.setInjectionTargetClass(qualifiedClass);
-        injectionTarget.setInjectionTargetName(javaType);
-
-        log.debug("configureInjectionTarget(): Exit");
-    }
-    */
-
 }

Modified: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/WebServiceRefAnnotationHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/WebServiceRefAnnotationHelper.java?view=diff&rev=525609&r1=525608&r2=525609
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/WebServiceRefAnnotationHelper.java (original)
+++ geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/WebServiceRefAnnotationHelper.java Wed Apr  4 14:20:03 2007
@@ -230,7 +230,7 @@
         //------------------------------------------------------------------------------------------
         Class webServiceRefType = annotation.type();
         Class webServiceRefValue = annotation.value();
-        if (webServiceRefType.equals(Object.class)) {
+        if (webServiceRefType.equals("") || webServiceRefType.equals(Object.class)) {
             if (method != null) {
                 webServiceRefType = method.getParameterTypes()[0];
             } else if (field != null) {
@@ -252,7 +252,7 @@
         //------------------------------------------------------------------------------------------
 
         ServiceRefType serviceRef = null;
-        
+
         ServiceRefType[] serviceRefs = annotatedApp.getServiceRefArray();
         for (ServiceRefType currServiceRef : serviceRefs) {
             if (currServiceRef.getServiceRefName().getStringValue().trim().equals(webServiceRefName)) {
@@ -272,7 +272,8 @@
             // service-ref-name
             JndiNameType serviceRefName = serviceRef.addNewServiceRefName();
             serviceRefName.setStringValue(webServiceRefName);
-        
+            serviceRef.setServiceRefName(serviceRefName);
+
             // service-ref-interface
             if (!webServiceRefValue.equals(Object.class)) {
                 FullyQualifiedClassType qualifiedClass = serviceRef.addNewServiceInterface();
@@ -284,7 +285,7 @@
                 serviceRef.setServiceInterface(qualifiedClass);
             }
         }
-        
+
         //------------------------------------------------------------------------------
         // <service-ref> optional elements:
         //------------------------------------------------------------------------------
@@ -306,7 +307,7 @@
         // WSDL document location
         if (!serviceRef.isSetWsdlFile()) {
             String wsdlLocation = annotation.wsdlLocation();
-            
+
             if (wsdlLocation == null || wsdlLocation.trim().length() == 0) {
                 WebServiceClient wsClient = null;
                 if (Object.class.equals(webServiceRefValue)) {
@@ -314,13 +315,13 @@
                 } else {
                     wsClient = (WebServiceClient) webServiceRefValue.getAnnotation(WebServiceClient.class);
                 }
-                if (wsClient == null) {                    
+                if (wsClient == null) {
                     wsdlLocation = null;
                 } else {
                     wsdlLocation = wsClient.wsdlLocation();
                 }
             }
-            
+
             if (wsdlLocation != null && wsdlLocation.trim().length() > 0) {
                 XsdAnyURIType wsdlFile = serviceRef.addNewWsdlFile();
                 wsdlFile.setStringValue(wsdlLocation);



Mime
View raw message