geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r699350 - in /geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src: main/java/org/apache/geronimo/j2ee/deployment/annotation/ test/java/org/apache/geronimo/j2ee/deployment/annotation/ test/resources/annotation/
Date Fri, 26 Sep 2008 14:57:43 GMT
Author: gawor
Date: Fri Sep 26 07:57:42 2008
New Revision: 699350

URL: http://svn.apache.org/viewvc?rev=699350&view=rev
Log:
fix injection of multiple @EJB objects with the same name, plus better reuse of code (GERONIMO-4210)

Modified:
    geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotationHelper.java
    geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/EJBAnnotationHelper.java
    geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/HandlerChainAnnotationHelper.java
    geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/PersistenceContextAnnotationHelper.java
    geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/PersistenceUnitAnnotationHelper.java
    geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/ResourceAnnotationHelper.java
    geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/WebServiceRefAnnotationHelper.java
    geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotationHelperTest.java
    geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/annotation/EJBAnnotationTest.java
    geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/test/resources/annotation/ejb-expected.xml

Modified: geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotationHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotationHelper.java?rev=699350&r1=699349&r2=699350&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotationHelper.java
(original)
+++ geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotationHelper.java
Fri Sep 26 07:57:42 2008
@@ -34,6 +34,21 @@
  * @version $Rev$ $Date$
  */
 public class AnnotationHelper {
+    
+    protected static String getName(String name, Method method, Field field) {
+        String resourceName = 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();
+            }
+        }
+        return resourceName;
+    }
+    
     protected static String getInjectionJavaType(Method method, Field field) {
         if (method != null) {
             String injectionJavaType = method.getName().substring(3);

Modified: geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/EJBAnnotationHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/EJBAnnotationHelper.java?rev=699350&r1=699349&r2=699350&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/EJBAnnotationHelper.java
(original)
+++ geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/EJBAnnotationHelper.java
Fri Sep 26 07:57:42 2008
@@ -32,15 +32,12 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
 import org.apache.geronimo.xbeans.javaee.DescriptionType;
 import org.apache.geronimo.xbeans.javaee.EjbLinkType;
 import org.apache.geronimo.xbeans.javaee.EjbLocalRefType;
 import org.apache.geronimo.xbeans.javaee.EjbRefNameType;
 import org.apache.geronimo.xbeans.javaee.EjbRefType;
-import org.apache.geronimo.xbeans.javaee.FullyQualifiedClassType;
 import org.apache.geronimo.xbeans.javaee.InjectionTargetType;
-import org.apache.geronimo.xbeans.javaee.JavaIdentifierType;
 import org.apache.geronimo.xbeans.javaee.LocalType;
 import org.apache.geronimo.xbeans.javaee.RemoteType;
 import org.apache.geronimo.xbeans.javaee.XsdStringType;
@@ -73,7 +70,7 @@
  * @since 02-2007
  */
 
-public final class EJBAnnotationHelper {
+public final class EJBAnnotationHelper extends AnnotationHelper {
 
     // Private instance variables
     private static final Log log = LogFactory.getLog(EJBAnnotationHelper.class);
@@ -265,30 +262,24 @@
 
             log.debug("addEJB(): <ejb-local-ref> found");
 
-            String localRefName = annotation.name();
-            if (localRefName.equals("")) {
-                if (method != null) {
-                    localRefName = method.getDeclaringClass().getName() + "/" + method.getName().substring(3);
 // method should start with "set"
-                } else if (field != null) {
-                    localRefName = field.getDeclaringClass().getName() + "/" + field.getName();
-                }
-            }
+            String localRefName = getName(annotation.name(), method, field);
 
-            boolean exists = false;
+            EjbLocalRefType ejbLocalRef = null;
+            
             EjbLocalRefType[] ejbLocalRefEntries = annotatedApp.getEjbLocalRefArray();
             for (EjbLocalRefType ejbLocalRefEntry : ejbLocalRefEntries) {
                 if (ejbLocalRefEntry.getEjbRefName().getStringValue().trim().equals(localRefName))
{
-                    exists = true;
+                    ejbLocalRef = ejbLocalRefEntry;
                     break;
                 }
             }
-            if (!exists) {
+            if (ejbLocalRef == null) {
                 try {
 
                     log.debug("addEJB(): Does not exist in DD: " + localRefName);
 
                     // Doesn't exist in deployment descriptor -- add new
-                    EjbLocalRefType ejbLocalRef = annotatedApp.addNewEjbLocalRef();
+                    ejbLocalRef = annotatedApp.addNewEjbLocalRef();
 
                     //------------------------------------------------------------------------------
                     // <ejb-local-ref> required elements:
@@ -335,30 +326,17 @@
                         DescriptionType description = ejbLocalRef.addNewDescription();
                         description.setStringValue(descriptionAnnotation);
                     }
-
-                    // injectionTarget
-                    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);
-                        }
-                    }
-
                 }
-                catch (Exception anyException) {
-                    log.debug("EJBAnnotationHelper: Exception caught while processing <ejb-local-ref>");
-                    anyException.printStackTrace();
+                catch (Exception e) {
+                    log.debug("EJBAnnotationHelper: Exception caught while processing <ejb-local-ref>",
e);
+                }
+            }
+            
+            // injectionTarget
+            if (method != null || field != null) {
+                InjectionTargetType[] targets = ejbLocalRef.getInjectionTargetArray();
+                if (!hasTarget(method, field, targets)) {
+                    configureInjectionTarget(ejbLocalRef.addNewInjectionTarget(), method,
field);
                 }
             }
         }                                                                           // end
if local
@@ -370,30 +348,24 @@
 
             log.debug("addEJB(): <ejb-ref> found");
 
-            String remoteRefName = annotation.name();
-            if (remoteRefName.equals("")) {
-                if (method != null) {
-                    remoteRefName = method.getDeclaringClass().getName() + "/" + method.getName().substring(3);
// method should start with "set"
-                } else if (field != null) {
-                    remoteRefName = field.getDeclaringClass().getName() + "/" + field.getName();
-                }
-            }
+            String remoteRefName = getName(annotation.name(), method, field);
+
+            EjbRefType ejbRef = null;
 
-            boolean exists = false;
             EjbRefType[] ejbRefEntries = annotatedApp.getEjbRefArray();
             for (EjbRefType ejbRefEntry : ejbRefEntries) {
                 if (ejbRefEntry.getEjbRefName().getStringValue().trim().equals(remoteRefName))
{
-                    exists = true;
+                    ejbRef = ejbRefEntry;
                     break;
                 }
             }
-            if (!exists) {
+            if (ejbRef == null) {
                 try {
 
                     log.debug("addEJB(): Does not exist in DD: " + remoteRefName);
 
                     // Doesn't exist in deployment descriptor -- add new
-                    EjbRefType ejbRef = annotatedApp.addNewEjbRef();
+                    ejbRef = annotatedApp.addNewEjbRef();
 
                     //------------------------------------------------------------------------------
                     // <ejb-ref> required elements:
@@ -440,30 +412,17 @@
                         DescriptionType description = ejbRef.addNewDescription();
                         description.setStringValue(descriptionAnnotation);
                     }
-
-                    // injectionTarget
-                    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);
-                        }
-                    }
-
                 }
