Wire Protocol Definition Language
jesper.pedersen Jul 16, 2009 4:25 PMHi all,
I have created a tool for defining a wire protocol - which I call "Wire Protocol Definition Language" currently.
Goals:
* Ease the definition of a wire protocol
* Generate code to handle communication
Description:
WPDL is a tool that can define a wire protocol and can generate the necessary bindings for it in the specified programming language.
WPDL allows you to specify data structures using primitives (such as signed8, signed32, ...) that will form a packet to a target system. The idea is that all communication is done in old-school binary in order to reduce the overhead seen in modern protocols such as HTTP and WebServices.
The tool is designed such that any bindings can be generated such as Java, C, Ruby and so on. The Proof-of-Concept binding was java-io and a java-nio is in the works - others could be java-netty3, java-javassist, c-std, c++-std and ruby-std.
Technology:
* JAXB
* Code generator
Example:
<packet name="Bind" frontend="true"> <signed8 name="Identifier" content="B"/> <signed32 name="Length"/> <string name="DestinationPortal"/> <string name="PreparedStatement"/> <signed16 name="ParameterFormatCodesNumber"/> <signed16 name="ParameterFormatCodes" array="ParameterFormatCodesNumber"/> <signed16 name="ParameterNumber"/> <group name="Parameter" array="ParameterNumber"> <signed32 name="ParameterLength"/> <signed8 name="ParameterValue" array="ParameterLength"/> </group> <signed16 name="ResultFormatCodesNumber"/> <signed16 name="ResultFormatCodes" array="ResultFormatCodesNumber"/> </packet>
Usage:
The binding generated will contain functionality to transmit or receive data from the server - this data is automatically parsed up as the packet structures defined.
Socket socket = new Socket(pgsqlServer);
Postgresql wire = new Postgresql(socket);
AuthenticationOk aok = wire.readAuthenticationOk();
Bind bind = new Bind();
bind.setDestinationPortal("");
...
wire.write(bind);
Let me know if there is an interested for such a project for Teiid.