|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.neeve.root.RootObject
com.neeve.pkt.PktFactory
public final class PktFactory
Factory class used to instantiate packets and packet bodies.
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.
Nested Class Summary | |
---|---|
static class |
PktFactory.PktType
Stores packet type information. |
Method Summary | |
---|---|
PktPacket |
createPacket(int pktTypeId)
Create a packet using a packet type id. |
PktPacket |
createPacket(PktSerializable.DeserializeContext context)
Create a packet from a byte buffer This method invokes createPacket(context, null)
|
PktPacket |
createPacket(PktSerializable.DeserializeContext context,
Tracer tracer)
Create a packet from a byte buffer |
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. |
Methods inherited from class com.neeve.root.RootObject |
---|
getChecked, getThreaded, getTracer, setChecked, setTracer |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public 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 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 body.registerPacketType(com.neeve.pkt.PktFactory.PktType, boolean)
.public final PktBody createPacketBody(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(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(PktSerializable.DeserializeContext context, Tracer tracer) throws EPktCorruptException, EPktVersionInvalidException, EPktTypeInvalidException, EPktBodyClassLoadException, EPktBodyClassInstantiateException, EPktException
context
- The context to use for the deserialization process. See
PktSerializable.DeserializeContext
for more information.tracer
- A trace object to use to output deserialization related
trace. This parameter can be null in which case no trace is output.
EPktCorruptException
- Thrown if the provided buffer does not
contain a valid serialized packet.
EPktVersionInvalidException
- Thrown if the provided buffer
contains a packet with an unsupported header format version.
EPktTypeInvalidException
- Thrown if the packet type id
present in the byte buffer is invalid i.e. packet type information
for such a packet type was not loaded.
EPktBodyClassLoadException
- Thrown if a failure was encountered
while loading the packet body as specified in the configuration file
for the packet type present in the buffer.
EPktBodyClassInstantiateException
- Thrown if a failure was
encountered while instantiating the packet body class as specified in
the configuration file for the packet type found in the buffer.
EPktException
- Thrown if any other exception was encountered
while creating/initializing the packet.registerPacketType(com.neeve.pkt.PktFactory.PktType, boolean)
.
This method instantiates a new packet from a byte buffer. The method creates a packet header, gets the packet type from the serialized buffer and instantiates a packet body using the information contained in the configuration file for the packet type. It then initialized the header and body from the provided buffer and returns a packet to the caller containing this created header and body.
public final PktPacket createPacket(PktSerializable.DeserializeContext context) throws EPktCorruptException, EPktVersionInvalidException, EPktTypeInvalidException, EPktBodyClassLoadException, EPktBodyClassInstantiateException, EPktException
This method invokes createPacket(context, null)
EPktCorruptException
EPktVersionInvalidException
EPktTypeInvalidException
EPktBodyClassLoadException
EPktBodyClassInstantiateException
EPktException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |