gov.nist.javax.sip
Class SipStackImpl

java.lang.Object
  extended by gov.nist.javax.sip.stack.SIPTransactionStack
      extended by gov.nist.javax.sip.SipStackImpl
All Implemented Interfaces:
SipStackExt, SIPDialogEventListener, SIPTransactionEventListener, EventListener, SipStack

public class SipStackImpl
extends SIPTransactionStack
implements SipStack, SipStackExt

Implementation of SipStack. The JAIN-SIP stack is initialized by a set of properties (see the JAIN SIP documentation for an explanation of these properties SipStack ). For NIST SIP stack all properties can also be passed as JVM system properties from the command line as -D arguments. In addition to these, the following are meaningful properties for the NIST SIP stack (specify these in the property array when you create the JAIN-SIP statck):

Note that the stack supports the extensions that are defined in SipStackExt. These will be supported in the next release of JAIN-SIP. You should only use the extensions that are defined in this class.

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

Nested Class Summary
 
Nested classes/interfaces inherited from class gov.nist.javax.sip.stack.SIPTransactionStack
SIPTransactionStack.PingTimer
 
Field Summary
protected  Hashtable<String,ListeningPointImpl> listeningPoints
           
static Integer MAX_DATAGRAM_SIZE
          Max datagram size.
protected  List<SipProviderImpl> sipProviders
           
 
Fields inherited from class gov.nist.javax.sip.stack.SIPTransactionStack
addressResolver, aggressiveCleanup, BASE_TIMER_INTERVAL, cacheClientConnections, cacheServerConnections, cancelClientTransactionChecked, checkBranchId, clientAuth, clientTransactionTable, clientTransactionTableHiwaterMark, clientTransactionTableLowaterMark, CONNECTION_LINGER_TIME, defaultRouter, deliverRetransmittedAckToListener, dialogCreatingMethods, dialogTable, dialogTimeoutFactor, earlyDialogTable, earlyDialogTimeout, forkedEvents, generateTimeStampHeader, ioHandler, isAutomaticDialogErrorHandlingEnabled, isAutomaticDialogSupportEnabled, isBackToBackUserAgent, isDialogTerminatedEventDeliveredForNullDialog, logRecordFactory, logStackTraceOnMessageSend, maxConnections, maxContentLength, maxForkTime, maxListenerResponseTime, maxMessageSize, maxTxLifetimeInvite, maxTxLifetimeNonInvite, messageParserFactory, messageProcessorFactory, minKeepAliveInterval, needsLogging, networkLayer, outboundProxy, readTimeout, receiveUdpBufferSize, reliableConnectionKeepAliveTimeout, remoteTagReassignmentAllowed, retransmissionAlertTransactions, rfc2543Supported, router, routerPath, selfRoutingThreadpoolExecutor, sendUdpBufferSize, serverDialogMergeTestTable, serverLogger, serverTransactionTable, serverTransactionTableHighwaterMark, serverTransactionTableLowaterMark, sipEventInterceptor, sipMessageFactory, sipMessageValve, stackAddress, stackCongenstionControlTimeout, stackInetAddress, stackName, threadAuditor, threadPoolSize, toExit, unlimitedClientTransactionTableSize, unlimitedServerTransactionTableSize, useRouterForAll
 
Constructor Summary
protected SipStackImpl()
          Creates a new instance of SipStackImpl.
  SipStackImpl(Properties configurationProperties)
          Constructor for the stack.
 
Method Summary
 boolean acquireSem()
           
 void addLogAppender(org.apache.log4j.Appender appender)
          Deprecated. TODO: remove this method May 11, 2010.
 ListeningPoint createListeningPoint(int port, String transport)
          Deprecated.  
 ListeningPoint createListeningPoint(String address, int port, String transport)
          Creates a ListeningPoint a given IP address, port and transport.
 SipProvider createSipProvider(ListeningPoint listeningPoint)
          Creates a new peer SipProvider on this SipStack on a specified ListeningPoint and returns a reference to the newly created SipProvider object.
 void deleteListeningPoint(ListeningPoint listeningPoint)
          Deletes the specified ListeningPoint attached to this SipStack.
 void deleteSipProvider(SipProvider sipProvider)
          Deletes the specified peer SipProvider attached to this SipStack.
