tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject tomee git commit: TOMEE-1710 unwrap delegete reference in Contextualjndireference
Date Thu, 11 Feb 2016 17:38:59 GMT
Repository: tomee
Updated Branches:
  refs/heads/master 269eedbbb -> fcf9c7d37


TOMEE-1710 unwrap delegete reference in Contextualjndireference


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

Branch: refs/heads/master
Commit: fcf9c7d3758abbe5da37cf40d68069848431e0e0
Parents: 269eedb
Author: Romain manni-Bucau <rmannibucau@gmail.com>
Authored: Thu Feb 11 18:38:17 2016 +0100
Committer: Romain manni-Bucau <rmannibucau@gmail.com>
Committed: Thu Feb 11 18:38:17 2016 +0100

----------------------------------------------------------------------
 .../ivm/naming/ContextualJndiReference.java     |  8 ++++
 .../ivm/naming/ContextualJndiReferenceTest.java | 42 ++++++++++++++++++++
 2 files changed, 50 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/fcf9c7d3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/ContextualJndiReference.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/ContextualJndiReference.java
b/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/ContextualJndiReference.java
index cd7e947..218efe8 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/ContextualJndiReference.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/ContextualJndiReference.java
@@ -79,6 +79,14 @@ public class ContextualJndiReference extends IntraVmJndiReference {
 
     @Override
     public Object getObject() throws NamingException {
+        final Object delegate = findDelegate();
+        if (Reference.class.isInstance(delegate)) {
+            return Reference.class.cast(delegate).getObject();
+        }
+        return delegate;
+    }
+
+    private Object findDelegate() throws NameNotFoundException {
         final Boolean rawValue = !followReference.get();
         followReference.remove();
         if (rawValue) {

http://git-wip-us.apache.org/repos/asf/tomee/blob/fcf9c7d3/container/openejb-core/src/test/java/org/apache/openejb/core/ivm/naming/ContextualJndiReferenceTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/core/ivm/naming/ContextualJndiReferenceTest.java
b/container/openejb-core/src/test/java/org/apache/openejb/core/ivm/naming/ContextualJndiReferenceTest.java
new file mode 100644
index 0000000..7da98eb
--- /dev/null
+++ b/container/openejb-core/src/test/java/org/apache/openejb/core/ivm/naming/ContextualJndiReferenceTest.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.core.ivm.naming;
+
+import org.apache.openejb.core.CoreContainerSystem;
+import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.spi.ContainerSystem;
+import org.junit.Test;
+
+import javax.naming.NamingException;
+
+import static org.junit.Assert.assertEquals;
+
+public class ContextualJndiReferenceTest {
+    @Test
+    public void propagateUnwrapping() throws NamingException {
+        SystemInstance.get().setComponent(ContainerSystem.class, new CoreContainerSystem(new
IvmJndiFactory()));
+        final ContextualJndiReference ref = new ContextualJndiReference("foo");
+        ref.setDefaultValue(new Reference() {
+            @Override
+            public Object getObject() throws NamingException {
+                return "yeah";
+            }
+        });
+        assertEquals("yeah", ref.getObject());
+        SystemInstance.reset();
+    }
+}


Mime
View raw message