org.echarts.servlet.sip
Class SipPort

java.lang.Object
  extended by org.echarts.Port
      extended by org.echarts.LocalPort
          extended by org.echarts.OutputPort
              extended by org.echarts.ExternalPort
                  extended by org.echarts.servlet.sip.Port
                      extended by org.echarts.servlet.sip.SipPort
All Implemented Interfaces:
java.io.Serializable, java.rmi.Remote, ExternalPortReference, PortReference

public class SipPort
extends Port

Port used for sending and receiving SIP messages. Can only be used for a single SIP dialog.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.echarts.servlet.sip.Port
box, portMonitor
 
Fields inherited from class org.echarts.LocalPort
inputQueue
 
Fields inherited from interface org.echarts.PortReference
serialVersionUID
 
Method Summary
 void bind(SipServletRequest req)
          Set up a bidirectional association between this port and the SipSession to which this message belongs.
 void copyHeaders(SipServletMessage from, SipServletMessage to)
          Copy (safe, non-system) headers from one message to another.
 void copyNoBodyHeaders(SipServletMessage from, SipServletMessage to)
          Copy (safe, non-system) headers from one message to another.
 void copyRouteHeaders(SipServletRequest from, SipServletRequest to, java.util.ListIterator modRouteHeaders)
          Copy route headers from one message to another.
 SipServletRequest createInvite(Address from, Address to)
          Create a new initial INVITE with the specified From and To and set up the bidirectional association between this port and its SipSession.
 SipServletRequest createInvite(SipServletRequest invite)
          Create a new initial INVITE based on existing invite, and set up the bidirectional association between this port and its SipSession.
 SipServletRequest createInvite(SipServletRequest invite, RequestModifier reqModifier)
          Create a new initial INVITE based on existing invite, apply RequestModifier, and set up the bidirectional association between this port and its SipSession.
 SipServletRequest createInvite(SipServletRequest oldReq, RequestModifier reqModifier, SipApplicationRoutingDirective routingDirective)
          Create a new initial INVITE, apply RequestModifier, and set up the bidirectional association between this port and its SipSession.
 SipServletRequest createInvite(URI from, URI to)
          Create a new initial INVITE with the specified From and To and set up the bidirectional association between this port and its SipSession.
 SipServletRequest createNoBodyInvite(SipServletRequest invite, RequestModifier reqModifier, SipApplicationRoutingDirective routingDirective)
          Create a new initial INVITE, apply RequestModifier, and set up the bidirectional association between this port and its SipSession.
 SipServletRequest createNoBodyRequest(SipServletRequest oldreq)
          Create a new non-initial SipServletRequest (e.g., re-INVITE, BYE, INFO) on this port/session based on the supplied request.
 SipServletResponse createNoBodyResponse(SipServletResponse oldResponse, SipServletRequest req)
          Create a SipServletResponse for the specified request, based on the specified response.
 SipServletRequest createRequest(SipServletRequest oldreq)
          Create a new non-initial SipServletRequest (e.g., re-INVITE, BYE, INFO) on this port/session based on the supplied request.
 SipServletRequest createRequest(java.lang.String method)
          Create a new non-initial SipServletRequest (e.g., re-INVITE, BYE, INFO) on this port/session.
 SipServletResponse createResponse(int status, SipServletRequest req)
          Create a SipServletResponse with the specified status for the specified request.
 SipServletResponse createResponse(SipServletResponse oldResponse, SipServletRequest req)
          Create a SipServletResponse for the specified request, based on the specified response.
 SipServletRequest createStatusMessage(java.lang.String type, java.util.Properties props)
          Create a Status message that can be read by other applications in the usage.
 void destroy()
          Destroy port.
 java.lang.Object getAttribute(java.lang.String attrName)
          Get the value of an attribute on the SipSession associated with this SipPort.
 SipServletRequest getInitialRequest()
          get initial request for this port.
 java.lang.Object getLastReceivedSDP()
          Returns the last SDP received on this SipPort.
 void input(SipServletMessage message)
          Inputs a message to this port's FIFO.
protected  boolean isContainerRoute(SipURI routeURI, SipServletMessage from)
          Determine if a particular URI points to container address.
 boolean isReadyToInvalidate()
          Returns true if associated SipSession is in a ready-to-invalidate state.
 boolean isValid()
          Returns true if associated SipSession is valid.
 void output(java.lang.Object message, Machine machine)
          Outputs a message to the port's peer FIFO.
 void removeAttribute(java.lang.String attrName)
          Remove an attribute from the SipSession associated with this SipPort.
 void setAttribute(java.lang.String attrName, java.lang.Object attr)
          Set the value an attribute on the SipSession associated with this SipPort.
 void setInitialRequest(SipServletRequest req)
          set initial request for this port.
 