protected  void finalize()
          Finalization -- stop the stack on finalization.
 AuthenticationHelper getAuthenticationHelper(AccountManager accountManager, HeaderFactory headerFactory)
          Get the authentication helper.
 Properties getConfigurationProperties()
           
 String[] getEnabledCipherSuites()
          Return the currently enabled cipher suites of the Stack.
 String[] getEnabledProtocols()
          Return the currently enabled protocols to use when creating TLS connection.
 gov.nist.javax.sip.EventScanner getEventScanner()
           
 String getIPAddress()
          Deprecated.  
 Iterator getListeningPoints()
          Returns an Iterator of existing ListeningPoints created by this SipStack.
 org.apache.log4j.Logger getLogger()
          Deprecated. TODO: This method will be removed May 11, 2010.
 LogRecordFactory getLogRecordFactory()
          Get the message log factory registered with the stack.
 AuthenticationHelper getSecureAuthenticationHelper(SecureAccountManager accountManager, HeaderFactory headerFactory)
          Get the authentication helper.
 SipListener getSipListener()
          Get the listener for the stack.
 Iterator<SipProviderImpl> getSipProviders()
          Returns an Iterator of existing SipProviders that have been created by this SipStack.
 String getStackName()
          Gets the user friendly name that identifies this SipStack instance.
 TlsSecurityPolicy getTlsSecurityPolicy()
          Get the TLS Security Policy implementation for the stack.
 boolean isAutomaticDialogErrorHandlingEnabled()
           
 boolean isBackToBackUserAgent()
          Get the "back to back User Agent" flag.
 boolean isReEntrantListener()
           
 boolean isRetransmissionFilterActive()
          Deprecated.  
 void releaseSem()
           
 void setEnabledCipherSuites(String[] newCipherSuites)
          Set the list of cipher suites supported by the stack.
 void setEnabledProtocols(String[] newProtocols)
          Set the list of protocols supported by the stack for outgoing TLS connections.
 void setIsBackToBackUserAgent(boolean flag)
          Set the "back to back User Agent" flag.
 void setTlsSecurityPolicy(TlsSecurityPolicy tlsSecurityPolicy)
           
 void start()
          This method initiates the active processing of the stack.
 void stop()
          This methods initiates the shutdown of the stack.
 
Methods inherited from class gov.nist.javax.sip.stack.SIPTransactionStack
addExtensionMethod, addForkedClientTransaction, addMessageProcessor, addTransaction, addTransaction, addTransactionPendingAck, auditStack, checkBranchId, closeReliableConnection, createClientTransaction, createDialog, createDialog, createDialog, createMessageChannel, createMessageProcessor, createRawMessageChannel, createServerTransaction, decrementActiveClientTransactionCount, dialogErrorEvent, disableLogging, enableLogging, findCancelTransaction, findMergedTransaction, findPendingTransaction, findSubscribeTransaction, findTransaction, findTransaction, findTransactionPendingAck, getAckTimeoutFactor, getActiveClientTransactionCount, getAddressResolver, getClientAuth, getClientTransactionTableSize, getDialog, getDialogs, getDialogs, getEarlyDialog, getEarlyDialogTimeout, getForkedTransaction, getHostAddress, getJoinDialog, getLocalAddressForTcpDst, getLocalAddressForTlsDst, getMaxForkTime, getMaxMessageSize, getMaxTxLifetimeInvite, getMaxTxLifetimeNonInvite, getMessageParserFactory, getMessageProcessorFactory, getMessageProcessors, getMinKeepAliveInterval, getNetworkLayer, getNextHop, getReceiveUdpBufferSize, getReinviteExecutor, getReliableConnectionKeepAliveTimeout, getReplacesDialog, getRetransmissionAlertTransaction, getRouter, getRouter, getSelfRoutingThreadpoolExecutor, getSendUdpBufferSize, getServerLogger, getServerTransactionTableSize, getSslHandshakeTimeout, getStackLogger, getTcpPostParsingThreadPoolSize, getThreadAuditor, getThreadPriority, getTimer, isAggressiveCleanup, isAlive, isCancelClientTransactionChecked, isDeliverRetransmittedAckToListener, isDeliverTerminatedEventForAck, isDeliverUnsolicitedNotify, isDialogCreated, isEventForked, isLoggingEnabled, isLoggingEnabled, isLogStackTraceOnMessageSend, isNon2XXAckPassedToListener, isRemoteTagReassignmentAllowed, isRfc2543Supported, isTransactionPendingAck, mapTransaction, newSIPServerRequest, newSIPServerResponse, printDialogTable, putDialog, putInMergeTable, putMergeDialog, putPendingTransaction, reInit, removeDialog, removeDialog, removeFromMergeTable, removeMergeDialog, removeMessageProcessor, removePendingTransaction, removeTransaction, removeTransactionHash, removeTransactionPendingAck, setAddressResolver, setAggressiveCleanup, setClientAuth, setDeliverDialogTerminatedEventForNullDialog, setDeliverTerminatedEventForAck, setDeliverUnsolicitedNotify, setEarlyDialogTimeout, setHostAddress, setKeepAliveTimeout, setLogRecordFactory, setLogStackTraceOnMessageSend, setMaxConnections, setMaxForkTime, setMaxTxLifetimeInvite, setMaxTxLifetimeNonInvite, setMessageFactory, setMessageParserFactory, setMessageProcessorFactory, setNon2XXAckPassedToListener, setReceiveUdpBufferSize, setReliableConnectionKeepAliveTimeout, setRouter, setSendUdpBufferSize, setSingleThreaded, setSslHandshakeTimeout, setStackName, setTcpPostParsingThreadPoolSize, setThreadPoolSize, setThreadPriority, setTimer, stopStack, transactionErrorEvent
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.nist.javax.sip.SipStackExt
getDialogs, getJoinDialog, getLocalAddressForTcpDst, getLocalAddressForTlsDst, getReplacesDialog, setAddressResolver
 