-                catch (Exception anyException) {
-                    log.debug("EJBAnnotationHelper: Exception caught while processing <ejb-ref>");
-                    anyException.printStackTrace();
+                catch (Exception e) {
+                    log.debug("EJBAnnotationHelper: Exception caught while processing <ejb-ref>",
e);
+                }
+            }
+            
+            // injectionTarget
+            if (method != null || field != null) {
+                InjectionTargetType[] targets = ejbRef.getInjectionTargetArray();
+                if (!hasTarget(method, field, targets)) {
+                    configureInjectionTarget(ejbRef.addNewInjectionTarget(), method, field);
                 }
             }
         }                                                                           // end
if remote
@@ -474,31 +433,25 @@
             //--------------------------------------------------------------------------------------
             log.debug("addEJB(): <UNKNOWN> found");
 
-            String remoteRefName = annotation.name();
-            if (remoteRefName.equals("")) {
-                if (method != null) {
-                    remoteRefName = method.getDeclaringClass().getName() + "/" + method.getName().substring(3);
// method should start with "set"
-                } else if (field != null) {
-                    remoteRefName = field.getDeclaringClass().getName() + "/" + field.getName();
-                }
-            }
+            String remoteRefName = getName(annotation.name(), method, field);
+
+            EjbRefType ejbRef = null;
 