Methods inherited from class org.echarts.servlet.sip.Port
getBox, isDestroyed
 
Methods inherited from class org.echarts.ExternalPort
getMonitorProperties, getRemote, input, setPeer, toString
 
Methods inherited from class org.echarts.LocalPort
clearMachineReference, getDynamicChildIndex, getDynamicParent, getInputQueue, isPossiblyReferencedBy, isPossiblyReferencedBySupermachineOf, isUniquelyReferenced, isUniquelyReferencedByMachine, setMachineReference
 
Methods inherited from class org.echarts.Port
equals, getID
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.echarts.PortReference
getID
 

Method Detail

bind

public void bind(SipServletRequest req)
          throws PortException
Set up a bidirectional association between this port and the SipSession to which this message belongs. Used to associate a port with a request that was received on the BoxPort so that further messages received on this SipSession are assigned to the correct port.

Parameters:
req - in SipSession to be bound to this port
Throws:
PortException

createInvite

public SipServletRequest createInvite(SipServletRequest invite)
Create a new initial INVITE based on existing invite, and set up the bidirectional association between this port and its SipSession.

Parameters:
invite - existing invite upon which to base created invite
Returns:
the created INVITE request

createInvite

public SipServletRequest createInvite(SipServletRequest invite,
                                      RequestModifier reqModifier)
Create a new initial INVITE based on existing invite, apply RequestModifier, and set up the bidirectional association between this port and its SipSession. If using application router, this will be a CONTINUEd request.

Parameters:
invite - existing invite upon which to base created invite
reqModifier - desired RequestModifier to apply to existing invite
Returns:
the created INVITE request

createInvite

public SipServletRequest createInvite(Address from,
                                      Address to)
Create a new initial INVITE with the specified From and To and set up the bidirectional association between this port and its SipSession. If using application router, this will be a NEW request.

Parameters:
from - desired From address
to - desired To address
Returns:
the created INVITE request

createInvite

public SipServletRequest createInvite(URI from,
                                      URI to)
Create a new initial INVITE with the specified From and To and set up the bidirectional association between this port and its SipSession. Is using application router, this will be a NEW request.

Parameters:
from - desired From address
to - desired To address
Returns:
the created INVITE request

createInvite

public SipServletRequest createInvite(SipServletRequest oldReq,
                                      RequestModifier reqModifier,
                                      SipApplicationRoutingDirective routingDirective)
Create a new initial INVITE, apply RequestModifier, and set up the bidirectional association between this port and its SipSession.

Parameters:
invite - The original received INVITE request that is to be relayed
reqModifier - Request modifier that may modify different headers in the created INVITE request
routingDirective - Routing directive for the application router
Returns:
the created INVITE request

createNoBodyInvite

public SipServletRequest createNoBodyInvite(SipServletRequest invite,
                                            RequestModifier reqModifier,
                                            SipApplicationRoutingDirective routingDirective)
Create a new initial INVITE, apply RequestModifier, and set up the bidirectional association between this port and its SipSession. Does not copy body and associated content headers from original INVITE request.

Parameters:
invite - The original received INVITE request that is to be relayed
reqModifier - Request modifier that may modify different headers in the created INVITE request
routingDirective - Routing directive for the application router
Returns:
the created INVITE request

createRequest

public final SipServletRequest createRequest(java.lang.String method)
Create a new non-initial SipServletRequest (e.g., re-INVITE, BYE, INFO) on this port/session.

Parameters:
method - desired SIP method
Returns:
newly-created request

createRequest

public final SipServletRequest createRequest(SipServletRequest oldreq)
Create a new non-initial SipServletRequest (e.g., re-INVITE, BYE, INFO) on this port/session based on the supplied request.

Parameters:
oldreq - existing request upon which to base new request
Returns:
newly-created request

createNoBodyRequest

public final SipServletRequest createNoBodyRequest(SipServletRequest oldreq)
Create a new non-initial SipServletRequest (e.g., re-INVITE, BYE, INFO) on this port/session based on the supplied request. Does not copy message body and associated content headers.

