com.alipay.remoting.rpc
Class RpcCommand

java.lang.Object
  extended by com.alipay.remoting.rpc.RpcCommand
All Implemented Interfaces:
RemotingCommand, Serializable
Direct Known Subclasses:
RequestCommand, ResponseCommand

public abstract class RpcCommand
extends Object
implements RemotingCommand

Remoting command.
A remoting command stands for a kind of transfer object in the network communication layer.

See Also:
Serialized Form

Constructor Summary
RpcCommand()
           
RpcCommand(byte type)
           
RpcCommand(byte version, byte type, CommandCode cmdCode)
           
RpcCommand(byte type, CommandCode cmdCode)
           
RpcCommand(CommandCode cmdCode)
           
 
Method Summary
 void deserialize()
          Deserialize the class header and content.
 void deserialize(long mask)
          Deserialize according to mask.
 void deserializeClazz()
          Deserialize the content class.
 void deserializeContent(InvokeContext invokeContext)
          Deserialize the content.
 void deserializeHeader(InvokeContext invokeContext)
          Deserialize the header.
 byte[] getClazz()
           
 short getClazzLength()
           
 CommandCode getCmdCode()
          Get the command code for this command
 byte[] getContent()
           
 int getContentLength()
           
 byte[] getHeader()
           
 short getHeaderLength()
           
 int getId()
          Get the id of the command
 InvokeContext getInvokeContext()
          Get invoke context for this command
 ProtocolCode getProtocolCode()
          Get the code of the protocol that this command belongs to
 ProtocolSwitch getProtocolSwitch()
          Get the protocol switch status for this command
 byte getSerializer()
          Get serializer type for this command
 byte getType()
           
 byte getVersion()
           
 void serialize()
          Serialize the class header and content.
 void serializeClazz()
          Serialize content class.
 void serializeContent(InvokeContext invokeContext)
          Serialize the content.
 void serializeHeader(InvokeContext invokeContext)
          Serialize the header.
 void setClazz(byte[] clazz)
           
 void setCmdCode(CommandCode cmdCode)
           
 void setContent(byte[] content)
           
 void setHeader(byte[] header)
           
 void setId(int id)
           
 void setInvokeContext(InvokeContext invokeContext)
           
 void setProtocolSwitch(ProtocolSwitch protocolSwitch)
           
 void setSerializer(byte serializer)
           
 void setType(byte type)
           
 void setVersion(byte version)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RpcCommand

public RpcCommand()

RpcCommand

public RpcCommand(byte type)

RpcCommand

public RpcCommand(CommandCode cmdCode)

RpcCommand

public RpcCommand(byte type,
                  CommandCode cmdCode)

RpcCommand

public RpcCommand(byte version,
                  byte type,
                  CommandCode cmdCode)
Method Detail

serialize

public void serialize()
               throws SerializationException
Serialize the class header and content.

Specified by:
serialize in interface RemotingCommand
Throws:
Exception
SerializationException

deserialize

public void deserialize()
                 throws DeserializationException
Deserialize the class header and content.

Specified by:
deserialize in interface RemotingCommand
Throws:
Exception
DeserializationException

deserialize

public void deserialize(long mask)
                 throws DeserializationException
Deserialize according to mask.
  1. If mask <= RpcDeserializeLevel.DESERIALIZE_CLAZZ, only deserialize clazz - only one part.
  2. If mask <= RpcDeserializeLevel.DESERIALIZE_HEADER, deserialize clazz and header - two parts.
  3. If mask <= RpcDeserializeLevel.DESERIALIZE_ALL, deserialize clazz, header and content - all three parts.

Parameters:
mask -
Throws:
CodecException
DeserializationException

serializeClazz

public void serializeClazz()
                    throws SerializationException
Serialize content class.

Throws:
Exception
SerializationException

deserializeClazz

public void deserializeClazz()
                      throws DeserializationException
Deserialize the content class.

Throws:
Exception
DeserializationException

serializeHeader

public void serializeHeader(InvokeContext invokeContext)
                     throws SerializationException
Serialize the header.

Throws:
Exception
SerializationException

serializeContent

public void serializeContent(InvokeContext invokeContext)
                      throws SerializationException
Serialize the content.

Specified by:
serializeContent in interface RemotingCommand
Throws:
Exception
SerializationException

deserializeHeader

public void deserializeHeader(InvokeContext invokeContext)
                       throws DeserializationException
Deserialize the header.

Throws:
Exception
DeserializationException

deserializeContent

public void deserializeContent(InvokeContext invokeContext)
                        throws DeserializationException
Deserialize the content.

Specified by:
deserializeContent in interface RemotingCommand
Throws:
Exception
DeserializationException

getProtocolCode

public ProtocolCode getProtocolCode()
Description copied from interface: RemotingCommand
Get the code of the protocol that this command belongs to

Specified by:
getProtocolCode in interface RemotingCommand
Returns:
protocol code

getCmdCode

public CommandCode getCmdCode()
Description copied from interface: RemotingCommand
Get the command code for this command

Specified by:
getCmdCode in interface RemotingCommand
Returns:
command code

getInvokeContext

public InvokeContext getInvokeContext()
Description copied from interface: RemotingCommand
Get invoke context for this command

Specified by:
getInvokeContext in interface RemotingCommand
Returns:
context

getSerializer

public byte getSerializer()
Description copied from interface: RemotingCommand
Get serializer type for this command

Specified by:
getSerializer in interface RemotingCommand
Returns:

getProtocolSwitch

public ProtocolSwitch getProtocolSwitch()
Description copied from interface: RemotingCommand
Get the protocol switch status for this command

Specified by:
getProtocolSwitch in interface RemotingCommand
Returns:

setCmdCode

public void setCmdCode(CommandCode cmdCode)

getVersion

public byte getVersion()

setVersion

public void setVersion(byte version)

getType

public byte getType()

setType

public void setType(byte type)

setSerializer

public void setSerializer(byte serializer)

setProtocolSwitch

public void setProtocolSwitch(ProtocolSwitch protocolSwitch)

getId

public int getId()
Description copied from interface: RemotingCommand
Get the id of the command

Specified by:
getId in interface RemotingCommand
Returns:
an int value represent the command id

setId

public void setId(int id)

getHeader

public byte[] getHeader()

setHeader

public void setHeader(byte[] header)

getContent

public byte[] getContent()

setContent

public void setContent(byte[] content)

getHeaderLength

public short getHeaderLength()

getContentLength

public int getContentLength()

getClazzLength

public short getClazzLength()

getClazz

public byte[] getClazz()

setClazz

public void setClazz(byte[] clazz)

setInvokeContext

public void setInvokeContext(InvokeContext invokeContext)


Copyright © 2018. All rights reserved.