Package net.morimekta.providence.logging
Class IOMessageReader
- java.lang.Object
-
- net.morimekta.providence.logging.IOMessageReader
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,MessageReader
public class IOMessageReader extends java.lang.Object implements MessageReader
A reader helper class for matching a serializer with an input stream.
-
-
Constructor Summary
Constructors Constructor Description IOMessageReader(java.io.InputStream in, Serializer serializer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
<Message extends PMessage<Message>>
Messageread(PMessageDescriptor<Message> descriptor)
Read a message from the stream.<Message extends PMessage<Message>>
PServiceCall<Message>read(PService service)
Read a service call from the stream.void
verifyEndOfContent()
Verify the stream read from is completed, and does not have garbage content after end of last message.
-
-
-
Constructor Detail
-
IOMessageReader
public IOMessageReader(java.io.InputStream in, Serializer serializer)
-
-
Method Detail
-
read
public <Message extends PMessage<Message>> Message read(PMessageDescriptor<Message> descriptor) throws java.io.IOException
Description copied from interface:MessageReader
Read a message from the stream.- Specified by:
read
in interfaceMessageReader
- Type Parameters:
Message
- The message type.- Parameters:
descriptor
- The descriptor for the message to be read.- Returns:
- The message read.
- Throws:
java.io.IOException
- If the message could not be read.
-
read
public <Message extends PMessage<Message>> PServiceCall<Message> read(PService service) throws java.io.IOException
Description copied from interface:MessageReader
Read a service call from the stream.- Specified by:
read
in interfaceMessageReader
- Type Parameters:
Message
- The type of the contained params or response message.- Parameters:
service
- The service whose call should be read.- Returns:
- The service call read.
- Throws:
java.io.IOException
- If the service call could not be read.
-
verifyEndOfContent
public void verifyEndOfContent() throws java.io.IOException
Description copied from interface:MessageReader
Verify the stream read from is completed, and does not have garbage content after end of last message.- Specified by:
verifyEndOfContent
in interfaceMessageReader
- Throws:
java.io.IOException
- If garbage found or unable to read from stream or close it.
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
-