org.mobicents.protocols.smpp.util
Class PacketFactory

java.lang.Object
  extended by org.mobicents.protocols.smpp.util.PacketFactory

public final class PacketFactory
extends Object

Factory class for SMPP packets.

Version:
$Id: PacketFactory.java 457 2009-01-15 17:37:42Z orank $

Constructor Summary
PacketFactory()
           
 
Method Summary
 SMPPPacket newInstance(int id)
          Create a new instance of the appropriate sub class of SMPPPacket.
 SMPPPacket newResponse(SMPPPacket packet)
          Get a response packet for the specified request.
 void registerVendorPacket(int id, Class<? extends SMPPPacket> requestType, Class<? extends SMPPPacket> responseType)
          Register a vendor packet with the factory.
 void unregisterVendorPacket(int id)
          Remove a vendor packet definition from this factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PacketFactory

public PacketFactory()
Method Detail

newInstance

public SMPPPacket newInstance(int id)
Create a new instance of the appropriate sub class of SMPPPacket. Packet fields are all left at their default initial state.

Parameters:
id - The SMPP command ID of the packet type to return.
Returns:
A sub-class instance of SMPPPacket representing SMPP command id.
Throws:
BadCommandIDException - if the command ID is not recognized.

newResponse

public SMPPPacket newResponse(SMPPPacket packet)
Get a response packet for the specified request. The returned response packet will have its sequence number initialised to the same value as packet.

Parameters:
packet - The request packet to get a response for.
Returns:
An SMPP response packet.
Throws:
BadCommandIDException - If there is no response packet for the specified request (for example, an AlertNotification).
SMPPRuntimeException - If an attempt is made to create a response to a response packet.

registerVendorPacket

public void registerVendorPacket(int id,
                                 Class<? extends SMPPPacket> requestType,
                                 Class<? extends SMPPPacket> responseType)
Register a vendor packet with the factory. The SMPP allows for vendor-specific packets to be defined. In order for these to be usable with the API, primarily so that they can be identified and decoded when received from an SMSC, they must be registered with the packet factory.

This implementation assumes that the ID of the response packet will be the ID of the request packet ORed with 0x80000000. This implementation also accepts null for the responseType since there is at least one incidence in the specification of such a case (AlertNotification has no response packet).

Parameters:
id - The command ID of the request packet.
requestType - The class which implements the vendor request packet.
responseType - The class which implements the vendor response packet.

unregisterVendorPacket

public void unregisterVendorPacket(int id)
Remove a vendor packet definition from this factory.

Parameters:
id - The ID of the vendor packet to remove. This will also unregister the response packet if it exists.


Copyright © 2011 Mobicents. All Rights Reserved.