Updated Branches:
  refs/heads/master 05967ac7f -> 18f8d29f9

Added blueprint example of our twitter example.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/131d39bc
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/131d39bc
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/131d39bc

Branch: refs/heads/master
Commit: 131d39bc51051343ddeda277a433a84f21a4c825
Parents: 05967ac
Author: Claus Ibsen <[email protected]>
Authored: Sat Jun 29 14:06:20 2013 +0400
Committer: Claus Ibsen <[email protected]>
Committed: Sat Jun 29 14:38:25 2013 +0400

----------------------------------------------------------------------
 .../README.txt                                  | 34 ++++++--
 .../pom.xml                                     |  7 +-
 .../OSGI-INF/blueprint/camel-twitter.xml        |  8 +-
 .../src/main/resources/webapp/index.html        | 84 +++++++++++---------
 examples/pom.xml                                |  1 +
 5 files changed, 88 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/131d39bc/examples/camel-example-twitter-websocket-blueprint/README.txt
----------------------------------------------------------------------
diff --git a/examples/camel-example-twitter-websocket-blueprint/README.txt 
b/examples/camel-example-twitter-websocket-blueprint/README.txt
index 6b6352b..4d7433b 100644
--- a/examples/camel-example-twitter-websocket-blueprint/README.txt
+++ b/examples/camel-example-twitter-websocket-blueprint/README.txt
@@ -1,5 +1,5 @@
-Twitter and Websocket Example
-=============================
+Twitter and Websocket Blueprint Example
+=======================================
 
 The example is demonstrating how to poll a constant feed of twitter searches
 and publish results in real time using web socket to a web page.
@@ -13,18 +13,38 @@ For that you need to setup and use your own twitter account.
 We have described this in more details at the Camel twitter documentation:
   http://camel.apache.org/twitter
 
-You will need to compile this example first:
-  mvn compile
+You will need to install this example first to your local maven repository 
with:
+  mvn install
 
-To run the example type
-  mvn exec:java
+This example requires running in Apache Karaf / ServiceMix
+
+To install Apache Camel in Karaf you type in the shell (we use version 2.12.0):
+
+  features:chooseurl camel 2.12.0
+  features:install camel
+
+First you need to install the following features in Karaf/ServiceMix with:
+
+  features:install camel-twitter
+  features:install camel-websocket
+
+Then you can install the Camel example:
+
+  osgi:install -s 
mvn:org.apache.camel/camel-example-twitter-websocket-blueprint/2.12.0
 
 Then open a browser to see live twitter updates in the web page
   http://localhost:9090
 
-To stop the example hit ctrl + c
+To stop the example run from Karaf/ServiceMix shell:
+  stop <bundle id>
+
+eg if the bundle id is 99 then type:
+  stop 99
 
 This example is documented at
+  http://camel.apache.org/twitter-websocket-blueprint-example.html
+
+There is a regular (non OSGi Blueprint) example as well documented at:
   http://camel.apache.org/twitter-websocket-example.html
 
 If you hit any problems please let us know on the Camel Forums

http://git-wip-us.apache.org/repos/asf/camel/blob/131d39bc/examples/camel-example-twitter-websocket-blueprint/pom.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-twitter-websocket-blueprint/pom.xml 
b/examples/camel-example-twitter-websocket-blueprint/pom.xml
index 4ce9d90..9265535 100644
--- a/examples/camel-example-twitter-websocket-blueprint/pom.xml
+++ b/examples/camel-example-twitter-websocket-blueprint/pom.xml
@@ -31,6 +31,9 @@
   <description>An example that pushes new tweets to a web page using 
web-socket</description>
   <packaging>bundle</packaging>
 
+  <!-- there is no maven dependencies needed as the Camel application has no 
Java code,
+       and its all defined in the 
src/main/resources/OSGI-INF/blueprint/camel-twitter.xml file -->
+
   <build>
     <plugins>
 
@@ -43,9 +46,9 @@
           <manifestLocation>target/META-INF</manifestLocation>
           <instructions>
             
<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
+            <Export-Package>org.apache.camel.example.twitter*</Export-Package>
             <Import-Package>
-              org.apache.camel.component.twitter,
-              org.apache.camel.component.websocket
+              *
             </Import-Package>
           </instructions>
         </configuration>

http://git-wip-us.apache.org/repos/asf/camel/blob/131d39bc/examples/camel-example-twitter-websocket-blueprint/src/main/resources/OSGI-INF/blueprint/camel-twitter.xml
----------------------------------------------------------------------
diff --git 
a/examples/camel-example-twitter-websocket-blueprint/src/main/resources/OSGI-INF/blueprint/camel-twitter.xml
 
b/examples/camel-example-twitter-websocket-blueprint/src/main/resources/OSGI-INF/blueprint/camel-twitter.xml
index 495bb64..47fef37 100644
--- 
a/examples/camel-example-twitter-websocket-blueprint/src/main/resources/OSGI-INF/blueprint/camel-twitter.xml
+++ 
b/examples/camel-example-twitter-websocket-blueprint/src/main/resources/OSGI-INF/blueprint/camel-twitter.xml
@@ -20,15 +20,21 @@
            xsi:schemaLocation="
            http://www.osgi.org/xmlns/blueprint/v1.0.0 
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd";>
 