Parameters:
oldreq - existing request upon which to base new request
Returns:
newly-created request

createStatusMessage

public final SipServletRequest createStatusMessage(java.lang.String type,
                                                   java.util.Properties props)
Create a Status message that can be read by other applications in the usage.

Parameters:
type - user-defined message type
props - user-defined message properties
Returns:
created Status message

createResponse

public final SipServletResponse createResponse(int status,
                                               SipServletRequest req)
Create a SipServletResponse with the specified status for the specified request.

Parameters:
status - desired response code
req - to which to respond
Returns:
newly-created response

createResponse

public final SipServletResponse createResponse(SipServletResponse oldResponse,
                                               SipServletRequest req)
Create a SipServletResponse for the specified request, based on the specified response.

Parameters:
oldResponse - existing response to base new response on
req - request to which to respond
Returns:
newly-created response

createNoBodyResponse

public final SipServletResponse createNoBodyResponse(SipServletResponse oldResponse,
                                                     SipServletRequest req)
Create a SipServletResponse for the specified request, based on the specified response. Does not copy body and associated content headers from specified oldResponse.

Parameters:
oldResponse - existing response to base new response on
req - request to which to respond
Returns:
newly-created response

copyHeaders

public final void copyHeaders(SipServletMessage from,
                              SipServletMessage to)
Copy (safe, non-system) headers from one message to another.

Parameters:
from - - old message
to - - new message

copyNoBodyHeaders

public final void copyNoBodyHeaders(SipServletMessage from,
                                    SipServletMessage to)
Copy (safe, non-system) headers from one message to another. Also does not copy content-type or content-length headers.

Parameters:
from - - old message
to - - new message

copyRouteHeaders

public final void copyRouteHeaders(SipServletRequest from,
                                   SipServletRequest to,
                                   java.util.ListIterator modRouteHeaders)
Copy route headers from one message to another. Only used for initial request.

Parameters:
from - - old message
to - - new message
modRouteHeaders - - modified routes

getLastReceivedSDP

public java.lang.Object getLastReceivedSDP()
Returns the last SDP received on this SipPort.

Returns:
last received SDP, or null if none received.

setAttribute

public void setAttribute(java.lang.String attrName,
                         java.lang.Object attr)
Set the value an attribute on the SipSession associated with this SipPort.

Parameters:
attrName - attribute name
attr - attribute value

getAttribute

public java.lang.Object getAttribute(java.lang.String attrName)
Get the value of an attribute on the SipSession associated with this SipPort.

Parameters:
attrName - attribute name
Returns:
value of the attribute, or null if not present

removeAttribute

public void removeAttribute(java.lang.String attrName)
Remove an attribute from the SipSession associated with this SipPort.

Parameters:
attrName - name of attribute to remove

isContainerRoute

protected boolean isContainerRoute(SipURI routeURI,
                                   SipServletMessage from)
Determine if a particular URI points to container address.

Parameters:
routeURI - URI to test
from - received message
Returns:
true if the value of routeURI points to container address

output

public void output(java.lang.Object message,
                   Machine machine)
            throws java.rmi.RemoteException,
                   SessionMismatchException,
                   java.io.IOException,
                   PortException
Outputs a message to the port's peer FIFO. Overrides parent method.

Overrides:
output in class ExternalPort
Parameters:
message - - message to be output by this port
Throws:
PortException - - if message is not a SipServletMessage
SessionMismatchException - - if message was not created by this port
java.io.IOException - - from message.send()
java.rmi.RemoteException - - TODO

input

public void input(SipServletMessage message)
           throws FeatureBoxException,
                  PortException
Inputs a message to this port's FIFO. Overrides parent method.

Parameters:
message - - message to be input for this port
Throws:
FeatureBoxException - in case of FSM error
PortException

setInitialRequest

public final void setInitialRequest(SipServletRequest req)
set initial request for this port.

Parameters:
req - initial request

getInitialRequest

public final SipServletRequest getInitialRequest()
get initial request for this port.

Returns:
initial request

destroy

public final void destroy()
Destroy port. SIP dialog must be properly terminated before calling this method.

Overrides:
destroy in class Port

isReadyToInvalidate

public final boolean isReadyToInvalidate()
Returns true if associated SipSession is in a ready-to-invalidate state.

Returns:
See Also:
SipSession.isReadyToInvalidate()

isValid

public final boolean isValid()
Returns true if associated SipSession is valid.

Returns:
See Also:
SipSession.isValid()