Project used to experiment with Thrift. Uses gradle to build.
- make sure thrift 0.3 is installed from http://incubator.apache.org/thrift/download/ the gradle script assumes the thrift executable to be in /usr/local/bin/thrift
- make sure gradle (>= 0.9) is installed
- actual code in src/main/java
- thrift file(s) in src/main/thrift/
- generated sources (by thrift) are in src/generated/java/gen-javabean/
- configuration and resources in src/main/resources
Generate and compile all source using:
gradle compileJava
Run the server (on port 1234) using:
gradle runServer
Run the client using:
gradle runClient
Both these tasks call the compile task before running.
Server:
peter ~/dev/thrift/Category-Service-Test-project (master) $ gradle runServer
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:runServer
2010-08-19 23:10:55 RunCategoryServer [INFO] server setup, starting on port: 1234
2010-08-19 23:11:02 CategoryServiceImpl [DEBUG] get category is called
2010-08-19 23:11:02 CategoryServiceImpl [DEBUG] get children is called
> Building > :runServer
Client:
peter ~/dev/thrift/Category-Service-Test-project (master) $ gradle runClient
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:runClient
2010-08-19 23:11:02 CategoryServiceClient [INFO] client ready
2010-08-19 23:11:02 CategoryServiceClient [DEBUG] calling ‘CategoryService.Client#get’
2010-08-19 23:11:02 CategoryServiceClient [DEBUG] returned category: Category(id:123, name:Category 123)
2010-08-19 23:11:02 CategoryServiceClient [DEBUG] calling ‘CategoryService.Client#getChildren’
2010-08-19 23:11:02 CategoryServiceClient [DEBUG] returned: [Category(id:0, name:Category 0), Category(id:1, name:Category 1), Category(id:2, name:Category 2), Category(id:3, name:Category 3), Category(id:4, name:Category 4), Category(id:5, name:Category 5), Category(id:6, name:Category 6), Category(id:7, name:Category 7), Category(id:8, name:Category 8), Category(id:9, name:Category 9)]BUILD SUCCESSFUL