geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r704978 - in /geronimo/server/branches/2.1/plugins/j2ee/geronimo-naming-builder/src: main/java/org/apache/geronimo/naming/deployment/ test/resources/annotation/
Date Wed, 15 Oct 2008 18:06:21 GMT
Author: gawor
Date: Wed Oct 15 11:06:21 2008
New Revision: 704978

URL: http://svn.apache.org/viewvc?rev=704978&view=rev
Log:
fixes for resource injection of simple env. entry types (GERONIMO-4361)

Modified:
    geronimo/server/branches/2.1/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java
    geronimo/server/branches/2.1/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/SwitchingServiceRefBuilder.java
    geronimo/server/branches/2.1/plugins/j2ee/geronimo-naming-builder/src/test/resources/annotation/env-entry-expected.xml
    geronimo/server/branches/2.1/plugins/j2ee/geronimo-naming-builder/src/test/resources/annotation/service-ref-expected.xml

Modified: geronimo/server/branches/2.1/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java?rev=704978&r1=704977&r2=704978&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java
(original)
+++ geronimo/server/branches/2.1/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java
Wed Oct 15 11:06:21 2008
@@ -93,7 +93,6 @@
         List<EnvEntryType> envEntriesUntyped = convert(specDD.selectChildren(envEntryQNameSet),
JEE_CONVERTER, EnvEntryType.class, EnvEntryType.type);
         for (EnvEntryType envEntry: envEntriesUntyped) {
             String name = getStringValue(envEntry.getEnvEntryName());
-            addInjections(name, envEntry.getInjectionTargetArray(), componentContext);
             String type = getStringValue(envEntry.getEnvEntryType());
             String text = getStringValue(envEntry.getEnvEntryValue());
             try {
@@ -125,7 +124,12 @@
                 } else {
                     throw new DeploymentException("unrecognized type: " + type);
                 }
-                getJndiContextMap(componentContext).put(ENV + name, value);
+                // perform resource injection only if there is a value specified
+                // see Java EE 5 spec, section EE.5.4.1.3
+                if (value != null) {
+                    addInjections(name, envEntry.getInjectionTargetArray(), componentContext);
+                    getJndiContextMap(componentContext).put(ENV + name, value);
+                }
             } catch (NumberFormatException e) {
                 throw new DeploymentException("Invalid env-entry value for name: " + name,
e);
             }
@@ -197,18 +201,19 @@
                             // env-entry-type
                             EnvEntryTypeValuesType envEntryType = envEntry.addNewEnvEntryType();
                             envEntryType.setStringValue(resourceType);
-                        } else if (method != null || field != null) {
+                        }                         
+                        if (method != null || field != null) {
                             // injectionTarget
                             InjectionTargetType injectionTarget = envEntry.addNewInjectionTarget();
                             configureInjectionTarget(injectionTarget, method, field);
                         }
 
-                        // env-entry-value
+                        // mappedName
                         String mappdedNameAnnotation = annotation.mappedName();
                         if (!mappdedNameAnnotation.equals("")) {
-                            XsdStringType value = envEntry.addNewEnvEntryValue();
-                            value.setStringValue(mappdedNameAnnotation);
-                            envEntry.setMappedName(value);
+                            XsdStringType mappedName = envEntry.addNewMappedName();
+                            mappedName.setStringValue(mappdedNameAnnotation);
+                            envEntry.setMappedName(mappedName);
                         }
 
                         //------------------------------------------------------------------------------

Modified: geronimo/server/branches/2.1/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/SwitchingServiceRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/SwitchingServiceRefBuilder.java?rev=704978&r1=704977&r2=704978&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/SwitchingServiceRefBuilder.java
(original)
+++ geronimo/server/branches/2.1/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/SwitchingServiceRefBuilder.java
Wed Oct 15 11:06:21 2008
@@ -300,6 +300,12 @@
                             serviceRef.setServiceRefType(serviceRefTypeClass);
                         }
 
+                        // injectionTarget
+                        if (method != null || field != null) {
+                            InjectionTargetType injectionTarget = serviceRef.addNewInjectionTarget();
+                            configureInjectionTarget(injectionTarget, method, field);
+                        }
+                        
                         // mappedName
                         if (!serviceRef.isSetMappedName() && annotation.mappedName().trim().length()
> 0) {
                             XsdStringType mappedName = serviceRef.addNewMappedName();

Modified: geronimo/server/branches/2.1/plugins/j2ee/geronimo-naming-builder/src/test/resources/annotation/env-entry-expected.xml
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/j2ee/geronimo-naming-builder/src/test/resources/annotation/env-entry-expected.xml?rev=704978&r1=704977&r2=704978&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/j2ee/geronimo-naming-builder/src/test/resources/annotation/env-entry-expected.xml
(original)
+++ geronimo/server/branches/2.1/plugins/j2ee/geronimo-naming-builder/src/test/resources/annotation/env-entry-expected.xml
Wed Oct 15 11:06:21 2008
@@ -27,12 +27,15 @@
         <description>description1</description>
         <env-entry-name>Resource1</env-entry-name>
         <env-entry-type>java.lang.String</env-entry-type>
-        <env-entry-value>mappedName1</env-entry-value>
         <mapped-name>mappedName1</mapped-name>
     </env-entry>
     <env-entry>
         <env-entry-name>org.apache.geronimo.j2ee.deployment.annotation.ResourceAnnotationTest/annotatedMethod2</env-entry-name>
         <env-entry-type>java.lang.String</env-entry-type>
+        <injection-target>
+             <injection-target-class>org.apache.geronimo.naming.deployment.annotation.ResourceAnnotationTest</injection-target-class>
+             <injection-target-name>annotatedMethod2</injection-target-name>
+        </injection-target>
     </env-entry>
 
 </web-app>

Modified: geronimo/server/branches/2.1/plugins/j2ee/geronimo-naming-builder/src/test/resources/annotation/service-ref-expected.xml
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/j2ee/geronimo-naming-builder/src/test/resources/annotation/service-ref-expected.xml?rev=704978&r1=704977&r2=704978&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/j2ee/geronimo-naming-builder/src/test/resources/annotation/service-ref-expected.xml
(original)
+++ geronimo/server/branches/2.1/plugins/j2ee/geronimo-naming-builder/src/test/resources/annotation/service-ref-expected.xml
Wed Oct 15 11:06:21 2008
@@ -34,6 +34,10 @@
         <service-interface>javax.xml.ws.Service</service-interface>
         <service-ref-type>javax.xml.ws.Service</service-ref-type>
         <mapped-name>mappedName4</mapped-name>
+        <injection-target>
+             <injection-target-class>org.apache.geronimo.naming.deployment.annotation.ResourceAnnotationTest</injection-target-class>
+             <injection-target-name>annotatedField2</injection-target-name>
+        </injection-target>
     </service-ref>
 
 </web-app>



Mime
View raw message