From 77cae908c03690fcc3c3b840eefff774620ba729 Mon Sep 17 00:00:00 2001
From: Bruce Robbins
Date: Fri, 3 Dec 2010 15:09:26 -0800
Subject: [PATCH] Add speech01 example app
---
speech01/README.md | 24 ++++++
speech01/assembly.xml | 36 +++++++++
speech01/pom.xml | 80 ++++++++++++++++++
.../io/s4/example/speech01/Highlight.java | 32 ++++++++
.../java/io/s4/example/speech01/Sentence.java | 81 +++++++++++++++++++
.../example/speech01/SentenceReceiverPE.java | 21 +++++
.../java/io/s4/example/speech01/Speech.java | 56 +++++++++++++
speech01/src/main/resources/speech01_conf.xml | 13 +++
8 files changed, 343 insertions(+)
create mode 100644 speech01/README.md
create mode 100644 speech01/assembly.xml
create mode 100644 speech01/pom.xml
create mode 100644 speech01/src/main/java/io/s4/example/speech01/Highlight.java
create mode 100644 speech01/src/main/java/io/s4/example/speech01/Sentence.java
create mode 100644 speech01/src/main/java/io/s4/example/speech01/SentenceReceiverPE.java
create mode 100644 speech01/src/main/java/io/s4/example/speech01/Speech.java
create mode 100644 speech01/src/main/resources/speech01_conf.xml
diff --git a/speech01/README.md b/speech01/README.md
new file mode 100644
index 0000000..1c36b5f
--- /dev/null
+++ b/speech01/README.md
@@ -0,0 +1,24 @@
+Hello World Example
+===============
+
+Introduction
+------------
+This sample application demonstrates getting an event into an s4 node cluster
+
+Requirements
+------------
+
+* Linux
+* Java 1.6
+* Maven
+* S4 Communication Layer
+* S4 Core
+
+Build Instructions
+------------------
+
+1. First build and install the comm and core packages in your Maven repository.
+
+2. Build and install using Maven
+
+ mvn install assembly:assembly
diff --git a/speech01/assembly.xml b/speech01/assembly.xml
new file mode 100644
index 0000000..a30cc60
--- /dev/null
+++ b/speech01/assembly.xml
@@ -0,0 +1,36 @@
+
+
+
+
+ tar.gz
+
+ true
+ ${artifactId}
+
+
+ false
+ lib
+ runtime
+ false
+
+ log4j:log4j
+
+
+
+
+
+ ${project.basedir}/target
+ lib
+
+ *.jar
+
+
+
+ ${project.basedir}/src/main/resources
+
+
+ speech01_conf.xml
+
+
+
+
diff --git a/speech01/pom.xml b/speech01/pom.xml
new file mode 100644
index 0000000..e26508b
--- /dev/null
+++ b/speech01/pom.xml
@@ -0,0 +1,80 @@
+
+ 4.0.0
+ io.s4.examples
+ speech01
+ jar
+ 0.0.0.1
+ speech01
+ http://maven.apache.org
+
+
+ log4j
+ log4j
+ 1.2.15
+
+
+ javax.mail
+ mail
+
+
+ javax.jms
+ jms
+
+
+ com.sun.jdmk
+ jmxtools
+
+
+ com.sun.jmx
+ jmxri
+
+
+
+
+ io.s4
+ s4_core
+ 0.2.1.0
+ provided
+
+
+
+ ${artifactId}-${version}
+
+
+ src/main/resources
+
+ *
+
+
+
+
+
+ maven-compiler-plugin
+ 2.0.1
+
+
+ 1.6
+
+
+
+ maven-assembly-plugin
+
+
+ assembly.xml
+
+
+
+
+ org.codehaus.mojo
+ findbugs-maven-plugin
+ 2.0
+
+ true
+ true
+ High
+
+
+
+
+
diff --git a/speech01/src/main/java/io/s4/example/speech01/Highlight.java b/speech01/src/main/java/io/s4/example/speech01/Highlight.java
new file mode 100644
index 0000000..8a7ce4e
--- /dev/null
+++ b/speech01/src/main/java/io/s4/example/speech01/Highlight.java
@@ -0,0 +1,32 @@
+package io.s4.example.speech01;
+
+public class Highlight {
+ private long sentenceId;
+ private long time;
+
+ public long getSentenceId() {
+ return sentenceId;
+ }
+
+ public void setSentenceId(long sentenceId) {
+ this.sentenceId = sentenceId;
+ }
+
+ public long getTime() {
+ return time;
+ }
+
+ public void setTime(long time) {
+ this.time = time;
+ }
+
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("{sentenceId:")
+ .append(sentenceId)
+ .append(",time:")
+ .append(time)
+ .append("}");
+ return sb.toString();
+ }
+}
diff --git a/speech01/src/main/java/io/s4/example/speech01/Sentence.java b/speech01/src/main/java/io/s4/example/speech01/Sentence.java
new file mode 100644
index 0000000..376a3c4
--- /dev/null
+++ b/speech01/src/main/java/io/s4/example/speech01/Sentence.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2010 Yahoo! Inc. All rights reserved.
+ *
+ * Licensed 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. See accompanying LICENSE file.
+ */
+package io.s4.example.speech01;
+
+public class Sentence {
+ private long id;
+ private long speechId;
+ private String text;
+ private long time;
+ private String location;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public long getSpeechId() {
+ return speechId;
+ }
+
+ public void setSpeechId(long speechId) {
+ this.speechId = speechId;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public long getTime() {
+ return time;
+ }
+
+ public void setTime(long time) {
+ this.time = time;
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("{id:")
+ .append(id)
+ .append(",speechId:")
+ .append(speechId)
+ .append(",text:")
+ .append(text)
+ .append(",time:")
+ .append(time)
+ .append(",location:")
+ .append(location)
+ .append("}");
+
+ return sb.toString();
+ }
+}
diff --git a/speech01/src/main/java/io/s4/example/speech01/SentenceReceiverPE.java b/speech01/src/main/java/io/s4/example/speech01/SentenceReceiverPE.java
new file mode 100644
index 0000000..724073e
--- /dev/null
+++ b/speech01/src/main/java/io/s4/example/speech01/SentenceReceiverPE.java
@@ -0,0 +1,21 @@
+package io.s4.example.speech01;
+
+import io.s4.processor.AbstractPE;
+
+public class SentenceReceiverPE extends AbstractPE {
+
+ public void processEvent(Sentence sentence) {
+ System.out.printf("Sentence is '%s', location %s\n", sentence.getText(), sentence.getLocation());
+ }
+
+ @Override
+ public void output() {
+ // not called in this example
+ }
+
+ @Override
+ public String getId() {
+ return this.getClass().getName();
+ }
+
+}
diff --git a/speech01/src/main/java/io/s4/example/speech01/Speech.java b/speech01/src/main/java/io/s4/example/speech01/Speech.java
new file mode 100644
index 0000000..065ba9a
--- /dev/null
+++ b/speech01/src/main/java/io/s4/example/speech01/Speech.java
@@ -0,0 +1,56 @@
+package io.s4.example.speech01;
+
+public class Speech {
+ private long id;
+ private String location;
+ private String speaker;
+ private long time;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ public String getSpeaker() {
+ return speaker;
+ }
+
+ public void setSpeaker(String speaker) {
+ this.speaker = speaker;
+ }
+
+ public long getTime() {
+ return time;
+ }
+
+ public void setTime(long time) {
+ this.time = time;
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("{id:")
+ .append(id)
+ .append(",location:")
+ .append(location)
+ .append(",speaker")
+ .append(speaker)
+ .append(",time")
+ .append(time)
+ .append("}");
+
+ return sb.toString();
+ }
+
+}
diff --git a/speech01/src/main/resources/speech01_conf.xml b/speech01/src/main/resources/speech01_conf.xml
new file mode 100644
index 0000000..48c4243
--- /dev/null
+++ b/speech01/src/main/resources/speech01_conf.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+ RawSentence *
+
+
+
+
+