camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ioca...@apache.org
Subject svn commit: r1403265 - in /camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi: OsgiComponentResolver.java OsgiDataFormatResolver.java OsgiLanguageResolver.java
Date Mon, 29 Oct 2012 12:23:18 GMT
Author: iocanel
Date: Mon Oct 29 12:23:18 2012
New Revision: 1403265

URL: http://svn.apache.org/viewvc?rev=1403265&view=rev
Log:
[CAMEL-5756] OSGi resolvers for component, dataformat and language, now check if service is
assignable

Modified:
    camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiComponentResolver.java
    camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiDataFormatResolver.java
    camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiLanguageResolver.java

Modified: camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiComponentResolver.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiComponentResolver.java?rev=1403265&r1=1403264&r2=1403265&view=diff
==============================================================================
--- camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiComponentResolver.java
(original)
+++ camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiComponentResolver.java
Mon Oct 29 12:23:18 2012
@@ -68,9 +68,14 @@ public class OsgiComponentResolver imple
         LOG.trace("Finding Component: {}", name);
         try {
             ServiceReference[] refs = bundleContext.getServiceReferences(ComponentResolver.class.getName(),
"(component=" + name + ")");
-            if (refs != null && refs.length > 0) {
-                ComponentResolver resolver = (ComponentResolver) bundleContext.getService(refs[0]);
-                return resolver.resolveComponent(name, context);
+            if (refs != null) {
+                for (ServiceReference ref : refs) {
+                    Object service = bundleContext.getService(ref);
+                    if (ComponentResolver.class.isAssignableFrom(service.getClass())) {
+                        ComponentResolver resolver = (ComponentResolver) service;
+                        return resolver.resolveComponent(name, context);
+                    }
+                }
             }
             return null;
         } catch (InvalidSyntaxException e) {

Modified: camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiDataFormatResolver.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiDataFormatResolver.java?rev=1403265&r1=1403264&r2=1403265&view=diff
==============================================================================
--- camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiDataFormatResolver.java
(original)
+++ camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiDataFormatResolver.java
Mon Oct 29 12:23:18 2012
@@ -58,9 +58,14 @@ public class OsgiDataFormatResolver impl
         LOG.trace("Finding DataFormat: {}", name);
         try {
             ServiceReference[] refs = bundleContext.getServiceReferences(DataFormatResolver.class.getName(),
"(dataformat=" + name + ")");
-            if (refs != null && refs.length > 0) {
-                DataFormatResolver resolver = (DataFormatResolver) bundleContext.getService(refs[0]);
-                return resolver.resolveDataFormat(name, context);
+            if (refs != null) {
+                for (ServiceReference ref : refs) {
+                    Object service = bundleContext.getService(ref);
+                    if (DataFormatResolver.class.isAssignableFrom(service.getClass())) {
+                        DataFormatResolver resolver = (DataFormatResolver) service;
+                        return resolver.resolveDataFormat(name, context);
+                    }
+                }
             }
             return null;
         } catch (InvalidSyntaxException e) {

Modified: camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiLanguageResolver.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiLanguageResolver.java?rev=1403265&r1=1403264&r2=1403265&view=diff
==============================================================================
--- camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiLanguageResolver.java
(original)
+++ camel/trunk/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiLanguageResolver.java
Mon Oct 29 12:23:18 2012
@@ -67,10 +67,16 @@ public class OsgiLanguageResolver implem
         LOG.trace("Finding Language: {}", name);
         try {
             ServiceReference[] refs = bundleContext.getServiceReferences(LanguageResolver.class.getName(),
"(language=" + name + ")");
-            if (refs != null && refs.length > 0) {
-                LanguageResolver resolver = (LanguageResolver) bundleContext.getService(refs[0]);
-                return resolver.resolveLanguage(name, context);
+            if (refs != null) {
+                for (ServiceReference ref : refs) {
+                    Object service = bundleContext.getService(ref);
+                    if (LanguageResolver.class.isAssignableFrom(service.getClass())) {
+                        LanguageResolver resolver = (LanguageResolver) service;
+                        return resolver.resolveLanguage(name, context);
+                    }
+                }
             }
+
             return null;
         } catch (InvalidSyntaxException e) {
             throw ObjectHelper.wrapRuntimeCamelException(e);
@@ -81,9 +87,14 @@ public class OsgiLanguageResolver implem
         LOG.trace("Finding LanguageResolver: {}", name);
         try {
             ServiceReference[] refs = bundleContext.getServiceReferences(LanguageResolver.class.getName(),
"(resolver=" + name + ")");
-            if (refs != null && refs.length > 0) {
-                LanguageResolver resolver = (LanguageResolver) bundleContext.getService(refs[0]);
-                return resolver;
+            if (refs != null) {
+                for (ServiceReference ref : refs) {
+                    Object service = bundleContext.getService(ref);
+                    if (service.getClass().isAssignableFrom(LanguageResolver.class)) {
+                        LanguageResolver resolver = (LanguageResolver) service;
+                        return resolver;
+                    }
+                }
             }
             return null;
         } catch (InvalidSyntaxException e) {



Mime
View raw message