Commit 67efb646 authored by Tigran Mkrtchyan's avatar Tigran Mkrtchyan
Browse files

rpc: add support for encode/decode ByteBuffer

parent 2d465b72
......@@ -224,6 +224,14 @@ public class Xdr implements XdrDecodingStream, XdrEncodingStream {
((xdrDecodeInt()) & 0x00000000FFFFFFFFl);
}
public ByteBuffer xdrDecodeByteBuffer() {
int len = this.xdrDecodeInt();
int padding = (4 - (len & 3)) & 3;
ByteBuffer slice = _body.slice();
slice.limit(len);
_body.position(_body.position() + len + padding);
return slice;
}
////////////////////////////////////////////////////////////////////////////
//
// Encoder
......@@ -318,4 +326,10 @@ public class Xdr implements XdrDecodingStream, XdrEncodingStream {
xdrEncodeInt((int)(value >>> 32));
xdrEncodeInt((int)(value & 0xFFFFFFFF));
}
public void xdrEncodeByteBuffer(ByteBuffer buf) {
buf.limit(buf.position());
buf.rewind();
_body.put(buf);
}
}
......@@ -17,6 +17,8 @@
package org.dcache.xdr;
import java.nio.ByteBuffer;
/**
* Defines interface for decoding XDR stream. A decoding
* XDR stream returns data in the form of Java data types which it reads
......@@ -36,6 +38,7 @@ public interface XdrDecodingStream {
boolean xdrDecodeBoolean();
String xdrDecodeString();
long xdrDecodeLong();
ByteBuffer xdrDecodeByteBuffer();
/*
* Fake interface for compatibility with Remote Tea RPC library
......
......@@ -38,6 +38,7 @@ public interface XdrEncodingStream {
void xdrEncodeString(String str);
void xdrEncodeLong(long value);
ByteBuffer body();
void xdrEncodeByteBuffer(ByteBuffer buf);
/*
* Fake interface for compatibility with Remote Tea RPC library
*
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment