abstract class RequestMessage
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
(package private) static class |
RequestMessage.EncodingMetadata |
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
collectionName |
private static int |
DOCUMENT_HEADROOM |
private RequestMessage.EncodingMetadata |
encodingMetadata |
private int |
id |
(package private) static int |
MESSAGE_PROLOGUE_LENGTH |
private OpCode |
opCode |
private static CodecRegistry |
REGISTRY |
(package private) static java.util.concurrent.atomic.AtomicInteger |
REQUEST_ID |
private MessageSettings |
settings |
Modifier | Constructor and Description |
---|---|
(package private) |
RequestMessage(OpCode opCode,
int requestId,
MessageSettings settings) |
(package private) |
RequestMessage(OpCode opCode,
MessageSettings settings) |
private |
RequestMessage(java.lang.String collectionName,
OpCode opCode,
int requestId,
MessageSettings settings) |
(package private) |
RequestMessage(java.lang.String collectionName,
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 void |
addDocument(BsonDocument document,
BsonOutput bsonOutput,
FieldNameValidator validator)
Appends a document to the message.
|
protected void |
addDocument(BsonDocument document,
BsonOutput bsonOutput,
FieldNameValidator validator,
java.util.List<BsonElement> extraElements) |
private <T> void |
addDocument(T obj,
Encoder<T> encoder,
EncoderContext encoderContext,
BsonOutput bsonOutput,
FieldNameValidator validator,
int maxDocumentSize,
java.util.List<BsonElement> extraElements) |
protected void |
backpatchMessageLength(int startPosition,
BsonOutput bsonOutput)
Backpatches the message length into the beginning of the message.
|
void |
encode(BsonOutput bsonOutput,
SessionContext sessionContext)
Encoded the message to the given output.
|
protected abstract RequestMessage.EncodingMetadata |
encodeMessageBodyWithMetadata(BsonOutput bsonOutput,
SessionContext sessionContext)
Encode the message body 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.
|
RequestMessage.EncodingMetadata |
getEncodingMetadata()
Gets the encoding metadata from the last attempt to encode this message.
|
int |
getId()
Gets the message id.
|
java.lang.String |
getNamespace()
Gets the collection namespace to send the message to.
|
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
static final int MESSAGE_PROLOGUE_LENGTH
private static final int DOCUMENT_HEADROOM
private static final CodecRegistry REGISTRY
private final java.lang.String collectionName
private final MessageSettings settings
private final int id
private final OpCode opCode
private RequestMessage.EncodingMetadata encodingMetadata
RequestMessage(OpCode opCode, MessageSettings settings)
RequestMessage(OpCode opCode, int requestId, MessageSettings settings)
RequestMessage(java.lang.String collectionName, OpCode opCode, MessageSettings settings)
private RequestMessage(java.lang.String collectionName, OpCode opCode, int requestId, MessageSettings settings)
public static int getCurrentGlobalId()
public int getId()
public OpCode getOpCode()
public java.lang.String getNamespace()
public MessageSettings getSettings()
public void encode(BsonOutput bsonOutput, SessionContext sessionContext)
bsonOutput
- the outputsessionContext
- the session contextpublic RequestMessage.EncodingMetadata getEncodingMetadata()
protected void writeMessagePrologue(BsonOutput bsonOutput)
bsonOutput
- the outputprotected abstract RequestMessage.EncodingMetadata encodeMessageBodyWithMetadata(BsonOutput bsonOutput, SessionContext sessionContext)
bsonOutput
- the outputsessionContext
- the session contextprotected void addDocument(BsonDocument document, BsonOutput bsonOutput, FieldNameValidator validator)
document
- the documentbsonOutput
- the outputvalidator
- the field name validatorprotected void addDocument(BsonDocument document, BsonOutput bsonOutput, FieldNameValidator validator, java.util.List<BsonElement> extraElements)
protected 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, java.util.List<BsonElement> extraElements)