Methods inherited from interface javax.sip.SipStack
getRouter
 

Field Detail

listeningPoints

protected Hashtable<String,ListeningPointImpl> listeningPoints

sipProviders

protected List<SipProviderImpl> sipProviders

MAX_DATAGRAM_SIZE

public static final Integer MAX_DATAGRAM_SIZE
Max datagram size.

Constructor Detail

SipStackImpl

protected SipStackImpl()
Creates a new instance of SipStackImpl.


SipStackImpl

public SipStackImpl(Properties configurationProperties)
             throws PeerUnavailableException
Constructor for the stack.

Parameters:
configurationProperties - -- stack configuration properties including NIST-specific extensions.
Throws:
PeerUnavailableException
Method Detail

createListeningPoint

public ListeningPoint createListeningPoint(String address,
                                           int port,
                                           String transport)
                                    throws TransportNotSupportedException,
                                           InvalidArgumentException
Description copied from interface: SipStack
Creates a ListeningPoint a given IP address, port and transport. If this method is used, the IP address of the stack is ignored and a listening point is created with the given parameters. This support is useful for multi-homed hosts which may have to listen at multiple IP addresses and have different dialogs for each IP address.

Specified by:
createListeningPoint in interface SipStack
Returns:
ListeningPoint that uses the IP address port and transport.
Throws:
InvalidArgumentException
TransportNotSupportedException

createSipProvider

public SipProvider createSipProvider(ListeningPoint listeningPoint)
                              throws ObjectInUseException
Description copied from interface: SipStack
Creates a new peer SipProvider on this SipStack on a specified ListeningPoint and returns a reference to the newly created SipProvider object. The newly created SipProvider is implicitly attached to this SipListener upon execution of this method, by adding the SipProvider to the list of SipProviders of this SipStack once it has been successfully created.

Specified by:
createSipProvider in interface SipStack
Parameters:
listeningPoint - listening point for this SipProvider.
Returns:
the newly created SipProvider been started.
Throws:
ObjectInUseException - if another SipProvider is already associated with this ListeningPoint.

deleteListeningPoint

public void deleteListeningPoint(ListeningPoint listeningPoint)
                          throws ObjectInUseException
Description copied from interface: SipStack
Deletes the specified ListeningPoint attached to this SipStack. The specified ListeningPoint is implicitly detached from this SipStack upon execution of this method, by removing the ListeningPoint from the ListeningPoints list of this SipStack.

Specified by:
deleteListeningPoint in interface SipStack
Parameters:
listeningPoint - the SipProvider to be deleted from this SipStack.
Throws:
ObjectInUseException - if the specified ListeningPoint cannot be deleted because the ListeningPoint is currently in use.

