You are viewing a plain text version of this content. The canonical link for it is here.
Posted to s4-commits@incubator.apache.org by mm...@apache.org on 2012/07/19 16:26:24 UTC
[25/32] Fixed s4r URI management + ensure only 1 app is loaded -
added a "-generatedS4R/-g" to specify output location when generating S4R" -
application reference in Zookeeper is now a single znode instead of a
directory, because we only allow 1 app per
http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/f6f91749/test-apps/producer-app/build.gradle
----------------------------------------------------------------------
diff --git a/test-apps/producer-app/build.gradle b/test-apps/producer-app/build.gradle
new file mode 100644
index 0000000..d71f75f
--- /dev/null
+++ b/test-apps/producer-app/build.gradle
@@ -0,0 +1,224 @@
+/*
+* Copyright 2010 the original author or authors.
+*
+* 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.
+*/
+
+/**
+* Apache S4 Application Build File
+*
+* Use this script to buils and package S4 apps.
+*
+* Run 'gradle install' on the s4 project to publish to your local maven repo.
+*
+* TODO: This should probably be distributed as an s4 plugin for Gradle.
+* TODO: There seem to be to be similarities with the war and jetty plugins. (war -> s4r, jetty -> s4Run).
+* We should make it easy to test the app from this script by a running a test task that starts and stops
+* an s4 server. See: http://www.gradle.org/releases/1.0-milestone-3/docs/userguide/userguide_single.html#war_plugin
+*
+* This is an interesting discussion:
+* http://gradle.1045684.n5.nabble.com/Exclude-properties-file-from-war-td3365147.html
+*
+*/
+
+/* Set the destination where we want to install the apps. */
+//s4AppInstallDir = "/tmp/s4Apps" // TODO: decide how to standarize dirs, use env var?
+
+project.ext["s4AppInstallDir"] = hasProperty('appsDir') ? "$appsDir" : "/tmp/appsDir"
+
+project.ext["s4Version"] = '0.5.0-SNAPSHOT'
+description = 'Apache S4 App'
+//defaultTasks 'installS4R'
+archivesBaseName = "$project.name"
+distRootFolder = "$archivesBaseName-${-> version}"
+
+
+// Append the suffix 'SNAPSHOT' when the build is not for release.
+version = new Version(major: 0, minor: 0, bugfix: 0, isRelease: false)
+group = 'org.apache.s4'
+
+apply plugin: 'java'
+apply plugin: 'eclipse'
+
+/* The app classname is set automatically from the source files. */
+def appClassname = ''
+
+/* Set Java version. */
+sourceCompatibility = 1.6
+targetCompatibility = 1.6
+
+
+
+/* All project libraries must be defined here. */
+project.ext["libraries"] = [
+ json: 'org.json:json:20090211',
+ guava: 'com.google.guava:guava:10.0.1',
+ gson: 'com.google.code.gson:gson:1.6',
+ guice: 'com.google.inject:guice:3.0',
+ guice_assist: 'com.google.inject.extensions:guice-assistedinject:3.0',
+ guice_grapher: 'com.google.inject:guice-grapher:3.0',
+ flexjson: 'net.sf.flexjson:flexjson:2.1',
+ bcel: 'org.apache.bcel:bcel:5.2',
+ jakarta_regexp: 'jakarta-regexp:jakarta-regexp:1.4',
+ kryo: 'com.googlecode:kryo:1.04',
+ netty: 'org.jboss.netty:netty:3.2.5.Final',
+ reflectasm: 'com.esotericsoftware:reflectasm:0.8',
+ minlog: 'com.esotericsoftware:minlog:1.2',
+ asm: 'asm:asm:3.2',
+ commons_io: 'commons-io:commons-io:2.0.1',
+ commons_config: 'commons-configuration:commons-configuration:1.6',
+ commons_codec: 'commons-codec:commons-codec:1.4',
+ commons_httpclient: 'commons-httpclient:commons-httpclient:3.1',
+ commons_coll: 'net.sourceforge.collections:collections-generic:4.01', // Use this lib until the commons collection with Generics is released.
+ slf4j: 'org.slf4j:slf4j-api:1.6.1',
+ logback_core: 'ch.qos.logback:logback-core:0.9.29',
+ logback_classic: 'ch.qos.logback:logback-classic:0.9.29',
+ zk: 'org.apache.zookeeper:zookeeper:3.3.1',
+ jcip: 'net.jcip:jcip-annotations:1.0',
+ junit: 'junit:junit:4.10',
+ ]
+
+
+dependencies {
+
+ /* S4 Platform. We only need the API, not the transitive dependencies. */
+// s4Libs.each { module ->
+// compile( module ) //{ transitive = false }
+// s4API( module )
+// }
+
+ compile project(":s4-base")
+ compile project(":s4-comm")
+ compile project(":s4-core")
+
+ /* Logging. */
+ compile( libraries.slf4j )
+ compile( libraries.logback_core )
+ compile( libraries.logback_classic )
+
+ /* Commons. */
+ compile( libraries.commons_io )
+ compile( libraries.commons_config )
+ compile( libraries.commons_coll )
+
+ /* Misc. */
+ compile( libraries.jcip )
+
+ /* Testing. */
+ testCompile( libraries.junit )
+}
+
+/* Set the manifest attributes for the S4 archive here.
+* TODO: separate custom properties from std ones and set custom properties at the top of the build script.
+*/
+manifest.mainAttributes(
+ provider: 'gradle',
+ 'Implementation-Url': 'http://incubator.apache.org/projects/s4.html',
+ 'Implementation-Version': version,
+ 'Implementation-Vendor': 'Apache S4',
+ 'Implementation-Vendor-Id': 's4app',
+ 'S4-App-Class': appClassname, // gets set by the s4r task.
+ 'S4-Version': s4Version
+ )
+
+project.ext["appDependencies"] = ( configurations.compile )
+
+/* This task will extract all the class files and create a fat jar. We set the manifest and the extension to make it an S4 archive file. */
+// TODO: exclude schenma files as needed (not critical) see: http://forums.gradle.org/gradle/topics/using_gradle_to_fat_jar_a_spring_project
+task s4r(type: Jar) {
+ dependsOn jar
+ from { appDependencies.collect { it.isDirectory() ? it : zipTree(it) } }
+ from { configurations.archives.allArtifacts.files.collect { it.isDirectory() ? it : zipTree(it) } }
+ manifest = project.manifest
+ extension = 's4r'
+
+ /* Set class name in manifest. Parse source files until we find a class that extends App.
+ * Get fully qualified Java class name and set attribute in Manifest.
+ */
+ sourceSets.main.allSource.files.each { File file ->
+ if (appClassname =="" || appClassname == "UNKNOWN") {
+ // only execute the closure for this file if we haven't already found the app class name
+ appClassname = getAppClassname(file)
+ if(appClassname != "") {
+ manifest.mainAttributes('S4-App-Class': appClassname)
+ }
+ }
+ }
+
+ if (appClassname == "UNKNOWN") {
+
+ println "Couldn't find App class in source files...aborting."
+ exit(1)
+ }
+}
+
+/* List the artifacts that will br added to the s4 archive (and explode if needed). */
+s4r << {
+ appDependencies.each { File file -> println 'Adding to s4 archive: ' + file.name }
+ configurations.archives.allArtifacts.files.each { File file -> println 'Adding to s4 archive: ' + file.name }
+
+ /* This is for debugging. */
+ //configurations.s4All.each { File file -> println 's4All: ' + file.name }
+ //deployableDependencies.each { File file -> println 'Deploy: ' + file.name }
+
+ // more debugging statements.
+ //sourceSets.main.compileClasspath.each { File file -> println 'compileClasspath: ' + file.name }
+
+}
+
+/* Install the S4 archive to the install directory. */
+task installS4R (type: Copy) {
+ dependsOn s4r
+ from s4r.archivePath
+ into s4AppInstallDir
+}
+
+/* Generates the gradlew scripts.
+http://www.gradle.org/1.0-milestone-3/docs/userguide/gradle_wrapper.html */
+task wrapper(type: Wrapper) { gradleVersion = '1.0-milestone-3' }
+
+
+/* Parse source file to get the app classname so we can use it in the manifest.
+* TODO: Use a real Java parser. (This is not skippong comments for example.)
+*/
+def getAppClassname(file) {
+ def classname = "UNKNOWN"
+ def lines= file.readLines()
+ def packageName=""
+ for(line in lines) {
+
+ def pn = line =~ /.*package\s+([\w\.]+)\s*;.*/
+ if(pn) {
+ packageName = pn[0][1] + "."
+ }
+
+ def an = line =~ /.*public\s+class\s+(\w+)\s+extends.+App.*\{/
+ if (an) {
+ classname = packageName + an[0][1]
+ println "Found app class name: " + classname
+ break
+ }
+ }
+ classname
+}
+
+class Version {
+ int major
+ int minor
+ int bugfix
+ boolean isRelease
+
+ String toString() {
+ "$major.$minor.$bugfix${isRelease ? '' : '-SNAPSHOT'}"
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/f6f91749/test-apps/producer-app/src/main/java/s4app/ProducerApp.java
----------------------------------------------------------------------
diff --git a/test-apps/producer-app/src/main/java/s4app/ProducerApp.java b/test-apps/producer-app/src/main/java/s4app/ProducerApp.java
new file mode 100644
index 0000000..4b54112
--- /dev/null
+++ b/test-apps/producer-app/src/main/java/s4app/ProducerApp.java
@@ -0,0 +1,32 @@
+package s4app;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.s4.core.App;
+
+public class ProducerApp extends App {
+
+ private ProducerPE producerPE;
+
+ @Override
+ protected void onStart() {
+ System.out.println("Starting CounterApp...");
+ producerPE.getInstanceForKey("single");
+ }
+
+ // generic array due to varargs generates a warning.
+ @Override
+ protected void onInit() {
+ System.out.println("Initing CounterApp...");
+
+ producerPE = createPE(ProducerPE.class, "producer");
+ producerPE.setStreams(createOutputStream("tickStream"));
+ producerPE.setTimerInterval(10, TimeUnit.MILLISECONDS);
+
+ }
+
+ @Override
+ protected void onClose() {
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/f6f91749/test-apps/producer-app/src/main/java/s4app/ProducerPE.java
----------------------------------------------------------------------
diff --git a/test-apps/producer-app/src/main/java/s4app/ProducerPE.java b/test-apps/producer-app/src/main/java/s4app/ProducerPE.java
new file mode 100644
index 0000000..7812bc6
--- /dev/null
+++ b/test-apps/producer-app/src/main/java/s4app/ProducerPE.java
@@ -0,0 +1,51 @@
+package s4app;
+
+import org.apache.s4.base.Event;
+import org.apache.s4.core.App;
+import org.apache.s4.core.ProcessingElement;
+import org.apache.s4.core.Streamable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ProducerPE extends ProcessingElement {
+
+ private static final Logger logger = LoggerFactory.getLogger(ProducerPE.class);
+
+ private Streamable[] targetStreams;
+ private long tick = 0;
+
+ public ProducerPE(App app) {
+ super(app);
+ }
+
+ /**
+ * @param targetStreams
+ * the {@link UserEvent} streams.
+ */
+ public void setStreams(Streamable... targetStreams) {
+ this.targetStreams = targetStreams;
+ }
+
+ public void onTime() {
+ if (tick < 1000) {
+ Event event = new Event();
+ event.put("tick", Long.class, tick++);
+
+ logger.info("Sending event with tick {} and time {}.", event.get("tick", Long.class), event.getTime());
+ for (int i = 0; i < targetStreams.length; i++) {
+ targetStreams[i].put(event);
+ }
+ }
+ }
+
+ @Override
+ protected void onRemove() {
+
+ }
+
+ @Override
+ protected void onCreate() {
+ // TODO Auto-generated method stub
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/f6f91749/test-apps/s4-counter/build.gradle
----------------------------------------------------------------------
diff --git a/test-apps/s4-counter/build.gradle b/test-apps/s4-counter/build.gradle
deleted file mode 100644
index d71f75f..0000000
--- a/test-apps/s4-counter/build.gradle
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
-* Copyright 2010 the original author or authors.
-*
-* 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.
-*/
-
-/**
-* Apache S4 Application Build File
-*
-* Use this script to buils and package S4 apps.
-*
-* Run 'gradle install' on the s4 project to publish to your local maven repo.
-*
-* TODO: This should probably be distributed as an s4 plugin for Gradle.
-* TODO: There seem to be to be similarities with the war and jetty plugins. (war -> s4r, jetty -> s4Run).
-* We should make it easy to test the app from this script by a running a test task that starts and stops
-* an s4 server. See: http://www.gradle.org/releases/1.0-milestone-3/docs/userguide/userguide_single.html#war_plugin
-*
-* This is an interesting discussion:
-* http://gradle.1045684.n5.nabble.com/Exclude-properties-file-from-war-td3365147.html
-*
-*/
-
-/* Set the destination where we want to install the apps. */
-//s4AppInstallDir = "/tmp/s4Apps" // TODO: decide how to standarize dirs, use env var?
-
-project.ext["s4AppInstallDir"] = hasProperty('appsDir') ? "$appsDir" : "/tmp/appsDir"
-
-project.ext["s4Version"] = '0.5.0-SNAPSHOT'
-description = 'Apache S4 App'
-//defaultTasks 'installS4R'
-archivesBaseName = "$project.name"
-distRootFolder = "$archivesBaseName-${-> version}"
-
-
-// Append the suffix 'SNAPSHOT' when the build is not for release.
-version = new Version(major: 0, minor: 0, bugfix: 0, isRelease: false)
-group = 'org.apache.s4'
-
-apply plugin: 'java'
-apply plugin: 'eclipse'
-
-/* The app classname is set automatically from the source files. */
-def appClassname = ''
-
-/* Set Java version. */
-sourceCompatibility = 1.6
-targetCompatibility = 1.6
-
-
-
-/* All project libraries must be defined here. */
-project.ext["libraries"] = [
- json: 'org.json:json:20090211',
- guava: 'com.google.guava:guava:10.0.1',
- gson: 'com.google.code.gson:gson:1.6',
- guice: 'com.google.inject:guice:3.0',
- guice_assist: 'com.google.inject.extensions:guice-assistedinject:3.0',
- guice_grapher: 'com.google.inject:guice-grapher:3.0',
- flexjson: 'net.sf.flexjson:flexjson:2.1',
- bcel: 'org.apache.bcel:bcel:5.2',
- jakarta_regexp: 'jakarta-regexp:jakarta-regexp:1.4',
- kryo: 'com.googlecode:kryo:1.04',
- netty: 'org.jboss.netty:netty:3.2.5.Final',
- reflectasm: 'com.esotericsoftware:reflectasm:0.8',
- minlog: 'com.esotericsoftware:minlog:1.2',
- asm: 'asm:asm:3.2',
- commons_io: 'commons-io:commons-io:2.0.1',
- commons_config: 'commons-configuration:commons-configuration:1.6',
- commons_codec: 'commons-codec:commons-codec:1.4',
- commons_httpclient: 'commons-httpclient:commons-httpclient:3.1',
- commons_coll: 'net.sourceforge.collections:collections-generic:4.01', // Use this lib until the commons collection with Generics is released.
- slf4j: 'org.slf4j:slf4j-api:1.6.1',
- logback_core: 'ch.qos.logback:logback-core:0.9.29',
- logback_classic: 'ch.qos.logback:logback-classic:0.9.29',
- zk: 'org.apache.zookeeper:zookeeper:3.3.1',
- jcip: 'net.jcip:jcip-annotations:1.0',
- junit: 'junit:junit:4.10',
- ]
-
-
-dependencies {
-
- /* S4 Platform. We only need the API, not the transitive dependencies. */
-// s4Libs.each { module ->
-// compile( module ) //{ transitive = false }
-// s4API( module )
-// }
-
- compile project(":s4-base")
- compile project(":s4-comm")
- compile project(":s4-core")
-
- /* Logging. */
- compile( libraries.slf4j )
- compile( libraries.logback_core )
- compile( libraries.logback_classic )
-
- /* Commons. */
- compile( libraries.commons_io )
- compile( libraries.commons_config )
- compile( libraries.commons_coll )
-
- /* Misc. */
- compile( libraries.jcip )
-
- /* Testing. */
- testCompile( libraries.junit )
-}
-
-/* Set the manifest attributes for the S4 archive here.
-* TODO: separate custom properties from std ones and set custom properties at the top of the build script.
-*/
-manifest.mainAttributes(
- provider: 'gradle',
- 'Implementation-Url': 'http://incubator.apache.org/projects/s4.html',
- 'Implementation-Version': version,
- 'Implementation-Vendor': 'Apache S4',
- 'Implementation-Vendor-Id': 's4app',
- 'S4-App-Class': appClassname, // gets set by the s4r task.
- 'S4-Version': s4Version
- )
-
-project.ext["appDependencies"] = ( configurations.compile )
-
-/* This task will extract all the class files and create a fat jar. We set the manifest and the extension to make it an S4 archive file. */
-// TODO: exclude schenma files as needed (not critical) see: http://forums.gradle.org/gradle/topics/using_gradle_to_fat_jar_a_spring_project
-task s4r(type: Jar) {
- dependsOn jar
- from { appDependencies.collect { it.isDirectory() ? it : zipTree(it) } }
- from { configurations.archives.allArtifacts.files.collect { it.isDirectory() ? it : zipTree(it) } }
- manifest = project.manifest
- extension = 's4r'
-
- /* Set class name in manifest. Parse source files until we find a class that extends App.
- * Get fully qualified Java class name and set attribute in Manifest.
- */
- sourceSets.main.allSource.files.each { File file ->
- if (appClassname =="" || appClassname == "UNKNOWN") {
- // only execute the closure for this file if we haven't already found the app class name
- appClassname = getAppClassname(file)
- if(appClassname != "") {
- manifest.mainAttributes('S4-App-Class': appClassname)
- }
- }
- }
-
- if (appClassname == "UNKNOWN") {
-
- println "Couldn't find App class in source files...aborting."
- exit(1)
- }
-}
-
-/* List the artifacts that will br added to the s4 archive (and explode if needed). */
-s4r << {
- appDependencies.each { File file -> println 'Adding to s4 archive: ' + file.name }
- configurations.archives.allArtifacts.files.each { File file -> println 'Adding to s4 archive: ' + file.name }
-
- /* This is for debugging. */
- //configurations.s4All.each { File file -> println 's4All: ' + file.name }
- //deployableDependencies.each { File file -> println 'Deploy: ' + file.name }
-
- // more debugging statements.
- //sourceSets.main.compileClasspath.each { File file -> println 'compileClasspath: ' + file.name }
-
-}
-
-/* Install the S4 archive to the install directory. */
-task installS4R (type: Copy) {
- dependsOn s4r
- from s4r.archivePath
- into s4AppInstallDir
-}
-
-/* Generates the gradlew scripts.
-http://www.gradle.org/1.0-milestone-3/docs/userguide/gradle_wrapper.html */
-task wrapper(type: Wrapper) { gradleVersion = '1.0-milestone-3' }
-
-
-/* Parse source file to get the app classname so we can use it in the manifest.
-* TODO: Use a real Java parser. (This is not skippong comments for example.)
-*/
-def getAppClassname(file) {
- def classname = "UNKNOWN"
- def lines= file.readLines()
- def packageName=""
- for(line in lines) {
-
- def pn = line =~ /.*package\s+([\w\.]+)\s*;.*/
- if(pn) {
- packageName = pn[0][1] + "."
- }
-
- def an = line =~ /.*public\s+class\s+(\w+)\s+extends.+App.*\{/
- if (an) {
- classname = packageName + an[0][1]
- println "Found app class name: " + classname
- break
- }
- }
- classname
-}
-
-class Version {
- int major
- int minor
- int bugfix
- boolean isRelease
-
- String toString() {
- "$major.$minor.$bugfix${isRelease ? '' : '-SNAPSHOT'}"
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/f6f91749/test-apps/s4-counter/src/main/java/s4app/ClockApp.java
----------------------------------------------------------------------
diff --git a/test-apps/s4-counter/src/main/java/s4app/ClockApp.java b/test-apps/s4-counter/src/main/java/s4app/ClockApp.java
deleted file mode 100644
index cab4eab..0000000
--- a/test-apps/s4-counter/src/main/java/s4app/ClockApp.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package s4app;
-
-import java.util.concurrent.TimeUnit;
-
-import org.apache.s4.core.App;
-import org.apache.s4.core.EventSource;
-import org.apache.s4.core.Streamable;
-
-public class ClockApp extends App {
-
- private EventSource eventSource;
- private ClockPE clockPE;
-
- @Override
- protected void onStart() {
- System.out.println("Starting CounterApp...");
- clockPE.getInstanceForKey("single");
- }
-
- // generic array due to varargs generates a warning.
- @Override
- protected void onInit() {
- System.out.println("Initing CounterApp...");
-
- clockPE = new ClockPE(this);
- clockPE.setTimerInterval(1, TimeUnit.SECONDS);
-
- eventSource = new EventSource(this, "clockStream");
- clockPE.setStreams((Streamable) eventSource);
- }
-
- @Override
- protected void onClose() {
- System.out.println("Closing CounterApp...");
- eventSource.close();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/f6f91749/test-apps/s4-counter/src/main/java/s4app/ClockPE.java
----------------------------------------------------------------------
diff --git a/test-apps/s4-counter/src/main/java/s4app/ClockPE.java b/test-apps/s4-counter/src/main/java/s4app/ClockPE.java
deleted file mode 100644
index cc81672..0000000
--- a/test-apps/s4-counter/src/main/java/s4app/ClockPE.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package s4app;
-
-import org.apache.s4.base.Event;
-import org.apache.s4.core.App;
-import org.apache.s4.core.ProcessingElement;
-import org.apache.s4.core.Streamable;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ClockPE extends ProcessingElement {
-
- private static final Logger logger = LoggerFactory.getLogger(ClockPE.class);
-
- private Streamable[] targetStreams;
- private long tick = 0;
-
- public ClockPE(App app) {
- super(app);
- }
-
- /**
- * @param targetStreams
- * the {@link UserEvent} streams.
- */
- public void setStreams(Streamable... targetStreams) {
- this.targetStreams = targetStreams;
- }
-
- public void onTime() {
- Event event = new Event();
- event.put("tick", Long.class, tick++);
-
- logger.info("Sending event with tick {} and time {}.", event.get("tick", Long.class), event.getTime());
- for (int i = 0; i < targetStreams.length; i++) {
- targetStreams[i].put(event);
- }
- }
-
- @Override
- protected void onRemove() {
-
- }
-
- @Override
- protected void onCreate() {
- // TODO Auto-generated method stub
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/f6f91749/test-apps/s4-showtime/build.gradle
----------------------------------------------------------------------
diff --git a/test-apps/s4-showtime/build.gradle b/test-apps/s4-showtime/build.gradle
deleted file mode 100644
index 3bfe72f..0000000
--- a/test-apps/s4-showtime/build.gradle
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
-* Copyright 2010 the original author or authors.
-*
-* 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.
-*/
-
-/**
-* Apache S4 Application Build File
-*
-* Use this script to buils and package S4 apps.
-*
-* Run 'gradle install' on the s4 project to publish to your local maven repo.
-*
-* TODO: This should probably be distributed as an s4 plugin for Gradle.
-* TODO: There seem to be to be similarities with the war and jetty plugins. (war -> s4r, jetty -> s4Run).
-* We should make it easy to test the app from this script by a running a test task that starts and stops
-* an s4 server. See: http://www.gradle.org/releases/1.0-milestone-3/docs/userguide/userguide_single.html#war_plugin
-*
-* This is an interesting discussion:
-* http://gradle.1045684.n5.nabble.com/Exclude-properties-file-from-war-td3365147.html
-*
-*/
-
-/* Set the destination where we want to install the apps. */
-//s4AppInstallDir = "/tmp/s4Apps" // TODO: decide how to standarize dirs, use env var?
-
-project.ext["s4AppInstallDir"] = hasProperty('appsDir') ? "$appsDir" : "/tmp/appsDir"
-
-project.ext["s4Version"] = '0.5.0-SNAPSHOT'
-description = 'Apache S4 App'
-//defaultTasks 'installS4R'
-archivesBaseName = "$project.name"
-distRootFolder = "$archivesBaseName-${-> version}"
-
-
-// Append the suffix 'SNAPSHOT' when the build is not for release.
-version = new Version(major: 0, minor: 0, bugfix: 0, isRelease: false)
-group = 'org.apache.s4'
-
-apply plugin: 'java'
-apply plugin: 'eclipse'
-
-/* The app classname is set automatically from the source files. */
-def appClassname = ''
-
-/* Set Java version. */
-sourceCompatibility = 1.6
-targetCompatibility = 1.6
-
-
-
-/* All project libraries must be defined here. */
-project.ext["libraries"] = [
- json: 'org.json:json:20090211',
- guava: 'com.google.guava:guava:10.0.1',
- gson: 'com.google.code.gson:gson:1.6',
- guice: 'com.google.inject:guice:3.0',
- guice_assist: 'com.google.inject.extensions:guice-assistedinject:3.0',
- guice_grapher: 'com.google.inject:guice-grapher:3.0',
- flexjson: 'net.sf.flexjson:flexjson:2.1',
- bcel: 'org.apache.bcel:bcel:5.2',
- jakarta_regexp: 'jakarta-regexp:jakarta-regexp:1.4',
- kryo: 'com.googlecode:kryo:1.04',
- netty: 'org.jboss.netty:netty:3.2.5.Final',
- reflectasm: 'com.esotericsoftware:reflectasm:0.8',
- minlog: 'com.esotericsoftware:minlog:1.2',
- asm: 'asm:asm:3.2',
- commons_io: 'commons-io:commons-io:2.0.1',
- commons_config: 'commons-configuration:commons-configuration:1.6',
- commons_codec: 'commons-codec:commons-codec:1.4',
- commons_httpclient: 'commons-httpclient:commons-httpclient:3.1',
- commons_coll: 'net.sourceforge.collections:collections-generic:4.01', // Use this lib until the commons collection with Generics is released.
- slf4j: 'org.slf4j:slf4j-api:1.6.1',
- logback_core: 'ch.qos.logback:logback-core:0.9.29',
- logback_classic: 'ch.qos.logback:logback-classic:0.9.29',
- zk: 'org.apache.zookeeper:zookeeper:3.3.1',
- jcip: 'net.jcip:jcip-annotations:1.0',
- junit: 'junit:junit:4.10',
- ]
-
-
-dependencies {
-
- /* S4 Platform. We only need the API, not the transitive dependencies. */
-// s4Libs.each { module ->
-// compile( module ) //{ transitive = false }
-// s4API( module )
-// }
-
- compile project(":s4-base")
- compile project(":s4-comm")
- compile project(":s4-core")
-
- /* Logging. */
- compile( libraries.slf4j )
- compile( libraries.logback_core )
- compile( libraries.logback_classic )
-
- /* Commons. */
- compile( libraries.commons_io )
- compile( libraries.commons_config )
- compile( libraries.commons_coll )
-
- /* Misc. */
- compile( libraries.jcip )
-
- /* Testing. */
- testCompile( libraries.junit )
-}
-
-/* Set the manifest attributes for the S4 archive here.
-* TODO: separate custom properties from std ones and set custom properties at the top of the build script.
-*/
-manifest.mainAttributes(
- provider: 'gradle',
- 'Implementation-Url': 'http://incubator.apache.org/projects/s4.html',
- 'Implementation-Version': version,
- 'Implementation-Vendor': 'Apache S4',
- 'Implementation-Vendor-Id': 's4app',
- 'S4-App-Class': appClassname, // gets set by the s4r task.
- 'S4-Version': s4Version
- )
-
-project.ext["appDependencies"] = ( configurations.compile )
-
-/* This task will extract all the class files and create a fat jar. We set the manifest and the extension to make it an S4 archive file. */
-// TODO: exclude schenma files as needed (not critical) see: http://forums.gradle.org/gradle/topics/using_gradle_to_fat_jar_a_spring_project
-task s4r(type: Jar) {
- dependsOn jar
- from { appDependencies.collect { it.isDirectory() ? it : zipTree(it) } }
- from { configurations.archives.allArtifacts.files.collect { it.isDirectory() ? it : zipTree(it) } }
- manifest = project.manifest
- extension = 's4r'
-
- /* Set class name in manifest. Parse source files until we find a class that extends App.
- * Get fully qualified Java class name and set attribute in Manifest.
- */
- sourceSets.main.allSource.files.each { File file ->
- if (appClassname =="" || appClassname == "UNKNOWN") {
- // only execute the closure for this file if we haven't already found the app class name
- appClassname = getAppClassname(file)
- if(appClassname != "") {
- manifest.mainAttributes('S4-App-Class': appClassname)
- }
- }
- }
-
- if (appClassname == "UNKNOWN") {
-
- println "Couldn't find App class in source files...aborting."
- exit(1)
- }
-}
-
-/* List the artifacts that will br added to the s4 archive (and explode if needed). */
-s4r << {
- appDependencies.each { File file -> println 'Adding to s4 archive: ' + file.name }
- configurations.archives.allArtifacts.files.each { File file -> println 'Adding to s4 archive: ' + file.name }
-
- /* This is for debugging. */
- //configurations.s4All.each { File file -> println 's4All: ' + file.name }
- //deployableDependencies.each { File file -> println 'Deploy: ' + file.name }
-
- // more debugging statements.
- //sourceSets.main.compileClasspath.each { File file -> println 'compileClasspath: ' + file.name }
-
-}
-
-/* Install the S4 archive to the install directory. */
-task installS4R (type: Copy) {
- dependsOn s4r
- from s4r.archivePath
- into s4AppInstallDir
-}
-
-
-
-
-/* Parse source file to get the app classname so we can use it in the manifest.
-* TODO: Use a real Java parser. (This is not skippong comments for example.)
-*/
-def getAppClassname(file) {
- def classname = "UNKNOWN"
- def lines= file.readLines()
- def packageName=""
- for(line in lines) {
-
- def pn = line =~ /.*package\s+([\w\.]+)\s*;.*/
- if(pn) {
- packageName = pn[0][1] + "."
- }
-
- def an = line =~ /.*public\s+class\s+(\w+)\s+extends.+App.*\{/
- if (an) {
- classname = packageName + an[0][1]
- println "Found app class name: " + classname
- break
- }
- }
- classname
-}
-
-class Version {
- int major
- int minor
- int bugfix
- boolean isRelease
-
- String toString() {
- "$major.$minor.$bugfix${isRelease ? '' : '-SNAPSHOT'}"
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/f6f91749/test-apps/s4-showtime/src/main/java/s4app/ShowPE.java
----------------------------------------------------------------------
diff --git a/test-apps/s4-showtime/src/main/java/s4app/ShowPE.java b/test-apps/s4-showtime/src/main/java/s4app/ShowPE.java
deleted file mode 100644
index f68516c..0000000
--- a/test-apps/s4-showtime/src/main/java/s4app/ShowPE.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package s4app;
-
-import org.apache.s4.base.Event;
-import org.apache.s4.core.App;
-import org.apache.s4.core.ProcessingElement;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ShowPE extends ProcessingElement {
-
- private static final Logger logger = LoggerFactory.getLogger(ShowPE.class);
-
- public ShowPE(App app) {
- super(app);
- }
-
- public void onEvent(Event event) {
-
- logger.info("Received event with tick {} and time {}.", event.get("tick", Long.class), event.getTime());
-
- }
-
- @Override
- protected void onRemove() {
-
- }
-
- @Override
- protected void onCreate() {
- // TODO Auto-generated method stub
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/f6f91749/test-apps/s4-showtime/src/main/java/s4app/ShowTimeApp.java
----------------------------------------------------------------------
diff --git a/test-apps/s4-showtime/src/main/java/s4app/ShowTimeApp.java b/test-apps/s4-showtime/src/main/java/s4app/ShowTimeApp.java
deleted file mode 100644
index 6652f59..0000000
--- a/test-apps/s4-showtime/src/main/java/s4app/ShowTimeApp.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package s4app;
-
-import org.apache.s4.core.App;
-
-public class ShowTimeApp extends App {
-
- private ShowPE showPE;
-
- @Override
- protected void onStart() {
- System.out.println("Starting ShowTimeApp...");
- showPE.getInstanceForKey("single");
- }
-
- @Override
- protected void onInit() {
- System.out.println("Initing ShowTimeApp...");
-
- showPE = new ShowPE(this);
-
- /* This stream will receive events from another app. */
- createStream("clockStream", showPE);
- }
-
- @Override
- protected void onClose() {
- System.out.println("Closing ShowTimeApp...");
- }
-}