brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From drigod...@apache.org
Subject [1/3] brooklyn-library git commit: * Added Redis integration into hello-world-sql example*
Date Tue, 28 Feb 2017 14:14:48 GMT
Repository: brooklyn-library
Updated Branches:
  refs/heads/master 02475704c -> 269c0436a


* Added Redis integration into hello-world-sql example*

- added Jedis dependency
- updated available.jsp to optionally display Redis link
- added a jsp for the Redis chatroom


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-library/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-library/commit/8540bab9
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-library/tree/8540bab9
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-library/diff/8540bab9

Branch: refs/heads/master
Commit: 8540bab993029c9b667ef8121e29dde8ad3dc999
Parents: f3cbc42
Author: Justin Thompson <justin.thompson@cloudsoftcorp.com>
Authored: Tue Feb 7 12:33:30 2017 +0000
Committer: Justin Thompson <justin.thompson@cloudsoftcorp.com>
Committed: Tue Feb 7 12:33:30 2017 +0000

----------------------------------------------------------------------
 examples/webapps/hello-world-sql/pom.xml        |  5 ++
 .../src/main/webapp/available.jsp               | 15 +++-
 .../hello-world-sql/src/main/webapp/redis.jsp   | 80 ++++++++++++++++++++
 3 files changed, 96 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/8540bab9/examples/webapps/hello-world-sql/pom.xml
----------------------------------------------------------------------
diff --git a/examples/webapps/hello-world-sql/pom.xml b/examples/webapps/hello-world-sql/pom.xml
index c55d0c7..fdd9189 100644
--- a/examples/webapps/hello-world-sql/pom.xml
+++ b/examples/webapps/hello-world-sql/pom.xml
@@ -101,6 +101,11 @@
                 </exclusion>
             </exclusions>
         </dependency>
+        <dependency>
+            <groupId>redis.clients</groupId>
+            <artifactId>jedis</artifactId>
+            <version>${redis.version}</version>
+        </dependency>
     </dependencies>
 
     <build>

http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/8540bab9/examples/webapps/hello-world-sql/src/main/webapp/available.jsp
----------------------------------------------------------------------
diff --git a/examples/webapps/hello-world-sql/src/main/webapp/available.jsp b/examples/webapps/hello-world-sql/src/main/webapp/available.jsp
index ddb4bf4..443e302 100644
--- a/examples/webapps/hello-world-sql/src/main/webapp/available.jsp
+++ b/examples/webapps/hello-world-sql/src/main/webapp/available.jsp
@@ -41,12 +41,19 @@ The following apps are available:
 
 <ul>
 <%
-String url=System.getProperty("brooklyn.example.db.url");
+String mySqlUrl=System.getProperty("brooklyn.example.db.url");
 //URL should be supplied e.g. "-Dbrooklyn.example.db.url=jdbc:mysql://localhost/visitors?user=brooklyn&password=br00k11n"
 //(note quoting needed due to ampersand)
-if (url!=null) {
+if (mySqlUrl!=null) {
 %>
 <li><a href="db.jsp">SQL database chatroom</a></li>
+<% }
+
+String redisUrl=System.getProperty("brooklyn.example.redis.host");
+//Host should be supplied e.g. "-Dbrooklyn.example.redis.host=localhost"
+if (redisUrl!=null) {
+%>
+<li><a href="redis.jsp">Redis chatroom</a></li>
 <% } %>
 
 <%
@@ -71,9 +78,9 @@ if (hadoop!=null) {
 %>
 <li><a href="riak.jsp">Riak chatroom</a></li>
 <% }
-if (hadoop==null && url==null && mongo==null && riak==null) {
+if (hadoop==null && mySqlUrl==null && mongo==null && riak==null &&
redisUrl==null) {
 %>
-<li><i>None.</i> Try one of the other Brooklyn examples to see SQL or Hadoop.</li>
+<li><i>None.</i> Try one of the other Brooklyn examples to see SQL, Hadoop
or Redis</li>
 <% } %>
 </ul>
 

http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/8540bab9/examples/webapps/hello-world-sql/src/main/webapp/redis.jsp
----------------------------------------------------------------------
diff --git a/examples/webapps/hello-world-sql/src/main/webapp/redis.jsp b/examples/webapps/hello-world-sql/src/main/webapp/redis.jsp
new file mode 100644
index 0000000..6a3bde6
--- /dev/null
+++ b/examples/webapps/hello-world-sql/src/main/webapp/redis.jsp
@@ -0,0 +1,80 @@
+<%@ page import="java.util.List" %>
+<%@ page import="redis.clients.jedis.Jedis" %>
+
+<html>
+<!--
+    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.
+-->
+<head>
+  <title>Sample Application Database JSP Page</title>
+</head>
+<br/>
+<body bgcolor=white>
+
+<table border="0">
+  <tr>
+    <td align=center>
+      <img src="images/bridge-small.png">
+    </td>
+    <td>
+      <h1>Sample Brooklyn Deployed WebApp (Database JSP)</h1>
+      This is the output of a JSP page that is part of the Hello, World application,
+      deployed by brooklyn, to show <b>Redis database interactivity</b>.
+    </td>
+  </tr>
+</table>
+<br/>
+<p>Visitors:</p>
+<ul>
+<%
+  String redisUrl=System.getProperty("brooklyn.example.redis.host");
+  Jedis jedis = new Jedis(redisUrl);
+
+  if (request.getParameter("name")!=null) {
+      jedis.lpush("messages", request.getParameter("name")+":"+request.getParameter("message"));
+  }
+
+  List<String> messages = jedis.lrange("messages", 0, 10);
+  for (int i =0; i < messages.size(); i++){
+      String[] messageParts = messages.get(i).split(":");
+      String name = messageParts[0];
+      String message = messageParts[1];
+    %>
+    <li> <b><%= name %></b>: <%= message %> </li>
+      <%
+      }
+%>
+
+</ul>
+
+<br/>
+
+<p>Please enter a message:</p>
+
+<form action="redis.jsp" method="GET">
+  <table>
+    <tr><td>Name: </td><td><input type="text" name="name"></td></tr>
+    <tr><td>Message: </td><td><input type="text" name="message"></td></tr>
+  </table>
+  <input type="submit" value="Submit"/>
+</form>
+
+<br/>
+<p>Click <a href="index.html">here</a> to go back to the main page.</p>
+</body>
+</html>


Mime
View raw message