+  <!-- CamelContext with the twitter websocket example -->
   <camelContext id="twitter-camel" 
xmlns="http://camel.apache.org/schema/blueprint";>
 
     <!-- use properties files for twitter codes -->
     <propertyPlaceholder id="placeholder" 
location="classpath:twitter.properties"/>
 
     <route id="twitter-route">
-      <from uri="twitter://search?type=polling&amp;delay=5s&amp;keywords=gaga
+      <!-- consume from twitter search to get new tweets about gaga every 5th 
second -->
+      <from uri="twitter://search?type=polling&amp;delay=5&amp;keywords=gaga
         
&amp;accessToken={{access.token}}&amp;accessTokenSecret={{access.token-secret}}&amp;consumerKey={{consumer.key}}&amp;consumerSecret={{consumer.secret}}"/>
+
+      <!-- log tweet to the log -->
       <to uri="log:tweet"/>
+
+      <!-- and send tweet to the websocket component so its viewable in the 
web page -->
       <to 
uri="websocket://localhost:9090/camel-tweet?sendToAll=true&amp;staticResources=classpath:webapp"/>
     </route>
 

http://git-wip-us.apache.org/repos/asf/camel/blob/131d39bc/examples/camel-example-twitter-websocket-blueprint/src/main/resources/webapp/index.html
----------------------------------------------------------------------
diff --git 
a/examples/camel-example-twitter-websocket-blueprint/src/main/resources/webapp/index.html
 
b/examples/camel-example-twitter-websocket-blueprint/src/main/resources/webapp/index.html
index fc01b8e..48b0176 100644
--- 
a/examples/camel-example-twitter-websocket-blueprint/src/main/resources/webapp/index.html
+++ 
b/examples/camel-example-twitter-websocket-blueprint/src/main/resources/webapp/index.html
@@ -20,54 +20,66 @@
 -->
 
 <html>
-<head>
-    <title>Camel Twitter WebSocket Example</title>
-    <script type='text/javascript'>
 
-        if (!window.WebSocket) {
-        alert("WebSocket not supported by this browser");
-        }
+<head>
+  <title>Camel Twitter WebSocket Blueprint Example</title>
+  <script type='text/javascript'>
 
-        function $() { return document.getElementById(arguments[0]); }
+    if (!window.WebSocket) {
+      alert("WebSocket not supported by this browser");
+    }
 
-        var room = {
-        join: function(name) {
-        this._username=name;
+    var room = {
+      join: function (name) {
+        this._username = name;
         var location = "ws://localhost:9090/camel-tweet";
-        this._ws=new WebSocket(location);
-        this._ws.onmessage=this._onmessage;
-        this._ws.onclose=this._onclose;
-        },
-
-        _onmessage: function(m) {
-        if (m.data){
-        var chat=$('chat');
-        var spanText = document.createElement('span');
-        spanText.className='text';
-        spanText.innerHTML=m.data;
-        var lineBreak = document.createElement('br');
-        chat.appendChild(spanText);
-        chat.appendChild(lineBreak);
-        chat.scrollTop = chat.scrollHeight - chat.clientHeight;
-        }
-        },
+        this._ws = new WebSocket(location);
+        this._ws.onmessage = this._onmessage;
+        this._ws.onclose = this._onclose;
+      },
 
-        _onclose: function(m) {
-        this._ws=null;
+      _onmessage: function (m) {
+        if (m.data) {
+          var chat = document.getElementById('chat')
+          var spanText = document.createElement('span');
+          spanText.className = 'text';
+          spanText.innerHTML = m.data;
+          var lineBreak = document.createElement('br');
+          chat.appendChild(spanText);
+          chat.appendChild(lineBreak);
+          chat.scrollTop = chat.scrollHeight - chat.clientHeight;
         }
+      },
 
-        };
+      _onclose: function (m) {
+        this._ws = null;
+      }
 
-    </script>
-    <style type='text/css'>
-        div { border: 0px solid black; }
-        div#chat { clear: both; width: 80em; height: 60ex; overflow: auto; 
background-color: #f0f0f0; padding: 4px; border: 1px solid black; }
-    </style>
+    };
+
+  </script>
+  <style type='text/css'>
+    div {
+      border: 0px solid black;
+    }
+
+    div#chat {
+      clear: both;
+      width: 80em;
+      height: 60ex;
+      overflow: auto;
+      background-color: #f0f0f0;
+      padding: 4px;
+      border: 1px solid black;
+    }
+  </style>
 </head>
+
 <body>
 <div id='chat'></div>
 <script type='text/javascript'>
-    room.join("Testing");
+  room.join("Testing");
 </script>
 </body>
+
 </html>

http://git-wip-us.apache.org/repos/asf/camel/blob/131d39bc/examples/pom.xml
----------------------------------------------------------------------
diff --git a/examples/pom.xml b/examples/pom.xml
index 1acb3cb..30b9b06 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -74,6 +74,7 @@
     <module>camel-example-sql</module>
     <module>camel-example-tracer</module>
     <module>camel-example-twitter-websocket</module>
+    <module>camel-example-twitter-websocket-blueprint</module>    
   </modules>
  
   <properties>

Reply via email to