Skip to content

Commit

Permalink
Add speech01 example app
Browse files Browse the repository at this point in the history
  • Loading branch information
brucerobbins committed Dec 3, 2010
1 parent c535cc5 commit 77cae90
Show file tree
Hide file tree
Showing 8 changed files with 343 additions and 0 deletions.
24 changes: 24 additions & 0 deletions speech01/README.md
Original file line number Diff line number Diff line change
@@ -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
36 changes: 36 additions & 0 deletions speech01/assembly.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0"?>
<assembly>
<id />
<formats>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<baseDirectory>${artifactId}</baseDirectory>
<dependencySets>
<dependencySet>
<unpack>false</unpack>
<outputDirectory>lib</outputDirectory>
<scope>runtime</scope>
<useProjectArtifact>false</useProjectArtifact>
<excludes>
<exclude>log4j:log4j</exclude>
</excludes>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>${project.basedir}/target</directory>
<outputDirectory>lib</outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/src/main/resources</directory>
<outputDirectory />
<includes>
<include>speech01_conf.xml</include>
</includes>
</fileSet>
</fileSets>
</assembly>
80 changes: 80 additions & 0 deletions speech01/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<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>
<groupId>io.s4.examples</groupId>
<artifactId>speech01</artifactId>
<packaging>jar</packaging>
<version>0.0.0.1</version>
<name>speech01</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
<exclusions>
<exclusion>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
</exclusion>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.s4</groupId>
<artifactId>s4_core</artifactId>
<version>0.2.1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>${artifactId}-${version}</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>*</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<findbugsXmlOutput>true</findbugsXmlOutput>
<xmlOutput>true</xmlOutput>
<threshold>High</threshold>
</configuration>
</plugin>
</plugins>
</build>
</project>
32 changes: 32 additions & 0 deletions speech01/src/main/java/io/s4/example/speech01/Highlight.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
81 changes: 81 additions & 0 deletions speech01/src/main/java/io/s4/example/speech01/Sentence.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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();
}

}
56 changes: 56 additions & 0 deletions speech01/src/main/java/io/s4/example/speech01/Speech.java
Original file line number Diff line number Diff line change
@@ -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();
}

}
13 changes: 13 additions & 0 deletions speech01/src/main/resources/speech01_conf.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

<bean id="eventCatcher" class="io.s4.example.speech01.SentenceReceiverPE">
<property name="keys">
<list>
<value>RawSentence *</value>
</list>
</property>
</bean>

</beans>

0 comments on commit 77cae90

Please sign in to comment.