geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r516650 - in /geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation: AnnotationHelper.java ResourceAnnotationHelper.java WebServiceRefAnnotationHelper.java
Date Sat, 10 Mar 2007 04:34:33 GMT
Author: djencks
Date: Fri Mar  9 20:34:32 2007
New Revision: 516650

URL: http://svn.apache.org/viewvc?view=rev&rev=516650
Log:
GERONIMO-2934 Fix the SwitchingServiceRefBuilder to add injections to existing service-ref
xml as necesary

Added:
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotationHelper.java
  (with props)
Modified:
    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

Added: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotationHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotationHelper.java?view=auto&rev=516650
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotationHelper.java
(added)
+++ geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotationHelper.java
Fri Mar  9 20:34:32 2007
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.geronimo.j2ee.deployment.annotation;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Field;
+
+import org.apache.geronimo.xbeans.javaee.InjectionTargetType;
+import org.apache.geronimo.xbeans.javaee.FullyQualifiedClassType;
+import org.apache.geronimo.xbeans.javaee.JavaIdentifierType;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class AnnotationHelper {
+    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
+     *
+     * @param injectionTarget
+     * @param method
+     * @param field
+     */
+    protected static void configureInjectionTarget(InjectionTargetType injectionTarget, Method
method, Field field) {
+
+        String injectionJavaType = getInjectionJavaType(method, field);
+        String injectionClass = getInjectionClass(method, field);
+
+        FullyQualifiedClassType qualifiedClass = injectionTarget.addNewInjectionTargetClass();
+        JavaIdentifierType javaType = injectionTarget.addNewInjectionTargetName();
+        qualifiedClass.setStringValue(injectionClass);
+        javaType.setStringValue(injectionJavaType);
+        injectionTarget.setInjectionTargetClass(qualifiedClass);
+        injectionTarget.setInjectionTargetName(javaType);
+
+    }
+}

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

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

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

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=516650&r1=516649&r2=516650
==============================================================================
--- 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 20:34:32 2007
@@ -75,7 +75,7 @@
  * @version $Rev$ $Date$
  * @since 02-2007
  */
-public final class ResourceAnnotationHelper {
+public final class ResourceAnnotationHelper extends AnnotationHelper {
 
     // Private instance variables
     private static final Log log = LogFactory.getLog(ResourceAnnotationHelper.class);
@@ -187,7 +187,7 @@
         log.debug("processResources(): Exit");
     }
 
-    public abstract static class ResourceProcessor {
+    public abstract static class ResourceProcessor extends AnnotationHelper {
 
         public abstract boolean processResource(AnnotatedApp annotatedApp, Resource annotation,
Class cls, Method method, Field field) throws DeploymentException;
 
@@ -237,66 +237,8 @@
             }
             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
-         *
-         * @param injectionTarget
-         * @param method
-         * @param field
-         */
-        protected static void configureInjectionTarget(InjectionTargetType injectionTarget,
Method method, Field field) {
-            log.debug("configureInjectionTarget(): Entry");
-
-            String injectionJavaType = getInjectionJavaType(method, field);
-            String injectionClass = getInjectionClass(method, field);
-
-            FullyQualifiedClassType qualifiedClass = injectionTarget.addNewInjectionTargetClass();
-            JavaIdentifierType javaType = injectionTarget.addNewInjectionTargetName();
-            qualifiedClass.setStringValue(injectionClass);
-            javaType.setStringValue(injectionJavaType);
-            injectionTarget.setInjectionTargetClass(qualifiedClass);
-            injectionTarget.setInjectionTargetName(javaType);
-
-            log.debug("configureInjectionTarget(): Exit");
-        }
     }
 
-
     /**
      * Add @Resource and @Resources annotations to the deployment descriptor. XMLBeans are
used to
      * read and manipulate the deployment descriptor as necessary. The Resource annotation(s)
will be
@@ -326,6 +268,7 @@
      * @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' +
@@ -776,7 +719,7 @@
         }
         log.debug("addResource(): Exit");
     }
-
+      */
 
     /**
      * Configure Injection Target
@@ -785,6 +728,7 @@
      * @param method
      * @param field
      */
+    /*
     private static void configureInjectionTarget(InjectionTargetType injectionTarget, Method
method, Field field) {
         log.debug("configureInjectionTarget(): Entry");
 
@@ -809,7 +753,7 @@
 
         log.debug("configureInjectionTarget(): Exit");
     }
-
+    */
 
     /**
      * Validate deployment descriptor

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=516650&r1=516649&r2=516650
==============================================================================
--- 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
Fri Mar  9 20:34:32 2007
@@ -64,7 +64,7 @@
  * @version $Rev $Date
  * @since 03-2007
  */
-public final class WebServiceRefAnnotationHelper {
+public final class WebServiceRefAnnotationHelper extends AnnotationHelper {
 
     // Private instance variables
     private static final Log log = LogFactory.getLog(WebServiceRefAnnotationHelper.class);
@@ -254,19 +254,8 @@
         // -- 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();
-        }
+        String injectionJavaType = getInjectionJavaType(method, field);
+        String injectionClass = getInjectionClass(method, field);
         log.debug("addWebServiceRef(): injectionJavaType: " + injectionJavaType);
         log.debug("addWebServiceRef(): injectionClass   : " + injectionClass);
 
@@ -278,8 +267,13 @@
         ServiceRefType[] serviceRefs = annotatedApp.getServiceRefArray();
         for ( ServiceRefType serviceRef : serviceRefs ) {
             if ( serviceRef.getServiceRefName().getStringValue().trim().equals(webServiceRefName)
) {
-                exists = true;
-                break;
+                if (method != null || field != null) {
+                    InjectionTargetType[] targets = serviceRef.getInjectionTargetArray();
+                    if (!hasTarget(method, field, targets)) {
+                        configureInjectionTarget(serviceRef.addNewInjectionTarget(), method,
field);
+                    }
+                }
+                return;
             }
         }
         if ( !exists ) {
@@ -348,7 +342,7 @@
     /**
      * Validate deployment descriptor
      *
-     * @param AnnotatedApp
+     * @parama annotatedApp
      * @throws Exception thrown if deployment descriptor cannot be parsed
      */
     private static void validateDD(AnnotatedApp annotatedApp) throws Exception {
@@ -358,4 +352,5 @@
 
         log.debug("validateDD(): Exit");
     }
+
 }



Mime
View raw message