-            boolean exists = false;
             EjbRefType[] ejbRefEntries = annotatedApp.getEjbRefArray();
             for (EjbRefType ejbRefEntry : ejbRefEntries) {
                 if (ejbRefEntry.getEjbRefName().getStringValue().trim().equals(remoteRefName))
{
-                    exists = true;
+                    ejbRef = ejbRefEntry;
                     break;
                 }
             }
-            if (!exists) {
+            if (ejbRef == null) {
                 try {
 
                     log.debug("addEJB(): Does not exist in DD: " + remoteRefName);
 
                     // Doesn't exist in deployment descriptor -- add as an <ejb-ref>
to the
                     // ambiguous list so that it can be resolved later
-                    EjbRefType ejbRef = EjbRefType.Factory.newInstance();
+                    ejbRef = EjbRefType.Factory.newInstance();
                     annotatedApp.getAmbiguousEjbRefs().add(ejbRef);
 
                     //------------------------------------------------------------------------------
@@ -546,30 +499,17 @@
                         DescriptionType description = ejbRef.addNewDescription();
                         description.setStringValue(descriptionAnnotation);
                     }
-
-                    // injectionTarget
-                    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);
-                        }
-                    }
-
                 }
-                catch (Exception anyException) {
-                    log.debug("EJBAnnotationHelper: Exception caught while processing <UNKNOWN>");
-                    anyException.printStackTrace();
+                catch (Exception e) {
+                    log.debug("EJBAnnotationHelper: Exception caught while processing <UNKNOWN>",
e);
+                }                
+            }
+            
+            // injectionTarget
+            if (method != null || field != null) {
+                InjectionTargetType[] targets = ejbRef.getInjectionTargetArray();
+                if (!hasTarget(method, field, targets)) {
+                    configureInjectionTarget(ejbRef.addNewInjectionTarget(), method, field);
                 }
             }
 
@@ -577,18 +517,4 @@
         log.debug("addEJB(): Exit");
     }
 
-
-    /**
-     * Validate deployment descriptor
-     *
-     * @param annotatedApp
-     * @throws Exception thrown if deployment descriptor cannot be parsed
-     */
-    private static void validateDD(AnnotatedApp annotatedApp) throws Exception {
-        log.debug("validateDD( " + annotatedApp.toString() + " ): Entry");
-
-        XmlBeansUtil.parse(annotatedApp.toString());
-
-        log.debug("validateDD(): Exit");
-    }
 }

Modified: geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/HandlerChainAnnotationHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/HandlerChainAnnotationHelper.java?rev=699350&r1=699349&r2=699350&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/HandlerChainAnnotationHelper.java
(original)
+++ geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/HandlerChainAnnotationHelper.java
Fri Sep 26 07:57:42 2008
@@ -39,7 +39,6 @@
 import org.apache.geronimo.xbeans.javaee.ServiceRefHandlerType;
 import org.apache.geronimo.xbeans.javaee.ServiceRefType;
 import org.apache.xbean.finder.ClassFinder;
-import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 
 

Modified: geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/PersistenceContextAnnotationHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/PersistenceContextAnnotationHelper.java?rev=699350&r1=699349&r2=699350&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/PersistenceContextAnnotationHelper.java
(original)
+++ geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/PersistenceContextAnnotationHelper.java
Fri Sep 26 07:57:42 2008
@@ -31,8 +31,6 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.common.DeploymentException;
-import org.apache.geronimo.xbeans.javaee.DescriptionType;
-import org.apache.geronimo.xbeans.javaee.FullyQualifiedClassType;
 import org.apache.geronimo.xbeans.javaee.InjectionTargetType;
 import org.apache.geronimo.xbeans.javaee.JndiNameType;
 import org.apache.geronimo.xbeans.javaee.PersistenceContextRefType;
@@ -207,16 +205,8 @@
         // -- When annotation is applied on a field:    Name is the field name qualified
by the
         //                                              class (or as provided on the annotation)
         //------------------------------------------------------------------------------------------
