Hi Jens,

The '#' symbol in Camel denotes a reference [1] which Camel will then try
to lookup in it's registries [2]. In an OSGI environment, Camel will lookup
the reference in the OsgiServiceRegistry [3] which thanks to [4] will try
to look up the OSGI service by class name AND service PID :). However, it
doesn't look like this PR is in any release so you'll have to use the
master branch for now.

Note that the service PID can change so by default I would recommend
looking up by class name which is supported in earlier versions of Camel.
So using the URI:

kura-cloud:myapp/xmltopic?cloudService=org.eclipse.kura.cloud.CloudService

should work.

Hope this helps,

John.


[1]
https://github.com/apache/camel/blob/master/camel-core/src/main/java/org/apache/camel/util/EndpointHelper.java#L292
[2]
https://github.com/apache/camel/blob/337a6756480354afea7531a1a4216de9d232f211/camel-core/src/main/java/org/apache/camel/impl/CompositeRegistry.java#L79
[3]
https://github.com/apache/camel/blob/master/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiServiceRegistry.java
[4] https://github.com/apache/camel/pull/1083

On Tue, Sep 13, 2016 at 5:27 PM, Jens Reimann <jreim...@redhat.com> wrote:

> Hi,
>
> I am currently trying to solve an issue of injecting a service with OSGi
> in an URL based endpoint. Using Camel 2.17.2.
>
> For example the URL is "kura-cloud:myapp/xmltopic?cloudService=#pid"
>
> I am using the OsgiDefaultCamelContext. The Camel component does call
> "setProperties(endpoint, properties)" with the provided properties map of
> camel. And now I would expect camel to lookup the OSGi service with the
> "service.pid=pid" and inject this, using the "setCloudService" setter on
> the endpoint.
>
> However I do get:
>
> ---
> Caused by: java.lang.IllegalArgumentException: Could not find a suitable
> setter for property: cloudService as there isn't a setter method with same
> type: java.lang.String nor type conversion possible: No type converter
> available to convert from type: java.lang.String to the required type:
> org.eclipse.kura.cloud.CloudService with value #pid
>     at org.apache.camel.util.IntrospectionSupport.setProperty(
> IntrospectionSupport.java:588)
>     at org.apache.camel.util.IntrospectionSupport.setProperty(
> IntrospectionSupport.java:616)
>     at org.apache.camel.util.IntrospectionSupport.setProperties(
> IntrospectionSupport.java:473)
>     at org.apache.camel.util.IntrospectionSupport.setProperties(
> IntrospectionSupport.java:483)
>     at org.apache.camel.util.EndpointHelper.setProperties(
> EndpointHelper.java:255)
>     at org.apache.camel.impl.DefaultComponent.setProperties(
> DefaultComponent.java:257)
>     at org.eclipse.kura.camel.cloud.KuraCloudComponent.createEndpoint(
> KuraCloudComponent.java:74)
>     at org.apache.camel.impl.DefaultComponent.createEndpoint(
> DefaultComponent.java:114)
>     at org.apache.camel.impl.DefaultCamelContext.getEndpoint(
> DefaultCamelContext.java:568)
> ---
>
> Any help debugging or understand this would be great.
>
> Thanks
>
> Jens
>
> --
> Jens Reimann
> Senior Software Engineer / EMEA ENG Middleware
> Werner-von-Siemens-Ring 14
> 85630 Grasbrunn
> Germany
> phone: +49 89 2050 71286
> ____________________________________________________________
> _________________
>
> Red Hat GmbH, www.de.redhat.com,
> Registered seat: Grasbrunn, Commercial register: Amtsgericht Muenchen, HRB
> 153243,
> Managing Directors: Paul Argiry, Charles Cachera, Michael Cunningham,
> Michael O'Neill
>

Reply via email to