You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2013/09/28 12:37:06 UTC
[1/3] git commit: CAMEL-6769: JndiRegistry implement all methods.
Thanks to Marios Trivizas for the patch.
Updated Branches:
refs/heads/camel-2.11.x 089a3f6af -> 45d537719
refs/heads/camel-2.12.x 08e7f8178 -> 258e7d6b0
refs/heads/master 6f729ece0 -> 542103e52
CAMEL-6769: JndiRegistry implement all methods. Thanks to Marios Trivizas for the patch.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/542103e5
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/542103e5
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/542103e5
Branch: refs/heads/master
Commit: 542103e52299e63302a7da174f0bf49d4f697c69
Parents: 6f729ec
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Sep 28 12:36:11 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Sep 28 12:36:11 2013 +0200
----------------------------------------------------------------------
.../org/apache/camel/impl/JndiRegistry.java | 38 ++++++++++++++++----
1 file changed, 31 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/542103e5/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 1ddc61c..5a63e48 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
@@ -16,13 +16,16 @@
*/
package org.apache.camel.impl;
-import java.util.Collections;
import java.util.Hashtable;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import javax.naming.Context;
import javax.naming.InitialContext;
+import javax.naming.NameClassPair;
import javax.naming.NameNotFoundException;
+import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import org.apache.camel.NoSuchBeanException;
@@ -31,8 +34,6 @@ import org.apache.camel.spi.Registry;
/**
* A {@link Registry} implementation which looks up the objects in JNDI
- *
- * @version
*/
public class JndiRegistry implements Registry {
private Context context;
@@ -72,13 +73,36 @@ public class JndiRegistry implements Registry {
}
public <T> Map<String, T> findByTypeWithName(Class<T> type) {
- // not implemented so we return an empty map
- return Collections.emptyMap();
+ Map<String, T> answer = new LinkedHashMap<String, T>();
+ try {
+ NamingEnumeration<NameClassPair> list = getContext().list("");
+ while (list.hasMore()) {
+ NameClassPair pair = list.next();
+ if (type.isInstance(pair.getClass())) {
+ answer.put(pair.getName(), type.cast(pair.getClass()));
+ }
+ }
+ } catch (NamingException e) {
+ // ignore
+ }
+
+ return answer;
}
public <T> Set<T> findByType(Class<T> type) {
- // not implemented so we return an empty set
- return Collections.emptySet();
+ Set<T> answer = new LinkedHashSet<T>();
+ try {
+ NamingEnumeration<NameClassPair> list = getContext().list("");
+ while (list.hasMore()) {
+ NameClassPair pair = list.next();
+ if (type.isInstance(pair.getClass())) {
+ answer.add(type.cast(pair.getClass()));
+ }
+ }
+ } catch (NamingException e) {
+ // ignore
+ }
+ return answer;
}
public Object lookup(String name) {
[3/3] git commit: CAMEL-6769: JndiRegistry implement all methods.
Thanks to Marios Trivizas for the patch.
Posted by da...@apache.org.
CAMEL-6769: JndiRegistry implement all methods. Thanks to Marios Trivizas for the patch.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/45d53771
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/45d53771
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/45d53771
Branch: refs/heads/camel-2.11.x
Commit: 45d5377196a2d79be9eceea28dfcf35645f244e2
Parents: 089a3f6a
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Sep 28 12:36:11 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Sep 28 12:36:51 2013 +0200
----------------------------------------------------------------------
.../org/apache/camel/impl/JndiRegistry.java | 38 ++++++++++++++++----
1 file changed, 31 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/45d53771/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 1ddc61c..5a63e48 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
@@ -16,13 +16,16 @@
*/
package org.apache.camel.impl;
-import java.util.Collections;
import java.util.Hashtable;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import javax.naming.Context;
import javax.naming.InitialContext;
+import javax.naming.NameClassPair;
import javax.naming.NameNotFoundException;
+import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import org.apache.camel.NoSuchBeanException;
@@ -31,8 +34,6 @@ import org.apache.camel.spi.Registry;
/**
* A {@link Registry} implementation which looks up the objects in JNDI
- *
- * @version
*/
public class JndiRegistry implements Registry {
private Context context;
@@ -72,13 +73,36 @@ public class JndiRegistry implements Registry {
}
public <T> Map<String, T> findByTypeWithName(Class<T> type) {
- // not implemented so we return an empty map
- return Collections.emptyMap();
+ Map<String, T> answer = new LinkedHashMap<String, T>();
+ try {
+ NamingEnumeration<NameClassPair> list = getContext().list("");
+ while (list.hasMore()) {
+ NameClassPair pair = list.next();
+ if (type.isInstance(pair.getClass())) {
+ answer.put(pair.getName(), type.cast(pair.getClass()));
+ }
+ }
+ } catch (NamingException e) {
+ // ignore
+ }
+
+ return answer;
}
public <T> Set<T> findByType(Class<T> type) {
- // not implemented so we return an empty set
- return Collections.emptySet();
+ Set<T> answer = new LinkedHashSet<T>();
+ try {
+ NamingEnumeration<NameClassPair> list = getContext().list("");
+ while (list.hasMore()) {
+ NameClassPair pair = list.next();
+ if (type.isInstance(pair.getClass())) {
+ answer.add(type.cast(pair.getClass()));
+ }
+ }
+ } catch (NamingException e) {
+ // ignore
+ }
+ return answer;
}
public Object lookup(String name) {
[2/3] git commit: CAMEL-6769: JndiRegistry implement all methods.
Thanks to Marios Trivizas for the patch.
Posted by da...@apache.org.
CAMEL-6769: JndiRegistry implement all methods. Thanks to Marios Trivizas for the patch.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/258e7d6b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/258e7d6b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/258e7d6b
Branch: refs/heads/camel-2.12.x
Commit: 258e7d6b0a1c9ee8576584055112d13c20da05d7
Parents: 08e7f81
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Sep 28 12:36:11 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Sep 28 12:36:26 2013 +0200
----------------------------------------------------------------------
.../org/apache/camel/impl/JndiRegistry.java | 38 ++++++++++++++++----
1 file changed, 31 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/258e7d6b/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 1ddc61c..5a63e48 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
@@ -16,13 +16,16 @@
*/
package org.apache.camel.impl;
-import java.util.Collections;
import java.util.Hashtable;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import javax.naming.Context;
import javax.naming.InitialContext;
+import javax.naming.NameClassPair;
import javax.naming.NameNotFoundException;
+import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import org.apache.camel.NoSuchBeanException;
@@ -31,8 +34,6 @@ import org.apache.camel.spi.Registry;
/**
* A {@link Registry} implementation which looks up the objects in JNDI
- *
- * @version
*/
public class JndiRegistry implements Registry {
private Context context;
@@ -72,13 +73,36 @@ public class JndiRegistry implements Registry {
}
public <T> Map<String, T> findByTypeWithName(Class<T> type) {
- // not implemented so we return an empty map
- return Collections.emptyMap();
+ Map<String, T> answer = new LinkedHashMap<String, T>();
+ try {
+ NamingEnumeration<NameClassPair> list = getContext().list("");
+ while (list.hasMore()) {
+ NameClassPair pair = list.next();
+ if (type.isInstance(pair.getClass())) {
+ answer.put(pair.getName(), type.cast(pair.getClass()));
+ }
+ }
+ } catch (NamingException e) {
+ // ignore
+ }
+
+ return answer;
}
public <T> Set<T> findByType(Class<T> type) {
- // not implemented so we return an empty set
- return Collections.emptySet();
+ Set<T> answer = new LinkedHashSet<T>();
+ try {
+ NamingEnumeration<NameClassPair> list = getContext().list("");
+ while (list.hasMore()) {
+ NameClassPair pair = list.next();
+ if (type.isInstance(pair.getClass())) {
+ answer.add(type.cast(pair.getClass()));
+ }
+ }
+ } catch (NamingException e) {
+ // ignore
+ }
+ return answer;
}
public Object lookup(String name) {