In a few weeks, I will be at JavaOne to talk about Apache Camel and the Camel Twitter component that I contributed, together with Brett Meyer, months ago. So while developing the demo, I found a small issue with the Camel Scala DSL that couldn't find anywhere else.
How to customize components within the Scala DSL for Apache Camel?
It happens that, using Java DSL, you can customize components simply like this:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TDCOnCamelRoute extends RouteBuilder { | |
@Override | |
public void configure() throws Exception { | |
String accessToken = System.getProperty("twitter.accessToken"); | |
String accessTokenSecret = System.getProperty("twitter.accessTokenSecret"); | |
String consumerKey = System.getProperty("twitter.consumerKey"); | |
String consumerSecret = System.getProperty("twitter.consumerSecret"); | |
TwitterComponent tc = new TwitterComponent(); | |
tc.setAccessToken(accessToken); | |
tc.setAccessTokenSecret(accessTokenSecret); | |
tc.setConsumerKey(consumerKey); | |
tc.setConsumerSecret(consumerSecret); | |
getContext().addComponent("twitter", tc); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TDCOnCamelRoute extends RouteBuilder { | |
val accessToken = System.getProperty("twitter.accessToken") | |
val accessTokenSecret = System.getProperty("twitter.accessTokenSecret") | |
val consumerKey = System.getProperty("twitter.consumerKey") | |
val consumerSecret = System.getProperty("twitter.consumerSecret") | |
val tc = new TwitterComponent() | |
tc.setAccessToken(accessToken) | |
tc.setAccessTokenSecret(accessTokenSecret) | |
tc.setConsumerKey(consumerKey) | |
tc.setConsumerSecret(consumerSecret) | |
getContext.addComponent("twitter", tc) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TDCOnCamelRoute extends RouteBuilder { | |
val accessToken = System.getProperty("twitter.accessToken") | |
val accessTokenSecret = System.getProperty("twitter.accessTokenSecret") | |
val consumerKey = System.getProperty("twitter.consumerKey") | |
val consumerSecret = System.getProperty("twitter.consumerSecret") | |
val tc = new TwitterComponent() | |
tc.setAccessToken(accessToken) | |
tc.setAccessTokenSecret(accessTokenSecret) | |
tc.setConsumerKey(consumerKey) | |
tc.setConsumerSecret(consumerSecret) | |
override def onJavaBuilder(builder: org.apache.camel.builder.RouteBuilder) = { | |
builder.getContext().addComponent("twitter", tc) | |
} | |
} |
Nenhum comentário:
Postar um comentário