From 515c2381b71cf997c17a70c144bfc622a388c6a0 Mon Sep 17 00:00:00 2001 From: Todd Lipcon Date: Mon, 27 Sep 2010 18:26:07 +0000 Subject: [PATCH] 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 --- tutorial/java/JavaClient | 5 ++++- tutorial/java/JavaServer | 5 ++++- tutorial/java/build.xml | 16 +++++++++++++--- tutorial/java/src/JavaServer.java | 12 ++++++------ tutorial/tutorial.thrift | 1 - 5 files changed, 27 insertions(+), 12 deletions(-) diff --git a/tutorial/java/JavaClient b/tutorial/java/JavaClient index 68d87b81..77b6a057 100755 --- a/tutorial/java/JavaClient +++ b/tutorial/java/JavaClient @@ -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 diff --git a/tutorial/java/JavaServer b/tutorial/java/JavaServer index 89616001..3ff9fd81 100755 --- a/tutorial/java/JavaServer +++ b/tutorial/java/JavaServer @@ -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 diff --git a/tutorial/java/build.xml b/tutorial/java/build.xml index 0ec1ea40..e7d5c8b3 100644 --- a/tutorial/java/build.xml +++ b/tutorial/java/build.xml @@ -23,7 +23,17 @@ - + + + + + + + + + + + @@ -31,8 +41,8 @@ - - + + diff --git a/tutorial/java/src/JavaServer.java b/tutorial/java/src/JavaServer.java index 14440eb7..da84c321 100644 --- a/tutorial/java/src/JavaServer.java +++ b/tutorial/java/src/JavaServer.java @@ -54,19 +54,19 @@ public class JavaServer { 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; } @@ -74,7 +74,7 @@ public class JavaServer { break; default: InvalidOperation io = new InvalidOperation(); - io.what = work.op; + io.what = work.op.getValue(); io.why = "Unknown operation"; throw io; } diff --git a/tutorial/tutorial.thrift b/tutorial/tutorial.thrift index 86e433dd..3ea496ca 100644 --- a/tutorial/tutorial.thrift +++ b/tutorial/tutorial.thrift @@ -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 -- 2.17.1