geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r515371 - 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/ geronimo-naming-builder/src/...
Date Tue, 06 Mar 2007 23:41:29 GMT
Author: djencks
Date: Tue Mar  6 15:41:28 2007
New Revision: 515371

URL: http://svn.apache.org/viewvc?view=rev&rev=515371
Log:
GERONIMO-2934 Further refactoring of resource annotation builders.  Removes duplicate processing

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
    geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.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=515371&r1=515370&r2=515371
==============================================================================
--- 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 Tue Mar  6 15:41:28 2007
@@ -17,10 +17,13 @@
 
 package org.apache.geronimo.connector.deployment;
 
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import javax.annotation.Resource;
 import javax.naming.Reference;
 import javax.xml.namespace.QName;
 
@@ -32,6 +35,7 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.j2ee.deployment.Module;
+import org.apache.geronimo.j2ee.deployment.annotation.AnnotatedApp;
 import org.apache.geronimo.j2ee.deployment.annotation.ResourceAnnotationHelper;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
@@ -44,10 +48,15 @@
 import org.apache.geronimo.xbeans.geronimo.naming.GerPatternType;
 import org.apache.geronimo.xbeans.geronimo.naming.GerResourceEnvRefDocument;
 import org.apache.geronimo.xbeans.geronimo.naming.GerResourceEnvRefType;
+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.MessageDestinationRefType;
 import org.apache.geronimo.xbeans.javaee.MessageDestinationType;
+import org.apache.geronimo.xbeans.javaee.MessageDestinationTypeType;
 import org.apache.geronimo.xbeans.javaee.ResourceEnvRefType;
+import org.apache.geronimo.xbeans.javaee.XsdStringType;
 import org.apache.xmlbeans.QNameSet;
 import org.apache.xmlbeans.XmlObject;
 
