Hi Scott On Thu, Feb 14, 2013 at 1:38 PM, Scott Cranton <sc...@cranton.com> 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: http://camel.apache.org/configuring-camel.html 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 / suggest. > It looks like Camel will resolve "#name" values for endpoint uri > properties to the a Registry id instance. > > <bean id="bar" class="some.java.clazz"/> > > <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(some.java.clazz 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 Email: cib...@redhat.com Web: http://fusesource.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen