geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r986048 - in /geronimo/server/trunk/plugins: connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/ j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/ j2ee/...
Date Mon, 16 Aug 2010 16:58:00 GMT
Author: gawor
Date: Mon Aug 16 16:58:00 2010
New Revision: 986048

URL: http://svn.apache.org/viewvc?rev=986048&view=rev
Log:
Annotation processing improvements and support for @EJB.lookup

Modified:
    geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/ResourceRefBuilder.java
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotationHelper.java
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/EJBAnnotationHelper.java
    geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/AbstractNamingBuilder.java
    geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java

Modified: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/ResourceRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/ResourceRefBuilder.java?rev=986048&r1=986047&r2=986048&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/ResourceRefBuilder.java
(original)
+++ geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/ResourceRefBuilder.java
Mon Aug 16 16:58:00 2010
@@ -353,27 +353,15 @@ public class ResourceRefBuilder extends 
 
                 log.debug("processResource(): <resource-ref> found");
 
-                boolean exists = false;
-                Collection<ResourceRef> resourceRefs = annotatedApp.getResourceRef();
-                for (ResourceRef resourceRef : resourceRefs) {
-                    if (resourceRef.getResRefName().trim().equals(resourceName)) {
-                        if (method != null || field != null) {
-                            List<InjectionTarget> targets = resourceRef.getInjectionTarget();
-                            if (!hasTarget(method, field, targets)) {
-                                resourceRef.getInjectionTarget().add(configureInjectionTarget(method,
field));
-                            }
-                        }
-                        exists = true;
-                        break;
-                    }
-                }
-                if (!exists) {
+                ResourceRef resourceRef = annotatedApp.getResourceRefMap().get(getJndiName(resourceName));
+
+                if (resourceRef == null) {
                     try {
 
                         log.debug("processResource(): Does not exist in DD: " + resourceName);
 
                         // Doesn't exist in deployment descriptor -- add new
-                        ResourceRef resourceRef = new ResourceRef();
+                        resourceRef = new ResourceRef();
 
                         //------------------------------------------------------------------------------
                         // <resource-ref> required elements:
@@ -386,10 +374,6 @@ public class ResourceRefBuilder extends 
                             // resource-ref-type
                             resourceRef.setResType(resourceType);
                         }
-                        if (method != null || field != null) {
-                            // injectionTarget
-                            resourceRef.getInjectionTarget().add(configureInjectionTarget(method,
field));
-                        }
 
                         //------------------------------------------------------------------------------
                         // <resource-ref> optional elements:
@@ -428,8 +412,17 @@ public class ResourceRefBuilder extends 
                         log.debug("ResourceRefBuilder: Exception caught while processing
<resource-ref>");
                     }
                 }
+                
+                if (method != null || field != null) {
+                    List<InjectionTarget> targets = resourceRef.getInjectionTarget();
+                    if (!hasTarget(method, field, targets)) {
+                        resourceRef.getInjectionTarget().add(configureInjectionTarget(method,
field));
+                    }
+                }
+                
                 return true;
             }
+            
             return false;
         }
     }

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotationHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotationHelper.java?rev=986048&r1=986047&r2=986048&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotationHelper.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotationHelper.java
Mon Aug 16 16:58:00 2010
@@ -96,6 +96,14 @@ public class AnnotationHelper {
         return injectionTarget;
     }
 
