camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <>
Subject Re: URI references to Objects in the Registry
Date Thu, 14 Feb 2013 14:30:23 GMT
Hi Scott

On Thu, Feb 14, 2013 at 1:38 PM, Scott Cranton <> wrote:
> I've just noticed the reference syntax that some components use, but
> its not clear to me exactly how it works, and more importantly how new
> components are supposed to use it correctly... I don't see any
> documentation on it, and I've only found some mentions of it in the
> JIRA where it was created and in the camel code itself.
> Sorry if I missed an earlier thread on this, but I couldn't find it...

Yeah Camel has many many pages. Its documented here:

At the section .. Referring beans from Endpoint URIs.

Maybe we should add a FAQ as well?
And if you have suggestions for other places in the docs to add
reference / note about this, then feel free to change the docs /

> It looks like Camel will resolve "#name" values for endpoint uri
> properties to the a Registry id instance.
> <bean id="bar" class=""/>
> <to uri="someEndpoint:foo?objectProperty=#bar" />
> The above syntax will set the Component's configuration, internally
> resolving "#bar" to the bean instance from the Camel Registry...
> setObjectProperty( value)

Yes the # is a reference lookup in the registry and will match with
the bean type as well.

> I'm also seeing some cases where it looks like there is magic if you
> suffix a property name with "Ref" that will do the same thing...

There is no magic. There is an option with that name.

> <to uri="someEndpoint:foo?objectPropertyRef=bar"/>

They are typically from the earlier days of Camel where we did not
have the # lookup.
Then we needed to have 2 options for the same thing. So you can
configure it as a java type.
And as well sometimes to refer to the registry. And hence we had the
xxx and xxxRef options.

> I assume its the same base Component and Endpoint code that's
> resolving this, but I can't find it (yet)...
> The confusing bit is that some Processors and Component doc use
> different conventions...
> It looks like an effort was made to normalize this convention around
> version 2.2 or 2.3 timeframe, hence some of the inconsistencies... My
> question is what is the current "best practice" and/or what would we
> like the convention, both in code and in doc, for version 3
> BTW: I like the reference syntax, but it did take me a bit to figure
> out "is this a Spring thing" or "Camel magic", and "is it just '#name'
> that is magic and/or is suffixing with Ref magic", etc.
> Thanks,
> Scott

You can check the source code for DefaultComponent as thats the one
that usually handles this.

We have some helper classes that does all the hard work

  EndpointHelper.setReferenceProperties(getCamelContext(), bean, parameters);
        EndpointHelper.setProperties(getCamelContext(), bean, parameters);

Claus Ibsen
Red Hat, Inc.
FuseSource is now part of Red Hat
Twitter: davsclaus
Author of Camel in Action:

View raw message