Question

there is a way to generate thrift description file for existing java classes using refletion? Avro has that feature, but i need to use thrift and i have a lot of existing business class in java that i need to serialize in c++ and java.

Was it helpful?

Solution

Not from the library directly; thrift generates it's own classes and some validation code so that both "ends" (client/server) can inter-operate without error. You should write code to map your business objects to thrift objects.

OTHER TIPS

Enter Swift: https://github.com/facebook/swift/

git clone https://github.com/facebook/swift
cd swift ; mvn package

In particular swift2thrift. Markup your classes as here: https://github.com/facebook/swift/

and run:

MY_CLASSES=$HOME/ExampleService/target/ExampleService-1.0-SNAPSHOT.jar  # just an example
cd ~/ExampleService ; mvn compile package && java -cp ~/swift/target/swift2thrift-generator-cli-0.15.0-SNAPSHOT-standalone.jar:$MY_CLASSEScom.facebook.swift.generator.swift2thrift.Main -package net.mycompany ExampleService -map ExampleService path/to/base.thrift -namespace py mycompany.thrift -namespace java net.mycompany.thrift -namespace cpp mycompany

outputs Thrift .idls for existsing Java classes.

Also see: Can generate .thrift files from existing java/scala interfaces and data types?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top