org.mobicents.servlet.sip.core
Class SipApplicationDispatcherImpl

java.lang.Object
  extended by org.mobicents.servlet.sip.core.SipApplicationDispatcherImpl
All Implemented Interfaces:
java.util.EventListener, javax.management.MBeanRegistration, javax.sip.SipListener, SipApplicationDispatcher

public class SipApplicationDispatcherImpl
extends java.lang.Object
implements SipApplicationDispatcher, javax.management.MBeanRegistration

Implementation of the SipApplicationDispatcher interface. Central point getting the sip messages from the different stacks for a Tomcat Service(Engine), translating jain sip SIP messages to sip servlets SIP messages, creating a MessageRouter responsible for choosing which Dispatcher will be used for routing the message and dispatches the messages.

Author:
Jean Deruelle

Nested Class Summary
 class SipApplicationDispatcherImpl.CongestionControlTimerTask
          Timer task that will gather information about congestion control
 
Field Summary
protected  java.util.concurrent.ScheduledFuture congestionControlTimerFuture
           
protected  SipApplicationDispatcherImpl.CongestionControlTimerTask congestionControlTimerTask
           
protected  java.lang.String domain
           
protected  javax.management.MBeanServer mserver
           
protected  javax.management.ObjectName oname
           
 
Fields inherited from interface org.mobicents.servlet.sip.core.SipApplicationDispatcher
EXTENSIONS_SUPPORTED, METHODS_SUPPORTED, RFC_SUPPORTED
 
Constructor Summary
SipApplicationDispatcherImpl()
           
 
Method Summary
 void addHostName(java.lang.String hostName)
          Add a new hostname to the application dispatcher.
 void addSipApplication(java.lang.String sipApplicationName, SipContext sipApplication)
          Add a new sip application to which sip messages can be routed
 java.util.Set<java.lang.String> findHostNames()
          Returns An immutable instance of the java.util.List interface containing the sip application dispatcher registered host names
 java.lang.String[] findInstalledSipApplications()
           
 SipContext findSipApplication(java.lang.String applicationName)
          Find the sip application to which sip messages can currently be routed by its name
 java.util.Iterator<SipContext> findSipApplications()
          Find the sip applications to which sip messages can currently be routed
 java.lang.String getApplicationNameFromHash(java.lang.String hash)
           
 java.util.concurrent.ThreadPoolExecutor getAsynchronousExecutor()
           
 ConcurrencyControlMode getConcurrencyControlMode()
           
 long getCongestionControlCheckingInterval()
           
 CongestionControlPolicy getCongestionControlPolicy()
           
 java.lang.String getDomain()
           
 java.lang.String getHashFromApplicationName(java.lang.String appName)
           
 int getMemoryThreshold()
           
 SipApplicationRouterInfo getNextInterestedApplication(SipServletRequestImpl sipServletRequest)
           
 int getNumberOfMessagesInQueue()
           
 int getNumberOfPendingMessages()
           
 javax.management.ObjectName getObjectName()
           
 java.util.List<SipURI> getOutboundInterfaces()
          Returns An immutable instance of the java.util.List interface containing the SipURI representation of IP addresses which are used by the container to send out the messages.
 double getPercentageOfMemoryUsed()
           
 int getQueueSize()
           
 long getRequestsProcessed()
           
 long getResponsesProcessed()
           
 SipApplicationRouter getSipApplicationRouter()
           
 SipFactoryImpl getSipFactory()
          retrieve the sip factory
 SipNetworkInterfaceManager getSipNetworkInterfaceManager()
          Retrieve the manager for the sip network interfaces for this application dispatcher
 void init()
          Initialize the sip application dispatcher.
 boolean isBypassRequestExecutor()
           
 boolean isBypassResponseExecutor()
           
 boolean isExternal(java.lang.String host, int port, java.lang.String transport)
          Check whether or not the triplet host, port and transport are corresponding to an interface
 boolean isRouteExternal(javax.sip.header.RouteHeader routeHeader)
          Check if the route is external
 boolean isViaHeaderExternal(javax.sip.header.ViaHeader viaHeader)
          Check if the via header is external
 void postDeregister()
           
 void postRegister(java.lang.Boolean registrationDone)
           
 void preDeregister()
           
 javax.management.ObjectName preRegister(javax.management.MBeanServer server, javax.management.ObjectName name)
           
 void processDialogTerminated(javax.sip.DialogTerminatedEvent dialogTerminatedEvent)
           
 void processIOException(javax.sip.IOExceptionEvent event)
           
 void processRequest(javax.sip.RequestEvent requestEvent)
           
 void processResponse(javax.sip.ResponseEvent responseEvent)
           
 void processTimeout(javax.sip.TimeoutEvent timeoutEvent)
           
 void processTransactionTerminated(javax.sip.TransactionTerminatedEvent transactionTerminatedEvent)
           
 void removeHostName(java.lang.String hostName)
          Remove the hostname from the application dispatcher.
 SipContext removeSipApplication(java.lang.String sipApplicationName)
          Remove a sip application to which sip messages can be routed
 java.lang.Object retrieveApplicationRouterConfiguration()
           
 void setBypassRequestExecutor(boolean bypassRequestExecutor)
           
 void setBypassResponseExecutor(boolean bypassResponseExecutor)
           
 void setConcurrencyControlMode(ConcurrencyControlMode concurrencyControlMode)
           
 void setConcurrencyControlModeByName(java.lang.String concurrencyControlMode)
           
 void setCongestionControlCheckingInterval(long congestionControlCheckingInterval)
           
 void setCongestionControlPolicy(CongestionControlPolicy congestionControlPolicy)
           
 void setCongestionControlPolicyByName(java.lang.String congestionControlPolicy)
           
 void setDomain(java.lang.String domain)
           
 void setMemoryThreshold(int memoryThreshold)
           
 void setQueueSize(int queueSize)
           
 void setSipApplicationRouter(SipApplicationRouter sipApplicationRouter)
           
 void start()
          Start the sip application dispatcher
 void stop()
          Stop the sip application dispatcher
 void updateApplicationRouterConfiguration(java.lang.Object configuration)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

