I would like to export spring bean from one bundle context to another. Problems begin when this bean doesn't have an interface such as MongoClient. First bundle context register Mongoclient, but when I want to expose it to another one I get: "no bean could be found in the registry for mongo of type: com.mongodb.Mongo" from reference bundle. Is there any way to define a bean in OSGi registry by class, not interface?
Exception comes from reference bundle:
Exception in thread "SpringOsgiExtenderThread-86"
org.apache.camel.RuntimeCamelException:
org.apache.camel.FailedToCreateRouteException: Failed to create route article-author-getAll at: >>> Filter[{in ([header{operationName} ==
getAllAuthors])} -> [SetHeader[CamelMongoDbLimit, {2}],
To[mongodb:mongo?database=xxxx&collection=xxxx&operation=findAll], Log[after db select getAllAuthors ${body}]]] <<< in route:
Route(article-author-getAll)[[From[activemq:queue:backend.au...
because of Failed to resolve endpoint:
mongodb://mongo?collection=xxx&database=xxxx&operation=findAll due to: No bean could be found in the registry for: mongo of type:
com.mongodb.Mongo
In service bundle, everything looks good!
code looks like this in service bundle:
<bean id="mongoDatasource" class="com.mongodb.MongoClient">
<constructor-arg name="uri" ref="mongoClientUri" />
</bean>
<bean id="mongoClientUri" class="com.mongodb.MongoClientURI">
<constructor-arg name="uri" value="${mongo_host}" />
</bean>
Code from reference bundle context:
<reference id="mongoDataSourceReference" bean-name="mongoDatasource"
context-class-loader="service-provider"
interface="com.mongodb.MongoClient"/>
MongoClient doesn't have interface and osgi:reference must have defined interface property.
I've tried to extend MongoClient class and implements Interface and then expose it to osgi registry I received it properly in reference bundle but then I got exception from camelMongo where I must define only MongoClient class!
Camel Mongo route look like this:
from("direct:findAll")
.to("mongodb:MYMONGOCLIENTBEAN?database=flights&collection=tickets&operation=findAll")
Camel mongo route expect MongoClient bean in connection string.
So is there any way to define the bean in osgi registry by class, not interface? or I should define MongoClient bean in the same bundle as camelMongo ?