-        String persistenceContextRefName = annotation.name();
-        if (persistenceContextRefName.equals("")) {
-            if (method != null) {
-                StringBuilder stringBuilder = new StringBuilder(method.getName().substring(3));
-                stringBuilder.setCharAt(0, Character.toLowerCase(stringBuilder.charAt(0)));
-                persistenceContextRefName = method.getDeclaringClass().getName() + "/" +
stringBuilder.toString();
-            } else if (field != null) {
-                persistenceContextRefName = field.getDeclaringClass().getName() + "/" + field.getName();
-            }
-        }
+        String persistenceContextRefName = getName(annotation.name(), method, field);
+
         log.debug("addPersistenceContext(): PersistenceContextRefName: " + persistenceContextRefName);
 
         // If there is already xml for the persistence context ref, just add injection targets
and return.

Modified: geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/PersistenceUnitAnnotationHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/PersistenceUnitAnnotationHelper.java?rev=699350&r1=699349&r2=699350&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/PersistenceUnitAnnotationHelper.java
(original)
+++ geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/PersistenceUnitAnnotationHelper.java
Fri Sep 26 07:57:42 2008
@@ -29,12 +29,9 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.common.DeploymentException;
-import org.apache.geronimo.xbeans.javaee.DescriptionType;
-import org.apache.geronimo.xbeans.javaee.FullyQualifiedClassType;
 import org.apache.geronimo.xbeans.javaee.InjectionTargetType;
 import org.apache.geronimo.xbeans.javaee.JndiNameType;
 import org.apache.geronimo.xbeans.javaee.PersistenceUnitRefType;
-import org.apache.geronimo.xbeans.javaee.XsdAnyURIType;
 import org.apache.xbean.finder.ClassFinder;
 
 
@@ -204,16 +201,8 @@
         // -- When annotation is applied on a field:    Name is the field name qualified
by the
         //                                              class (or as provided on the annotation)
         //------------------------------------------------------------------------------------------
-        String persistenceUnitRefName = annotation.name();
-        if (persistenceUnitRefName.equals("")) {
-            if (method != null) {
-                StringBuilder stringBuilder = new StringBuilder(method.getName().substring(3));
-                stringBuilder.setCharAt(0, Character.toLowerCase(stringBuilder.charAt(0)));
-                persistenceUnitRefName = method.getDeclaringClass().getName() + "/" + stringBuilder.toString();
-            } else if (field != null) {
-                persistenceUnitRefName = field.getDeclaringClass().getName() + "/" + field.getName();
-            }
-        }
+        String persistenceUnitRefName = getName(annotation.name(), method, field);
+
         log.debug("addPersistenceUnit(): persistenceUnitRefName: " + persistenceUnitRefName);
 
         // If there is already xml for the persistence unit ref, just add injection targets
and return.

Modified: geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/ResourceAnnotationHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/ResourceAnnotationHelper.java?rev=699350&r1=699349&r2=699350&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/ResourceAnnotationHelper.java
(original)
+++ geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/ResourceAnnotationHelper.java
Fri Sep 26 07:57:42 2008
@@ -176,17 +176,7 @@
          * @return
          */
         protected static String getResourceName(Resource annotation, Method method, Field
field) {
-            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();
-                }
-            }
-            return resourceName;
+            return getName(annotation.name(), method, field);
         }
 
         protected static String getResourceType(Resource annotation, Method method, Field
field) {

Modified: geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/WebServiceRefAnnotationHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/WebServiceRefAnnotationHelper.java?rev=699350&r1=699349&r2=699350&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/WebServiceRefAnnotationHelper.java
(original)
+++ geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/WebServiceRefAnnotationHelper.java
Fri Sep 26 07:57:42 2008
@@ -204,16 +204,8 @@
         // -- When annotation is applied on a field:    Name is the field name qualified
by the
         //                                              class (or as provided on the annotation)
         //------------------------------------------------------------------------------------------
-        String webServiceRefName = annotation.name();
-        if (webServiceRefName.equals("")) {
-            if (method != null) {
-                StringBuilder stringBuilder = new StringBuilder(method.getName().substring(3));
-                stringBuilder.setCharAt(0, Character.toLowerCase(stringBuilder.charAt(0)));
-                webServiceRefName = method.getDeclaringClass().getName() + "/" + stringBuilder.toString();
-            } else if (field != null) {
-                webServiceRefName = field.getDeclaringClass().getName() + "/" + field.getName();
-            }
-        }
+        String webServiceRefName = getName(annotation.name(), method, field);
+
         log.debug("addWebServiceRef(): webServiceRefName: " + webServiceRefName);
 
         //------------------------------------------------------------------------------------------

Modified: geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotationHelperTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotationHelperTest.java?rev=699350&r1=699349&r2=699350&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotationHelperTest.java
(original)
+++ geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotationHelperTest.java
Fri Sep 26 07:57:42 2008
@@ -102,10 +102,14 @@
 
         List<Field> annotatedFields = classFinder.findAnnotatedFields(EJB.class);
         assertNotNull(annotatedFields);
-        assertEquals(2, annotatedFields.size());
+        assertEquals(6, annotatedFields.size());
         assertTrue(annotatedFields.contains(EJBAnnotationTest.class.getDeclaredField("annotatedField1")));
         assertTrue(annotatedFields.contains(EJBAnnotationTest.class.getDeclaredField("annotatedField2")));
-
+        assertTrue(annotatedFields.contains(EJBAnnotationTest.class.getDeclaredField("annotatedField3")));
+        assertTrue(annotatedFields.contains(EJBAnnotationTest.class.getDeclaredField("annotatedField4")));
+        assertTrue(annotatedFields.contains(EJBAnnotationTest.class.getDeclaredField("annotatedField5")));
+        assertTrue(annotatedFields.contains(EJBAnnotationTest.class.getDeclaredField("annotatedField6")));
+        
         //-------------------------------------------------
         // Ensure annotations are processed correctly
         //-------------------------------------------------

Modified: geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/annotation/EJBAnnotationTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/annotation/EJBAnnotationTest.java?rev=699350&r1=699349&r2=699350&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/annotation/EJBAnnotationTest.java
(original)
+++ geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/annotation/EJBAnnotationTest.java
Fri Sep 26 07:57:42 2008
@@ -89,5 +89,21 @@
          mappedName = "mappedName11")
     public void setAnnotatedMethod2(String string) {
     }
