[muscle] Re: Patch for supporting NIO in Java client

  • From: "Jeremy Friesner" <jaf@xxxxxxxxxxxx>
  • To: muscle@xxxxxxxxxxxxx
  • Date: Sat, 28 Jan 2006 09:20:51 PST (-0800)

Hi Lior,

Thanks for the patch -- is there any way to re-code it so that the Java
classes will still run on earlier versions of Java?  It would be nice if we
could add support for the newer APIs without having to give up compatibility 
older systems.  Perhaps using a bit of Class.forName() and some exception
handling to fall back to the old code if the new code won't run?

Also it's not clear to me what the purpose of the MessageTransceiver2 class
is -- does it do something that the regular MessageTransceiver class doesn't do?
It seems like an awful lot of code duplication that would make code maintenance
more difficult in the future.


> 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.
> Regards,
> Lior

Other related posts: