mirror of https://github.com/apache/jclouds.git
Ported gae-tweetstore to the 1.4.2 appengine API and to changed in Twitter4j
This commit is contained in:
parent
6c9ca419f6
commit
b07ca99372
|
@ -20,20 +20,23 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<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">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.jclouds.demos</groupId>
|
<parent>
|
||||||
<artifactId>gae-replicator</artifactId>
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-demos-project</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<artifactId>jclouds-demo-gae-tweetstore</artifactId>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<name>JClouds example to replicate the contents of a container</name>
|
<name>JClouds TweetStore for Google App Engine</name>
|
||||||
<description>JClouds example to replicate the contents of a container</description>
|
<description>JClouds TweetStore for Google App Engine using Guice for Dependency Injection</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<!--
|
<!--
|
||||||
note you must set the property ${appengine.home} to a valid
|
note you must set the property ${appengine.home} to a valid
|
||||||
extraction of appengine-java-sdk
|
extraction of appengine-java-sdk
|
||||||
-->
|
-->
|
||||||
<appengine.home>YOUR_APPENGINE_HOME</appengine.home>
|
|
||||||
<appengine.applicationid>jclouds-replicate</appengine.applicationid>
|
<appengine.applicationid>jclouds-replicate</appengine.applicationid>
|
||||||
|
<appengine.sdk.version>1.4.2</appengine.sdk.version>
|
||||||
<devappserver.address>localhost</devappserver.address>
|
<devappserver.address>localhost</devappserver.address>
|
||||||
<devappserver.port>8088</devappserver.port>
|
<devappserver.port>8088</devappserver.port>
|
||||||
<jclouds.replicate.source>googlestorage</jclouds.replicate.source>
|
<jclouds.replicate.source>googlestorage</jclouds.replicate.source>
|
||||||
|
@ -44,9 +47,14 @@
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>jclouds-allblobstore</artifactId>
|
<artifactId>jclouds-blobstore</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.twitter4j</groupId>
|
||||||
|
<artifactId>twitter4j-core</artifactId>
|
||||||
|
<version>[2.1,)</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>jclouds-blobstore</artifactId>
|
<artifactId>jclouds-blobstore</artifactId>
|
||||||
|
@ -54,28 +62,29 @@
|
||||||
<type>test-jar</type>
|
<type>test-jar</type>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds.provider</groupId>
|
||||||
|
<artifactId>aws-s3</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>jclouds-core</artifactId>
|
<artifactId>jclouds-atmos</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>jclouds-azure</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>jclouds-rackspace</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<type>test-jar</type>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jclouds.driver</groupId>
|
<groupId>org.jclouds.driver</groupId>
|
||||||
<artifactId>jclouds-log4j</artifactId>
|
<artifactId>jclouds-gae</artifactId>
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>log4j</groupId>
|
|
||||||
<artifactId>log4j</artifactId>
|
|
||||||
<version>1.2.16</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jclouds.driver</groupId>
|
|
||||||
<artifactId>gae</artifactId>
|
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -99,6 +108,11 @@
|
||||||
<artifactId>slf4j-jdk14</artifactId>
|
<artifactId>slf4j-jdk14</artifactId>
|
||||||
<version>1.5.6</version>
|
<version>1.5.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<artifactId>jstl</artifactId>
|
||||||
|
<groupId>javax.servlet</groupId>
|
||||||
|
<version>1.1.2</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<artifactId>standard</artifactId>
|
<artifactId>standard</artifactId>
|
||||||
<groupId>taglibs</groupId>
|
<groupId>taglibs</groupId>
|
||||||
|
@ -106,16 +120,22 @@
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<artifactId>jstl</artifactId>
|
|
||||||
<groupId>javax.servlet</groupId>
|
<groupId>javax.servlet</groupId>
|
||||||
<version>1.1.2</version>
|
<artifactId>servlet-api</artifactId>
|
||||||
|
<version>2.5</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Google App Engine API -->
|
<!-- Google App Engine API -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.appengine</groupId>
|
<groupId>com.google.appengine</groupId>
|
||||||
<artifactId>appengine-api-1.0-sdk</artifactId>
|
<artifactId>appengine-api-1.0-sdk</artifactId>
|
||||||
<version>1.4.2</version>
|
<version>${appengine.sdk.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.appengine</groupId>
|
||||||
|
<artifactId>appengine-tools-sdk</artifactId>
|
||||||
|
<version>${appengine.sdk.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Google App Engine Runtime Dependencies -->
|
<!-- Google App Engine Runtime Dependencies -->
|
||||||
|
@ -125,47 +145,35 @@
|
||||||
<version>1.1.1</version>
|
<version>1.1.1</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.geronimo.specs</groupId>
|
<groupId>org.apache.geronimo.specs</groupId>
|
||||||
<artifactId>geronimo-jpa_3.0_spec</artifactId>
|
<artifactId>geronimo-jpa_3.0_spec</artifactId>
|
||||||
<version>1.1.1</version>
|
<version>1.1.1</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.appengine.orm</groupId>
|
<groupId>com.google.appengine.orm</groupId>
|
||||||
<artifactId>jdo2-api</artifactId>
|
<artifactId>jdo2-api</artifactId>
|
||||||
<version>2.3-eb</version>
|
<version>2.3-eb</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.datanucleus</groupId>
|
<groupId>org.datanucleus</groupId>
|
||||||
<artifactId>datanucleus-core</artifactId>
|
<artifactId>datanucleus-core</artifactId>
|
||||||
<version>1.1.5</version>
|
<version>1.1.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.appengine.orm</groupId>
|
<groupId>com.google.appengine.orm</groupId>
|
||||||
<artifactId>datanucleus-appengine</artifactId>
|
<artifactId>datanucleus-appengine</artifactId>
|
||||||
<version>1.0.8</version>
|
<version>1.0.8</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.datanucleus</groupId>
|
<groupId>org.datanucleus</groupId>
|
||||||
<artifactId>datanucleus-jpa</artifactId>
|
<artifactId>datanucleus-jpa</artifactId>
|
||||||
<version>1.1.5</version>
|
<version>1.1.5</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- App Engine Runtime Dependencies-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.appengine</groupId>
|
|
||||||
<artifactId>appengine-tools-sdk</artifactId>
|
|
||||||
<version>1.4.2</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<finalName>${project.artifactId}</finalName>
|
<finalName>${project.artifactId}</finalName>
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.demo.tweetstore.config;
|
package org.jclouds.demo.tweetstore.config;
|
||||||
|
|
||||||
import static com.google.appengine.api.labs.taskqueue.TaskOptions.Builder.url;
|
import static com.google.appengine.api.taskqueue.TaskOptions.Builder.withUrl;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.demo.tweetstore.reference.TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER;
|
import static org.jclouds.demo.tweetstore.reference.TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER;
|
||||||
|
|
||||||
|
@ -38,10 +38,13 @@ import org.jclouds.gae.config.GoogleAppEngineConfigurationModule;
|
||||||
|
|
||||||
import twitter4j.Twitter;
|
import twitter4j.Twitter;
|
||||||
import twitter4j.TwitterFactory;
|
import twitter4j.TwitterFactory;
|
||||||
|
import twitter4j.conf.Configuration;
|
||||||
|
import twitter4j.conf.ConfigurationBuilder;
|
||||||
|
|
||||||
import com.google.appengine.api.labs.taskqueue.Queue;
|
import com.google.appengine.api.taskqueue.Queue;
|
||||||
import com.google.appengine.api.labs.taskqueue.QueueFactory;
|
import com.google.appengine.api.taskqueue.QueueFactory;
|
||||||
import com.google.appengine.api.labs.taskqueue.TaskOptions.Method;
|
import com.google.appengine.api.taskqueue.TaskOptions.Builder;
|
||||||
|
import com.google.appengine.api.taskqueue.TaskOptions.Method;
|
||||||
import com.google.appengine.repackaged.com.google.common.base.Splitter;
|
import com.google.appengine.repackaged.com.google.common.base.Splitter;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
@ -77,8 +80,10 @@ public class GuiceServletConfig extends GuiceServletContextListener {
|
||||||
Set<Module> modules = ImmutableSet.<Module> of(googleModule);
|
Set<Module> modules = ImmutableSet.<Module> of(googleModule);
|
||||||
// shared across all blobstores and used to retrieve tweets
|
// shared across all blobstores and used to retrieve tweets
|
||||||
try {
|
try {
|
||||||
twitterClient = new TwitterFactory().getInstance(props.getProperty("twitter.identity"), props
|
Configuration twitterConf = new ConfigurationBuilder()
|
||||||
.getProperty("twitter.credential"));
|
.setUser(props.getProperty("twitter.identity"))
|
||||||
|
.setPassword(props.getProperty("twitter.credential")).build();
|
||||||
|
twitterClient = new TwitterFactory(twitterConf).getInstance();
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
throw new IllegalArgumentException("properties for twitter not configured properly in " + props.toString(), e);
|
throw new IllegalArgumentException("properties for twitter not configured properly in " + props.toString(), e);
|
||||||
}
|
}
|
||||||
|
@ -96,7 +101,7 @@ public class GuiceServletConfig extends GuiceServletContextListener {
|
||||||
Queue queue = QueueFactory.getQueue("twitter");
|
Queue queue = QueueFactory.getQueue("twitter");
|
||||||
// submit a job to store tweets for each configured blobstore
|
// submit a job to store tweets for each configured blobstore
|
||||||
for (String name : providerTypeToBlobStoreMap.keySet()) {
|
for (String name : providerTypeToBlobStoreMap.keySet()) {
|
||||||
queue.add(url("/store/do").header("context", name).method(Method.GET));
|
queue.add(withUrl("/store/do").header("context", name).method(Method.GET));
|
||||||
}
|
}
|
||||||
|
|
||||||
super.contextInitialized(servletContextEvent);
|
super.contextInitialized(servletContextEvent);
|
||||||
|
|
|
@ -48,6 +48,8 @@ import twitter4j.Status;
|
||||||
import twitter4j.Twitter;
|
import twitter4j.Twitter;
|
||||||
import twitter4j.TwitterException;
|
import twitter4j.TwitterException;
|
||||||
import twitter4j.TwitterFactory;
|
import twitter4j.TwitterFactory;
|
||||||
|
import twitter4j.conf.Configuration;
|
||||||
|
import twitter4j.conf.ConfigurationBuilder;
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
|
@ -98,8 +100,10 @@ public class TweetStoreLiveTest {
|
||||||
contexts.put(provider, factory.createContext(provider, wiring, props));
|
contexts.put(provider, factory.createContext(provider, wiring, props));
|
||||||
}
|
}
|
||||||
|
|
||||||
Twitter client = new TwitterFactory().getInstance(props.getProperty("twitter.identity"),
|
Configuration conf = new ConfigurationBuilder()
|
||||||
props.getProperty("twitter.credential"));
|
.setUser(props.getProperty("twitter.identity"))
|
||||||
|
.setPassword(props.getProperty("twitter.credential")).build();
|
||||||
|
Twitter client = new TwitterFactory(conf).getInstance();
|
||||||
StoreTweetsController controller = new StoreTweetsController(contexts, container, client);
|
StoreTweetsController controller = new StoreTweetsController(contexts, container, client);
|
||||||
|
|
||||||
ResponseList<Status> statuses = client.getMentions();
|
ResponseList<Status> statuses = client.getMentions();
|
||||||
|
|
Loading…
Reference in New Issue