deleteSipProvider

public void deleteSipProvider(SipProvider sipProvider)
                       throws ObjectInUseException
Description copied from interface: SipStack
Deletes the specified peer SipProvider attached to this SipStack. The specified SipProvider is implicitly detached from this SipStack upon execution of this method, by removing the SipProvider from the SipProviders list of this SipStack. Deletion of a SipProvider does not automatically delete the SipProvider's ListeningPoint from the SipStack.

Specified by:
deleteSipProvider in interface SipStack
Parameters:
sipProvider - the peer SipProvider to be deleted from this SipStack.
Throws:
ObjectInUseException - if the specified SipProvider cannot be deleted because the SipProvider is currently in use.

getIPAddress

public String getIPAddress()
Deprecated. 

Get the IP Address of the stack.

Specified by:
getIPAddress in interface SipStack
Returns:
a string identifing the IP Address. Null if there is no default IP address associated with the stack instance.
See Also:
SipStack.getIPAddress()

getListeningPoints

public Iterator getListeningPoints()
Description copied from interface: SipStack
Returns an Iterator of existing ListeningPoints created by this SipStack. All of the ListeningPoints of this SipStack belong to the same stack vendor.

Specified by:
getListeningPoints in interface SipStack
Returns:
an Iterator containing all existing ListeningPoints created by this SipStack. Returns an empty Iterator if no ListeningPoints exist.

isRetransmissionFilterActive

public boolean isRetransmissionFilterActive()
Deprecated. 

Return true if retransmission filter is active.

Specified by:
isRetransmissionFilterActive in interface SipStack
Returns:
the value of the retransmission filter, true if the filter is set, false otherwise.
See Also:
SipStack.isRetransmissionFilterActive()

getSipProviders

public Iterator<SipProviderImpl> getSipProviders()
Description copied from interface: SipStack
Returns an Iterator of existing SipProviders that have been created by this SipStack. All of the SipProviders of this SipStack will belong to the same stack vendor.

Specified by:
getSipProviders in interface SipStack
Returns:
the list of Providers attached to this Sipstack.

getStackName

public String getStackName()
Description copied from interface: SipStack
Gets the user friendly name that identifies this SipStack instance. This value is set using the Properties object passed to the SipFactory.createSipStack(Properties)method upon creation of the SipStack object.

Specified by:
getStackName in interface SipStack
Returns:
a string identifing the stack instance

finalize

protected void finalize()
Finalization -- stop the stack on finalization. Exit the transaction scanner and release all resources.

Overrides:
finalize in class Object
See Also:
Object.finalize()

createListeningPoint

public ListeningPoint createListeningPoint(int port,
                                           String transport)
                                    throws TransportNotSupportedException,
                                           InvalidArgumentException
Deprecated. 

This uses the default stack address to create a listening point.

Specified by:
createListeningPoint in interface SipStack
Parameters:
port - the port of the new ListeningPoint.
transport - the transport of the new ListeningPoint.
Returns:
the ListeningPoint attached to this SipStack.
Throws:
InvalidArgumentException - if the specified port is invalid.
TransportNotSupportedException
See Also:
SipStack.createListeningPoint(java.lang.String, int, java.lang.String)

stop

public void stop()
Description copied from interface: SipStack
This methods initiates the shutdown of the stack. The stack will terminate all ongoing transactions, without providing notificatin to the listener, close all listening points and release all resources associated with this stack. Note that this is a hard stop and should be used with care. The application may build graceful stop measures if needed, however the implementation is expected to immediately release any resources such as threads sockets and buffers that are allocated to this stack.

Specified by:
stop in interface SipStack

start

public void start()
           throws ProviderDoesNotExistException,
                  SipException
Description copied from interface: SipStack
This method initiates the active processing of the stack. This method is used to start the stack after the necessary SipProviders have been created. After calling this method, the stack can handle incoming requests and responses on the ListeningPoints associated to the SipProviders.

Specified by:
start in interface SipStack
Throws:
SipException - if the stack cannot be started due to some system level failure.
ProviderDoesNotExistException

getSipListener

public SipListener getSipListener()
Get the listener for the stack. A stack can have only one listener. To get an event from a provider, the listener has to be registered with the provider. The SipListener is application code.

