Have you tried using the org.apache.camel.osgi.CamelContextFactory?
It is located in the camel-spring module. Honestly no idea why as it does not have to do with spring.

cf = new CamelContextFactory();
cf.setBundleContext(context);
cf.createContext();

You can do this from you bundle Activator. This creates a CamelContext suitable for Osgi that finds all converters and components. The nice thing is that you do not even have to import the packages for the components.

Christian

Am 27.06.2011 22:21, schrieb Michael Furtak:
Ok. I seem to have found a resolution. Now the question is whether or not it is 
appropriate. :)

Since we seemed to agree that classes are not being found by their annotations, 
I tried to backtrace how that was being resolved. Where I wound up was in 
org.apache.camel.core.osgi.OsgiTypeConverter.createRegistry(OsgiTypeConverter.java:166)

There, it seems to be setting up the DefaultTypeConverter which will be used as 
the delegate. It sets it up to use a DefaultPackageScanClassResolver, which 
seems to be failing to find anything. If I change:

protected DefaultTypeConverter createRegistry() {
   // base the osgi type converter on the default type converter
   DefaultTypeConverter answer = new DefaultTypeConverter(new 
DefaultPackageScanClassResolver() {
     @Override
     public Set<ClassLoader>  getClassLoaders() {
       // we don't need any classloaders as we use osgi service tracker instead
       return Collections.emptySet();
     }
   }, injector, factoryFinder);
// ...

to:

protected DefaultTypeConverter createRegistry() {
   // base the osgi type converter on the default type converter
   PackageScanClassResolver resolver = new 
OsgiPackageScanClassResolver(bundleContext);
   DefaultTypeConverter answer = new DefaultTypeConverter(resolver, injector, 
factoryFinder);


then I get a successful startup and a working test case:

from("file:data/inbox").to("file:data/outbox");


Hurrah! So, is this a reasonable fix? Does the code I replaced in 
OsgiTypeConverter make sense as written?

Thanks to all who've helped so far.

-Mike



--
--
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
Talend Application Integration Division http://www.talend.com

Reply via email to