+    protected static String getJndiName(String name) {
+        if (name.indexOf(':') == -1) {   
+            return "java:comp/env/" + name.trim();
+        } else {
+            return name.trim();
+        }
+    }
+    
     /**
      * Validate deployment descriptor
      *

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/EJBAnnotationHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/EJBAnnotationHelper.java?rev=986048&r1=986047&r2=986048&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/EJBAnnotationHelper.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/EJBAnnotationHelper.java
Mon Aug 16 16:58:00 2010
@@ -21,7 +21,6 @@ import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.List;
 
 import javax.ejb.EJB;
@@ -261,18 +260,11 @@ public final class EJBAnnotationHelper e
 
             String localRefName = getName(annotation.name(), method, field);
 
-            EjbLocalRef ejbLocalRef = null;
-            
-            Collection<EjbLocalRef> ejbLocalRefEntries = annotatedApp.getEjbLocalRef();
-            for (EjbLocalRef ejbLocalRefEntry : ejbLocalRefEntries) {
-                if (ejbLocalRefEntry.getEjbRefName().trim().equals(localRefName)) {
-                    ejbLocalRef = ejbLocalRefEntry;
-                    break;
-                }
-            }
+            EjbLocalRef ejbLocalRef = annotatedApp.getEjbLocalRefMap().get(getJndiName(localRefName));
+                        
             if (ejbLocalRef == null) {
                 try {
-
+                    
                     log.debug("addEJB(): Does not exist in DD: " + localRefName);
 
                     // Doesn't exist in deployment descriptor -- add new
@@ -308,12 +300,19 @@ public final class EJBAnnotationHelper e
                     if (!mappdedNameAnnotation.isEmpty()) {
                         ejbLocalRef.setMappedName(mappdedNameAnnotation);
                     }
-
+                    
+                    // lookup
+                    String lookupName = annotation.lookup();
+                    if (!lookupName.isEmpty()) {
+                        ejbLocalRef.setLookupName(lookupName);
+                    }
+                    
                     // description
                     String descriptionAnnotation = annotation.description();
                     if (!descriptionAnnotation.isEmpty()) {
                         ejbLocalRef.setDescriptions(new Text[] {new Text(null, descriptionAnnotation)});
                     }
+                    
                     ejbLocalRef.setRefType(EjbReference.Type.LOCAL);
                     annotatedApp.getEjbLocalRef().add(ejbLocalRef);
                 }
@@ -340,15 +339,8 @@ public final class EJBAnnotationHelper e
 
             String remoteRefName = getName(annotation.name(), method, field);
 
-            EjbRef ejbRef = null;
+            EjbRef ejbRef = annotatedApp.getEjbRefMap().get(getJndiName(remoteRefName));
 
-            Collection<EjbRef> ejbRefEntries = annotatedApp.getEjbRef();
-            for (EjbRef ejbRefEntry : ejbRefEntries) {
-                if (ejbRefEntry.getEjbRefName().trim().equals(remoteRefName)) {
-                    ejbRef = ejbRefEntry;
-                    break;
-                }
-            }
             if (ejbRef == null) {
                 try {
 
@@ -388,11 +380,18 @@ public final class EJBAnnotationHelper e
                         ejbRef.setMappedName(mappdedNameAnnotation);
                     }
 
+                    // lookup
+                    String lookupName = annotation.lookup();
+                    if (!lookupName.isEmpty()) {
+                        ejbRef.setLookupName(lookupName);
+                    }
+                    
                     // description
                     String descriptionAnnotation = annotation.description();
                     if (!descriptionAnnotation.isEmpty()) {
                         ejbRef.setDescriptions(new Text[] {new Text(null, descriptionAnnotation)
});
                     }
+                    
                     ejbRef.setRefType(EjbReference.Type.REMOTE);
                     annotatedApp.getEjbRef().add(ejbRef);
                 }
@@ -418,15 +417,8 @@ public final class EJBAnnotationHelper e
 
             String remoteRefName = getName(annotation.name(), method, field);
 
-            EjbRef ejbRef = null;
+            EjbRef ejbRef = annotatedApp.getEjbRefMap().get(getJndiName(remoteRefName));
 
-            Collection<EjbRef> ejbRefEntries = annotatedApp.getEjbRef();
-            for (EjbRef ejbRefEntry : ejbRefEntries) {
-                if (ejbRefEntry.getEjbRefName().trim().equals(remoteRefName)) {
-                    ejbRef = ejbRefEntry;
-                    break;
-                }
-            }
             if (ejbRef == null) {
                 try {
 
@@ -467,12 +459,19 @@ public final class EJBAnnotationHelper e
                         ejbRef.setMappedName(mappdedNameAnnotation);
                     }
 
+                    // lookup
+                    String lookupName = annotation.lookup();
+                    if (!lookupName.isEmpty()) {
+                        ejbRef.setLookupName(lookupName);
+                    }
+                    
                     // description
                     String descriptionAnnotation = annotation.description();
                     if (!descriptionAnnotation.isEmpty()) {
                         ejbRef.setDescriptions(new Text[] {new Text(null, descriptionAnnotation)
});
                     }
-                    ejbRef.setRefType(EjbReference.Type.UNKNOWN);
+                    
+                    ejbRef.setRefType(EjbReference.Type.UNKNOWN);                    
                     //openejb sorts out ambiguous ejb refs.
                     annotatedApp.getEjbRef().add(ejbRef);
                 }

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/AbstractNamingBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/AbstractNamingBuilder.java?rev=986048&r1=986047&r2=986048&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/AbstractNamingBuilder.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/AbstractNamingBuilder.java
Mon Aug 16 16:58:00 2010
@@ -187,9 +187,9 @@ public abstract class AbstractNamingBuil
 
     protected static String getJndiName(String name) {
         if (name.indexOf(':') == -1) {   
-            return "java:comp/env/" + name;
+            return "java:comp/env/" + name.trim();
         } else {
-            return name;
+            return name.trim();
         }
     }
     

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java?rev=986048&r1=986047&r2=986048&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java
Mon Aug 16 16:58:00 2010
@@ -20,7 +20,6 @@ package org.apache.geronimo.naming.deplo
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -241,27 +240,15 @@ public class EnvironmentEntryBuilder ext
             if (knownEnvironmentEntries.contains(resourceType.getName()) || resourceType.isEnum())
{
                 log.debug("addResource(): <env-entry> found");
 
-                boolean exists = false;
-                Collection<EnvEntry> envEntries = annotatedApp.getEnvEntry();
-                for (EnvEntry envEntry : envEntries) {
-                    if (getStringValue(envEntry.getEnvEntryName()).equals(resourceName))
{
-                        exists = true;
-                        if (method != null || field != null) {
-                            List<InjectionTarget> targets = envEntry.getInjectionTarget();
-                            if (!hasTarget(method, field, targets)) {
-                                targets.add(configureInjectionTarget(method, field));
-                            }
-                        }
-                        break;
-                    }
-                }
-                if (!exists) {
+                EnvEntry envEntry = annotatedApp.getEnvEntryMap().get(getJndiName(resourceName));
+                                
+                if (envEntry == null) {
                     try {
-
+                        
                         log.debug("addResource(): Does not exist in DD: " + resourceName);
 
                         // Doesn't exist in deployment descriptor -- add new
-                        EnvEntry envEntry = new EnvEntry();
+                        envEntry = new EnvEntry();
 
                         //------------------------------------------------------------------------------
                         // <env-entry> required elements:
@@ -274,10 +261,6 @@ public class EnvironmentEntryBuilder ext
                             // env-entry-type
                             envEntry.setEnvEntryType(deprimitivize(resourceType).getCanonicalName());
                         }
-                        if (method != null || field != null) {
-                            // injectionTarget
-                            envEntry.getInjectionTarget().add(configureInjectionTarget(method,
field));
-                        }
 
                         //------------------------------------------------------------------------------
                         // <env-entry> optional elements:
@@ -306,7 +289,17 @@ public class EnvironmentEntryBuilder ext
                         log.debug("ResourceAnnotationHelper: Exception caught while processing
<env-entry>");
                     }
                 }
+                
+                if (method != null || field != null) {
+                    List<InjectionTarget> targets = envEntry.getInjectionTarget();
+                    if (!hasTarget(method, field, targets)) {
+                        envEntry.getInjectionTarget().add(configureInjectionTarget(method,
field));
+                    }
+                }
+                
+                return true;
             }
+            
             return false;
         }
     }



Mime
View raw message