Java 类org.apache.camel.component.twitter.TwitterComponent 实例源码

项目:Camel    文件:TwitterWebSocketRoute.java   
@Override
public void configure() throws Exception {
    // setup Camel web-socket component on the port we have defined
    WebsocketComponent wc = getContext().getComponent("websocket", WebsocketComponent.class);
    wc.setPort(port);
    // we can serve static resources from the classpath: or file: system
    wc.setStaticResources("classpath:.");

    // setup Twitter component
    TwitterComponent tc = getContext().getComponent("twitter", TwitterComponent.class);
    tc.setAccessToken(accessToken);
    tc.setAccessTokenSecret(accessTokenSecret);
    tc.setConsumerKey(consumerKey);
    tc.setConsumerSecret(consumerSecret);

    // poll twitter search for new tweets
    fromF("twitter://search?type=polling&delay=%s&keywords=%s", delay, searchTerm)
        .to("log:tweet")
        // and push tweets to all web socket subscribers on camel-tweet
        .to("websocket:camel-tweet?sendToAll=true");
}
项目:servicemix-example-twitter    文件:TwitterRouteBuilder.java   
/**
 * Configura el componente para el acceso a twitter.
 */
private void initTwitter()
{
    TwitterComponent tc = new TwitterComponent();
    getContext().addComponent( "twitter", tc );

    Properties p = new Properties();
    try
    {
        p.load( getClass().getResourceAsStream( "/twitter4j.properties" ) );
    }
    catch ( IOException i )
    {
        throw new RuntimeException(
                                    "No se pudo encontrar el fichero con las credenciales para el acceso a Twitter",
                                    i );
    }

    tc.setAccessToken( p.getProperty( "oauth.accessToken" ) );
    tc.setAccessTokenSecret( p.getProperty( "oauth.accessTokenSecret" ) );
    tc.setConsumerKey( p.getProperty( "oauth.consumerKey" ) );
    tc.setConsumerSecret( p.getProperty( "oauth.consumerSecret" ) );
}
项目:the-job-announcement    文件:ContextBootStrap.java   
@PostConstruct
public void init() throws Exception {
    logger.info(">> Starting Apache Camel's context: ...");

    /*
     *  Setup the Twitter component
     */
    TwitterComponent tc = camelCtx.getComponent("twitter", TwitterComponent.class);
    tc.setAccessToken(accessToken);
    tc.setAccessTokenSecret(accessTokenSecret);
    tc.setConsumerKey(consumerKey);
    tc.setConsumerSecret(consumerSecret);

    /*
     * Add the Camel routes
     */
    camelCtx.addRoutes(tweetRoute);

    /*
     * Start Camel context
     */
    camelCtx.start();

    logger.info(">> Camel context started and routes started.");
}
项目:Camel    文件:TwitterComponentAutoConfiguration.java   
@Bean
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(TwitterComponent.class)
public TwitterComponent configureTwitterComponent(
        CamelContext camelContext,
        TwitterComponentConfiguration configuration) throws Exception {
    TwitterComponent component = new TwitterComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    IntrospectionSupport.setProperties(camelContext,
            camelContext.getTypeConverter(), component, parameters);
    return component;
}