geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r516573 - in /geronimo/server/trunk/modules: geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/ geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/
Date Fri, 09 Mar 2007 21:52:27 GMT
Author: djencks
Date: Fri Mar  9 13:52:27 2007
New Revision: 516573

URL: http://svn.apache.org/viewvc?view=rev&rev=516573
Log:
GERONIMO-2837 Even if a resource-ref etc is already there, we need to check whether to add
injection targets to it

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/ResourceAnnotationHelper.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=516573&r1=516572&r2=516573
==============================================================================
--- 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
Fri Mar  9 13:52:27 2007
@@ -305,13 +305,25 @@
             MessageDestinationRefType[] messageDestinationRefs = annotatedApp.getMessageDestinationRefArray();
             for (MessageDestinationRefType messageDestinationRef : messageDestinationRefs)
{
                 if (messageDestinationRef.getMessageDestinationRefName().getStringValue().trim().equals(resourceName))
{
-                    return false;
+                    if (method != null || field != null) {
+                        InjectionTargetType[] targets = messageDestinationRef.getInjectionTargetArray();
+                        if (!hasTarget(method, field, targets)) {
+                            configureInjectionTarget(messageDestinationRef.addNewInjectionTarget(),
method, field);
+                        }
+                    }
+                    return true;
                 }
             }
             ResourceEnvRefType[] ResourceEnvRefs = annotatedApp.getResourceEnvRefArray();
             for (ResourceEnvRefType resourceEnvRefType : ResourceEnvRefs) {
                 if (resourceEnvRefType.getResourceEnvRefName().getStringValue().trim().equals(resourceName))
{
-                    return false;
+                    if (method != null || field != null) {
+                        InjectionTargetType[] targets = resourceEnvRefType.getInjectionTargetArray();
+                        if (!hasTarget(method, field, targets)) {
+                            configureInjectionTarget(resourceEnvRefType.addNewInjectionTarget(),
method, field);
+                        }
+                    }
+                    return true;
                 }
             }
 

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=516573&r1=516572&r2=516573
==============================================================================
--- 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
Fri Mar  9 13:52:27 2007
@@ -267,6 +267,12 @@
                 ResourceRefType[] resourceRefs = annotatedApp.getResourceRefArray();
                 for (ResourceRefType resourceRef : resourceRefs) {
                     if (resourceRef.getResRefName().getStringValue().trim().equals(resourceName))
{
+                        if (method != null || field != null) {
+                            InjectionTargetType[] targets = resourceRef.getInjectionTargetArray();
+                            if (!hasTarget(method, field, targets)) {
+                                configureInjectionTarget(resourceRef.addNewInjectionTarget(),
method, field);
+                            }
+                        }
                         exists = true;
                         break;
                     }

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=516573&r1=516572&r2=516573
==============================================================================
--- 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
Fri Mar  9 13:52:27 2007
@@ -238,6 +238,40 @@
             return resourceType;
         }
 
+        protected static String getInjectionJavaType(Method method, Field field) {
+            if (method != null) {
+                String injectionJavaType = method.getName().substring(3);
+                StringBuilder stringBuilder = new StringBuilder(injectionJavaType);
+                stringBuilder.setCharAt(0, Character.toLowerCase(stringBuilder.charAt(0)));
+                return stringBuilder.toString();
+            } else if (field != null) {
+                return field.getName();
+            } else {
+                throw new IllegalArgumentException("You must supply exactly one of Method,
Field");
+            }
+        }
+
+        protected static String getInjectionClass(Method method, Field field) {
+            if (method != null) {
+                return method.getDeclaringClass().getName();
+            } else if (field != null) {
+                return field.getDeclaringClass().getName();
+            } else {
+                throw new IllegalArgumentException("You must supply exactly one of Method,
Field");
+            }
+        }
+
+        protected static boolean hasTarget(Method method, Field field, InjectionTargetType[]
targets) {
+            String injectionJavaType = getInjectionJavaType(method, field);
+            String injectionClass = getInjectionClass(method, field);
+            for (InjectionTargetType target : targets) {
+                if (injectionClass.equals(target.getInjectionTargetClass().getStringValue().trim())
+                        && injectionJavaType.equals(target.getInjectionTargetName().getStringValue().trim()))
{
+                    return true;
+                }
+            }
+            return false;
+        }
         /**
          * Configure Injection Target
          *
@@ -248,18 +282,9 @@
         protected 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();
-            }
+            String injectionJavaType = getInjectionJavaType(method, field);
+            String injectionClass = getInjectionClass(method, field);
+
             FullyQualifiedClassType qualifiedClass = injectionTarget.addNewInjectionTargetClass();
             JavaIdentifierType javaType = injectionTarget.addNewInjectionTargetName();
             qualifiedClass.setStringValue(injectionClass);



Mime
View raw message