You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wink.apache.org by bl...@apache.org on 2009/08/25 21:27:01 UTC

svn commit: r807773 - in /incubator/wink/trunk/wink-examples: ./ client/ client/ReadRSS-client/ client/ReadRSS-client/src/ client/ReadRSS-client/src/main/ client/ReadRSS-client/src/main/java/ client/ReadRSS-client/src/main/java/org/ client/ReadRSS-clie...

Author: bluk
Date: Tue Aug 25 19:27:00 2009
New Revision: 807773

URL: http://svn.apache.org/viewvc?rev=807773&view=rev
Log:
RSS client example with Wink

Thanks Shiva Kumar H R for the contribution.

See [WINK-147]

Added:
    incubator/wink/trunk/wink-examples/client/ReadRSS-client/
    incubator/wink/trunk/wink-examples/client/ReadRSS-client/build.xml   (with props)
    incubator/wink/trunk/wink-examples/client/ReadRSS-client/pom.xml
      - copied, changed from r807724, incubator/wink/trunk/wink-examples/client/pom.xml
    incubator/wink/trunk/wink-examples/client/ReadRSS-client/readme.txt
    incubator/wink/trunk/wink-examples/client/ReadRSS-client/src/
    incubator/wink/trunk/wink-examples/client/ReadRSS-client/src/main/
    incubator/wink/trunk/wink-examples/client/ReadRSS-client/src/main/java/
    incubator/wink/trunk/wink-examples/client/ReadRSS-client/src/main/java/org/
    incubator/wink/trunk/wink-examples/client/ReadRSS-client/src/main/java/org/apache/
    incubator/wink/trunk/wink-examples/client/ReadRSS-client/src/main/java/org/apache/wink/
    incubator/wink/trunk/wink-examples/client/ReadRSS-client/src/main/java/org/apache/wink/example/
    incubator/wink/trunk/wink-examples/client/ReadRSS-client/src/main/java/org/apache/wink/example/ReadRSSClient.java   (with props)
Modified:
    incubator/wink/trunk/wink-examples/client/pom.xml
    incubator/wink/trunk/wink-examples/readme.txt

Added: incubator/wink/trunk/wink-examples/client/ReadRSS-client/build.xml
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/client/ReadRSS-client/build.xml?rev=807773&view=auto
==============================================================================
--- incubator/wink/trunk/wink-examples/client/ReadRSS-client/build.xml (added)
+++ incubator/wink/trunk/wink-examples/client/ReadRSS-client/build.xml Tue Aug 25 19:27:00 2009
@@ -0,0 +1,105 @@
+<?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 name="ReadRSSClient" default="dist" basedir=".">
+	<description>
+        Ant build file for Wink Client example ReadRSS
+    </description>
+
+	<property name="example.jar.name" value="ReadRSS-client.jar" />
+	<property name="common.jar.name" value="@SDK_COMMON_JAR_NAME@" />
+	<property name="client.jar.name" value="@SDK_CLIENT_JAR_NAME@" />
+
+
+	<!-- set global properties for this build -->
+	<property name="src" location="src" />
+	<property name="build" location="build" />
+	<property name="build.classes" location="${build}/classes" />
+	<property name="client.base" location="${basedir}/../../.." />
+	<property name="client.lib" location="${client.base}/lib" />
+	<property name="client.dist" location="${client.base}/dist" />
+	<property name="client.jar" location="${client.dist}/${client.jar.name}" />
+	<property name="common.jar" location="${client.dist}/${common.jar.name}" />
+	<property name="example.jar" location="${basedir}/${example.jar.name}" />
+	<property name="main" location="${basedir}/src/main" />
+	<property name="resources" location="${main}/resources" />
+
+
+	<target name="init">
+		<!-- Create the time stamp -->
+		<tstamp />
+		<!-- Create the build directory structure used by compile -->
+		<mkdir dir="${build.classes}" />
+	</target>
+
+
+	<target name="compile" depends="init" description="compile the source ">
+		<!-- Set classpath for client lib -->
+		<path id="client.classpath">
+			<fileset dir="${client.lib}" includes="**/*.jar" />
+			<pathelement path="${common.jar}" />
+			<pathelement path="${client.jar}" />
+		</path>
+
+		<!-- Compile the java code from ${src} into ${build} -->
+		<javac srcdir="${src}" destdir="${build.classes}">
+			<classpath refid="client.classpath" />
+		</javac>
+	</target>
+
+	<target name="dist" depends="compile" description="generate the distribution">
+		<manifestclasspath property="jar.classpath" jarfile="${example.jar}" maxParentLevels="10">
+			<classpath>
+				<fileset dir="${client.lib}" includes="*.jar" />
+				<fileset dir="${client.dist}">
+                    <include name="${common.jar.name}"/>
+                    <include name="${client.jar.name}"/>
+                </fileset>
+			</classpath>
+		</manifestclasspath>
+
+		<!-- Create the jar file -->
+		<jar destfile="${example.jar}" basedir="${build.classes}">
+			<manifest>
+				<attribute name="Main-Class" value="org.apache.wink.example.ReadRSSClient" />
+				<attribute name="Class-Path" value="${jar.classpath}" />
+			</manifest>
+		</jar>
+	</target>
+
+
+	<target name="clean" description="clean up">
+		<!-- Delete the ${build} and ${dist} directory trees -->
+		<delete dir="${build}" />
+		<delete file="${example.jar}" />
+	</target>
+
+
+	<target name="run" depends="dist">
+		<java classname="org.apache.wink.example.ReadRSSClient">
+			<classpath>
+				<fileset dir="${client.lib}" includes="**/*.jar" />
+				<fileset dir="${client.dist}" includes="**/*.jar" />
+				<fileset dir="." includes="**/*.jar" />
+			</classpath>
+		</java>
+	</target>
+
+</project>

