Package one.nio.rpc.stream
Class RpcStreamImpl<S,R>
- java.lang.Object
-
- one.nio.rpc.stream.RpcStreamImpl<S,R>
-
- All Implemented Interfaces:
java.io.DataInput,java.io.DataOutput,java.io.ObjectInput,java.io.ObjectOutput,java.lang.AutoCloseable,BaseStream,BidiStream<S,R>,ReceiveStream<R>,RpcStream,SendStream<S>
public class RpcStreamImpl<S,R> extends java.lang.Object implements RpcStream, BidiStream<S,R>
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanerrorprotected ObjectInputChannelinprotected ObjectOutputChanneloutprotected Socketsocket
-
Constructor Summary
Constructors Constructor Description RpcStreamImpl(Socket socket)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()voidclose()voidflush()longgetBytesRead()longgetBytesWritten()voidinvalidate()intread()intread(byte[] b)intread(byte[] b, int off, int len)voidread(java.nio.ByteBuffer buf)booleanreadBoolean()bytereadByte()charreadChar()doublereadDouble()floatreadFloat()voidreadFully(byte[] b)voidreadFully(byte[] b, int off, int len)intreadInt()java.lang.StringreadLine()longreadLong()java.lang.ObjectreadObject()shortreadShort()intreadUnsignedByte()intreadUnsignedShort()java.lang.StringreadUTF()Rreceive()voidsend(S object)RsendAndGet(S object)longskip(long n)intskipBytes(int n)Socketsocket()voidwrite(byte[] b)voidwrite(byte[] b, int off, int len)voidwrite(int b)voidwrite(java.nio.ByteBuffer buf)voidwriteBoolean(boolean v)voidwriteByte(int v)voidwriteBytes(java.lang.String s)voidwriteChar(int v)voidwriteChars(java.lang.String s)voidwriteDouble(double v)voidwriteFloat(float v)voidwriteInt(int v)voidwriteLong(long v)voidwriteObject(java.lang.Object obj)voidwriteShort(int v)voidwriteUTF(java.lang.String s)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface one.nio.rpc.stream.BaseStream
getLocalAddress, getRemoteAddress
-
-
-
-
Field Detail
-
socket
protected final Socket socket
-
in
protected final ObjectInputChannel in
-
out
protected final ObjectOutputChannel out
-
error
protected boolean error
-
-
Constructor Detail
-
RpcStreamImpl
public RpcStreamImpl(Socket socket)
-
-
Method Detail
-
socket
public Socket socket()
- Specified by:
socketin interfaceBaseStream
-
getBytesRead
public long getBytesRead()
- Specified by:
getBytesReadin interfaceBaseStream
-
getBytesWritten
public long getBytesWritten()
- Specified by:
getBytesWrittenin interfaceBaseStream
-
invalidate
public void invalidate()
- Specified by:
invalidatein interfaceBaseStream
-
read
public void read(java.nio.ByteBuffer buf) throws java.io.IOException
-
readObject
public java.lang.Object readObject() throws java.io.IOException, java.lang.ClassNotFoundException- Specified by:
readObjectin interfacejava.io.ObjectInput- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
read
public int read() throws java.io.IOException- Specified by:
readin interfacejava.io.ObjectInput- Throws:
java.io.IOException
-
read
public int read(byte[] b) throws java.io.IOException- Specified by:
readin interfacejava.io.ObjectInput- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException- Specified by:
readin interfacejava.io.ObjectInput- Throws:
java.io.IOException
-
skip
public long skip(long n) throws java.io.IOException- Specified by:
skipin interfacejava.io.ObjectInput- Throws:
java.io.IOException
-
available
public int available()
- Specified by:
availablein interfacejava.io.ObjectInput
-
readFully
public void readFully(byte[] b) throws java.io.IOException- Specified by:
readFullyin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readFully
public void readFully(byte[] b, int off, int len) throws java.io.IOException- Specified by:
readFullyin interfacejava.io.DataInput- Throws:
java.io.IOException
-
skipBytes
public int skipBytes(int n) throws java.io.IOException- Specified by:
skipBytesin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readBoolean
public boolean readBoolean() throws java.io.IOException- Specified by:
readBooleanin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readByte
public byte readByte() throws java.io.IOException- Specified by:
readBytein interfacejava.io.DataInput- Throws:
java.io.IOException
-
readUnsignedByte
public int readUnsignedByte() throws java.io.IOException- Specified by:
readUnsignedBytein interfacejava.io.DataInput- Throws:
java.io.IOException
-
readShort
public short readShort() throws java.io.IOException- Specified by:
readShortin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readUnsignedShort
public int readUnsignedShort() throws java.io.IOException- Specified by:
readUnsignedShortin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readChar
public char readChar() throws java.io.IOException- Specified by:
readCharin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readInt
public int readInt() throws java.io.IOException- Specified by:
readIntin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readLong
public long readLong() throws java.io.IOException- Specified by:
readLongin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readFloat
public float readFloat() throws java.io.IOException- Specified by:
readFloatin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readDouble
public double readDouble() throws java.io.IOException- Specified by:
readDoublein interfacejava.io.DataInput- Throws:
java.io.IOException
-
readLine
public java.lang.String readLine() throws java.io.IOException- Specified by:
readLinein interfacejava.io.DataInput- Throws:
java.io.IOException
-
readUTF
public java.lang.String readUTF() throws java.io.IOException- Specified by:
readUTFin interfacejava.io.DataInput- Throws:
java.io.IOException
-
write
public void write(java.nio.ByteBuffer buf) throws java.io.IOException
-
writeObject
public void writeObject(java.lang.Object obj) throws java.io.IOException- Specified by:
writeObjectin interfacejava.io.ObjectOutput- Throws:
java.io.IOException
-
write
public void write(int b) throws java.io.IOException- Specified by:
writein interfacejava.io.DataOutput- Specified by:
writein interfacejava.io.ObjectOutput- Throws:
java.io.IOException
-
write
public void write(byte[] b) throws java.io.IOException- Specified by:
writein interfacejava.io.DataOutput- Specified by:
writein interfacejava.io.ObjectOutput- Throws:
java.io.IOException
-
write
public void write(byte[] b, int off, int len) throws java.io.IOException- Specified by:
writein interfacejava.io.DataOutput- Specified by:
writein interfacejava.io.ObjectOutput- Throws:
java.io.IOException
-
writeBoolean
public void writeBoolean(boolean v) throws java.io.IOException- Specified by:
writeBooleanin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeByte
public void writeByte(int v) throws java.io.IOException- Specified by:
writeBytein interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeShort
public void writeShort(int v) throws java.io.IOException- Specified by:
writeShortin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeChar
public void writeChar(int v) throws java.io.IOException- Specified by:
writeCharin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeInt
public void writeInt(int v) throws java.io.IOException- Specified by:
writeIntin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeLong
public void writeLong(long v) throws java.io.IOException- Specified by:
writeLongin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeFloat
public void writeFloat(float v) throws java.io.IOException- Specified by:
writeFloatin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeDouble
public void writeDouble(double v) throws java.io.IOException- Specified by:
writeDoublein interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeBytes
public void writeBytes(java.lang.String s) throws java.io.IOException- Specified by:
writeBytesin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeChars
public void writeChars(java.lang.String s) throws java.io.IOException- Specified by:
writeCharsin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeUTF
public void writeUTF(java.lang.String s) throws java.io.IOException- Specified by:
writeUTFin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException- Specified by:
flushin interfaceBidiStream<S,R>- Specified by:
flushin interfacejava.io.ObjectOutput- Throws:
java.io.IOException
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceBaseStream- Specified by:
closein interfacejava.io.ObjectInput- Specified by:
closein interfacejava.io.ObjectOutput
-
receive
public R receive() throws java.io.IOException, java.lang.ClassNotFoundException
- Specified by:
receivein interfaceReceiveStream<S>- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
send
public void send(S object) throws java.io.IOException
- Specified by:
sendin interfaceSendStream<S>- Throws:
java.io.IOException
-
sendAndGet
public R sendAndGet(S object) throws java.io.IOException, java.lang.ClassNotFoundException
- Specified by:
sendAndGetin interfaceBidiStream<S,R>- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
-