public final class PktFactory extends RootObject
This class is a singleton class used to instantiate packets. Packets are classified by type. Type information is loaded at class load time from a deployment's default configuration repository and also can be registered by the user programattically.
| Modifier and Type | Class and Description |
|---|---|
static class |
PktFactory.PktType
Stores packet type information.
|
| Modifier and Type | Method and Description |
|---|---|
PktPacket |
createPacket(ByteBuffer buffer)
Create a packet from its serialized form.
|
PktPacket |
createPacket(ByteBuffer buffer,
int offset,
int length)
Create a packet from its serialized form.
|
PktPacket |
createPacket(int pktTypeId)
Create a packet using a packet type id.
|
PktPacket |
createPacket(IOBuffer buffer,
int offset,
int length,
boolean wrap)
Create a packet from its serialized form.
|
PktPacket |
createPacket(long addr,
int offset,
int length)
Create a packet from its serialized form.
|
PktPacket |
createPacket(String pktTypeName)
Create a packet using a packet type name.
|
PktBody |
createPacketBody(int pktTypeId)
Create a packet body using a packet type id
|
PktBody |
createPacketBody(String pktTypeName)
Create a packet body using the packet type name.
|
PktPacket |
createPacketNonPooled(int pktTypeId)
Create a packet using a packet type id.
|
static PktFactory |
getInstance()
Return the singleton packet factory instance
|
PktFactory.PktType |
getPacketType(int pktTypeId)
Get a packet type by packet type id.
|
PktFactory.PktType |
getPacketType(String pktTypeName)
Get a packet type by packet type name.
|
String |
getPacketTypeNameFromId(int pktTypeId)
Get the packet type name by id
|
void |
registerPacketType(PktFactory.PktType pktType)
Register a packet type with the factory.
|
getChecked, getThreaded, getTracerpublic static PktFactory getInstance()
public final void registerPacketType(PktFactory.PktType pktType)
IllegalArgumentException - Thrown in case the supplied packet
type is null.This method is supplied for programmatic registration of packet types with the packet factory. This method should be used with caution since the underlying packet type table is not managed in a thread safe manner and invoking this method while messaging is in progress can corrupt the table. The recommended practice is to register all packet types in the local configuration repository. The factory loads up all packet types in the local repository in its class constructor thus ensuring thread safe management of the type table. If this method is used to register packet types, the user must ensure it is done so before any messaging is started.
It is a fatal error to register a packet type with a duplicate name or id. Doing so will result in an {link hava.lang.Error} being thrown.
public final PktFactory.PktType getPacketType(int pktTypeId)
registerPacketType(com.neeve.pkt.PktFactory.PktType, boolean).public final PktFactory.PktType getPacketType(String pktTypeName)
registerPacketType(com.neeve.pkt.PktFactory.PktType, boolean).public final String getPacketTypeNameFromId(int pktTypeId)
pktTypeId - The id for which to return the nameregisterPacketType(com.neeve.pkt.PktFactory.PktType, boolean).public final PktBody createPacketBody(int pktTypeId) throws EPktTypeInvalidException, EPktBodyClassLoadException, EPktBodyClassInstantiateException, EPktException
pktTypeId - The packet type idEPktTypeInvalidException - Thrown if the specified id is not a
valid packet body type id.EPktBodyClassLoadException - Thrown if a failure was encountered
while loading the packet body class.EPktBodyClassInstantiateException - Thrown if a failure was
encountered while instantiating the packet body class.EPktException - Thrown if any other exception was encountered
while creating the new packet body.registerPacketType(com.neeve.pkt.PktFactory.PktType, boolean).public final PktBody createPacketBody(String pktTypeName) throws EPktTypeInvalidException, EPktBodyClassLoadException, EPktBodyClassInstantiateException, EPktException
pktTypeName - The packet type nameEPktTypeInvalidException - Thrown if the specified name is not
a valid packet type name.EPktBodyClassLoadException - Thrown if a failure was encountered
while loading the packet body class.EPktBodyClassInstantiateException - Thrown if a failure was
encountered while instantiating the packet body class.EPktException - Thrown if any other exception was encountered
while creating the new packet.registerPacketType(com.neeve.pkt.PktFactory.PktType, boolean).public final PktPacket createPacket(int pktTypeId) throws EPktTypeInvalidException, EPktBodyClassLoadException, EPktBodyClassInstantiateException, EPktException
pktTypeId - The packet type id.EPktTypeInvalidException - Thrown if the specified id is not a
valid packet body type id.EPktBodyClassLoadException - Thrown if a failure was encountered
while loading the packet body class.EPktBodyClassInstantiateException - Thrown if a failure was
encountered while instantiating the packet body class.EPktException - Thrown if any other exception was encountered
while creating the new packet.registerPacketType(com.neeve.pkt.PktFactory.PktType, boolean).public final PktPacket createPacketNonPooled(int pktTypeId) throws EPktTypeInvalidException, EPktBodyClassLoadException, EPktBodyClassInstantiateException, EPktException
pktTypeId - The packet type id.EPktTypeInvalidException - Thrown if the specified id is not a
valid packet body type id.EPktBodyClassLoadException - Thrown if a failure was encountered
while loading the packet body class.EPktBodyClassInstantiateException - Thrown if a failure was
encountered while instantiating the packet body class.EPktException - Thrown if any other exception was encountered
while creating the new packet.registerPacketType(com.neeve.pkt.PktFactory.PktType, boolean).
This method is identical to createPacket(int) except that the
packet is always created fresh and not from the packet type's pool
NOTE: THIS METHOD IS INTENDED FOR X PLATFORM INTERNAL USE AND SHOULD
NOT BE USED. PLEASE CONSULT NEEVE TECHNICAL SUPPORT BEFORE YOU
USE THIS METHOD. THIS METHOD CAN BE DEPRECATED/REMOVED/CHANGED
AT ANY TIME WIHOUT NOTICE
public final PktPacket createPacket(String pktTypeName) throws EPktTypeInvalidException, EPktBodyClassLoadException, EPktBodyClassInstantiateException, EPktException
pktTypeName - The packet type name.EPktTypeInvalidException - Thrown if the specified name is not
a valid packet type name.EPktBodyClassLoadException - Thrown if a failure was encountered
while loading the packet body class.EPktBodyClassInstantiateException - Thrown if a failure was
encountered while instantiating the packet body class.EPktException - Thrown if any other exception was encountered
while creating the new packet.registerPacketType(com.neeve.pkt.PktFactory.PktType, boolean).public final PktPacket createPacket(ByteBuffer buffer, int offset, int length)
buffer - The buffer that contains the serialized packet.offset - The offset into the buffer where the serialized packet starts.length - The number of valid bytes in buffer. The number of bytes
must be greater or equal to the length of the serialized packet. Otherwise,
this method will throw an EPktIncompleteException.EPktCorruptException - Thrown if a valid packet does not start at
the specified offset in the bufferEPktVersionInvalidException - Thrown in case the buffer contains
a serialized packet with an invalid header format versionEPktIncompleteException - Thrown if the number of valid bytes
in the supplied buffer does not form a complete packetregisterPacketType(com.neeve.pkt.PktFactory.PktType, boolean).public final PktPacket createPacket(ByteBuffer buffer)
This method invokes createPacket(buffer, buffer.position(), buffer.remaining())
public final PktPacket createPacket(IOBuffer buffer, int offset, int length, boolean wrap)
buffer - The buffer that contains the serialized packet.offset - The offset into the buffer where the serialized packet starts.length - The number of valid bytes in buffer. The number of bytes
must be greater or equal to the length of the serialized packet. Otherwise,
this method will throw an EPktIncompleteException.wrap - Indicates whether the new packet should copy its contents from
the supplied buffer to the packet header or wrap the packet around the supplied
bufferEPktCorruptException - Thrown if a valid packet does not start at
the specified offset in the bufferEPktVersionInvalidException - Thrown in case the buffer contains
a serialized packet with an invalid header format versionEPktIncompleteException - Thrown if the number of valid bytes
in the supplied buffer does not form a complete packetregisterPacketType(com.neeve.pkt.PktFactory.PktType, boolean).public final PktPacket createPacket(long addr, int offset, int length)
addr - The address of the memory region that contains the serialized packet.offset - The offset into the buffer where the serialized packet starts.length - The number of valid bytes in buffer. The number of bytes
must be greater or equal to the length of the serialized packet. Otherwise,
this method will throw an EPktIncompleteException.EPktCorruptException - Thrown if a valid packet does not start at
the specified offset in the bufferEPktVersionInvalidException - Thrown in case the buffer contains
a serialized packet with an invalid header format versionEPktIncompleteException - Thrown if the number of valid bytes
in the supplied buffer does not form a complete packetregisterPacketType(com.neeve.pkt.PktFactory.PktType, boolean).Copyright © 2019 N5 Technologies, Inc. All Rights Reserved.