Propchange: incubator/wink/trunk/wink-examples/client/ReadRSS-client/build.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: incubator/wink/trunk/wink-examples/client/ReadRSS-client/pom.xml (from r807724, incubator/wink/trunk/wink-examples/client/pom.xml)
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/client/ReadRSS-client/pom.xml?p2=incubator/wink/trunk/wink-examples/client/ReadRSS-client/pom.xml&p1=incubator/wink/trunk/wink-examples/client/pom.xml&r1=807724&r2=807773&rev=807773&view=diff
==============================================================================
--- incubator/wink/trunk/wink-examples/client/pom.xml (original)
+++ incubator/wink/trunk/wink-examples/client/ReadRSS-client/pom.xml Tue Aug 25 19:27:00 2009
@@ -7,9 +7,9 @@
     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
@@ -20,18 +20,21 @@
 
 <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>
-    <artifactId>client</artifactId>
-    <packaging>pom</packaging>
-    <name>Apache Wink Examples Clients</name>
-    <properties>
-    </properties>
+    <artifactId>ReadRSS-client</artifactId>
+    <name>Apache Wink Examples Clients :: ReadRSS</name>
     <parent>
         <groupId>org.apache.wink.example</groupId>
-        <artifactId>wink-examples</artifactId>
+        <artifactId>client</artifactId>
         <version>0.2-incubating-SNAPSHOT</version>
     </parent>
-    <modules>
-        <module>QADefects-client</module>
-        <module>GoogleDocs-client</module>
-    </modules>
+    <build>
+        <finalName>ReadRSS-client</finalName>
+    </build>
+    <!-- Dependency on Wink SDK library -->
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.wink</groupId>
+            <artifactId>wink-client</artifactId>
+        </dependency>
+    </dependencies>
 </project>

Added: incubator/wink/trunk/wink-examples/client/ReadRSS-client/readme.txt
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/client/ReadRSS-client/readme.txt?rev=807773&view=auto
==============================================================================
--- incubator/wink/trunk/wink-examples/client/ReadRSS-client/readme.txt (added)
+++ incubator/wink/trunk/wink-examples/client/ReadRSS-client/readme.txt Tue Aug 25 19:27:00 2009
@@ -0,0 +1,20 @@
+ReadRSS Client Example
+===============================================================================
+
+Description 
+===============================================================================
+- a simple example that introduces Wink Client usage
+- demonstrates the consumption of an RSS feed say the one available from http://www.rssboard.org/files/rss-2.0-sample.xml
+
+Build
+===============================================================================
+- use Ant version 1.7.0 or greater
+- build the example using 'ant'
+- an executable jar is created under the example directory  
+
+Running the Example
+===============================================================================
+- make sure you are connected to internet
+- to run the example, run the following command: java -jar ReadRSS-client.jar
+
+--- readme.txt EOF ---

Added: incubator/wink/trunk/wink-examples/client/ReadRSS-client/src/main/java/org/apache/wink/example/ReadRSSClient.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/client/ReadRSS-client/src/main/java/org/apache/wink/example/ReadRSSClient.java?rev=807773&view=auto
==============================================================================
--- incubator/wink/trunk/wink-examples/client/ReadRSS-client/src/main/java/org/apache/wink/example/ReadRSSClient.java (added)
+++ incubator/wink/trunk/wink-examples/client/ReadRSS-client/src/main/java/org/apache/wink/example/ReadRSSClient.java Tue Aug 25 19:27:00 2009
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * 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.wink.example;
+
+import javax.ws.rs.core.MediaType;
+import javax.xml.bind.JAXB;
+
+import org.apache.wink.client.Resource;
+import org.apache.wink.client.RestClient;
+import org.apache.wink.common.model.rss.RssFeed;
+import org.apache.wink.common.model.rss.RssItem;
+
+/**
+ * This is an example of consuming an RSS Feed
+ */
+public class ReadRSSClient {
+
+    public static void main(String[] args) {
+        try {
+            // create the rest client instance
+            RestClient restClient = new RestClient();
+
+            // create the resource instance to interact with
+            String rss_url = "http://www.rssboard.org/files/rss-2.0-sample.xml";
+            Resource feedResource = restClient.resource(rss_url);
+
+            // perform a GET on the resource. The resource will be returned as
+            // an Rss object
+            RssFeed rss = feedResource.accept(MediaType.APPLICATION_XML_TYPE).get(RssFeed.class);
+
+            System.out.println("RSS Title = " + rss.getChannel().getTitle());
+            System.out.println("RSS Descritpion = " + rss.getChannel().getDescription());
+            System.out.println("RSS Link = " + rss.getChannel().getLink());
+            int itemCount = 0;
+            for (RssItem item : rss.getChannel().getItems()) {
+                System.out.println("Item " + ++itemCount + ":");
+                System.out.println("\tTitle = " + item.getTitle());
+                System.out.println("\tDescription = " + item.getDescription());
+                System.out.println("\tLink = " + item.getLink());
+            }
+
+            //System.out.println("\nComplete XML contents:");
+            //JAXB.marshal(rss, System.out);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+}

Propchange: incubator/wink/trunk/wink-examples/client/ReadRSS-client/src/main/java/org/apache/wink/example/ReadRSSClient.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/wink/trunk/wink-examples/client/pom.xml
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/client/pom.xml?rev=807773&r1=807772&r2=807773&view=diff
==============================================================================
--- incubator/wink/trunk/wink-examples/client/pom.xml (original)
+++ incubator/wink/trunk/wink-examples/client/pom.xml Tue Aug 25 19:27:00 2009
@@ -31,6 +31,7 @@
         <version>0.2-incubating-SNAPSHOT</version>
     </parent>
     <modules>
+        <module>ReadRSS-client</module>
         <module>QADefects-client</module>
         <module>GoogleDocs-client</module>
     </modules>

Modified: incubator/wink/trunk/wink-examples/readme.txt
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/readme.txt?rev=807773&r1=807772&r2=807773&view=diff
==============================================================================
--- incubator/wink/trunk/wink-examples/readme.txt (original)
+++ incubator/wink/trunk/wink-examples/readme.txt Tue Aug 25 19:27:00 2009
@@ -16,6 +16,7 @@
 		- Preconditions
 
 	"client" module contains Wink client examples
+		- ReadRSS-client
 		- QADefects-client
 		- GoogleDocs-client