summaryrefslogtreecommitdiff
path: root/tutorial/java
diff options
context:
space:
mode:
authorRoger Meier <roger@apache.org>2012-10-22 19:27:38 +0000
committerRoger Meier <roger@apache.org>2012-10-22 19:27:38 +0000
commitfa89932a49f80ddea079c783232f6d304c59352e (patch)
tree53555241d1c9efd42dd284b02acb71a3ef01590d /tutorial/java
parent8d410de0a057e301505c870a9a67e0e73510d0a0 (diff)
downloadthrift-fa89932a49f80ddea079c783232f6d304c59352e.tar.gz
THRIFT-1735 integrate tutorial into regular build
Patch: Roger Meier git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1401032 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'tutorial/java')
-rwxr-xr-xtutorial/java/JavaServer29
-rwxr-xr-xtutorial/java/Makefile.am (renamed from tutorial/java/JavaClient)21
-rw-r--r--tutorial/java/README37
-rw-r--r--tutorial/java/build.xml62
4 files changed, 89 insertions, 60 deletions
diff --git a/tutorial/java/JavaServer b/tutorial/java/JavaServer
deleted file mode 100755
index cf977caaa..000000000
--- a/tutorial/java/JavaServer
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/sh
-
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you 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.
-#
-
-# Optionally the following properties could be set for SSL instead
-# of configuring it in the code
-# -Djavax.net.ssl.trustStore=../../lib/java/test/.truststore
-# -Djavax.net.ssl.trustStorePassword=thrift
-# -Djavax.net.ssl.keyStore=../../lib/java/test/.keystore
-# -Djavax.net.ssl.keyStorePassword=thrift
-
-java -cp ../../lib/java/build/lib/*:../../lib/java/build/*:tutorial.jar JavaServer
diff --git a/tutorial/java/JavaClient b/tutorial/java/Makefile.am
index dae515e44..16ae399c6 100755
--- a/tutorial/java/JavaClient
+++ b/tutorial/java/Makefile.am
@@ -1,5 +1,3 @@
-#!/bin/sh
-
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -19,4 +17,21 @@
# under the License.
#
-java -cp ../../lib/java/build/lib/*:../../lib/java/build/*:tutorial.jar JavaClient $1
+export CLASSPATH
+
+# Make sure this doesn't fail if ant is not configured.
+clean-local:
+ ANT=$(ANT) ; if test -z "$$ANT" ; then ANT=: ; fi ; \
+ $$ANT $(ANT_FLAGS) clean
+
+check-local: all
+ $(ANT) $(ANT_FLAGS) test
+
+tutorial: all
+ $(ANT) $(ANT_FLAGS) tutorial
+
+tutorialserver: all
+ $(ANT) $(ANT_FLAGS) tutorialserver
+
+tutorialclient: all
+ $(ANT) $(ANT_FLAGS) tutorialclient \ No newline at end of file
diff --git a/tutorial/java/README b/tutorial/java/README
index 9f03ba7f1..c0811f7f2 100644
--- a/tutorial/java/README
+++ b/tutorial/java/README
@@ -1,29 +1,20 @@
-Steps for Java tutorial
+Thrift Java Tutorial
==================================================
+1) Compile the Java library
-1) Make sure thrift is compiled, both the compiler and the Java library. You should
-be able to verify the following:
+thrift/lib/java$ make
+or:
+thrift/lib/java$ ant
-thrift/tutorial/java$ file ../../lib/java/build/libthrift-${version}-${release}.jar
-../../lib/java/libthrift.jar: Zip archive data, at least v1.0 to extract
+4) Run the tutorial:
-thrift/tutorial/java$ file ../../compiler/cpp/thrift
-../../compiler/cpp/thrift: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped
+start server and client with one step:
+thrift/tutorial/java$ make tutorial
-thrift/tutorial/java$ ls ../../lib/java/build/ivy/lib/
-commons-lang-2.5.jar junit-4.4.jar servlet-api-2.5.jar slf4j-api-1.5.8.jar slf4j-simple-1.5.8.jar
+or:
+thrift/tutorial/java$ make tutorialserver
+thrift/tutorial/java$ make tutorialclient
-
-2) Generate code for java:
-
-thrift/tutorial/java$ cd ..
-thrift/tutorial$ thrift -r -gen java tutorial.thrift
-
-3) Compile example
-
-thrift/tutorial/java$ ant
-
-4) Run example:
-
-thrift/tutorial/java$ ./JavaServer &
-thrift/tutorial/java$ ./JavaClient
+or:
+thrift/tutorial/java$ ant tutorialserver
+thrift/tutorial/java$ ant tutorialclient
diff --git a/tutorial/java/build.xml b/tutorial/java/build.xml
index 2ee11c0c2..28c3bd64f 100644
--- a/tutorial/java/build.xml
+++ b/tutorial/java/build.xml
@@ -18,10 +18,10 @@
-->
<project name="tutorial" default="tutorial" basedir=".">
- <description>Thrift Tutorial</description>
+ <description>Thrift Java Tutorial</description>
<property name="src" location="src" />
- <property name="gen" location="../gen-java" />
+ <property name="gen" location="gen-java" />
<property name="build" location="build" />
<path id="libs.classpath">
@@ -37,19 +37,71 @@
<path refid="libs.classpath" />
<pathelement path="${gen}" />
</path>
-
+ <path id="tutorial.classpath">
+ <path refid="build.classpath" />
+ <pathelement path="${build}" />
+ <pathelement path="tutorial.jar" />
+ </path>
+
<target name="init">
<tstamp />
<mkdir dir="${build}"/>
+ <mkdir dir="${build}/log"/>
</target>
- <target name="compile" depends="init">
+ <target name="compile" depends="init, generate">
<javac srcdir="${gen}" destdir="${build}" classpathref="libs.classpath" />
<javac srcdir="${src}" destdir="${build}" classpathref="build.classpath" />
</target>
- <target name="tutorial" depends="compile">
+ <target name="test" depends="tutorial" />
+
+ <target name="tutorial" description="Run the tutorial" depends="compile">
<jar jarfile="tutorial.jar" basedir="${build}"/>
+ <parallel>
+ <java classname="JavaServer" fork="true" timeout="10000"
+ classpathref="tutorial.classpath" failonerror="false" output="${build}/log/tutorial.log">
+ </java>
+ <sequential>
+ <sleep seconds="2"/>
+ <echo>tutorial client simple:</echo>
+ <java classname="JavaClient"
+ classpathref="tutorial.classpath" failonerror="true">
+ <arg line="simple"/>
+ </java>
+ <echo>tutorial client secure:</echo>
+ <java classname="JavaClient"
+ classpathref="tutorial.classpath" failonerror="true">
+ <arg line="secure"/>
+ </java>
+ </sequential>
+ </parallel>
+ </target>
+
+ <target name="generate">
+ <!-- Generate the thrift gen-java source -->
+ <exec executable="../../compiler/cpp/thrift" failonerror="true">
+ <arg line="--gen java -r ../tutorial.thrift"/>
+ </exec>
+ </target>
+
+ <target name="tutorialclient" description="Run a tutorial client" depends="compile">
+ <echo>tutorial client simple:</echo>
+ <java classname="JavaClient"
+ classpathref="tutorial.classpath" failonerror="true">
+ <arg line="simple"/>
+ </java>
+ <echo>tutorial client secure:</echo>
+ <java classname="JavaClient"
+ classpathref="tutorial.classpath" failonerror="true">
+ <arg line="secure"/>
+ </java>
+ </target>
+
+ <target name="tutorialserver" description="Run a tutorial server" depends="compile">
+ <java classname="JavaServer" fork="true"
+ classpathref="tutorial.classpath" failonerror="false" output="${build}/log/tutorial.log">
+ </java>
</target>
<target name="clean">