You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by an...@apache.org on 2015/12/01 23:04:10 UTC

[58/77] [abbrv] tomee git commit: using web jndi entries if global lookup fails in embedded mode

using web jndi entries if global lookup fails in embedded mode


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/ede8b747
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/ede8b747
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/ede8b747

Branch: refs/heads/tomee-7.0.0-M1
Commit: ede8b7471c1c667b013a812e6ab740b92563d496
Parents: 5f0adff
Author: Romain Manni-Bucau <rm...@gmail.com>
Authored: Tue Nov 24 23:26:44 2015 +0100
Committer: Romain Manni-Bucau <rm...@gmail.com>
Committed: Tue Nov 24 23:26:44 2015 +0100

----------------------------------------------------------------------
 .../org/apache/openejb/web/WebInitialContext.java   | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/ede8b747/container/openejb-core/src/main/java/org/apache/openejb/web/WebInitialContext.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/web/WebInitialContext.java b/container/openejb-core/src/main/java/org/apache/openejb/web/WebInitialContext.java
index f2dff36..4041e2e 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/web/WebInitialContext.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/web/WebInitialContext.java
@@ -21,7 +21,9 @@ import org.apache.openejb.core.ivm.naming.Reference;
 
 import javax.naming.Context;
 import javax.naming.LinkRef;
+import javax.naming.NameNotFoundException;
 import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 import java.util.Map;
@@ -47,9 +49,21 @@ public class WebInitialContext implements InvocationHandler {
                 } else if (lookedUp instanceof LinkRef) {
                     return ((Context) proxy).lookup(((LinkRef) lookedUp).getLinkName());
                 }
+                try {
+                    return method.invoke(delegate, args);
+                } catch (final InvocationTargetException nnfe) {
+                    if (NameNotFoundException.class.isInstance(nnfe.getTargetException())) {
+                        return lookedUp;
+                    }
+                    throw nnfe.getTargetException();
+                }
             }
         }
-        return method.invoke(delegate, args);
+        try {
+            return method.invoke(delegate, args);
+        } catch (final InvocationTargetException nnfe) {
+            throw nnfe.getTargetException();
+        }
     }
 
     private static String normalize(final String arg) {