Package org.jdrupes.httpcodec
Class ClientEngine<Q extends MessageHeader,R extends MessageHeader>
java.lang.Object
org.jdrupes.httpcodec.Engine
org.jdrupes.httpcodec.ClientEngine<Q,R>
- Type Parameters:
Q
- the message header type handled be the encoder (the request)R
- the message header type handled by the decoder (the response)
An engine that can be used as a client.
It has an associated
request encoder and a response decoder. Using a ClientEngine
has two main advantages over using an encoder and decoder
directly. It links encoder and decoder (see
Encoder.setPeerDecoder(Decoder)
and
Decoder.setPeerEncoder(Encoder)
) and it replaces the encoder
and decoder if the decoded result indicates a switch. The change takes
place upon the next encode
or decode
invocation. The “old” encoders
and decoders are thus still available when the result of
a decode invocation, that indicates a switch, is processed.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns the last encoded request.decode
(ByteBuffer in, Buffer out, boolean endOfInput) Convenience method to invoke the decoder’s decode method.encode
(Buffer in, ByteBuffer out, boolean endOfInput) Convenience method to invoke the encoder’s encode method.encode
(ByteBuffer out) Convenience method to invoke the encoder’s encode method.void
Convenience method to invoke the encoder’s encode method.Methods inherited from class org.jdrupes.httpcodec.Engine
setSwitchedTo, switchedTo
-
Constructor Details
-
ClientEngine
Creates a new instance.- Parameters:
requestEncoder
- the encoder for the requestresponseDecoder
- the decoder for the response
-
-
Method Details
-
requestEncoder
- Returns:
- the requestEncoder
-
responseDecoder
- Returns:
- the responseDecoder
-
encode
Convenience method to invoke the encoder’s encode method.- Parameters:
out
- the buffer to use for the result- Returns:
- the result
-
encode
Convenience method to invoke the encoder’s encode method.- Parameters:
in
- the buffer with the data to encodeout
- the buffer to use for the resultendOfInput
- true if end of input- Returns:
- the result
-
encode
Convenience method to invoke the encoder’s encode method.- Parameters:
messageHeader
- the message header
-
decode
public Decoder.Result<Q> decode(ByteBuffer in, Buffer out, boolean endOfInput) throws ProtocolException Convenience method to invoke the decoder’s decode method.- Parameters:
in
- the buffer with the data to decodeout
- the buffer to use for the resultendOfInput
- true if end of input- Returns:
- the result
- Throws:
ProtocolException
- if the input violates the protocol- See Also:
-
currentRequest
Returns the last encoded request.- Returns:
- the request
-