You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2012/01/05 11:34:27 UTC
svn commit: r1227546 [1/3] - in /camel/trunk/components: ./ camel-twitter/
camel-twitter/src/ camel-twitter/src/main/ camel-twitter/src/main/java/
camel-twitter/src/main/java/org/ camel-twitter/src/main/java/org/apache/
camel-twitter/src/main/java/org/...
Author: ningjiang
Date: Thu Jan 5 10:34:25 2012
New Revision: 1227546
URL: http://svn.apache.org/viewvc?rev=1227546&view=rev
Log:
CAMEL-4017 Added camel-twitter component into trunk
Added:
camel/trunk/components/camel-twitter/
camel/trunk/components/camel-twitter/pom.xml (with props)
camel/trunk/components/camel-twitter/src/
camel/trunk/components/camel-twitter/src/main/
camel/trunk/components/camel-twitter/src/main/java/
camel/trunk/components/camel-twitter/src/main/java/org/
camel/trunk/components/camel-twitter/src/main/java/org/apache/
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/Twitter4JFactory.java (with props)
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterComponent.java (with props)
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpoint.java (with props)
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointDirect.java (with props)
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointPolling.java (with props)
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/Twitter4JConsumer.java (with props)
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/TwitterConsumer.java (with props)
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/TwitterConsumerDirect.java (with props)
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/TwitterConsumerPolling.java (with props)
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/directmessage/
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/directmessage/DirectMessageConsumer.java (with props)
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/search/
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/search/SearchConsumer.java (with props)
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/FilterConsumer.java (with props)
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/SampleConsumer.java (with props)
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/StreamingConsumer.java (with props)
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/HomeConsumer.java (with props)
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/MentionsConsumer.java (with props)
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/PublicConsumer.java (with props)
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/RetweetsConsumer.java (with props)
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/UserConsumer.java (with props)
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/ConsumerType.java (with props)
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/EndpointType.java (with props)
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/GeoLocation.java (with props)
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/Status.java (with props)
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/StreamingType.java (with props)
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/TimelineType.java (with props)
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/TrendsType.java (with props)
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/User.java (with props)
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/producer/
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/producer/DirectMessageProducer.java (with props)
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/producer/UserProducer.java (with props)
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/util/
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/util/TwitterConverter.java (with props)
camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/util/TwitterProperties.java (with props)
camel/trunk/components/camel-twitter/src/main/resources/
camel/trunk/components/camel-twitter/src/main/resources/META-INF/
camel/trunk/components/camel-twitter/src/main/resources/META-INF/LICENSE.txt (with props)
camel/trunk/components/camel-twitter/src/main/resources/META-INF/NOTICE.txt (with props)
camel/trunk/components/camel-twitter/src/main/resources/META-INF/services/
camel/trunk/components/camel-twitter/src/main/resources/META-INF/services/org/
camel/trunk/components/camel-twitter/src/main/resources/META-INF/services/org/apache/
camel/trunk/components/camel-twitter/src/main/resources/META-INF/services/org/apache/camel/
camel/trunk/components/camel-twitter/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
camel/trunk/components/camel-twitter/src/main/resources/META-INF/services/org/apache/camel/component/
camel/trunk/components/camel-twitter/src/main/resources/META-INF/services/org/apache/camel/component/twitter
camel/trunk/components/camel-twitter/src/main/resources/log4j.properties (with props)
camel/trunk/components/camel-twitter/src/test/
camel/trunk/components/camel-twitter/src/test/java/
camel/trunk/components/camel-twitter/src/test/java/org/
camel/trunk/components/camel-twitter/src/test/java/org/apache/
camel/trunk/components/camel-twitter/src/test/java/org/apache/camel/
camel/trunk/components/camel-twitter/src/test/java/org/apache/camel/component/
camel/trunk/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/
camel/trunk/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/CamelTwitterTestSupport.java (with props)
camel/trunk/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/DirectMessageDirectTest.java (with props)
camel/trunk/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/DirectMessagePollingTest.java (with props)
camel/trunk/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/HomeTimeLineDirectTest.java (with props)
camel/trunk/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/HomeTimeLinePollingTest.java (with props)
camel/trunk/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/PublicTimeLineDirectTest.java (with props)
camel/trunk/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/PublicTimeLinePollingTest.java (with props)
camel/trunk/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/SearchDirectTest.java (with props)
camel/trunk/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/SearchPollingTest.java (with props)
camel/trunk/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/UriConfigurationTest.java (with props)
camel/trunk/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/UserTimeLineDirectTest.java (with props)
camel/trunk/components/camel-twitter/src/test/java/org/apache/camel/component/twitter/UserTimeLinePollingTest.java (with props)
camel/trunk/components/camel-twitter/src/test/resources/
camel/trunk/components/camel-twitter/src/test/resources/log4j.properties (with props)
camel/trunk/components/camel-twitter/src/test/resources/test-options.properties (with props)
Modified:
camel/trunk/components/pom.xml
Added: camel/trunk/components/camel-twitter/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/pom.xml?rev=1227546&view=auto
==============================================================================
--- camel/trunk/components/camel-twitter/pom.xml (added)
+++ camel/trunk/components/camel-twitter/pom.xml Thu Jan 5 10:34:25 2012
@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-parent</artifactId>
+ <version>2.10-SNAPSHOT</version>
+ <relativePath>../../parent</relativePath>
+ </parent>
+
+ <artifactId>camel-twitter</artifactId>
+ <packaging>bundle</packaging>
+ <name>Camel :: Twitter</name>
+ <description>Camel Twitter support</description>
+
+ <properties>
+ <camel.osgi.export.pkg>org.apache.camel.component.twitter.*</camel.osgi.export.pkg>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.twitter4j</groupId>
+ <artifactId>twitter4j-core</artifactId>
+ <version>2.2.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.twitter4j</groupId>
+ <artifactId>twitter4j-stream</artifactId>
+ <version>2.2.5</version>
+ </dependency>
+ <!-- to allow Spring annotations (jmx) to be tested -->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <optional>true</optional>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-aop</artifactId>
+ <optional>true</optional>
+ <scope>test</scope>
+ </dependency>
+ <!-- testing -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <childDelegation>false</childDelegation>
+ <useFile>true</useFile>
+ <forkMode>once</forkMode>
+ <includes>
+ <!-- Here we only run test of -->
+ <include>**/*UriConfigurationTest.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>twitter-test</id>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <childDelegation>false</childDelegation>
+ <useFile>true</useFile>
+ <forkMode>once</forkMode>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
Propchange: camel/trunk/components/camel-twitter/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-twitter/pom.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: camel/trunk/components/camel-twitter/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/Twitter4JFactory.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/Twitter4JFactory.java?rev=1227546&view=auto
==============================================================================
--- camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/Twitter4JFactory.java (added)
+++ camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/Twitter4JFactory.java Thu Jan 5 10:34:25 2012
@@ -0,0 +1,194 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.twitter;
+
+import java.util.regex.Pattern;
+
+import org.apache.camel.component.twitter.consumer.Twitter4JConsumer;
+import org.apache.camel.component.twitter.consumer.directmessage.DirectMessageConsumer;
+import org.apache.camel.component.twitter.consumer.search.SearchConsumer;
+import org.apache.camel.component.twitter.consumer.streaming.FilterConsumer;
+import org.apache.camel.component.twitter.consumer.streaming.SampleConsumer;
+import org.apache.camel.component.twitter.consumer.timeline.HomeConsumer;
+import org.apache.camel.component.twitter.consumer.timeline.MentionsConsumer;
+import org.apache.camel.component.twitter.consumer.timeline.PublicConsumer;
+import org.apache.camel.component.twitter.consumer.timeline.RetweetsConsumer;
+import org.apache.camel.component.twitter.consumer.timeline.UserConsumer;
+import org.apache.camel.component.twitter.data.ConsumerType;
+import org.apache.camel.component.twitter.data.StreamingType;
+import org.apache.camel.component.twitter.data.TimelineType;
+import org.apache.camel.component.twitter.data.TrendsType;
+import org.apache.camel.component.twitter.producer.DirectMessageProducer;
+import org.apache.camel.component.twitter.producer.UserProducer;
+import org.apache.camel.impl.DefaultProducer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Maps the endpoint URI to the respective Twitter4J consumer or producer.
+ *
+ * URI STRUCTURE:
+ *
+ * timeline/
+ * public
+ * home
+ * friends
+ * user (ALSO A PRODUCER)
+ * mentions
+ * retweetsofme
+ * user/
+ * search users (DIRECT ONLY)
+ * user suggestions (DIRECT ONLY)
+ * trends/
+ * daily
+ * weekly
+ * userlist
+ * directmessage (ALSO A PRODUCER)
+ * streaming/
+ * filter (POLLING ONLY)
+ * sample (POLLING ONLY)
+ *
+ */
+public final class Twitter4JFactory {
+
+ private static final transient Logger LOG = LoggerFactory.getLogger(Twitter4JFactory.class);
+
+ private Twitter4JFactory() {
+ // helper class
+ }
+
+ public static Twitter4JConsumer getConsumer(TwitterEndpoint te, String uri)
+ throws IllegalArgumentException {
+ String[] uriSplit = splitUri(uri);
+
+ if (uriSplit.length > 0) {
+ switch (ConsumerType.fromUri(uriSplit[0])) {
+ case DIRECTMESSAGE:
+ return new DirectMessageConsumer(te);
+ case SEARCH:
+ if (te.getProperties().getKeywords() == null
+ || te.getProperties().getKeywords().trim().isEmpty()) {
+ throw new IllegalArgumentException("Type set to SEARCH but no keywords were provided.");
+ } else {
+ return new SearchConsumer(te);
+ }
+ case STREAMING:
+ switch (StreamingType.fromUri(uriSplit[1])) {
+ case SAMPLE:
+ return new SampleConsumer(te);
+ case FILTER:
+ return new FilterConsumer(te);
+ default:
+ break;
+ }
+ break;
+ case TIMELINE:
+ if (uriSplit.length > 1) {
+ switch (TimelineType.fromUri(uriSplit[1])) {
+ case HOME:
+ return new HomeConsumer(te);
+ case MENTIONS:
+ return new MentionsConsumer(te);
+ case PUBLIC:
+ return new PublicConsumer(te);
+ case RETWEETSOFME:
+ return new RetweetsConsumer(te);
+ case USER:
+ if (te.getProperties().getUser() == null
+ || te.getProperties().getUser().trim().isEmpty()) {
+ throw new IllegalArgumentException(
+ "Fetch type set to USER TIMELINE but no user was set.");
+ } else {
+ return new UserConsumer(te);
+ }
+ default:
+ break;
+ }
+ }
+ break;
+ case TRENDS:
+ if (uriSplit.length > 1) {
+ switch (TrendsType.fromUri(uriSplit[1])) {
+ case DAILY:
+ // TODO
+ break;
+ case WEEKLY:
+ // TODO
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ case USER:
+ // TODO
+ break;
+ case USERLIST:
+ // TODO
+ break;
+ default:
+ break;
+ }
+ }
+
+ LOG.warn("A consumer type was not provided (or an incorrect pairing was used). Defaulting to Public Timeline!");
+ return new PublicConsumer(te);
+ }
+
+ public static DefaultProducer getProducer(TwitterEndpoint te, String uri) throws IllegalArgumentException {
+ String[] uriSplit = splitUri(uri);
+
+ if (uriSplit.length > 0) {
+ switch (ConsumerType.fromUri(uriSplit[0])) {
+ case DIRECTMESSAGE:
+ if (te.getProperties().getUser() == null || te.getProperties().getUser().trim().isEmpty()) {
+ throw new IllegalArgumentException("Producer type set to DIRECT MESSAGE but no recipientuser was set.");
+ } else {
+ return new DirectMessageProducer(te);
+ }
+ case TIMELINE:
+ if (uriSplit.length > 1) {
+ switch (TimelineType.fromUri(uriSplit[1])) {
+ case USER:
+ return new UserProducer(te);
+ default:
+ break;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ }
+
+ LOG.warn("A producer type was not provided (or an incorrect pairing was used). Defaulting to a MOCK!");
+ throw new IllegalArgumentException("Cannot create any producer with uri " + uri
+ + "A producer type was not provided (or an incorrect pairing was used).");
+ }
+
+ private static String[] splitUri(String uri) {
+ Pattern p1 = Pattern.compile("twitter:(//)*");
+ Pattern p2 = Pattern.compile("\\?.*");
+
+ uri = p1.matcher(uri).replaceAll("");
+ uri = p2.matcher(uri).replaceAll("");
+
+ return uri.split("/");
+ }
+}
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/Twitter4JFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/Twitter4JFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterComponent.java?rev=1227546&view=auto
==============================================================================
--- camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterComponent.java (added)
+++ camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterComponent.java Thu Jan 5 10:34:25 2012
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.twitter;
+
+import java.util.Map;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.component.twitter.data.EndpointType;
+import org.apache.camel.component.twitter.util.TwitterProperties;
+import org.apache.camel.impl.DefaultComponent;
+
+/**
+ * Main component class
+ *
+ */
+public class TwitterComponent extends DefaultComponent {
+
+ protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters)
+ throws Exception {
+ TwitterProperties properties = new TwitterProperties();
+ setProperties(properties, parameters);
+
+ TwitterEndpoint endpoint = null;
+ switch (EndpointType.fromUri(properties.getType())) {
+ case POLLING:
+ endpoint = new TwitterEndpointPolling(uri, this, properties);
+ break;
+ default:
+ endpoint = new TwitterEndpointDirect(uri, this, properties);
+ break;
+ }
+
+ endpoint.initiate();
+ return endpoint;
+ }
+
+}
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterComponent.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterComponent.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpoint.java?rev=1227546&view=auto
==============================================================================
--- camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpoint.java (added)
+++ camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpoint.java Thu Jan 5 10:34:25 2012
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.twitter;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.component.twitter.util.TwitterProperties;
+
+import twitter4j.Twitter;
+
+public interface TwitterEndpoint extends Endpoint {
+
+ void initiate();
+
+ Twitter getTwitter();
+
+ TwitterProperties getProperties();
+}
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpoint.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpoint.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointDirect.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointDirect.java?rev=1227546&view=auto
==============================================================================
--- camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointDirect.java (added)
+++ camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointDirect.java Thu Jan 5 10:34:25 2012
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.twitter;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.component.direct.DirectEndpoint;
+import org.apache.camel.component.twitter.consumer.Twitter4JConsumer;
+import org.apache.camel.component.twitter.consumer.TwitterConsumerDirect;
+import org.apache.camel.component.twitter.util.TwitterProperties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import twitter4j.Twitter;
+import twitter4j.TwitterFactory;
+
+
+public class TwitterEndpointDirect extends DirectEndpoint implements TwitterEndpoint {
+
+ private static final Logger LOG = LoggerFactory.getLogger(TwitterEndpointDirect.class);
+
+ private Twitter twitter;
+
+ private TwitterProperties properties;
+
+ public TwitterEndpointDirect(String uri, TwitterComponent component, TwitterProperties properties) {
+ super(uri, component);
+ this.properties = properties;
+ }
+
+ public Consumer createConsumer(Processor processor) throws Exception {
+ Twitter4JConsumer twitter4jConsumer = Twitter4JFactory.getConsumer(this, getEndpointUri());
+ return new TwitterConsumerDirect(this, processor, twitter4jConsumer);
+ }
+
+ public Producer createProducer() throws Exception {
+ return Twitter4JFactory.getProducer(this, getEndpointUri());
+ }
+
+ public void initiate() {
+ properties.checkComplete();
+
+ try {
+ twitter = new TwitterFactory(properties.getConfiguration()).getInstance();
+ } catch (Exception e) {
+ LOG.error("Could not instantiate Twitter! Exception: " + e.getMessage());
+ }
+ }
+
+ public Twitter getTwitter() {
+ return twitter;
+ }
+
+ public TwitterProperties getProperties() {
+ return properties;
+ }
+}
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointDirect.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointDirect.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointPolling.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointPolling.java?rev=1227546&view=auto
==============================================================================
--- camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointPolling.java (added)
+++ camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointPolling.java Thu Jan 5 10:34:25 2012
@@ -0,0 +1,82 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.twitter;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.component.twitter.consumer.Twitter4JConsumer;
+import org.apache.camel.component.twitter.consumer.TwitterConsumer;
+import org.apache.camel.component.twitter.consumer.TwitterConsumerPolling;
+import org.apache.camel.component.twitter.util.TwitterProperties;
+import org.apache.camel.impl.DefaultPollingEndpoint;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import twitter4j.Twitter;
+import twitter4j.TwitterFactory;
+
+/**
+ * Scheduled polling endpoint
+ *
+ */
+public class TwitterEndpointPolling extends DefaultPollingEndpoint implements TwitterEndpoint {
+
+ private static final Logger LOG = LoggerFactory.getLogger(TwitterEndpointPolling.class);
+
+ private Twitter twitter;
+
+ private TwitterProperties properties;
+
+ public TwitterEndpointPolling(String uri, TwitterComponent component, TwitterProperties properties) {
+ super(uri, component);
+ this.properties = properties;
+ }
+
+ public Consumer createConsumer(Processor processor) throws Exception {
+ Twitter4JConsumer twitter4jConsumer = Twitter4JFactory.getConsumer(this, getEndpointUri());
+ TwitterConsumer tc = new TwitterConsumerPolling(this, processor, twitter4jConsumer);
+ configureConsumer(tc);
+ return tc;
+ }
+
+ public Producer createProducer() throws Exception {
+ return Twitter4JFactory.getProducer(this, getEndpointUri());
+ }
+
+ public void initiate() {
+ properties.checkComplete();
+
+ try {
+ twitter = new TwitterFactory(properties.getConfiguration()).getInstance();
+ } catch (Exception e) {
+ LOG.error("Could not instantiate Twitter! Exception: " + e.getMessage());
+ }
+ }
+
+ public Twitter getTwitter() {
+ return twitter;
+ }
+
+ public boolean isSingleton() {
+ return true;
+ }
+
+ public TwitterProperties getProperties() {
+ return properties;
+ }
+}
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointPolling.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointPolling.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/Twitter4JConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/Twitter4JConsumer.java?rev=1227546&view=auto
==============================================================================
--- camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/Twitter4JConsumer.java (added)
+++ camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/Twitter4JConsumer.java Thu Jan 5 10:34:25 2012
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.twitter.consumer;
+
+import java.util.Iterator;
+
+import org.apache.camel.component.twitter.data.Status;
+
+import twitter4j.TwitterException;
+
+
+public interface Twitter4JConsumer {
+
+ Iterator<Status> requestPollingStatus(long lastStatusUpdateId) throws TwitterException;
+
+ Iterator<Status> requestDirectStatus() throws TwitterException;
+}
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/Twitter4JConsumer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/Twitter4JConsumer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/TwitterConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/TwitterConsumer.java?rev=1227546&view=auto
==============================================================================
--- camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/TwitterConsumer.java (added)
+++ camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/TwitterConsumer.java Thu Jan 5 10:34:25 2012
@@ -0,0 +1,23 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.twitter.consumer;
+
+import org.apache.camel.Consumer;
+
+public interface TwitterConsumer extends Consumer {
+
+}
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/TwitterConsumer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/TwitterConsumer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/TwitterConsumerDirect.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/TwitterConsumerDirect.java?rev=1227546&view=auto
==============================================================================
--- camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/TwitterConsumerDirect.java (added)
+++ camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/TwitterConsumerDirect.java Thu Jan 5 10:34:25 2012
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.twitter.consumer;
+
+import java.util.Iterator;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.direct.DirectConsumer;
+import org.apache.camel.component.twitter.TwitterEndpoint;
+import org.apache.camel.component.twitter.data.Status;
+
+/**
+ * Camel DirectConsumer implementation.
+ *
+ */
+public class TwitterConsumerDirect extends DirectConsumer implements TwitterConsumer {
+
+ private Twitter4JConsumer twitter4jConsumer;
+
+ public TwitterConsumerDirect(TwitterEndpoint endpoint, Processor processor,
+ Twitter4JConsumer twitter4jConsumer) {
+ super(endpoint, processor);
+
+ this.twitter4jConsumer = twitter4jConsumer;
+ }
+
+ @Override
+ protected void doStart() throws Exception {
+ super.doStart();
+
+ Iterator<Status> statusIterator = twitter4jConsumer.requestDirectStatus();
+ while (statusIterator.hasNext()) {
+ Status tStatus = statusIterator.next();
+
+ Exchange e = getEndpoint().createExchange();
+
+ e.getIn().setHeader("screenName", tStatus.getUser().getScreenName());
+ e.getIn().setHeader("date", tStatus.getDate());
+
+ e.getIn().setBody(tStatus);
+
+ getProcessor().process(e);
+ }
+ }
+}
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/TwitterConsumerDirect.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/TwitterConsumerDirect.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/TwitterConsumerPolling.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/TwitterConsumerPolling.java?rev=1227546&view=auto
==============================================================================
--- camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/TwitterConsumerPolling.java (added)
+++ camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/TwitterConsumerPolling.java Thu Jan 5 10:34:25 2012
@@ -0,0 +1,87 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.twitter.consumer;
+
+import java.util.Iterator;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.twitter.TwitterEndpoint;
+import org.apache.camel.component.twitter.data.Status;
+import org.apache.camel.impl.ScheduledPollConsumer;
+
+/**
+ * Provides a scheduled polling consumer
+ *
+ */
+public class TwitterConsumerPolling extends ScheduledPollConsumer implements TwitterConsumer {
+
+ private Twitter4JConsumer twitter4jConsumer;
+
+ private long lastStatusUpdateID = 1;
+
+ private int delay;
+
+ public TwitterConsumerPolling(TwitterEndpoint endpoint, Processor processor,
+ Twitter4JConsumer twitter4jConsumer) {
+ super(endpoint, processor);
+
+ this.twitter4jConsumer = twitter4jConsumer;
+
+ delay = endpoint.getProperties().getDelay();
+
+ setInitialDelay(0);
+ setDelay(delay);
+ setTimeUnit(TimeUnit.SECONDS);
+ }
+
+ protected int poll() throws Exception {
+ Iterator<Status> statusIterator = twitter4jConsumer.requestPollingStatus(lastStatusUpdateID);
+
+ int total = 0;
+ while (statusIterator.hasNext()) {
+ Status tStatus = statusIterator.next();
+
+ // if (tStatus.getId() <= lastStatusUpdateID) {
+ // return 0;
+ // }
+
+ Exchange e = getEndpoint().createExchange();
+
+ e.getIn().setHeader("screenName", tStatus.getUser().getScreenName());
+ e.getIn().setHeader("date", tStatus.getDate());
+
+ e.getIn().setBody(tStatus);
+
+ getProcessor().process(e);
+
+ total++;
+ // make sure it ignores updates that were already polled
+ long newerStatusID = tStatus.getId();
+ if (newerStatusID > lastStatusUpdateID) {
+ lastStatusUpdateID = newerStatusID;
+ }
+ }
+
+ return total;
+ }
+
+ public long getLastStatusUpdateID() {
+ return lastStatusUpdateID;
+ }
+}
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/TwitterConsumerPolling.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/TwitterConsumerPolling.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/directmessage/DirectMessageConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/directmessage/DirectMessageConsumer.java?rev=1227546&view=auto
==============================================================================
--- camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/directmessage/DirectMessageConsumer.java (added)
+++ camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/directmessage/DirectMessageConsumer.java Thu Jan 5 10:34:25 2012
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.twitter.consumer.directmessage;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.camel.component.twitter.TwitterEndpoint;
+import org.apache.camel.component.twitter.consumer.Twitter4JConsumer;
+import org.apache.camel.component.twitter.data.Status;
+
+import twitter4j.DirectMessage;
+import twitter4j.Paging;
+import twitter4j.TwitterException;
+
+/**
+ * Consumes a user's direct messages
+ */
+public class DirectMessageConsumer implements Twitter4JConsumer {
+
+ TwitterEndpoint te;
+
+ public DirectMessageConsumer(TwitterEndpoint te) {
+ this.te = te;
+ }
+
+ public Iterator<Status> requestPollingStatus(long lastStatusUpdateId) throws TwitterException {
+ return getIterator(te.getTwitter().getDirectMessages(new Paging(lastStatusUpdateId)));
+ }
+
+ public Iterator<Status> requestDirectStatus() throws TwitterException {
+ return getIterator(te.getTwitter().getDirectMessages());
+ }
+
+ private Iterator<Status> getIterator(List<DirectMessage> messagesList) {
+ List<Status> statusCamelTweet = new ArrayList<Status>(messagesList.size());
+ for (Iterator<DirectMessage> i = messagesList.iterator(); i.hasNext();) {
+ statusCamelTweet.add(new Status(i.next()));
+ }
+ return statusCamelTweet.iterator();
+ }
+}
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/directmessage/DirectMessageConsumer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/directmessage/DirectMessageConsumer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/search/SearchConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/search/SearchConsumer.java?rev=1227546&view=auto
==============================================================================
--- camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/search/SearchConsumer.java (added)
+++ camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/search/SearchConsumer.java Thu Jan 5 10:34:25 2012
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.twitter.consumer.search;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.camel.component.twitter.TwitterEndpoint;
+import org.apache.camel.component.twitter.consumer.Twitter4JConsumer;
+import org.apache.camel.component.twitter.data.Status;
+
+import twitter4j.Query;
+import twitter4j.QueryResult;
+import twitter4j.Tweet;
+import twitter4j.TwitterException;
+
+/**
+ * Consumes search requests
+ *
+ */
+public class SearchConsumer implements Twitter4JConsumer {
+
+ TwitterEndpoint te;
+
+ public SearchConsumer(TwitterEndpoint te) {
+ this.te = te;
+ }
+
+ public Iterator<Status> requestPollingStatus(long lastStatusUpdateId) throws TwitterException {
+ String keywords = te.getProperties().getKeywords();
+ Query query = new Query(keywords);
+ query.setSinceId(lastStatusUpdateId);
+ return search(query);
+ }
+
+ public Iterator<Status> requestDirectStatus() throws TwitterException {
+ String keywords = te.getProperties().getKeywords();
+ return search(new Query(keywords));
+ }
+
+ private Iterator<Status> search(Query query) throws TwitterException {
+ QueryResult qr = te.getTwitter().search(query);
+ List<Tweet> tweets = qr.getTweets();
+
+ List<Status> statusCamel = new ArrayList<Status>(tweets.size());
+ Iterator<Tweet> i = tweets.iterator();
+ while (i.hasNext()) {
+ statusCamel.add(new Status(i.next()));
+ }
+
+ return statusCamel.iterator();
+ }
+}
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/search/SearchConsumer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/search/SearchConsumer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/FilterConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/FilterConsumer.java?rev=1227546&view=auto
==============================================================================
--- camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/FilterConsumer.java (added)
+++ camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/FilterConsumer.java Thu Jan 5 10:34:25 2012
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.twitter.consumer.streaming;
+
+import org.apache.camel.component.twitter.TwitterEndpoint;
+
+import twitter4j.FilterQuery;
+import twitter4j.TwitterStream;
+import twitter4j.TwitterStreamFactory;
+
+/**
+ * Consumes the filter stream
+ *
+ */
+public class FilterConsumer extends StreamingConsumer {
+
+ public FilterConsumer(TwitterEndpoint te) {
+ super(te);
+
+ TwitterStream twitterStream = new TwitterStreamFactory(te.getProperties().getConfiguration())
+ .getInstance();
+ twitterStream.addListener(this);
+
+ String allLocationsString = te.getProperties().getLocations();
+ String[] locationStrings = allLocationsString.split(";");
+ double[][] locations = new double[locationStrings.length][2];
+ for (int i = 0; i < locationStrings.length; i++) {
+ String[] coords = locationStrings[i].split(",");
+ locations[i][0] = Double.valueOf(coords[0]);
+ locations[i][1] = Double.valueOf(coords[1]);
+ }
+
+ FilterQuery fq = new FilterQuery();
+ fq.locations(locations);
+
+ twitterStream.filter(fq);
+ }
+}
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/FilterConsumer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/FilterConsumer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/SampleConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/SampleConsumer.java?rev=1227546&view=auto
==============================================================================
--- camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/SampleConsumer.java (added)
+++ camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/SampleConsumer.java Thu Jan 5 10:34:25 2012
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.twitter.consumer.streaming;
+
+import org.apache.camel.component.twitter.TwitterEndpoint;
+
+import twitter4j.TwitterStream;
+import twitter4j.TwitterStreamFactory;
+
+/**
+ * Consumes the sample stream
+ *
+ */
+public class SampleConsumer extends StreamingConsumer {
+
+ public SampleConsumer(TwitterEndpoint te) {
+ super(te);
+
+ TwitterStream twitterStream = new TwitterStreamFactory(te.getProperties().getConfiguration())
+ .getInstance();
+ twitterStream.addListener(this);
+ twitterStream.sample();
+ }
+}
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/SampleConsumer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/SampleConsumer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/StreamingConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/StreamingConsumer.java?rev=1227546&view=auto
==============================================================================
--- camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/StreamingConsumer.java (added)
+++ camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/StreamingConsumer.java Thu Jan 5 10:34:25 2012
@@ -0,0 +1,92 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.twitter.consumer.streaming;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.camel.component.twitter.TwitterEndpoint;
+import org.apache.camel.component.twitter.consumer.Twitter4JConsumer;
+import org.apache.camel.component.twitter.data.Status;
+import org.apache.camel.component.twitter.util.TwitterConverter;
+
+import twitter4j.StatusDeletionNotice;
+import twitter4j.StatusListener;
+import twitter4j.TwitterException;
+
+/**
+ * Super class providing consuming capabilities for the streaming API.
+ *
+ */
+public class StreamingConsumer implements Twitter4JConsumer, StatusListener {
+
+ TwitterEndpoint te;
+
+ private List<Status> receivedStatuses = new ArrayList<Status>();
+
+ private boolean clear;
+
+ public StreamingConsumer(TwitterEndpoint te) {
+ this.te = te;
+ }
+
+ public Iterator<Status> requestPollingStatus(long lastStatusUpdateId) throws TwitterException {
+ clear = true;
+ return Collections.unmodifiableList(receivedStatuses).iterator();
+ }
+
+ public Iterator<Status> requestDirectStatus() throws TwitterException {
+ // not used
+ return null;
+ }
+
+ @Override
+ public void onException(Exception ex) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void onStatus(twitter4j.Status status) {
+ if (clear) {
+ receivedStatuses.clear();
+ clear = false;
+ }
+ receivedStatuses.add(TwitterConverter.convertStatus(status));
+ }
+
+ @Override
+ public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void onTrackLimitationNotice(int numberOfLimitedStatuses) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void onScrubGeo(long userId, long upToStatusId) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/StreamingConsumer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/streaming/StreamingConsumer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/HomeConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/HomeConsumer.java?rev=1227546&view=auto
==============================================================================
--- camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/HomeConsumer.java (added)
+++ camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/HomeConsumer.java Thu Jan 5 10:34:25 2012
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.twitter.consumer.timeline;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.camel.component.twitter.TwitterEndpoint;
+import org.apache.camel.component.twitter.consumer.Twitter4JConsumer;
+import org.apache.camel.component.twitter.data.Status;
+import org.apache.camel.component.twitter.util.TwitterConverter;
+
+import twitter4j.Paging;
+import twitter4j.TwitterException;
+
+/**
+ * Consumes the user's home timeline.
+ *
+ */
+public class HomeConsumer implements Twitter4JConsumer {
+
+ TwitterEndpoint te;
+
+ public HomeConsumer(TwitterEndpoint te) {
+ this.te = te;
+ }
+
+ public Iterator<Status> requestPollingStatus(long lastStatusUpdateId) throws TwitterException {
+ List<twitter4j.Status> statusList = te.getTwitter().getHomeTimeline(new Paging(lastStatusUpdateId));
+ return TwitterConverter.convertStatuses(statusList).iterator();
+ }
+
+ public Iterator<Status> requestDirectStatus() throws TwitterException {
+ List<twitter4j.Status> statusList = te.getTwitter().getHomeTimeline();
+ return TwitterConverter.convertStatuses(statusList).iterator();
+ }
+}
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/HomeConsumer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/HomeConsumer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/MentionsConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/MentionsConsumer.java?rev=1227546&view=auto
==============================================================================
--- camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/MentionsConsumer.java (added)
+++ camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/MentionsConsumer.java Thu Jan 5 10:34:25 2012
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.twitter.consumer.timeline;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.camel.component.twitter.TwitterEndpoint;
+import org.apache.camel.component.twitter.consumer.Twitter4JConsumer;
+import org.apache.camel.component.twitter.data.Status;
+import org.apache.camel.component.twitter.util.TwitterConverter;
+
+import twitter4j.Paging;
+import twitter4j.TwitterException;
+
+/**
+ * Consumes tweets in which the user has been mentioned.
+ */
+public class MentionsConsumer implements Twitter4JConsumer {
+
+ TwitterEndpoint te;
+
+ public MentionsConsumer(TwitterEndpoint te) {
+ this.te = te;
+ }
+
+ public Iterator<Status> requestPollingStatus(long lastStatusUpdateId) throws TwitterException {
+ List<twitter4j.Status> statusList = te.getTwitter().getMentions(new Paging(lastStatusUpdateId));
+ return TwitterConverter.convertStatuses(statusList).iterator();
+ }
+
+ public Iterator<Status> requestDirectStatus() throws TwitterException {
+ List<twitter4j.Status> statusList = te.getTwitter().getMentions();
+ return TwitterConverter.convertStatuses(statusList).iterator();
+ }
+}
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/MentionsConsumer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/MentionsConsumer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/PublicConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/PublicConsumer.java?rev=1227546&view=auto
==============================================================================
--- camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/PublicConsumer.java (added)
+++ camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/PublicConsumer.java Thu Jan 5 10:34:25 2012
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.twitter.consumer.timeline;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.camel.component.twitter.TwitterEndpoint;
+import org.apache.camel.component.twitter.consumer.Twitter4JConsumer;
+import org.apache.camel.component.twitter.data.Status;
+import org.apache.camel.component.twitter.util.TwitterConverter;
+
+import twitter4j.TwitterException;
+
+/**
+ * Consumes the public timeline
+ *
+ */
+public class PublicConsumer implements Twitter4JConsumer {
+
+ TwitterEndpoint te;
+
+ public PublicConsumer(TwitterEndpoint te) {
+ this.te = te;
+ }
+
+ public Iterator<Status> requestPollingStatus(long lastStatusUpdateId) throws TwitterException {
+ return getPublicTimeline();
+ }
+
+ public Iterator<Status> requestDirectStatus() throws TwitterException {
+ return getPublicTimeline();
+ }
+
+ private Iterator<Status> getPublicTimeline() throws TwitterException {
+ List<twitter4j.Status> statusList = te.getTwitter().getPublicTimeline();
+ return TwitterConverter.convertStatuses(statusList).iterator();
+ }
+}
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/PublicConsumer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/PublicConsumer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/RetweetsConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/RetweetsConsumer.java?rev=1227546&view=auto
==============================================================================
--- camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/RetweetsConsumer.java (added)
+++ camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/RetweetsConsumer.java Thu Jan 5 10:34:25 2012
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.twitter.consumer.timeline;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.camel.component.twitter.TwitterEndpoint;
+import org.apache.camel.component.twitter.consumer.Twitter4JConsumer;
+import org.apache.camel.component.twitter.data.Status;
+import org.apache.camel.component.twitter.util.TwitterConverter;
+
+import twitter4j.Paging;
+import twitter4j.TwitterException;
+
+/**
+ * Consumes a user's tweets that have been retweeted
+ *
+ */
+public class RetweetsConsumer implements Twitter4JConsumer {
+
+ TwitterEndpoint te;
+
+ public RetweetsConsumer(TwitterEndpoint te) {
+ this.te = te;
+ }
+
+ public Iterator<Status> requestPollingStatus(long lastStatusUpdateId) throws TwitterException {
+ List<twitter4j.Status> statusList = te.getTwitter().getRetweetsOfMe(new Paging(lastStatusUpdateId));
+ return TwitterConverter.convertStatuses(statusList).iterator();
+ }
+
+ public Iterator<Status> requestDirectStatus() throws TwitterException {
+ List<twitter4j.Status> statusList = te.getTwitter().getRetweetsOfMe();
+ return TwitterConverter.convertStatuses(statusList).iterator();
+ }
+}
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/RetweetsConsumer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/RetweetsConsumer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/UserConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/UserConsumer.java?rev=1227546&view=auto
==============================================================================
--- camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/UserConsumer.java (added)
+++ camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/UserConsumer.java Thu Jan 5 10:34:25 2012
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.twitter.consumer.timeline;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.camel.component.twitter.TwitterEndpoint;
+import org.apache.camel.component.twitter.consumer.Twitter4JConsumer;
+import org.apache.camel.component.twitter.data.Status;
+import org.apache.camel.component.twitter.util.TwitterConverter;
+
+import twitter4j.Paging;
+import twitter4j.TwitterException;
+
+/**
+ * Consumes the timeline of a given user.
+ */
+public class UserConsumer implements Twitter4JConsumer {
+
+ TwitterEndpoint te;
+
+ public UserConsumer(TwitterEndpoint te) {
+ this.te = te;
+ }
+
+ public Iterator<Status> requestPollingStatus(long lastStatusUpdateId) throws TwitterException {
+ List<twitter4j.Status> statusList = te.getTwitter().getUserTimeline(te.getProperties().getUser(),
+ new Paging(lastStatusUpdateId));
+ return TwitterConverter.convertStatuses(statusList).iterator();
+ }
+
+ public Iterator<Status> requestDirectStatus() throws TwitterException {
+ List<twitter4j.Status> statusList = te.getTwitter().getUserTimeline(te.getProperties().getUser());
+ return TwitterConverter.convertStatuses(statusList).iterator();
+ }
+}
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/UserConsumer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/consumer/timeline/UserConsumer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/ConsumerType.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/ConsumerType.java?rev=1227546&view=auto
==============================================================================
--- camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/ConsumerType.java (added)
+++ camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/ConsumerType.java Thu Jan 5 10:34:25 2012
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.twitter.data;
+
+
+public enum ConsumerType {
+
+ TIMELINE, SEARCH, USER, TRENDS, USERLIST, DIRECTMESSAGE, STREAMING, UNKNOWN;
+
+ public static ConsumerType fromUri(String uri) {
+ for (ConsumerType consumerType : ConsumerType.values()) {
+ if (consumerType.name().equalsIgnoreCase(uri)) {
+ return consumerType;
+ }
+ }
+ return ConsumerType.UNKNOWN;
+ }
+}
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/ConsumerType.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/ConsumerType.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/EndpointType.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/EndpointType.java?rev=1227546&view=auto
==============================================================================
--- camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/EndpointType.java (added)
+++ camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/EndpointType.java Thu Jan 5 10:34:25 2012
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.twitter.data;
+
+public enum EndpointType {
+
+ POLLING, DIRECT;
+
+ public static EndpointType fromUri(String uri) {
+ for (EndpointType endpointType : EndpointType.values()) {
+ if (endpointType.name().equalsIgnoreCase(uri)) {
+ return endpointType;
+ }
+ }
+ return EndpointType.DIRECT;
+ }
+}
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/EndpointType.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/EndpointType.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/GeoLocation.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/GeoLocation.java?rev=1227546&view=auto
==============================================================================
--- camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/GeoLocation.java (added)
+++ camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/GeoLocation.java Thu Jan 5 10:34:25 2012
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.twitter.data;
+
+public class GeoLocation {
+
+ private double latitude;
+
+ private double longitude;
+
+ public GeoLocation(twitter4j.GeoLocation geoLocation) {
+ this.latitude = geoLocation.getLatitude();
+ this.longitude = geoLocation.getLongitude();
+ }
+
+ public double getLatitude() {
+ return latitude;
+ }
+
+ public void setLatitude(double latitude) {
+ this.latitude = latitude;
+ }
+
+ public double getLongitude() {
+ return longitude;
+ }
+
+ public void setLongitude(double longitude) {
+ this.longitude = longitude;
+ }
+}
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/GeoLocation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/data/GeoLocation.java
------------------------------------------------------------------------------
svn:keywords = Rev Date