Specified by:
getSipListener in class SIPTransactionStack
Returns:
-- the stack SipListener

getTlsSecurityPolicy

public TlsSecurityPolicy getTlsSecurityPolicy()
Get the TLS Security Policy implementation for the stack. The TlsSecurityPolicy is application code.

Returns:
-- the TLS Security Policy implementation

getLogRecordFactory

public LogRecordFactory getLogRecordFactory()
Get the message log factory registered with the stack.

Returns:
-- the messageLogFactory of the stack.

addLogAppender

@Deprecated
public void addLogAppender(org.apache.log4j.Appender appender)
Deprecated. TODO: remove this method May 11, 2010.

Set the log appender ( this is useful if you want to specify a particular log format or log to something other than a file for example). This method is will be removed May 11, 2010 or shortly there after.

Parameters:
Appender - - the log4j appender to add.

getLogger

@Deprecated
public org.apache.log4j.Logger getLogger()
Deprecated. TODO: This method will be removed May 11, 2010.

Get the log4j logger ( for log stream integration ). This method will be removed May 11, 2010 or shortly there after.

Returns:
the log4j logger.

getEventScanner

public gov.nist.javax.sip.EventScanner getEventScanner()

getAuthenticationHelper

public AuthenticationHelper getAuthenticationHelper(AccountManager accountManager,
                                                    HeaderFactory headerFactory)
Description copied from interface: SipStackExt
Get the authentication helper.

Specified by:
getAuthenticationHelper in interface SipStackExt
Parameters:
accountManager - -- account manager (for fetching credentials).
headerFactory - -- header factory.
Returns:
- the authentication helper which can be used for generating the appropriate headers for handling authentication challenges for user agents.

getSecureAuthenticationHelper

public AuthenticationHelper getSecureAuthenticationHelper(SecureAccountManager accountManager,
                                                          HeaderFactory headerFactory)
Description copied from interface: SipStackExt
Get the authentication helper.

Specified by:
getSecureAuthenticationHelper in interface SipStackExt
Parameters:
accountManager - -- account manager (for fetching credentials).
headerFactory - -- header factory.
Returns:
- the authentication helper which can be used for generating the appropriate headers for handling authentication challenges for user agents.

setEnabledCipherSuites

public void setEnabledCipherSuites(String[] newCipherSuites)
Set the list of cipher suites supported by the stack. A stack can have only one set of suites. These are not validated against the supported cipher suites of the java runtime, so specifying a cipher here does not guarantee that it will work.
The stack has a default cipher suite of: NOTE: This function must be called before adding a TLS listener

Specified by:
setEnabledCipherSuites in interface SipStackExt
Parameters:
String - [] The new set of ciphers to support.

getEnabledCipherSuites

public String[] getEnabledCipherSuites()
Return the currently enabled cipher suites of the Stack.

Returns:
The currently enabled cipher suites.

setEnabledProtocols

public void setEnabledProtocols(String[] newProtocols)
Set the list of protocols supported by the stack for outgoing TLS connections. A stack can have only one set of protocols. These are not validated against the supported protocols of the java runtime, so specifying a protocol here does not guarantee that it will work.
The stack has a default protocol suite of: NOTE: This function must be called before creating a TLSMessageChannel.

Parameters:
String - [] The new set of protocols to use for outgoing TLS connections.

getEnabledProtocols

public String[] getEnabledProtocols()
Return the currently enabled protocols to use when creating TLS connection.

Returns:
The currently enabled protocols.

setIsBackToBackUserAgent

public void setIsBackToBackUserAgent(boolean flag)
Set the "back to back User Agent" flag.

Parameters:
flag - - boolean flag to set.

isBackToBackUserAgent

public boolean isBackToBackUserAgent()
Get the "back to back User Agent" flag. return the value of the flag


isAutomaticDialogErrorHandlingEnabled

public boolean isAutomaticDialogErrorHandlingEnabled()

setTlsSecurityPolicy

public void setTlsSecurityPolicy(TlsSecurityPolicy tlsSecurityPolicy)

acquireSem

public boolean acquireSem()

releaseSem

public void releaseSem()

getConfigurationProperties

public Properties getConfigurationProperties()
Returns:
the configurationProperties

isReEntrantListener

public boolean isReEntrantListener()
Returns:
the reEntrantListener


Copyright © 2012. All Rights Reserved.