Saturday 31 December 2011

Creating Thrift generated File

Follow the below steps to download thrift.exe
·                Download Thrift.exe from  apache
·                Save this exe file in a location (ex: D:/apache/thrift.exe)
·                Now create follow below given steps to create .thrift file
Example for .thrift file,
namespace java example
strut Employee {
  1: string    id,
  2: string name,
  3: string address,
  4: string phoneNumber
}
struct EmployeeId {
  1: string    id
}
service EmployeeService {
  Employee getEmployee(1:EmployeeId id)
}
·                Copy this to a file and save it as empDetails.thrift ( ex: in location D:/thrift/ empDetails.thrift)
·                Open command prompt
·                In command prompt go to the thrift file location (D:/thrift/ empDetails.thrift)
·                Now type D:/apache/thrift.exe -gen java empDetails.thrift
·                Now you will get java thrift generated files

No comments:

Post a Comment