+    
+    @EJB(name="myejb1", 
+         beanInterface = javax.ejb.EJBLocalHome.class)
+    Object annotatedField3;
+    
+    @EJB(name="myejb1", 
+         beanInterface = javax.ejb.EJBLocalHome.class)
+    Object annotatedField4;
+    
+    @EJB(name="myejb2", 
+         beanInterface = javax.ejb.EJBHome.class)
+    Object annotatedField5;
+       
+    @EJB(name="myejb2", 
+         beanInterface = javax.ejb.EJBHome.class)
+    Object annotatedField6;
 }
 

Modified: geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/test/resources/annotation/ejb-expected.xml
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/test/resources/annotation/ejb-expected.xml?rev=699350&r1=699349&r2=699350&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/test/resources/annotation/ejb-expected.xml
(original)
+++ geronimo/server/branches/2.1/plugins/j2ee/geronimo-j2ee-builder/src/test/resources/annotation/ejb-expected.xml
Fri Sep 26 07:57:42 2008
@@ -68,5 +68,29 @@
             <injection-target-name>AnnotatedMethod1</injection-target-name>
         </injection-target>
     </ejb-local-ref>
+    <ejb-local-ref>
+        <ejb-ref-name>myejb1</ejb-ref-name>
+        <local>javax.ejb.EJBLocalHome</local>
+        <injection-target>
+            <injection-target-class>org.apache.geronimo.j2ee.deployment.annotation.EJBAnnotationTest</injection-target-class>
+            <injection-target-name>annotatedField3</injection-target-name>
+        </injection-target>
+        <injection-target>
+            <injection-target-class>org.apache.geronimo.j2ee.deployment.annotation.EJBAnnotationTest</injection-target-class>
+            <injection-target-name>annotatedField4</injection-target-name>
+        </injection-target>
+    </ejb-local-ref>
+    <ejb-ref>
+        <ejb-ref-name>myejb2</ejb-ref-name>
+        <remote>javax.ejb.EJBHome</remote>
+        <injection-target>
+            <injection-target-class>org.apache.geronimo.j2ee.deployment.annotation.EJBAnnotationTest</injection-target-class>
+            <injection-target-name>annotatedField5</injection-target-name>
+        </injection-target>
+        <injection-target>
+            <injection-target-class>org.apache.geronimo.j2ee.deployment.annotation.EJBAnnotationTest</injection-target-class>
+            <injection-target-name>annotatedField6</injection-target-name>
+        </injection-target>
+    </ejb-ref>
 
 </web-app>



Mime
View raw message