org.jnetstream.packet
Interface PacketTemplate

All Superinterfaces:
java.lang.Iterable<Header>, Packet
All Known Implementing Classes:
TcpNic0Template

public interface PacketTemplate
extends Packet

Interface which allows a packet to be configured and initialized once and then reused as a template to initialize efficiently other packets. The requirements for a packet template are that the implementing class provide a no-argument public constructor and that all the packet initialization code go into the init method. In all respects the template is a normal packet with the exception, that templates are singletons, instatiated only once, initialized and then cached.

You can request new packets to be created based on the template using the Packets.newPacket(Class) call or Packets.newPacket(PacketTemplate). The first method will instantiate and cache the template for you, the second call requires an already instantiated packet to exist and no caching will be performed.

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jnetstream.packet.Packet
Packet.Property
 
Method Summary
 void init()
          Initialization method for the template.
 
Methods inherited from interface org.jnetstream.packet.Packet
format, getAllHeaders, getBuffer, getData, getHeader, getHeader, getHeaderCount, getIncludedLength, getOriginalLength, getProperty, getTimestampNanos, getTimestampSeconds, hasCompleteHeader, hasCompleteHeader, hasHeader, hasHeader, isTruncated, iterator
 

Method Detail

init

void init()
Initialization method for the template. You need to put all your packet initialization code in this method. Create any properties, add headers and set values.