You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Bruno Borges <br...@gmail.com> on 2012/09/14 21:15:46 UTC
Global config of components and Scala DSL
Hi,
Have anyone had any problem trying to configure components and using Scala
DSL?
I'm trying to configure the TwitterComponent in a RouteBuilder with Scala
DSL but changes are not being picked by the component.
class DemoRouteBuilder extends RouteBuilder {
... extract twitter.properties to asign to the component
val tc = new TwitterComponent()
tc.setAccessToken(accessToken)
tc.setAccessTokenSecret(accessTokenSecret)
tc.setConsumerKey(consumerKey)
tc.setConsumerSecret(consumerSecret)
getContext.addComponent("twitter", tc)
"twitter://streaming/sample?type=event" to "log:output"
}
Twitter4J tells me the the accessToken has not being informed.
The same code works fine using Java DSL
*Bruno Borges*
(11) 99564-9058
*www.brunoborges.com*
Re: Global config of components and Scala DSL
Posted by Bruno Borges <br...@gmail.com>.
Answering my own question, for the sake of history :-)
Blog post about this issue:
http://blog.brunoborges.com.br/2012/09/customizing-camel-components-within.html
Or simply put:
class CamelRoute extends RouteBuilder {
val accessToken = System.getProperty("twitter.accessToken")
...
val tc = new TwitterComponent()
tc.setAccessToken(accessToken)
...
override def onJavaBuilder(builder:
org.apache.camel.builder.RouteBuilder) = {
builder.getContext().addComponent("twitter", tc)
}
}
Best regards,
*Bruno Borges*
(11) 99564-9058
*www.brunoborges.com*
On Fri, Sep 14, 2012 at 4:15 PM, Bruno Borges <br...@gmail.com>wrote:
> Hi,
>
> Have anyone had any problem trying to configure components and using Scala
> DSL?
>
> I'm trying to configure the TwitterComponent in a RouteBuilder with Scala
> DSL but changes are not being picked by the component.
>
> class DemoRouteBuilder extends RouteBuilder {
>
> ... extract twitter.properties to asign to the component
>
> val tc = new TwitterComponent()
> tc.setAccessToken(accessToken)
> tc.setAccessTokenSecret(accessTokenSecret)
> tc.setConsumerKey(consumerKey)
> tc.setConsumerSecret(consumerSecret)
>
> getContext.addComponent("twitter", tc)
>
> "twitter://streaming/sample?type=event" to "log:output"
>
> }
>
> Twitter4J tells me the the accessToken has not being informed.
>
> The same code works fine using Java DSL
>
> *Bruno Borges*
> (11) 99564-9058
> *www.brunoborges.com*
>
>