Permalink
Browse files

THRIFT-890. java: Fix tutorial to build and run in trunk

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1001856 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent fa6eaca commit 515c2381b71cf997c17a70c144bfc622a388c6a0 @toddlipcon toddlipcon committed Sep 27, 2010
Showing with 27 additions and 12 deletions.
  1. +4 −1 tutorial/java/JavaClient
  2. +4 −1 tutorial/java/JavaServer
  3. +13 −3 tutorial/java/build.xml
  4. +6 −6 tutorial/java/src/JavaServer.java
  5. +0 −1 tutorial/tutorial.thrift
View
@@ -18,5 +18,8 @@
# specific language governing permissions and limitations
# under the License.
#
+THIS_DIR=$(dirname $0)
+LIB_DIR=$THIS_DIR/../../lib/java/
+IVY_DIR=$LIB_DIR/build/ivy/lib/
-java -cp tutorial.jar:/usr/local/lib/libthrift.jar JavaClient
+java -cp $IVY_DIR/*:$LIB_DIR/libthrift.jar:tutorial.jar JavaClient
View
@@ -18,5 +18,8 @@
# specific language governing permissions and limitations
# under the License.
#
+THIS_DIR=$(dirname $0)
+LIB_DIR=$THIS_DIR/../../lib/java/
+IVY_DIR=$LIB_DIR/build/ivy/lib/
-java -cp tutorial.jar:/usr/local/lib/libthrift.jar JavaServer
+java -cp $IVY_DIR/*:$LIB_DIR/libthrift.jar:tutorial.jar JavaServer
View
@@ -23,16 +23,26 @@
<property name="src" location="src" />
<property name="gen" location="../gen-java" />
<property name="build" location="build" />
- <property name="cpath" location="/usr/local/lib/libthrift.jar" />
+
+ <path id="libs.classpath">
+ <pathelement path="../../lib/java/libthrift.jar" />
+ <fileset dir="../../lib/java/build/ivy/lib">
+ <include name="*.jar" />
+ </fileset>
+ </path>
+ <path id="build.classpath">
+ <path refid="libs.classpath" />
+ <pathelement path="${gen}" />
+ </path>
<target name="init">
<tstamp />
<mkdir dir="${build}"/>
</target>
<target name="compile" depends="init">
- <javac srcdir="${gen}" destdir="${build}" classpath="${cpath}" />
- <javac srcdir="${src}" destdir="${build}" classpath="${cpath}:${gen}" />
+ <javac srcdir="${gen}" destdir="${build}" classpathref="libs.classpath" />
+ <javac srcdir="${src}" destdir="${build}" classpathref="build.classpath" />
</target>
<target name="tutorial" depends="compile">
@@ -54,27 +54,27 @@ public int calculate(int logid, Work work) throws InvalidOperation {
System.out.println("calculate(" + logid + ", {" + work.op + "," + work.num1 + "," + work.num2 + "})");
int val = 0;
switch (work.op) {
- case Operation.ADD:
+ case ADD:
val = work.num1 + work.num2;
break;
- case Operation.SUBTRACT:
+ case SUBTRACT:
val = work.num1 - work.num2;
break;
- case Operation.MULTIPLY:
+ case MULTIPLY:
val = work.num1 * work.num2;
break;
- case Operation.DIVIDE:
+ case DIVIDE:
if (work.num2 == 0) {
InvalidOperation io = new InvalidOperation();
- io.what = work.op;
+ io.what = work.op.getValue();
io.why = "Cannot divide by 0";
throw io;
}
val = work.num1 / work.num2;
break;
default:
InvalidOperation io = new InvalidOperation();
- io.what = work.op;
+ io.what = work.op.getValue();
io.why = "Unknown operation";
throw io;
}
View
@@ -66,7 +66,6 @@ namespace cpp tutorial
namespace java tutorial
namespace php tutorial
namespace perl tutorial
-namespace smalltalk.category Thrift.Tutorial
/**
* Thrift lets you do typedefs to get pretty names for your types. Standard

0 comments on commit 515c238

Please sign in to comment.