congestionControlTimerTask

protected transient SipApplicationDispatcherImpl.CongestionControlTimerTask congestionControlTimerTask

congestionControlTimerFuture

protected transient java.util.concurrent.ScheduledFuture congestionControlTimerFuture

domain

protected java.lang.String domain

oname

protected javax.management.ObjectName oname

mserver

protected javax.management.MBeanServer mserver
Constructor Detail

SipApplicationDispatcherImpl

public SipApplicationDispatcherImpl()
Method Detail

init

public void init()
          throws org.apache.catalina.LifecycleException
Initialize the sip application dispatcher.
It will look for the first implementation of an application routerand packaged in accordance with the rules specified by the Java SE Service Provider framework.
It will first look for the javax.servlet.sip.ar.spi.SipApplicationRouterProvider system property since it can be used to override loading behavior. See JSR 289 Section 15.4.2 Application Router Packaging and Deployment for more information

Specified by:
init in interface SipApplicationDispatcher
Throws:
org.apache.catalina.LifecycleException - The Sip Application Router cannot be initialized correctly

start

public void start()
Start the sip application dispatcher

Specified by:
start in interface SipApplicationDispatcher

stop

public void stop()
Stop the sip application dispatcher

Specified by:
stop in interface SipApplicationDispatcher

addSipApplication

public void addSipApplication(java.lang.String sipApplicationName,
                              SipContext sipApplication)
Add a new sip application to which sip messages can be routed

Specified by:
addSipApplication in interface SipApplicationDispatcher
Parameters:
sipApplicationName - the sip application logical name
sipApplication - the sip context representing the application

removeSipApplication

public SipContext removeSipApplication(java.lang.String sipApplicationName)
Remove a sip application to which sip messages can be routed

Specified by:
removeSipApplication in interface SipApplicationDispatcher
Parameters:
sipApplicationName - the sip application logical name of the application to remove

processIOException

public void processIOException(javax.sip.IOExceptionEvent event)
Specified by:
processIOException in interface javax.sip.SipListener

getNumberOfPendingMessages

public int getNumberOfPendingMessages()

processRequest

public void processRequest(javax.sip.RequestEvent requestEvent)
Specified by:
processRequest in interface javax.sip.SipListener

processResponse

public void processResponse(javax.sip.ResponseEvent responseEvent)
Specified by:
processResponse in interface javax.sip.SipListener

processDialogTerminated

public void processDialogTerminated(javax.sip.DialogTerminatedEvent dialogTerminatedEvent)
Specified by:
processDialogTerminated in interface javax.sip.SipListener

processTimeout

public void processTimeout(javax.sip.TimeoutEvent timeoutEvent)
Specified by:
processTimeout in interface javax.sip.SipListener

processTransactionTerminated

public void processTransactionTerminated(javax.sip.TransactionTerminatedEvent transactionTerminatedEvent)
Specified by:
processTransactionTerminated in interface javax.sip.SipListener

getApplicationNameFromHash

public java.lang.String getApplicationNameFromHash(java.lang.String hash)
Specified by:
getApplicationNameFromHash in interface SipApplicationDispatcher

getHashFromApplicationName

public java.lang.String getHashFromApplicationName(java.lang.String appName)
Specified by:
getHashFromApplicationName in interface SipApplicationDispatcher

isRouteExternal

public final boolean isRouteExternal(javax.sip.header.RouteHeader routeHeader)
Check if the route is external

Specified by:
isRouteExternal in interface SipApplicationDispatcher
Parameters:
routeHeader - the route to check
Returns:
true if the route is external, false otherwise

isViaHeaderExternal

public final boolean isViaHeaderExternal(javax.sip.header.ViaHeader viaHeader)
Check if the via header is external

Specified by:
isViaHeaderExternal in interface SipApplicationDispatcher
Parameters:
viaHeader - the via header to check
Returns:
true if the via header is external, false otherwise

isExternal

public final boolean isExternal(java.lang.String host,
                                int port,
                                java.lang.String transport)
Check whether or not the triplet host, port and transport are corresponding to an interface

Specified by:
isExternal in interface SipApplicationDispatcher
Parameters:
host - can be hostname or ipaddress
port - port number
transport - transport used
Returns:
true if the triplet host, port and transport are corresponding to an interface false otherwise

getSipApplicationRouter

public SipApplicationRouter getSipApplicationRouter()
Specified by:
getSipApplicationRouter in interface SipApplicationDispatcher
Returns:
the sipApplicationRouter

setSipApplicationRouter

public void setSipApplicationRouter(SipApplicationRouter sipApplicationRouter)
Parameters:
sipApplicationRouter - the sipApplicationRouter to set

getSipNetworkInterfaceManager

public SipNetworkInterfaceManager getSipNetworkInterfaceManager()
Description copied from interface: SipApplicationDispatcher
Retrieve the manager for the sip network interfaces for this application dispatcher

Specified by:
getSipNetworkInterfaceManager in interface SipApplicationDispatcher
Returns:
the manager for the sip network interfaces for this application dispatcher

getSipFactory

public SipFactoryImpl getSipFactory()
Description copied from interface: SipApplicationDispatcher
retrieve the sip factory

Specified by:
getSipFactory in interface SipApplicationDispatcher
Returns:
the sip factory

getOutboundInterfaces

public java.util.List<SipURI> getOutboundInterfaces()
Description copied from interface: SipApplicationDispatcher
Returns An immutable instance of the java.util.List interface containing the SipURI representation of IP addresses which are used by the container to send out the messages.

Specified by:
getOutboundInterfaces in interface SipApplicationDispatcher
Returns:
immutable List containing the SipURI representation of IP addresses

addHostName

public void addHostName(java.lang.String hostName)
Description copied from interface: SipApplicationDispatcher
Add a new hostname to the application dispatcher. This information is used for the routing algorithm of an incoming Request.

Specified by:
addHostName in interface SipApplicationDispatcher
Parameters:
hostName - the host name

findHostNames

public java.util.Set<java.lang.String> findHostNames()
Description copied from interface: SipApplicationDispatcher
Returns An immutable instance of the java.util.List interface containing the sip application dispatcher registered host names

Specified by:
findHostNames in interface SipApplicationDispatcher
Returns:
An immutable instance of the java.util.List interface containing the sip application dispatcher registered host names

removeHostName

public void removeHostName(java.lang.String hostName)
Description copied from interface: SipApplicationDispatcher
Remove the hostname from the application dispatcher. This information is used for the routing algorithm of an incoming Request.

Specified by:
removeHostName in interface SipApplicationDispatcher
Parameters:
hostName - the host name

getNextInterestedApplication

public SipApplicationRouterInfo getNextInterestedApplication(SipServletRequestImpl sipServletRequest)
Specified by:
getNextInterestedApplication in interface SipApplicationDispatcher
Returns:

getAsynchronousExecutor

public java.util.concurrent.ThreadPoolExecutor getAsynchronousExecutor()

findSipApplications

public java.util.Iterator<SipContext> findSipApplications()
Description copied from interface: SipApplicationDispatcher
Find the sip applications to which sip messages can currently be routed

Specified by:
findSipApplications in interface SipApplicationDispatcher
Returns:
the sip applications to which sip messages can currently be routed

findSipApplication

public SipContext findSipApplication(java.lang.String applicationName)
Description copied from interface: SipApplicationDispatcher
Find the sip application to which sip messages can currently be routed by its name

Specified by:
findSipApplication in interface SipApplicationDispatcher
Parameters:
applicationName - the name of the application
Returns:
the sip application to which sip messages can currently be routed by its name if it has been find, null otherwise

getObjectName

public javax.management.ObjectName getObjectName()

getDomain

public java.lang.String getDomain()
Specified by:
getDomain in interface SipApplicationDispatcher

setDomain

public void setDomain(java.lang.String domain)
Specified by:
setDomain in interface SipApplicationDispatcher

postDeregister

public void postDeregister()
Specified by:
postDeregister in interface javax.management.MBeanRegistration

postRegister

public void postRegister(java.lang.Boolean registrationDone)
Specified by:
postRegister in interface javax.management.MBeanRegistration

