tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r984176 - /openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
Date Tue, 10 Aug 2010 19:22:16 GMT
Author: gawor
Date: Tue Aug 10 19:22:15 2010
New Revision: 984176

URL: http://svn.apache.org/viewvc?rev=984176&view=rev
Log:
OPENEJB-1326: Use reflection to get value of lookup attribute of Resource annotation

Modified:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java?rev=984176&r1=984175&r2=984176&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
Tue Aug 10 19:22:15 2010
@@ -649,6 +649,8 @@ public class AnnotationDeployer implemen
 
         private static final String STRICT_INTERFACE_DECLARATION = "openejb.strict.interface.declaration";
 
+        private static final Method LOOKUP_METHOD = getLookupMethod();
+        
         public AppModule deploy(AppModule appModule) throws OpenEJBException {
             for (EjbModule ejbModule : appModule.getEjbModules()) {
                 setModule(ejbModule);
@@ -2728,8 +2730,35 @@ public class AnnotationDeployer implemen
                 reference.setMappedName(resource.mappedName());
             }
 
+            // Override the lookup name if not set
+            if (reference.getLookupName() == null) {
+                String lookupName = getLookupName(resource);
+                if (!lookupName.equals("")) {
+                    reference.setLookupName(lookupName);
+                }
+            }
         }
 
+        private static Method getLookupMethod() {
+            try {
+                return Resource.class.getMethod("lookup", null);
+            } catch (NoSuchMethodException e) {
+                return null;
+            }
+        }
+        
+        private static String getLookupName(Resource resource) {
+            String value = "";
+            if (LOOKUP_METHOD != null) {
+                try {
+                    value = (String) LOOKUP_METHOD.invoke(resource, null);
+                } catch (Exception e) {
+                    // ignore
+                }
+            }
+            return value;
+        }
+        
         /**
          * Process @PersistenceUnit into <persistence-unit> for the specified member
(field or method)
          *



Mime
View raw message