com.aelitis.azureus.core.peermanager.messaging.azureus
Class AZMessageFactory

java.lang.Object
  extended by com.aelitis.azureus.core.peermanager.messaging.azureus.AZMessageFactory

public class AZMessageFactory
extends java.lang.Object

Factory for handling AZ message creation. NOTE: wire format: [total message length] + [id length] + [id bytes] + [version byte] + [payload bytes]


Nested Class Summary
protected static class AZMessageFactory.LegacyData
           
 
Field Summary
static int AZ_HANDSHAKE_PAD_MAX
           
static int BIG_PAD_MAX
           
static byte MESSAGE_VERSION_INITIAL
           
static byte MESSAGE_VERSION_SUPPORTS_PADDING
           
static int SMALL_PAD_MAX
           
 
Constructor Summary
AZMessageFactory()
           
 
Method Summary
static Message createAZMessage(DirectByteBuffer stream_payload)
          Construct a new AZ message instance from the given message raw byte stream.
static RawMessage createAZRawMessage(Message base_message, int padding_mode)
          Create the proper AZ raw message from the given base message.
static void init()
          Initialize the factory, i.e.
static void registerGenericMapPayloadMessageType(java.lang.String type_id)
          Register a generic map payload type with the factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MESSAGE_VERSION_INITIAL

public static final byte MESSAGE_VERSION_INITIAL
See Also:
Constant Field Values

MESSAGE_VERSION_SUPPORTS_PADDING

public static final byte MESSAGE_VERSION_SUPPORTS_PADDING
See Also:
Constant Field Values

AZ_HANDSHAKE_PAD_MAX

public static final int AZ_HANDSHAKE_PAD_MAX
See Also:
Constant Field Values

SMALL_PAD_MAX

public static final int SMALL_PAD_MAX
See Also:
Constant Field Values

BIG_PAD_MAX

public static final int BIG_PAD_MAX
See Also:
Constant Field Values
Constructor Detail

AZMessageFactory

public AZMessageFactory()
Method Detail

init

public static void init()
Initialize the factory, i.e. register the messages with the message manager.


registerGenericMapPayloadMessageType

public static void registerGenericMapPayloadMessageType(java.lang.String type_id)
                                                 throws MessageException
Register a generic map payload type with the factory.

Parameters:
type_id - to register
Throws:
MessageException - on registration error

createAZMessage

public static Message createAZMessage(DirectByteBuffer stream_payload)
                               throws MessageException
Construct a new AZ message instance from the given message raw byte stream.

Parameters:
stream_payload - data
Returns:
decoded/deserialized AZ message
Throws:
MessageException - if message creation failed. NOTE: Does not auto-return to buffer pool the given direct buffer on thrown exception.

createAZRawMessage

public static RawMessage createAZRawMessage(Message base_message,
                                            int padding_mode)
Create the proper AZ raw message from the given base message.

Parameters:
base_message - to create from
Returns:
AZ raw message