Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 329FB10438 for ; Sat, 8 Jun 2013 05:52:13 +0000 (UTC) Received: (qmail 9505 invoked by uid 500); 8 Jun 2013 05:52:08 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 9413 invoked by uid 500); 8 Jun 2013 05:51:59 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 9392 invoked by uid 99); 8 Jun 2013 05:51:54 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 08 Jun 2013 05:51:54 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id EB6A08A0BB2; Sat, 8 Jun 2013 05:51:53 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jstrachan@apache.org To: commits@camel.apache.org Message-Id: <3478e58172e74f91bd821bc4f8f6fbe6@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: add an OSGi specific implementation of the findComponents() helper method on the MBean and on the CamelContext API so that implementations can behave differently (e.g. inside OSGi and outside) Date: Sat, 8 Jun 2013 05:51:53 +0000 (UTC) Updated Branches: refs/heads/master 2fe5d2aca -> 5e1a3a3ea add an OSGi specific implementation of the findComponents() helper method on the MBean and on the CamelContext API so that implementations can behave differently (e.g. inside OSGi and outside) Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/5e1a3a3e Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/5e1a3a3e Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/5e1a3a3e Branch: refs/heads/master Commit: 5e1a3a3ea80d0b455eb445ede1e7fa6c96d4538f Parents: 2fe5d2a Author: James Strachan Authored: Sat Jun 8 07:51:45 2013 +0200 Committer: James Strachan Committed: Sat Jun 8 07:51:45 2013 +0200 ---------------------------------------------------------------------- .../main/java/org/apache/camel/CamelContext.java | 15 ++++++++++++--- .../org/apache/camel/impl/DefaultCamelContext.java | 6 ++++++ .../management/mbean/ManagedCamelContext.java | 2 +- .../org/apache/camel/util/CamelContextHelper.java | 12 +++++++++--- .../camel/core/osgi/OsgiDefaultCamelContext.java | 15 +++++++++++++++ 5 files changed, 43 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/5e1a3a3e/camel-core/src/main/java/org/apache/camel/CamelContext.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/CamelContext.java b/camel-core/src/main/java/org/apache/camel/CamelContext.java index 5a87ea0..5b2b4f6 100644 --- a/camel-core/src/main/java/org/apache/camel/CamelContext.java +++ b/camel-core/src/main/java/org/apache/camel/CamelContext.java @@ -16,10 +16,10 @@ */ package org.apache.camel; +import java.io.IOException; import java.io.InputStream; -import java.util.Collection; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.Properties; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; @@ -53,6 +53,7 @@ import org.apache.camel.spi.ServicePool; import org.apache.camel.spi.ShutdownStrategy; import org.apache.camel.spi.TypeConverterRegistry; import org.apache.camel.spi.UuidGenerator; +import org.apache.camel.util.LoadPropertiesException; /** * Interface used to represent the context used to configure routes and the @@ -1196,4 +1197,12 @@ public interface CamelContext extends SuspendableService, RuntimeConfiguration { * @param useBreadcrumb true to enable breadcrumb, false to disable */ void setUseBreadcrumb(Boolean useBreadcrumb); + + /** + * Find information about all the Camel components available in the classpath and {@link org.apache.camel.spi.Registry}. + * + * @return a map with the component name, and value with component details. + * @throws Exception is thrown if error occurred + */ + Map findComponents() throws LoadPropertiesException, IOException; } http://git-wip-us.apache.org/repos/asf/camel/blob/5e1a3a3e/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java index 56a5504..c61c79f 100644 --- a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java +++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java @@ -29,6 +29,7 @@ import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; +import java.util.Properties; import java.util.Set; import java.util.TreeMap; import java.util.concurrent.ScheduledExecutorService; @@ -125,6 +126,7 @@ import org.apache.camel.util.CamelContextHelper; import org.apache.camel.util.EndpointHelper; import org.apache.camel.util.EventHelper; import org.apache.camel.util.IntrospectionSupport; +import org.apache.camel.util.LoadPropertiesException; import org.apache.camel.util.ObjectHelper; import org.apache.camel.util.ServiceHelper; import org.apache.camel.util.StopWatch; @@ -1005,6 +1007,10 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon } } + public Map findComponents() throws LoadPropertiesException, IOException { + return CamelContextHelper.findComponents(this); + } + // Helper methods // ----------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/5e1a3a3e/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java index 2f5a76e..d01d3d0 100644 --- a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java +++ b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java @@ -342,7 +342,7 @@ public class ManagedCamelContext extends ManagedPerformanceCounter implements Ti } public Map findComponents() throws Exception { - return CamelContextHelper.findComponents(context); + return context.findComponents(); } public List findComponentNames() throws Exception { http://git-wip-us.apache.org/repos/asf/camel/blob/5e1a3a3e/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java b/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java index 03b5422..40d7a1c 100644 --- a/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java +++ b/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java @@ -354,10 +354,16 @@ public final class CamelContextHelper { * Finds all possible Components on the classpath and Registry */ public static SortedMap findComponents(CamelContext camelContext) throws LoadPropertiesException { - SortedMap map = new TreeMap(); Enumeration iter = camelContext.getClassResolver().loadResourcesAsURL(COMPONENT_DESCRIPTOR); - while (iter != null && iter.hasMoreElements()) { - URL url = iter.nextElement(); + return findComponents(camelContext, iter); + } + + public static SortedMap findComponents(CamelContext camelContext, + Enumeration componentDescriptionIter) + throws LoadPropertiesException { + SortedMap map = new TreeMap(); + while (componentDescriptionIter != null && componentDescriptionIter.hasMoreElements()) { + URL url = componentDescriptionIter.nextElement(); try { Properties properties = new Properties(); properties.load(url.openStream()); http://git-wip-us.apache.org/repos/asf/camel/blob/5e1a3a3e/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiDefaultCamelContext.java ---------------------------------------------------------------------- diff --git a/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiDefaultCamelContext.java b/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiDefaultCamelContext.java index 80002c1..9f7b0b2 100644 --- a/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiDefaultCamelContext.java +++ b/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiDefaultCamelContext.java @@ -16,11 +16,20 @@ */ package org.apache.camel.core.osgi; +import java.io.IOException; +import java.net.URL; +import java.util.Enumeration; +import java.util.Map; +import java.util.Properties; + import org.apache.camel.TypeConverter; import org.apache.camel.core.osgi.utils.BundleContextUtils; import org.apache.camel.impl.DefaultCamelContext; import org.apache.camel.spi.FactoryFinder; import org.apache.camel.spi.Registry; +import org.apache.camel.util.CamelContextHelper; +import org.apache.camel.util.LoadPropertiesException; +import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; public class OsgiDefaultCamelContext extends DefaultCamelContext { @@ -38,6 +47,12 @@ public class OsgiDefaultCamelContext extends DefaultCamelContext { OsgiCamelContextHelper.osgiUpdate(this, bundleContext); } + public Map findComponents() throws LoadPropertiesException, IOException { + Bundle bundle = bundleContext.getBundle(); + Enumeration iter = bundle.getResources(CamelContextHelper.COMPONENT_DESCRIPTOR); + return CamelContextHelper.findComponents(this, iter); + } + @Override protected Registry createRegistry() { if (registry != null) {