Author: ningjiang
Date: Thu Sep 17 09:50:44 2009
New Revision: 816114

URL: http://svn.apache.org/viewvc?rev=816114&view=rev
Log:
CAMEL-1936 backport the patch to camel-1.x branch

Modified:
    camel/branches/camel-1.x/   (props changed)
    
camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiAnnotationTypeConverterLoader.java
    
camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiResolverUtil.java

Propchange: camel/branches/camel-1.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Sep 17 09:50:44 2009
@@ -1 +1 @@
-/camel/trunk:736980,739733,739904,740251,740295,740306,740596,740663,741848,742231,742705,742739,742854,742856,742898,742906,743613,743762,743773,743920,743959-743960,744123,745105,745367,745541,745751,745826,745978,746269,746872,746895,746962,747258,747678-747704,748392,748436,748821,749563-749564,749574,749628-749629,749936,749956,750017,750334,750396,750761,750796,752068,752117,752418,752751-752755,752764-752773,752956,753087,753101,753175,755136,755487,756313,756348,756870,756939,757636,757693,757743,757865,758539,758563,758600,758617,758692,758990,759362,759453,759887,759931,760003,760890,760909,760937,761194,761536,761583,761607,762047,762633,762650,762935,763095,763484,763551,765154,765686,765729,765743,765824,766016,766289,766584,766588,766590,766602,766673,767403,767824,768342,769239,769346,769368,769434,770172,770906,771303,773193,773446,773781,774192,774383,774658-774659,776198,776289,776504,776975,778102,778689-778701,779121,779143,779489,781314-781349,781775,781
 
923,781974,781993,782557,782594,782681,782886,782918-782923,783204,783248,783363,783639,783704,785564,785584,785599,787206,787581,787598,787605,787928,788393,789121,789703,790560,790936,791379,791476,791767,792038,792381,792398,792899,793359,793518,793547-793555,793862,793935,794237,794368,794550,794967,795790,798027,798052,798063,798489,798864,799252,800340,800785,800797,801960,802307,802478,803559,807476,810751,812937,814493
+/camel/trunk:736980,739733,739904,740251,740295,740306,740596,740663,741848,742231,742705,742739,742854,742856,742898,742906,743613,743762,743773,743920,743959-743960,744123,745105,745367,745541,745751,745826,745978,746269,746872,746895,746962,747258,747678-747704,748392,748436,748821,749563-749564,749574,749628-749629,749936,749956,750017,750334,750396,750761,750796,752068,752117,752418,752751-752755,752764-752773,752956,753087,753101,753175,755136,755487,756313,756348,756870,756939,757636,757693,757743,757865,758539,758563,758600,758617,758692,758990,759362,759453,759887,759931,760003,760890,760909,760937,761194,761536,761583,761607,762047,762633,762650,762935,763095,763484,763551,765154,765686,765729,765743,765824,766016,766289,766584,766588,766590,766602,766673,767403,767824,768342,769239,769346,769368,769434,770172,770906,771303,773193,773446,773781,774192,774383,774658-774659,776198,776289,776504,776975,778102,778689-778701,779121,779143,779489,781314-781349,781775,781
 
923,781974,781993,782557,782594,782681,782886,782918-782923,783204,783248,783363,783639,783704,785564,785584,785599,787206,787581,787598,787605,787928,788393,789121,789703,790560,790936,791379,791476,791767,792038,792381,792398,792899,793359,793518,793547-793555,793862,793935,794237,794368,794550,794967,795790,798027,798052,798063,798489,798864,799252,800340,800785,800797,801960,802307,802478,803559,807476,810751,812937,814493,816105

Propchange: camel/branches/camel-1.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: 
camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiAnnotationTypeConverterLoader.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiAnnotationTypeConverterLoader.java?rev=816114&r1=816113&r2=816114&view=diff
==============================================================================
--- 
camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiAnnotationTypeConverterLoader.java
 (original)
+++ 
camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiAnnotationTypeConverterLoader.java
 Thu Sep 17 09:50:44 2009
@@ -37,7 +37,7 @@
     @Override
     public void load(TypeConverterRegistry registry) throws Exception {
         for (Activator.TypeConverterEntry entry : 
Activator.getTypeConverterEntries()) {
-            OsgiResolverUtil resolver = new 
OsgiResolverUtil(entry.bundle.getBundleContext());
+            OsgiResolverUtil resolver = new OsgiResolverUtil(entry.bundle);
             String[] packages = entry.converterPackages.toArray(new 
String[entry.converterPackages.size()]);
             resolver.findAnnotated(Converter.class, packages);
             Set<Class> classes = resolver.getClasses();

Modified: 
camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiResolverUtil.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiResolverUtil.java?rev=816114&r1=816113&r2=816114&view=diff
==============================================================================
--- 
camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiResolverUtil.java
 (original)
+++ 
camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiResolverUtil.java
 Thu Sep 17 09:50:44 2009
@@ -32,6 +32,10 @@
 public class OsgiResolverUtil extends ResolverUtil {
     private Bundle bundle;
     
+    public OsgiResolverUtil(Bundle bundle) {
+        this.bundle = bundle;
+    }
+    
     public OsgiResolverUtil(BundleContext context) {
         bundle = context.getBundle();
     }
@@ -150,10 +154,20 @@
 
         static Set<String> getImplementationsInBundle(Test test, String 
packageName, ClassLoader loader, Method mth) {
             try {
-                org.osgi.framework.Bundle bundle = (org.osgi.framework.Bundle) 
mth.invoke(loader);
-                org.osgi.framework.Bundle[] bundles = 
bundle.getBundleContext().getBundles();
+                Bundle bundle = (Bundle) mth.invoke(loader);                
+                Bundle[] bundles = null;
+                
+                BundleContext bundleContext = bundle.getBundleContext();
+                if (bundleContext == null) {
+                    // Bundle is not in STARTING|ACTIVE|STOPPING state
+                    // (See OSGi 4.1 spec, section 4.3.17)
+                    bundles = new Bundle[] {bundle};
+                } else {
+                    bundles = bundleContext.getBundles();
+                }
+                
                 Set<String> urls = new HashSet<String>();
-                for (org.osgi.framework.Bundle bd : bundles) {
+                for (Bundle bd : bundles) {
                     if (LOG.isTraceEnabled()) {
                         LOG.trace("Searching in bundle:" + bd);
                     }


Reply via email to