gov.nist.javax.sip.stack
Class MessageProcessor

java.lang.Object
  extended by gov.nist.javax.sip.stack.MessageProcessor
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
ConnectionOrientedMessageProcessor, SCTPMessageProcessor, UDPMessageProcessor

public abstract class MessageProcessor
extends Object
implements Runnable

This is the Stack abstraction for the active object that waits for messages to appear on the wire and processes these messages by calling the MessageFactory interface to create a ServerRequest or ServerResponse object. The main job of the message processor is to instantiate message channels for the given transport.

Version:
1.2 $Revision: 1.20 $ $Date: 2010-12-02 22:04:15 $
Author:
M. Ranganathan

Field Summary
protected static String IN_ADDR_ANY
          A string containing the 0.0.0.0 IPv4 ANY address.
protected static String IN6_ADDR_ANY
          A string containing the ::0 IPv6 ANY address.
protected  SIPTransactionStack sipStack
          Our stack (that created us).
protected  String transport
          The transport where I am listening
 
Constructor Summary
protected MessageProcessor(InetAddress ipAddress, int port, String transport, SIPTransactionStack transactionStack)
          Constructor
protected MessageProcessor(String transport)
           
 
Method Summary
abstract  MessageChannel createMessageChannel(HostPort targetHostPort)
          Create a message channel for the specified host/port.
abstract  MessageChannel createMessageChannel(InetAddress targetHost, int port)
          Create a message channel for the specified host/port.
static int getDefaultPort(String transport)
          Get the defalt port for the message processor.
abstract  int getDefaultTargetPort()
          Default target port used by this processor.
 InetAddress getIpAddress()
           
 ListeningPointImpl getListeningPoint()
           
abstract  int getMaximumMessageSize()
          Maximum number of bytes that this processor can handle.
 int getPort()
          Get the port identifier.
 String getSavedIpAddress()
          Get the saved IP Address.
 String getSentBy()
          Get the sentby string.
abstract  SIPTransactionStack getSIPStack()
          Get the SIP Stack.
 String getTransport()
          Get the transport string.
 Via getViaHeader()
          Get the Via header to assign for this message processor.
 void initialize(InetAddress ipAddress, int port, SIPTransactionStack transactionStack)
          Initializes this MessageProcessor.
abstract  boolean inUse()
          Return true if there are pending messages to be processed (which prevents the message channel from being closed).
abstract  boolean isSecure()
          Flags whether this processor is secure or not.
 boolean isSentBySet()
           
abstract  void run()
          Run method.
protected  void setIpAddress(InetAddress ipAddress)
           
 void setListeningPoint(ListeningPointImpl lp)
           
 void setSentBy(String sentBy)
          Set the sentby string.
abstract  void start()
          Start our thread.
abstract  void stop()
          Stop method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IN_ADDR_ANY

protected static final String IN_ADDR_ANY
A string containing the 0.0.0.0 IPv4 ANY address.

See Also:
Constant Field Values

IN6_ADDR_ANY

protected static final String IN6_ADDR_ANY
A string containing the ::0 IPv6 ANY address.

See Also:
Constant Field Values

transport

protected String transport
The transport where I am listening


sipStack

protected SIPTransactionStack sipStack
Our stack (that created us).

Constructor Detail

MessageProcessor

protected MessageProcessor(String transport)

MessageProcessor

protected MessageProcessor(InetAddress ipAddress,
                           int port,
                           String transport,
                           SIPTransactionStack transactionStack)
Constructor

Parameters:
ipAddress - -- ip address where I am listening for incoming requests.
port - -- port where i am listening for incoming requests.
transport - -- transport to use for the message processor (UDP/TCP/TLS).
Method Detail

initialize

public final void initialize(InetAddress ipAddress,
                             int port,
                             SIPTransactionStack transactionStack)
Initializes this MessageProcessor. Needed for extensions that use classloading

Parameters:
ipAddress2 -
transactionStack -
port2 -

getTransport

public String getTransport()
Get the transport string.

Returns:
A string that indicates the transport. (i.e. "tcp" or "udp")

getPort

public int getPort()
Get the port identifier.

Returns:
the port for this message processor. This is where you receive messages.

getViaHeader

public Via getViaHeader()
Get the Via header to assign for this message processor. The topmost via header of the outoging messages use this.

Returns:
the ViaHeader to be used by the messages sent via this message processor.

getListeningPoint

public ListeningPointImpl getListeningPoint()

setListeningPoint

public void setListeningPoint(ListeningPointImpl lp)

getSavedIpAddress

public String getSavedIpAddress()
Get the saved IP Address.


getIpAddress

public InetAddress getIpAddress()
Returns:
the ip address for this message processor.

setIpAddress

protected void setIpAddress(InetAddress ipAddress)
Parameters:
ipAddress - the ipAddress to set

setSentBy

public void setSentBy(String sentBy)
               throws ParseException
Set the sentby string. This is used for stamping outgoing messages sent from this listening point.

Parameters:
sentBy -
Throws:
ParseException

getSentBy

public String getSentBy()
Get the sentby string.


getSIPStack

public abstract SIPTransactionStack getSIPStack()
Get the SIP Stack.

Returns:
the sip stack.

createMessageChannel

public abstract MessageChannel createMessageChannel(HostPort targetHostPort)
                                             throws IOException
Create a message channel for the specified host/port.

Returns:
New MessageChannel for this processor.
Throws:
IOException

createMessageChannel

public abstract MessageChannel createMessageChannel(InetAddress targetHost,
                                                    int port)
                                             throws IOException
Create a message channel for the specified host/port.

Returns:
New MessageChannel for this processor.
Throws:
IOException

start

public abstract void start()
                    throws IOException
Start our thread.

Throws:
IOException

stop

public abstract void stop()
Stop method.


getDefaultTargetPort

public abstract int getDefaultTargetPort()
Default target port used by this processor. This is 5060 for TCP / UDP


isSecure

public abstract boolean isSecure()
Flags whether this processor is secure or not.


getMaximumMessageSize

public abstract int getMaximumMessageSize()
Maximum number of bytes that this processor can handle.


inUse

public abstract boolean inUse()
Return true if there are pending messages to be processed (which prevents the message channel from being closed).


run

public abstract void run()
Run method.

Specified by:
run in interface Runnable

isSentBySet

public boolean isSentBySet()
Returns:
Returns the sentBySet.

getDefaultPort

public static int getDefaultPort(String transport)
Get the defalt port for the message processor.

Parameters:
transport -
Returns:
-- the default port for the message processor.


Copyright © 2012. All Rights Reserved.