preDeregister

public void preDeregister()
                   throws java.lang.Exception
Specified by:
preDeregister in interface javax.management.MBeanRegistration
Throws:
java.lang.Exception

preRegister

public javax.management.ObjectName preRegister(javax.management.MBeanServer server,
                                               javax.management.ObjectName name)
                                        throws java.lang.Exception
Specified by:
preRegister in interface javax.management.MBeanRegistration
Throws:
java.lang.Exception

findInstalledSipApplications

public java.lang.String[] findInstalledSipApplications()

retrieveApplicationRouterConfiguration

public java.lang.Object retrieveApplicationRouterConfiguration()

updateApplicationRouterConfiguration

public void updateApplicationRouterConfiguration(java.lang.Object configuration)

getConcurrencyControlMode

public ConcurrencyControlMode getConcurrencyControlMode()
Specified by:
getConcurrencyControlMode in interface SipApplicationDispatcher

setConcurrencyControlMode

public void setConcurrencyControlMode(ConcurrencyControlMode concurrencyControlMode)
Specified by:
setConcurrencyControlMode in interface SipApplicationDispatcher

getQueueSize

public int getQueueSize()
Specified by:
getQueueSize in interface SipApplicationDispatcher

setQueueSize

public void setQueueSize(int queueSize)
Specified by:
setQueueSize in interface SipApplicationDispatcher

setConcurrencyControlModeByName

public void setConcurrencyControlModeByName(java.lang.String concurrencyControlMode)
Specified by:
setConcurrencyControlModeByName in interface SipApplicationDispatcher

getRequestsProcessed

public long getRequestsProcessed()
Returns:
the requestsProcessed

getResponsesProcessed

public long getResponsesProcessed()
Returns:
the requestsProcessed

setCongestionControlCheckingInterval

public void setCongestionControlCheckingInterval(long congestionControlCheckingInterval)
Specified by:
setCongestionControlCheckingInterval in interface SipApplicationDispatcher
Parameters:
congestionControlCheckingInterval - the congestionControlCheckingInterval to set

getCongestionControlCheckingInterval

public long getCongestionControlCheckingInterval()
Specified by:
getCongestionControlCheckingInterval in interface SipApplicationDispatcher
Returns:
the congestionControlCheckingInterval

setCongestionControlPolicy

public void setCongestionControlPolicy(CongestionControlPolicy congestionControlPolicy)
Specified by:
setCongestionControlPolicy in interface SipApplicationDispatcher
Parameters:
congestionControlPolicy - the congestionControlPolicy to set

setCongestionControlPolicyByName

public void setCongestionControlPolicyByName(java.lang.String congestionControlPolicy)
Specified by:
setCongestionControlPolicyByName in interface SipApplicationDispatcher

getCongestionControlPolicy

public CongestionControlPolicy getCongestionControlPolicy()
Specified by:
getCongestionControlPolicy in interface SipApplicationDispatcher
Returns:
the congestionControlPolicy

setMemoryThreshold

public void setMemoryThreshold(int memoryThreshold)
Specified by:
setMemoryThreshold in interface SipApplicationDispatcher
Parameters:
memoryThreshold - the memoryThreshold to set

getMemoryThreshold

public int getMemoryThreshold()
Specified by:
getMemoryThreshold in interface SipApplicationDispatcher
Returns:
the memoryThreshold

getNumberOfMessagesInQueue

public int getNumberOfMessagesInQueue()
Specified by:
getNumberOfMessagesInQueue in interface SipApplicationDispatcher
Returns:
the numberOfMessagesInQueue

getPercentageOfMemoryUsed

public double getPercentageOfMemoryUsed()
Specified by:
getPercentageOfMemoryUsed in interface SipApplicationDispatcher
Returns:
the percentageOfMemoryUsed

setBypassRequestExecutor

public void setBypassRequestExecutor(boolean bypassRequestExecutor)
Specified by:
setBypassRequestExecutor in interface SipApplicationDispatcher
Parameters:
bypassRequestExecutor - the bypassRequestExecutor to set

isBypassRequestExecutor

public boolean isBypassRequestExecutor()
Specified by:
isBypassRequestExecutor in interface SipApplicationDispatcher
Returns:
the bypassRequestExecutor

setBypassResponseExecutor

public void setBypassResponseExecutor(boolean bypassResponseExecutor)
Specified by:
setBypassResponseExecutor in interface SipApplicationDispatcher
Parameters:
bypassResponseExecutor - the bypassResponseExecutor to set

isBypassResponseExecutor

public boolean isBypassResponseExecutor()
Specified by:
isBypassResponseExecutor in interface SipApplicationDispatcher
Returns:
the bypassResponseExecutor


Copyright © 2009. All Rights Reserved.