开发者

Using thrift with PHP and Java

I am getting myself a bit confused about how to go about this. My plan is to use PHP to perform the final page construction and this PHP web app will contact multiple services, which i will also to develop, for the data. Lets say one of those services was done in Java. I wou开发者_开发百科ld define a Java interface which was implemented by a concrete class. This is where I get confused - how does Thrift link the PHP web app with the java service or am I getting totally mixed up??

Thanks


Thrift is based on the use of an IDL (Interface Definition Language). Using the definition from Wikipedia:

An interface description language (or alternately, interface definition language), or IDL for short, is a specification language used to describe a software component's interface. IDLs describe an interface in a language-neutral way, enabling communication between software components that do not share a language – for example, between components written in C++ and components written in Java.

An example on how to use the Thrift interface language is available in the Thrift tutorial.

By the use of a .thrift file, you're suppose to define the interfaces you need (in terms of types and services). For example, in your .thrift file, you could define a simple function like:

i32 add(1:i32 num1, 2:i32 num2)

that represents a function to sum two integers.

When you're ready with your .thrift file, you can generate the Java, PHP, Erlang, whatever code that you need (server-side or client-side), using the Thrift generator.

Refer to the Thrift wiki for more information.


I would be very curious to see benchmarks between Thrift and PHP / Java bridge http://php-java-bridge.sourceforge.net/pjb/. By heart i would advocate Thrift but i have doubts it is as fast as php/java bridge.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