[muscle] Patch for supporting NIO in Java client

  • From: Lior Okman <lior.okman@xxxxxxxxxxxxxxxxxxxxxxxx>
  • To: muscle@xxxxxxxxxxxxx
  • Date: Sat, 28 Jan 2006 18:59:48 +0200


Attached is a patch that adds support to the Java client for using
java.nio instead of old-style i/o.

It removes the need for the LEDataOutputStream and LEDataInputStream
classes that are currently used, and it uses java.nio.ByteBuffer
instead, as well as SocketChannel, instead of Socket classes, both of
which should be good for performance.

I haven't removed the old classes, just added support for nio in the
relevant classes, as well as an extra class
"com/lcs/muscle/client/MessageTransceiver2.java" that uses ServerSocket
instead of Socket by default.

I've also fixed a bug in the NativeZLibMessageIOGateway class, and since
the JCraft classes are now distributed along with the MUSCLE classes,
I've fixed the AbstractMessageIOGateway class to use the JZLib enabled
class directly, instead of with reflection.

I'm also attaching an updated build.xml file that expects to find the
JZLib classes instead of the JZlib jar.

NIO support means that the MUSCLE java client code will require at least
Java 1.4.0 to compile.

<?xml version="1.0" encoding="utf-8" ?>
<project default="jar" name="Build the muscle jar for this version" basedir=".">

    <target name="init">
        <mkdir dir="src"/>
        <mkdir dir="bin"/>
                <copy todir="src/com">
                    <fileset dir="com"/>
    <target name="build" depends="init" >
        <javac destdir="bin" debug="on">
                <src path="src" />

    <target name="jar" depends="build" >
        <jar destfile="muscle.jar" basedir="bin" index="true" >
                    <attribute name="Built-By" value="${user.name}"/>
                    <section name="common">
                      <attribute name="Specification-Title" value="Muscle"/>
                      <attribute name="Specification-Version" value="3.10"/>
                      <attribute name="Specification-Vendor" value="Level 
Control Systems"/>

        <target name='clean'>
                <delete file='muscle.jar'/>
                <delete dir='src'/>
                <delete dir='bin'/>

Other related posts: