camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/2] camel git commit: CAMEL-9326: JndiRegistry should default to use CamelInitialContextFactory if no env factory specified in standalone mode to be backwards compatible.
Date Mon, 16 Nov 2015 13:21:24 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.16.x 22fa248db -> 4ac1aed00
  refs/heads/master 95392e49a -> aaa2f55b7


CAMEL-9326: JndiRegistry should default to use CamelInitialContextFactory if no env factory
specified in standalone mode to be backwards compatible.


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

Branch: refs/heads/master
Commit: aaa2f55b788474f04416a8f722e17b7802653aa3
Parents: 95392e4
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Mon Nov 16 14:24:00 2015 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Mon Nov 16 14:24:00 2015 +0100

----------------------------------------------------------------------
 .../java/org/apache/camel/impl/JndiRegistry.java   | 17 +++++++++++++++--
 .../org/apache/camel/impl/JndiRegistryTest.java    |  6 +++---
 2 files changed, 18 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/aaa2f55b/camel-core/src/main/java/org/apache/camel/impl/JndiRegistry.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/JndiRegistry.java b/camel-core/src/main/java/org/apache/camel/impl/JndiRegistry.java
index 21fc178..cc39b21 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/JndiRegistry.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/JndiRegistry.java
@@ -31,6 +31,7 @@ import javax.naming.NamingException;
 import org.apache.camel.NoSuchBeanException;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.spi.Registry;
+import org.apache.camel.util.jndi.CamelInitialContextFactory;
 
 /**
  * A {@link Registry} implementation which looks up the objects in JNDI
@@ -38,16 +39,28 @@ import org.apache.camel.spi.Registry;
 public class JndiRegistry implements Registry {
     private Context context;
     private Map environment;
+    private final boolean standalone;
 
     public JndiRegistry() {
+        this.standalone = false;
     }
 
     public JndiRegistry(Map environment) {
         this.environment = environment;
+        this.standalone = false;
     }
 
     public JndiRegistry(Context context) {
         this.context = context;
+        this.standalone = false;
+    }
+
+    /**
+     * Whether to use standalone mode, where the JNDI initial context factory is using
+     * {@link CamelInitialContextFactory}.
+     */
+    public JndiRegistry(boolean standalone) {
+        this.standalone = true;
     }
 
     public <T> T lookupByNameAndType(String name, Class<T> type) {
@@ -154,8 +167,8 @@ public class JndiRegistry implements Registry {
         if (environment != null) {
             properties.putAll(environment);
         }
-        // must include a factory if none provided
-        if (!properties.containsKey("java.naming.factory.initial")) {
+        // must include a factory if none provided in standalone mode
+        if (standalone && !properties.containsKey("java.naming.factory.initial"))
{
             properties.put("java.naming.factory.initial", "org.apache.camel.util.jndi.CamelInitialContextFactory");
         }
         return new InitialContext(properties);

http://git-wip-us.apache.org/repos/asf/camel/blob/aaa2f55b/camel-core/src/test/java/org/apache/camel/impl/JndiRegistryTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/impl/JndiRegistryTest.java b/camel-core/src/test/java/org/apache/camel/impl/JndiRegistryTest.java
index a46b219..21e0eef 100644
--- a/camel-core/src/test/java/org/apache/camel/impl/JndiRegistryTest.java
+++ b/camel-core/src/test/java/org/apache/camel/impl/JndiRegistryTest.java
@@ -58,13 +58,13 @@ public class JndiRegistryTest extends TestCase {
         assertSame(jndi.lookupByName("foo"), set.values().iterator().next());
     }
 
-    public void testDefault() throws Exception {
-        JndiRegistry jndi = new JndiRegistry();
+    public void testStandalone() throws Exception {
+        JndiRegistry jndi = new JndiRegistry(true);
         jndi.bind("bar", "Hello bar");
         assertEquals("Hello bar", jndi.lookup("bar"));
     }
 
-    public void testMap() throws Exception {
+    public void testCamelContextFactory() throws Exception {
         Map<Object, Object> env = new HashMap<Object, Object>();
         env.put("java.naming.factory.initial", "org.apache.camel.util.jndi.CamelInitialContextFactory");
 


Mime
View raw message