abstract class RequestMessage
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
(package private) static class |
RequestMessage.EncodingMetadata |
(package private) static class |
RequestMessage.OpCode |
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
collectionName |
private int |
id |
private RequestMessage.OpCode |
opCode |
private static int |
QUERY_DOCUMENT_HEADROOM |
private static CodecRegistry |
REGISTRY |
(package private) static java.util.concurrent.atomic.AtomicInteger |
REQUEST_ID |
private MessageSettings |
settings |
Constructor and Description |
---|
RequestMessage(RequestMessage.OpCode opCode,
MessageSettings settings) |
RequestMessage(java.lang.String collectionName,
RequestMessage.OpCode opCode,
MessageSettings settings) |
Modifier and Type | Method and Description |
---|---|
protected void |
addCollectibleDocument(BsonDocument document,
BsonOutput bsonOutput,
FieldNameValidator validator)
Appends a document to the message that is intended for storage in a collection.
|
protected <T> void |
addDocument(BsonDocument document,
BsonOutput bsonOutput,
FieldNameValidator validator)
Appends a document to the message.
|
private <T> void |
addDocument(T obj,
Encoder<T> encoder,
EncoderContext encoderContext,
BsonOutput bsonOutput,
FieldNameValidator validator,
int maxDocumentSize) |
protected void |
backpatchMessageLength(int startPosition,
BsonOutput bsonOutput)
Backpatches the message length into the beginning of the message.
|
RequestMessage |
encode(BsonOutput bsonOutput)
Encoded the message to the given output.
|
protected abstract RequestMessage |
encodeMessageBody(BsonOutput bsonOutput,
int messageStartPosition)
Encode the message body to the given output.
|
protected abstract RequestMessage.EncodingMetadata |
encodeMessageBodyWithMetadata(BsonOutput bsonOutput,
int messageStartPosition)
Encode the message body to the given output.
|
RequestMessage.EncodingMetadata |
encodeWithMetadata(BsonOutput bsonOutput)
Encoded the message to the given output.
|
(package private) Codec<BsonDocument> |
getCodec(BsonDocument document) |
protected java.lang.String |
getCollectionName()
Gets the collection name, which may be null for some message types
|
static int |
getCurrentGlobalId()
Gets the next available unique message identifier.
|
int |
getId()
Gets the message id.
|
java.lang.String |
getNamespace()
Gets the collection namespace to send the message to.
|
RequestMessage.OpCode |
getOpCode()
Gets the op code of the message.
|
MessageSettings |
getSettings()
Gets the message settings.
|
protected void |
writeMessagePrologue(BsonOutput bsonOutput)
Writes the message prologue to the given output.
|
static final java.util.concurrent.atomic.AtomicInteger REQUEST_ID
private static final int QUERY_DOCUMENT_HEADROOM
private static final CodecRegistry REGISTRY
private final java.lang.String collectionName
private final MessageSettings settings
private final int id
private final RequestMessage.OpCode opCode
RequestMessage(RequestMessage.OpCode opCode, MessageSettings settings)
RequestMessage(java.lang.String collectionName, RequestMessage.OpCode opCode, MessageSettings settings)
public static int getCurrentGlobalId()
public int getId()
public RequestMessage.OpCode getOpCode()
public java.lang.String getNamespace()
public MessageSettings getSettings()
public RequestMessage encode(BsonOutput bsonOutput)
bsonOutput
- the outputpublic RequestMessage.EncodingMetadata encodeWithMetadata(BsonOutput bsonOutput)
bsonOutput
- the outputprotected void writeMessagePrologue(BsonOutput bsonOutput)
bsonOutput
- the outputprotected abstract RequestMessage encodeMessageBody(BsonOutput bsonOutput, int messageStartPosition)
bsonOutput
- the outputmessageStartPosition
- the start position of the messageprotected abstract RequestMessage.EncodingMetadata encodeMessageBodyWithMetadata(BsonOutput bsonOutput, int messageStartPosition)
bsonOutput
- the outputmessageStartPosition
- the start position of the messageprotected <T> void addDocument(BsonDocument document, BsonOutput bsonOutput, FieldNameValidator validator)
T
- the document typedocument
- the documentbsonOutput
- the outputvalidator
- the field name validatorprotected void addCollectibleDocument(BsonDocument document, BsonOutput bsonOutput, FieldNameValidator validator)
document
- the documentbsonOutput
- the outputvalidator
- the field name validatorprotected void backpatchMessageLength(int startPosition, BsonOutput bsonOutput)
startPosition
- the start position of the messagebsonOutput
- the outputprotected java.lang.String getCollectionName()
Codec<BsonDocument> getCodec(BsonDocument document)
private <T> void addDocument(T obj, Encoder<T> encoder, EncoderContext encoderContext, BsonOutput bsonOutput, FieldNameValidator validator, int maxDocumentSize)