@@ -56,7 +65,7 @@
  */
 public class AdminObjectRefBuilder extends AbstractNamingBuilder {
     private final static Log log = LogFactory.getLog(AdminObjectRefBuilder.class);
-    private  final QNameSet adminOjbectRefQNameSet;
+    private final QNameSet adminOjbectRefQNameSet;
     private final QNameSet messageDestinationQNameSet;
     private final QNameSet messageDestinationRefQNameSet;
 
@@ -79,7 +88,7 @@
     public void initContext(XmlObject specDD, XmlObject plan, Configuration localConfiguration, Configuration remoteConfiguration, Module module) throws DeploymentException {
         List<MessageDestinationType> specDestinations = convert(specDD.selectChildren(messageDestinationQNameSet), JEE_CONVERTER, MessageDestinationType.class, MessageDestinationType.type);
         XmlObject[] gerDestinations = plan.selectChildren(GER_MESSAGE_DESTINATION_QNAME_SET);
-            Map<String, GerMessageDestinationType> nameMap = new HashMap<String, GerMessageDestinationType>();
+        Map<String, GerMessageDestinationType> nameMap = new HashMap<String, GerMessageDestinationType>();
         for (XmlObject gerDestination : gerDestinations) {
             GerMessageDestinationType destination = (GerMessageDestinationType) gerDestination.copy().changeType(GerMessageDestinationType.type);
             String name = destination.getMessageDestinationName().trim();
@@ -103,14 +112,21 @@
 
         // Discover and process any @Resource annotations (if !metadata-complete)
         if ((module != null) && (module.getClassFinder() != null)) {
-            processAnnotations(module);
+
+            // Process all the annotations for this naming builder type
+            try {
+                ResourceAnnotationHelper.processAnnotations(module.getAnnotatedApp(), module.getClassFinder(), AdminObjectRefProcessor.INSTANCE);
+            }
+            catch (Exception e) {
+                log.warn("Unable to process @Resource annotations for module" + module.getName(), e);
+            }
         }
 
         List<ResourceEnvRefType> resourceEnvRefsUntyped = convert(specDD.selectChildren(adminOjbectRefQNameSet), JEE_CONVERTER, ResourceEnvRefType.class, ResourceEnvRefType.type);
         ClassLoader cl = module.getEarContext().getClassLoader();
-        XmlObject[] gerResourceEnvRefsUntyped = plan == null? NO_REFS: plan.selectChildren(GER_ADMIN_OBJECT_REF_QNAME_SET);
+        XmlObject[] gerResourceEnvRefsUntyped = plan == null ? NO_REFS : plan.selectChildren(GER_ADMIN_OBJECT_REF_QNAME_SET);
         Map refMap = mapResourceEnvRefs(gerResourceEnvRefsUntyped);
-        for (ResourceEnvRefType resourceEnvRef: resourceEnvRefsUntyped) {
+        for (ResourceEnvRefType resourceEnvRef : resourceEnvRefsUntyped) {
             String name = resourceEnvRef.getResourceEnvRefName().getStringValue().trim();
             addInjections(name, resourceEnvRef.getInjectionTargetArray(), componentContext);
             String type = resourceEnvRef.getResourceEnvRefType().getStringValue().trim();
@@ -133,7 +149,7 @@
         //message-destination-refs
         List<MessageDestinationRefType> messageDestinationRefsUntyped = convert(specDD.selectChildren(messageDestinationRefQNameSet), JEE_CONVERTER, MessageDestinationRefType.class, MessageDestinationRefType.type);
 
-        for (MessageDestinationRefType messageDestinationRef: messageDestinationRefsUntyped) {
+        for (MessageDestinationRefType messageDestinationRef : messageDestinationRefsUntyped) {
             String name = getStringValue(messageDestinationRef.getMessageDestinationRefName());
             addInjections(name, messageDestinationRef.getInjectionTargetArray(), componentContext);
             String linkName = getStringValue(messageDestinationRef.getMessageDestinationLink());
@@ -146,7 +162,7 @@
                 //must have an injection target to determine type EE5.8.1.3
                 InjectionTargetType[] targets = messageDestinationRef.getInjectionTargetArray();
                 if (targets.length == 0) {
-                    throw new DeploymentException("No type for message-destination-ref can be determined from explicit specification or injection target: " + messageDestinationRef );
+                    throw new DeploymentException("No type for message-destination-ref can be determined from explicit specification or injection target: " + messageDestinationRef);
                 }
                 type = getStringValue(targets[0].getInjectionTargetClass());
                 if (type == null) {
@@ -250,20 +266,6 @@
         return containerId;
     }
 
-    private void processAnnotations(Module module) throws DeploymentException {
-
-        // Process all the annotations for this naming builder type
-        if (ResourceAnnotationHelper.annotationsPresent(module.getClassFinder())) {
-            try {
-                ResourceAnnotationHelper.processAnnotations(module.getAnnotatedApp(), module.getClassFinder());
-            }
-            catch (Exception e) {
-                log.warn("Unable to process @Resource annotations for module" +
-                module.getName(), e);
-            }
-        }
-    }
-
     private static Map<String, XmlObject> mapResourceEnvRefs(XmlObject[] refs) {
         Map<String, XmlObject> refMap = new HashMap<String, XmlObject>();
         if (refs != null) {
@@ -283,6 +285,156 @@
         return GER_ADMIN_OBJECT_REF_QNAME_SET;
     }
 
+    static class AdminObjectRefProcessor extends ResourceAnnotationHelper.ResourceProcessor {
+
+        public static final AdminObjectRefProcessor INSTANCE = new AdminObjectRefProcessor();
+
+        private AdminObjectRefProcessor() {
+        }
+
+        public boolean processResource(AnnotatedApp annotatedApp, Resource annotation, Class cls, Method method, Field field) {
+            String resourceName = getResourceName(annotation, method, field);
+            String resourceType = getResourceType(annotation, method, field);
+            if (resourceType.equals("javax.jms.Queue") ||
+                    resourceType.equals("javax.jms.Topic")) {
+
+                log.debug("addResource(): <message-destination-ref> found");
+
+                boolean exists = false;
+                MessageDestinationRefType[] messageDestinationRefs = annotatedApp.getMessageDestinationRefArray();
+                for (MessageDestinationRefType messageDestinationRef : messageDestinationRefs) {
+                    if (messageDestinationRef.getMessageDestinationRefName().getStringValue().trim().equals(resourceName)) {
+                        exists = true;
+                        break;
+                    }
+                }
+                if (!exists) {
+                    try {
+
+                        log.debug("addResource(): Does not exist in DD: " + resourceName);
+
+                        // Doesn't exist in deployment descriptor -- add new
+                        MessageDestinationRefType messageDestinationRef = annotatedApp.addNewMessageDestinationRef();
+
+                        //------------------------------------------------------------------------------
+                        // <message-destination-ref> required elements:
+                        //------------------------------------------------------------------------------
+
+                        // message-destination-ref-name
+                        JndiNameType messageDestinationRefName = messageDestinationRef.addNewMessageDestinationRefName();
+                        messageDestinationRefName.setStringValue(resourceName);
+                        messageDestinationRef.setMessageDestinationRefName(messageDestinationRefName);
+
+                        if (!resourceType.equals("")) {
+                            // message-destination-ref-type
+                            MessageDestinationTypeType msgDestType = messageDestinationRef.addNewMessageDestinationType();
+                            msgDestType.setStringValue(resourceType);
+                            messageDestinationRef.setMessageDestinationType(msgDestType);
+                        } else if (method != null || field != null) {
+                            // injectionTarget
+                            InjectionTargetType injectionTarget = messageDestinationRef.addNewInjectionTarget();
+                            configureInjectionTarget(injectionTarget, method, field);
+                        }
+
+                        //------------------------------------------------------------------------------
+                        // <message-destination-ref> optional elements:
+                        //------------------------------------------------------------------------------
+
+                        // description
+                        String descriptionAnnotation = annotation.description();
+                        if (!descriptionAnnotation.equals("")) {
+                            DescriptionType description = messageDestinationRef.addNewDescription();
+                            description.setStringValue(descriptionAnnotation);
+                        }
+
+                        // mappedName
+                        String mappdedNameAnnotation = annotation.mappedName();
+                        if (!mappdedNameAnnotation.equals("")) {
+                            XsdStringType mappedName = messageDestinationRef.addNewMappedName();
+                            mappedName.setStringValue(mappdedNameAnnotation);
+                            messageDestinationRef.setMappedName(mappedName);
+                        }
+
+                    }
+                    catch (Exception anyException) {
+                        log.debug("ResourceAnnotationHelper: Exception caught while processing <message-destination-ref>");
+                        anyException.printStackTrace();
+                    }
+                }
+            }
+
+            //------------------------------------------------------------------------------------------
+            // 5. Everything else must be a <resource-env-ref>
+            //------------------------------------------------------------------------------------------
+            else if (annotation.type().getCanonicalName().equals("javax.resource.cci.InteractionSpec") ||
+                    annotation.type().getCanonicalName().equals("javax.transaction.UserTransaction") || true) {
+
+                log.debug("addResource(): <resource-env-ref> found");
+
+                boolean exists = false;
+                ResourceEnvRefType[] resourceEnvRefs = annotatedApp.getResourceEnvRefArray();
+                for (ResourceEnvRefType resourceEnvRef : resourceEnvRefs) {
+                    if (resourceEnvRef.getResourceEnvRefName().getStringValue().trim().equals(resourceName)) {
+                        exists = true;
+                        break;
+                    }
+                }
+                if (!exists) {
+                    try {
+
+                        log.debug("addResource(): Does not exist in DD: " + resourceName);
+
+                        // Doesn't exist in deployment descriptor -- add new
+                        ResourceEnvRefType resourceEnvRef = annotatedApp.addNewResourceEnvRef();
+
+                        //------------------------------------------------------------------------------
+                        // <resource-env-ref> required elements:
+                        //------------------------------------------------------------------------------
+
+                        // resource-env-ref-name
+                        JndiNameType resourceEnvRefName = resourceEnvRef.addNewResourceEnvRefName();
+                        resourceEnvRefName.setStringValue(resourceName);
+                        resourceEnvRef.setResourceEnvRefName(resourceEnvRefName);
+
+                        if (!resourceType.equals("")) {
+                            // resource-env-ref-type
+                            FullyQualifiedClassType qualifiedClass = resourceEnvRef.addNewResourceEnvRefType();
+                            qualifiedClass.setStringValue(resourceType);
+                            resourceEnvRef.setResourceEnvRefType(qualifiedClass);
+                        } else if (method != null || field != null) {
+                            // injectionTarget
+                            InjectionTargetType injectionTarget = resourceEnvRef.addNewInjectionTarget();
+                            configureInjectionTarget(injectionTarget, method, field);
+                        }
+
+                        //------------------------------------------------------------------------------
+                        // <resource-env-ref> optional elements:
+                        //------------------------------------------------------------------------------
+
+                        // description
+                        String descriptionAnnotation = annotation.description();
+                        if (!descriptionAnnotation.equals("")) {
+                            DescriptionType description = resourceEnvRef.addNewDescription();
+                            description.setStringValue(descriptionAnnotation);
+                        }
+
+                        // mappedName
+                        String mappdedNameAnnotation = annotation.mappedName();
+                        if (!mappdedNameAnnotation.equals("")) {
+                            XsdStringType mappedName = resourceEnvRef.addNewMappedName();
+                            mappedName.setStringValue(mappdedNameAnnotation);
+                            resourceEnvRef.setMappedName(mappedName);
+                        }
+                    } catch (Exception e) {
+                        log.debug("ResourceAnnotationHelper: Exception caught while processing <resource-env-ref>", e);
+                    }
+                }
+                return true;
+            }
+            return false;
+        }
+    }
+
     public static final GBeanInfo GBEAN_INFO;
 
     static {
@@ -290,12 +442,13 @@
         infoBuilder.addAttribute("eeNamespaces", String[].class, true, true);
         infoBuilder.addAttribute("defaultEnvironment", Environment.class, true, true);
 
-        infoBuilder.setConstructor(new String[] {"defaultEnvironment", "eeNamespaces"});
+        infoBuilder.setConstructor(new String[]{"defaultEnvironment", "eeNamespaces"});
 
         GBEAN_INFO = infoBuilder.getBeanInfo();
     }
 
-    public static GBeanInfo getGBeanInfo() {
+    public static GBeanInfo getGBeanInfo
+            () {
         return GBEAN_INFO;
     }
 

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=515371&r1=515370&r2=515371
==============================================================================
--- 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 Tue Mar  6 15:41:28 2007
@@ -17,6 +17,8 @@
 
 package org.apache.geronimo.connector.deployment;
 
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
@@ -26,6 +28,7 @@
 import java.util.Map;
 import java.util.Set;
 
+import javax.annotation.Resource;
 import javax.naming.Reference;
 import javax.xml.namespace.QName;
 
@@ -37,6 +40,7 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.j2ee.deployment.Module;
+import org.apache.geronimo.j2ee.deployment.annotation.AnnotatedApp;
 import org.apache.geronimo.j2ee.deployment.annotation.ResourceAnnotationHelper;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
@@ -49,7 +53,14 @@
 import org.apache.geronimo.xbeans.geronimo.naming.GerPatternType;
 import org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefDocument;
 import org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType;
+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.ResAuthType;
+import org.apache.geronimo.xbeans.javaee.ResSharingScopeType;
 import org.apache.geronimo.xbeans.javaee.ResourceRefType;
+import org.apache.geronimo.xbeans.javaee.XsdStringType;
 import org.apache.xmlbeans.QNameSet;
 import org.apache.xmlbeans.XmlObject;
 
@@ -63,7 +74,7 @@
     private static final QName GER_RESOURCE_REF_QNAME = GerResourceRefDocument.type.getDocumentElementName();
     private static final QNameSet GER_RESOURCE_REF_QNAME_SET = QNameSet.singleton(GER_RESOURCE_REF_QNAME);
 
-    private  final QNameSet resourceRefQNameSet;
+    private final QNameSet resourceRefQNameSet;
 
     private static final String JAXR_CONNECTION_FACTORY_CLASS = "javax.xml.registry.ConnectionFactory";
     private static final String JAVAX_MAIL_SESSION_CLASS = "javax.mail.Session";
@@ -82,15 +93,22 @@
 
         // Discover and process any @Resource annotations (if !metadata-complete)
         if ((module != null) && (module.getClassFinder() != null)) {
-            processAnnotations(module);
+
+            // Process all the annotations for this naming builder type
+            try {
+                ResourceAnnotationHelper.processAnnotations(module.getAnnotatedApp(), module.getClassFinder(), ResourceRefProcessor.INSTANCE);
+            }
+            catch (Exception e) {
+                log.warn("Unable to process @Resource annotations for module" + module.getName(), e);
+            }
         }
 
         List<ResourceRefType> resourceRefsUntyped = convert(specDD.selectChildren(resourceRefQNameSet), J2EE_CONVERTER, ResourceRefType.class, ResourceRefType.type);
-        XmlObject[] gerResourceRefsUntyped = plan == null? NO_REFS: plan.selectChildren(GER_RESOURCE_REF_QNAME_SET);
+        XmlObject[] gerResourceRefsUntyped = plan == null ? NO_REFS : plan.selectChildren(GER_RESOURCE_REF_QNAME_SET);
         Map refMap = mapResourceRefs(gerResourceRefsUntyped);
         ClassLoader cl = module.getEarContext().getClassLoader();
 
-        for (ResourceRefType resourceRef: resourceRefsUntyped) {
+        for (ResourceRefType resourceRef : resourceRefsUntyped) {
             String name = resourceRef.getResRefName().getStringValue().trim();
             addInjections(name, resourceRef.getInjectionTargetArray(), componentContext);
             String type = resourceRef.getResType().getStringValue().trim();
@@ -165,7 +183,7 @@
         Map refMap = mapResourceRefs(gerResourceRefs);
         Set unshareableResources = new HashSet();
         Set applicationManagedSecurityResources = new HashSet();
-        for (ResourceRefType resourceRefType: resourceRefList) {
+        for (ResourceRefType resourceRefType : resourceRefList) {
 
             String type = resourceRefType.getResType().getStringValue().trim();
 
@@ -215,19 +233,6 @@
     }
 
 
-    private void processAnnotations(Module module) throws DeploymentException {
-
-        // Process all the annotations for this naming builder type
-        if (ResourceAnnotationHelper.annotationsPresent(module.getClassFinder())) {
-            try {
-                ResourceAnnotationHelper.processAnnotations(module.getAnnotatedApp(), module.getClassFinder());
-            }
-            catch (Exception e) {
-                log.warn("Unable to process @Resource annotations for module" + module.getName(), e);
-            }
-        }
-    }
-
     public QNameSet getSpecQNameSet() {
         return resourceRefQNameSet;
     }
@@ -236,6 +241,112 @@
         return GER_RESOURCE_REF_QNAME_SET;
     }
 
+    static class ResourceRefProcessor extends ResourceAnnotationHelper.ResourceProcessor {
+
+        public static final ResourceRefProcessor INSTANCE = new ResourceRefProcessor();
+
+        private ResourceRefProcessor() {
+        }
+
+        public boolean processResource(AnnotatedApp annotatedApp, Resource annotation, Class cls, Method method, Field field) {
+            String resourceName = getResourceName(annotation, method, field);
+            String resourceType = getResourceType(annotation, method, field);
+            if (resourceType.equals("javax.sql.DataSource") ||
+                    resourceType.equals("javax.jms.ConnectionFactory") ||
+                    resourceType.equals("javax.jms.QueueConnectionFactory") ||
+                    resourceType.equals("javax.jms.TopicConnectionFactory") ||
+                    resourceType.equals("javax.mail.Session") ||
+                    resourceType.equals("java.net.URL") ||
+                    resourceType.equals("javax.resource.cci.ConnectionFactory") ||
+                    resourceType.equals("org.omg.CORBA_2_3.ORB") ||
+                    resourceType.endsWith("ConnectionFactory")) {
+
+                log.debug("addResource(): <resource-ref> found");
+
+                boolean exists = false;
+                ResourceRefType[] resourceRefs = annotatedApp.getResourceRefArray();
+                for (ResourceRefType resourceRef : resourceRefs) {
+                    if (resourceRef.getResRefName().getStringValue().trim().equals(resourceName)) {
+                        exists = true;
+                        break;
+                    }
+                }
+                if (!exists) {
+                    try {
+
+                        log.debug("addResource(): Does not exist in DD: " + resourceName);
+
+                        // Doesn't exist in deployment descriptor -- add new
+                        ResourceRefType resourceRef = annotatedApp.addNewResourceRef();
+
+                        //------------------------------------------------------------------------------
+                        // <resource-ref> required elements:
+                        //------------------------------------------------------------------------------
+
+                        // resource-ref-name
+                        JndiNameType resourceRefName = resourceRef.addNewResRefName();
+                        resourceRefName.setStringValue(resourceName);
+                        resourceRef.setResRefName(resourceRefName);
+
+                        if (!resourceType.equals("")) {
+                            // resource-ref-type
+                            FullyQualifiedClassType qualifiedClass = resourceRef.addNewResType();
+                            qualifiedClass.setStringValue(resourceType);
+                            resourceRef.setResType(qualifiedClass);
+                        } else if (method != null || field != null) {
+                            // injectionTarget
+                            InjectionTargetType injectionTarget = resourceRef.addNewInjectionTarget();
+                            configureInjectionTarget(injectionTarget, method, field);
+                        }
+
+                        //------------------------------------------------------------------------------
+                        // <resource-ref> optional elements:
+                        //------------------------------------------------------------------------------
+
+                        // description
+                        String descriptionAnnotation = annotation.description();
+                        if (!descriptionAnnotation.equals("")) {
+                            DescriptionType description = resourceRef.addNewDescription();
+                            description.setStringValue(descriptionAnnotation);
+                        }
+
+                        // authentication
+                        if (annotation.authenticationType() == Resource.AuthenticationType.CONTAINER) {
+                            ResAuthType resAuth = resourceRef.addNewResAuth();
+                            resAuth.setStringValue("Container");
+                            resourceRef.setResAuth(resAuth);
+                        } else if (annotation.authenticationType() == Resource.AuthenticationType.APPLICATION) {
+                            ResAuthType resAuth = resourceRef.addNewResAuth();
+                            resAuth.setStringValue("Application");
+                            resourceRef.setResAuth(resAuth);
+                        }
+
+                        // sharing scope
+                        ResSharingScopeType resScope = resourceRef.addNewResSharingScope();
+                        resScope.setStringValue(annotation.shareable() ? "Shareable" : "Unshareable");
+                        resourceRef.setResSharingScope(resScope);
+
+                        // mappedName
+                        String mappdedNameAnnotation = annotation.mappedName();
+                        if (!mappdedNameAnnotation.equals("")) {
+                            XsdStringType mappedName = resourceRef.addNewMappedName();
+                            mappedName.setStringValue(mappdedNameAnnotation);
+                            resourceRef.setMappedName(mappedName);
+                        }
+
+                    }
+                    catch (Exception anyException) {
+                        log.debug("ResourceAnnotationHelper: Exception caught while processing <resource-ref>");
+                        anyException.printStackTrace();
+                    }
+                }
+                return true;
+            }
+            return false;
+        }
+    }
+
+
     public static final GBeanInfo GBEAN_INFO;
 
     static {
@@ -243,7 +354,7 @@
         infoBuilder.addAttribute("eeNamespaces", String[].class, true, true);
         infoBuilder.addAttribute("defaultEnvironment", Environment.class, true, true);
 
-        infoBuilder.setConstructor(new String[] {"defaultEnvironment", "eeNamespaces"});
+        infoBuilder.setConstructor(new String[]{"defaultEnvironment", "eeNamespaces"});
 
         GBEAN_INFO = infoBuilder.getBeanInfo();
     }

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=515371&r1=515370&r2=515371
==============================================================================
--- 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 Tue Mar  6 15:41:28 2007
@@ -53,22 +53,22 @@
  * <strong>@Resource</strong> and <strong>@Resources</strong> annotations to deployment descriptor
  * tags. The ResourceAnnotationHelper class can be used as part of the deployment of a module into
  * the Geronimo server. It performs the following major functions:
- *
+ * <p/>
  * <ol>
- *      <li>Translates annotations into corresponding deployment descriptor elements (so that the
- *      actual deployment descriptor in the module can be updated or even created if necessary)
+ * <li>Translates annotations into corresponding deployment descriptor elements (so that the
+ * actual deployment descriptor in the module can be updated or even created if necessary)
  * </ol>
- *
+ * <p/>
  * <p><strong>Note(s):</strong>
  * <ul>
- *      <li>The user is responsible for invoking change to metadata-complete
- *      <li>This helper class will validate any changes it makes to the deployment descriptor. An
- *      exception will be thrown if it fails to parse
+ * <li>The user is responsible for invoking change to metadata-complete
+ * <li>This helper class will validate any changes it makes to the deployment descriptor. An
+ * exception will be thrown if it fails to parse
  * </ul>
- *
+ * <p/>
  * <p><strong>Remaining ToDo(s):</strong>
  * <ul>
- *      <li>Usage of mappedName
+ * <li>Usage of mappedName
  * </ul>
  *
  * @version $Rev$ $Date$
@@ -101,10 +101,12 @@
      * @return Updated deployment descriptor
      * @throws Exception if parsing or validation error
      */
-    public static void processAnnotations(AnnotatedApp annotatedApp, ClassFinder classFinder) throws Exception {
+    public static void processAnnotations(AnnotatedApp annotatedApp, ClassFinder classFinder, ResourceProcessor resourceProcessor) throws Exception {
         if (annotatedApp != null) {
-            processResources(annotatedApp, classFinder);
-            processResource(annotatedApp, classFinder);
+            if (!classFinder.isAnnotationPresent(Resource.class)
+                    && !classFinder.isAnnotationPresent(Resources.class)) return;
+            processResources(annotatedApp, classFinder, resourceProcessor);
+            processResource(annotatedApp, classFinder, resourceProcessor);
         }
     }
 
@@ -114,9 +116,10 @@
      *
      * @param annotatedApp
      * @param classFinder
+     * @param resourceProcessor
      * @throws Exception
      */
-    private static void processResource(AnnotatedApp annotatedApp, ClassFinder classFinder) throws Exception {
+    private static void processResource(AnnotatedApp annotatedApp, ClassFinder classFinder, ResourceProcessor resourceProcessor) throws Exception {
         log.debug("processResource(): Entry: AnnotatedApp: " + annotatedApp.toString());
 
         List<Class> classeswithResource = classFinder.findAnnotatedClasses(Resource.class);
@@ -127,7 +130,7 @@
         for (Class cls : classeswithResource) {
             Resource resource = (Resource) cls.getAnnotation(Resource.class);
             if (resource != null) {
-                addResource(annotatedApp, resource, cls, null, null);
+                resourceProcessor.processResource(annotatedApp, resource, cls, null, null);
             }
         }
 
@@ -135,7 +138,7 @@
         for (Method method : methodswithResource) {
             Resource resource = (Resource) method.getAnnotation(Resource.class);
             if (resource != null) {
-                addResource(annotatedApp, resource, null, method, null);
+                resourceProcessor.processResource(annotatedApp, resource, null, method, null);
             }
         }
 
@@ -143,7 +146,7 @@
         for (Field field : fieldswithResource) {
             Resource resource = (Resource) field.getAnnotation(Resource.class);
             if (resource != null) {
-                addResource(annotatedApp, resource, null, null, field);
+                resourceProcessor.processResource(annotatedApp, resource, null, null, field);
             }
         }
 
@@ -159,9 +162,10 @@
      *
      * @param annotatedApp
      * @param classFinder
-     * @exception Exception
+     * @param resourceProcessor
+     * @throws Exception
      */
-    private static void processResources(AnnotatedApp annotatedApp, ClassFinder classFinder) throws Exception {
+    private static void processResources(AnnotatedApp annotatedApp, ClassFinder classFinder, ResourceProcessor resourceProcessor) throws Exception {
         log.debug("processResources(): Entry");
 
         List<Class> classeswithResources = classFinder.findAnnotatedClasses(Resources.class);
@@ -174,7 +178,7 @@
                 resourceList.addAll(Arrays.asList(resources.value()));
             }
             for (Resource resource : resourceList) {
-                addResource(annotatedApp, resource, cls, null, null);
+                resourceProcessor.processResource(annotatedApp, resource, cls, null, null);
             }
             resourceList.clear();
         }
@@ -182,6 +186,90 @@
         log.debug("processResources(): Exit");
     }
 
+    public abstract static class ResourceProcessor {
+
+        public abstract boolean processResource(AnnotatedApp annotatedApp, Resource annotation, Class cls, Method method, Field field);
+
+        /**
+         * Resource name:
+         * -- When annotation is applied on a class:    Name must be provided (cannot be inferred)
+         * -- When annotation is applied on a method:   Name is JavaBeans property name qualified
+         * by the class (or as provided on the annotation)
+         * -- When annotation is applied on a field:    Name is the field name qualified by the
+         * class (or as provided on the annotation)
+         *
+         * @param annotation
+         * @param method
+         * @param field
+         * @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;
+        }
+
+        protected static String getResourceType(Resource annotation, Method method, Field field) {
+            //------------------------------------------------------------------------------------------
+            // Resource type:
+            // -- When annotation is applied on a class:    Type must be provided (cannot be inferred)
+            // -- When annotation is applied on a method:   Type is the JavaBeans property type (or as
+            //                                              provided on the annotation)
+            // -- When annotation is applied on a field:    Type is the field type (or as provided on
+            //                                              the annotation)
+            //------------------------------------------------------------------------------------------
+            String resourceType = annotation.type().getCanonicalName();
+            if (resourceType.equals("") || resourceType.equals(Object.class.getName())) {
+                if (method != null) {
+                    resourceType = method.getParameterTypes()[0].getCanonicalName();
+                } else if (field != null) {
+                    resourceType = field.getType().getName();
+                }
+            }
+            return resourceType;
+        }
+
+        /**
+         * 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 = "";
+            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();
+            }
+            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
@@ -331,7 +419,7 @@
                     } else if (!injectionJavaType.equals("")) {
                         // injectionTarget
                         InjectionTargetType injectionTarget = envEntry.addNewInjectionTarget();
-                        configureInjectionTarget(injectionTarget, injectionClass, injectionJavaType);
+                        configureInjectionTarget(injectionTarget, method, field);
                     }
 
                     // env-entry-value
@@ -344,7 +432,7 @@
 
                     // description
                     String descriptionAnnotation = annotation.description();
-                    if ( !descriptionAnnotation.equals("") ) {
+                    if (!descriptionAnnotation.equals("")) {
                         DescriptionType description = envEntry.addNewDescription();
                         description.setStringValue(descriptionAnnotation);
                     }
@@ -395,7 +483,7 @@
                     } else if (!injectionJavaType.equals("")) {
                         // injectionTarget
                         InjectionTargetType injectionTarget = serviceRef.addNewInjectionTarget();
-                        configureInjectionTarget(injectionTarget, injectionClass, injectionJavaType);
+                        configureInjectionTarget(injectionTarget, method, field);
                     }
 
                     //------------------------------------------------------------------------------
@@ -411,7 +499,7 @@
 
                     // WSDL document location
                     String documentAnnotation = annotation.mappedName();
-                    if ( !documentAnnotation.equals("") ) {
+                    if (!documentAnnotation.equals("")) {
                         XsdAnyURIType wsdlFile = serviceRef.addNewWsdlFile();
                         wsdlFile.setStringValue(documentAnnotation);
                         serviceRef.setWsdlFile(wsdlFile);
@@ -473,7 +561,7 @@
                     } else if (!injectionJavaType.equals("")) {
                         // injectionTarget
                         InjectionTargetType injectionTarget = resourceRef.addNewInjectionTarget();
-                        configureInjectionTarget(injectionTarget, injectionClass, injectionJavaType);
+                        configureInjectionTarget(injectionTarget, method, field);
                     }
 
                     //------------------------------------------------------------------------------
@@ -482,7 +570,7 @@
 
                     // description
                     String descriptionAnnotation = annotation.description();
-                    if ( !descriptionAnnotation.equals("") ) {
+                    if (!descriptionAnnotation.equals("")) {
                         DescriptionType description = resourceRef.addNewDescription();
                         description.setStringValue(descriptionAnnotation);
                     }
@@ -492,8 +580,7 @@
                         ResAuthType resAuth = resourceRef.addNewResAuth();
                         resAuth.setStringValue("Container");
                         resourceRef.setResAuth(resAuth);
-                    }
-                    else if (annotation.authenticationType() == Resource.AuthenticationType.APPLICATION) {
+                    } else if (annotation.authenticationType() == Resource.AuthenticationType.APPLICATION) {
                         ResAuthType resAuth = resourceRef.addNewResAuth();
                         resAuth.setStringValue("Application");
                         resourceRef.setResAuth(resAuth);
@@ -506,7 +593,7 @@
 
                     // mappedName
                     String mappdedNameAnnotation = annotation.mappedName();
-                    if (!mappdedNameAnnotation.equals("") ) {
+                    if (!mappdedNameAnnotation.equals("")) {
                         XsdStringType mappedName = resourceRef.addNewMappedName();
                         mappedName.setStringValue(mappdedNameAnnotation);
                         resourceRef.setMappedName(mappedName);
@@ -561,7 +648,7 @@
                     } else if (!injectionJavaType.equals("")) {
                         // injectionTarget
                         InjectionTargetType injectionTarget = messageDestinationRef.addNewInjectionTarget();
-                        configureInjectionTarget(injectionTarget, injectionClass, injectionJavaType);
+                        configureInjectionTarget(injectionTarget, method, field);
                     }
 
                     //------------------------------------------------------------------------------
@@ -570,14 +657,14 @@
 
                     // description
                     String descriptionAnnotation = annotation.description();
-                    if ( !descriptionAnnotation.equals("") ) {
+                    if (!descriptionAnnotation.equals("")) {
                         DescriptionType description = messageDestinationRef.addNewDescription();
                         description.setStringValue(descriptionAnnotation);
                     }
 
                     // mappedName
                     String mappdedNameAnnotation = annotation.mappedName();
-                    if (!mappdedNameAnnotation.equals("") ) {
+                    if (!mappdedNameAnnotation.equals("")) {
                         XsdStringType mappedName = messageDestinationRef.addNewMappedName();
                         mappedName.setStringValue(mappdedNameAnnotation);
                         messageDestinationRef.setMappedName(mappedName);
@@ -632,7 +719,7 @@
                     } else if (!injectionJavaType.equals("")) {
                         // injectionTarget
                         InjectionTargetType injectionTarget = resourceEnvRef.addNewInjectionTarget();
-                        configureInjectionTarget(injectionTarget, injectionClass, injectionJavaType);
+                        configureInjectionTarget(injectionTarget, method, field);
                     }
 
                     //------------------------------------------------------------------------------
@@ -641,14 +728,14 @@
 
                     // description
                     String descriptionAnnotation = annotation.description();
-                    if ( !descriptionAnnotation.equals("") ) {
+                    if (!descriptionAnnotation.equals("")) {
                         DescriptionType description = resourceEnvRef.addNewDescription();
                         description.setStringValue(descriptionAnnotation);
                     }
 
                     // mappedName
                     String mappdedNameAnnotation = annotation.mappedName();
-                    if (!mappdedNameAnnotation.equals("") ) {
+                    if (!mappdedNameAnnotation.equals("")) {
                         XsdStringType mappedName = resourceEnvRef.addNewMappedName();
                         mappedName.setStringValue(mappdedNameAnnotation);
                         resourceEnvRef.setMappedName(mappedName);
@@ -669,12 +756,24 @@
      * Configure Injection Target
      *
      * @param injectionTarget
-     * @param injectionClass
-     * @param injectionJavaType
+     * @param method
+     * @param field
      */
-    private static void configureInjectionTarget(InjectionTargetType injectionTarget, String injectionClass, String injectionJavaType) {
+    private 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();
+        }
         FullyQualifiedClassType qualifiedClass = injectionTarget.addNewInjectionTargetClass();
         JavaIdentifierType javaType = injectionTarget.addNewInjectionTargetName();
         qualifiedClass.setStringValue(injectionClass);
@@ -689,7 +788,7 @@
     /**
      * Validate deployment descriptor
      *
-     * @param AnnotatedApp
+     * @param annotatedApp
      * @throws Exception thrown if deployment descriptor cannot be parsed
      */
     private static void validateDD(AnnotatedApp annotatedApp) throws Exception {

Modified: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java?view=diff&rev=515371&r1=515370&r2=515371
==============================================================================
--- geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java Tue Mar  6 15:41:28 2007
@@ -19,8 +19,10 @@
 
 import java.util.Map;
 import java.util.List;
+import java.lang.reflect.Method;
+import java.lang.reflect.Field;
 
-import javax.xml.namespace.QName;
+import javax.annotation.Resource;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -29,13 +31,17 @@
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.j2ee.deployment.annotation.ResourceAnnotationHelper;
+import org.apache.geronimo.j2ee.deployment.annotation.AnnotatedApp;
 import org.apache.geronimo.j2ee.deployment.Module;
-import org.apache.geronimo.j2ee.deployment.NamingBuilder;
 import org.apache.geronimo.kernel.config.Configuration;
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.naming.reference.KernelReference;
 import org.apache.geronimo.xbeans.javaee.EnvEntryType;
-import org.apache.geronimo.schema.NamespaceElementConverter;
+import org.apache.geronimo.xbeans.javaee.JndiNameType;
+import org.apache.geronimo.xbeans.javaee.EnvEntryTypeValuesType;
+import org.apache.geronimo.xbeans.javaee.InjectionTargetType;
+import org.apache.geronimo.xbeans.javaee.XsdStringType;
+import org.apache.geronimo.xbeans.javaee.DescriptionType;
 import org.apache.xmlbeans.QNameSet;
 import org.apache.xmlbeans.XmlObject;
 
@@ -61,7 +67,14 @@
 
         // Discover and process any @Resource annotations (if !metadata-complete)
         if ((module != null) && (module.getClassFinder() != null)) {
-            processAnnotations(module);
+
+            // Process all the annotations for this naming builder type
+            try {
+                ResourceAnnotationHelper.processAnnotations(module.getAnnotatedApp(), module.getClassFinder(), EnvEntryRefProcessor.INSTANCE);
+            }
+            catch (Exception e) {
+                log.warn("Unable to process @Resource annotations for module" + module.getName(), e);
+            }
         }
 
         List<EnvEntryType> envEntriesUntyped = convert(specDD.selectChildren(envEntryQNameSet), JEE_CONVERTER, EnvEntryType.class, EnvEntryType.type);
@@ -107,25 +120,93 @@
 
     }
 
-    private void processAnnotations(Module module) throws DeploymentException {
-
-        // Process all the annotations for this naming builder type
-        if (ResourceAnnotationHelper.annotationsPresent(module.getClassFinder())) {
-            try {
-                ResourceAnnotationHelper.processAnnotations(module.getAnnotatedApp(), module.getClassFinder());
-            }
-            catch (Exception e) {
-                log.warn("Unable to process @Resource annotations for module" + module.getName(), e);
-            }
-        }
-    }
-
     public QNameSet getSpecQNameSet() {
         return envEntryQNameSet;
     }
 
     public QNameSet getPlanQNameSet() {
         return QNameSet.EMPTY;
+    }
+
+    static class EnvEntryRefProcessor extends ResourceAnnotationHelper.ResourceProcessor {
+
+        public static final EnvEntryRefProcessor INSTANCE = new EnvEntryRefProcessor();
+
+        private EnvEntryRefProcessor() {
+        }
+
+        public boolean processResource(AnnotatedApp annotatedApp, Resource annotation, Class cls, Method method, Field field) {
+            String resourceName = getResourceName(annotation, method, field);
+            String resourceType = getResourceType(annotation, method, field);
+            if (resourceType.equals("java.lang.String") ||
+                    resourceType.equals("java.lang.Character") ||
+                    resourceType.equals("java.lang.Integer") ||
+                    resourceType.equals("java.lang.Boolean") ||
+                    resourceType.equals("java.lang.Double") ||
+                    resourceType.equals("java.lang.Byte") ||
+                    resourceType.equals("java.lang.Short") ||
+                    resourceType.equals("java.lang.Long") ||
+                    resourceType.equals("java.lang.Float")) {
+
+                log.debug("addResource(): <env-entry> found");
+
+                boolean exists = false;
+                EnvEntryType[] envEntries = annotatedApp.getEnvEntryArray();
+                for (EnvEntryType envEntry : envEntries) {
+                    if (envEntry.getEnvEntryName().getStringValue().trim().equals(resourceName)) {
+                        exists = true;
+                        break;
+                    }
+                }
+                if (!exists) {
+                    try {
+
+                        log.debug("addResource(): Does not exist in DD: " + resourceName);
+
+                        // Doesn't exist in deployment descriptor -- add new
+                        EnvEntryType envEntry = annotatedApp.addNewEnvEntry();
+
+                        //------------------------------------------------------------------------------
+                        // <env-entry> required elements:
+                        //------------------------------------------------------------------------------
+
+                        // env-entry-name
+                        JndiNameType envEntryName = envEntry.addNewEnvEntryName();
+                        envEntryName.setStringValue(resourceName);
+
+                        if (!resourceType.equals("")) {
+                            // env-entry-type
+                            EnvEntryTypeValuesType envEntryType = envEntry.addNewEnvEntryType();
+                            envEntryType.setStringValue(resourceType);
+                        } else if (method != null || field != null) {
+                            // injectionTarget
+                            InjectionTargetType injectionTarget = envEntry.addNewInjectionTarget();
+                            configureInjectionTarget(injectionTarget, method, field);
+                        }
+
+                        // env-entry-value
+                        XsdStringType value = envEntry.addNewEnvEntryValue();
+                        value.setStringValue(annotation.mappedName());
+
+                        //------------------------------------------------------------------------------
+                        // <env-entry> optional elements:
+                        //------------------------------------------------------------------------------
+
+                        // description
+                        String descriptionAnnotation = annotation.description();
+                        if (!descriptionAnnotation.equals("")) {
+                            DescriptionType description = envEntry.addNewDescription();
+                            description.setStringValue(descriptionAnnotation);
+                        }
+
+                    }
+                    catch (Exception anyException) {
+                        log.debug("ResourceAnnotationHelper: Exception caught while processing <env-entry>");
+                    }
+                }
+            }
+            return false;
+        }
     }
 
     public static final GBeanInfo GBEAN_INFO;



Mime
View raw message