Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.opencloud.slee.services.sip.common
Class AbstractSipProxy  view AbstractSipProxy download AbstractSipProxy.java

java.lang.Object
  extended bycom.opencloud.slee.services.sip.common.MessageHandler
      extended bycom.opencloud.slee.services.sip.common.AbstractSipProxy

public abstract class AbstractSipProxy
extends MessageHandler

A template class that does much of what a typical SIP proxy would do, according to RFC3261 section 16. Applications should override the methods called by processRequest and processResponse to implement specific features.


Field Summary
 
Fields inherited from class com.opencloud.slee.services.sip.common.MessageHandler
config
 
Constructor Summary
AbstractSipProxy(SipServerConfig config)
           
 
Method Summary
 void addRecordRouteHeader(Request request)
          Adds a default Record-Route header to the request.
 void addViaHeader(Request request)
          Adds a default Via header to the request.
 void checkMaxForwards(ServerTransaction txn, Request request)
          Validate the max-forwards header throw a user error exception (too many hops) if max-forwards reaches 0.
 void decrementMaxForwards(Request request)
          Decrement the value of max-forwards.
 java.util.List determineRequestTargets(Request request)
          Determines target SIP URI(s) for request, using location service or other criteria.
 URI findLocalTarget(URI uri)
          Attempts to find a locally registered contact address for the given URI, using the location service interface.
 void forwardRequest(ServerTransaction txn, Request request)
          Forwards request on to destination.
 void forwardResponse(ServerTransaction txn, Response response)
           
 void processRequest(ServerTransaction txn, Request request)
          This method defines the default behaviour for a proxy procesing a request.
 void processResponse(ServerTransaction serverTransaction, Response response)
          Generic proxy response processing
 void routePreProcess(Request request)
          Check for strict-routing style route headers and swap with Request-URI if applicable.
 void sendErrorResponse(ServerTransaction txn, Request request, int statusCode)
           
 void validateRequest(ServerTransaction txn, Request request)
          Performs request validation as per RFC 3261 section 16.3.
 
Methods inherited from class com.opencloud.slee.services.sip.common.MessageHandler
getCanonicalAddress, getDomain, isLocalDomain, isSupportedURIScheme
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractSipProxy

public AbstractSipProxy(SipServerConfig config)
Method Detail

processRequest

public void processRequest(ServerTransaction txn,
                           Request request)
This method defines the default behaviour for a proxy procesing a request. Implementations should override as appropriate to customize proxy behaviour. Steps in processing a request, from RFC3261: 16.3 Request Validation 16.4 Route Information Preprocessing 16.5 Determining Request Targets 16.6 Request Forwarding 1. Copy request 2. Set Request-URI 3. Decrement Max-Forwards 4. Add Record-Route 5. Add Additional Header Fields 6. Postprocess routing information 7. Determine Next-Hop Address, Port and Transport 8. Add a Via header field value 9. Add a Content-Leangth header field if necessary 10. Forward Request 11. Set timer C

Specified by:
processRequest in class MessageHandler

sendErrorResponse

public void sendErrorResponse(ServerTransaction txn,
                              Request request,
                              int statusCode)

forwardRequest

public void forwardRequest(ServerTransaction txn,
                           Request request)
Forwards request on to destination. This method should be overridden to preserve state (eg. client txn -> server txn mapping) by proxy implementations


validateRequest

public void validateRequest(ServerTransaction txn,
                            Request request)
                     throws SipSendErrorResponseException
Performs request validation as per RFC 3261 section 16.3. If a request fails validation, throw exception to cause appropriate error response to client.


checkMaxForwards

public void checkMaxForwards(ServerTransaction txn,
                             Request request)
                      throws SipSendErrorResponseException
Validate the max-forwards header throw a user error exception (too many hops) if max-forwards reaches 0.


findLocalTarget

public URI findLocalTarget(URI uri)
                    throws SipSendErrorResponseException
Attempts to find a locally registered contact address for the given URI, using the location service interface.


addViaHeader

public void addViaHeader(Request request)
Adds a default Via header to the request. Override to provide a different Via header.


addRecordRouteHeader

public void addRecordRouteHeader(Request request)
Adds a default Record-Route header to the request. Override to provide a different Record-Route header.


decrementMaxForwards

public void decrementMaxForwards(Request request)
                          throws SipSendErrorResponseException
Decrement the value of max-forwards. If no max-forwards header present, create a max-forwards header with the RFC3261 recommended default value


routePreProcess

public void routePreProcess(Request request)
                     throws SipSendErrorResponseException
Check for strict-routing style route headers and swap with Request-URI if applicable.


determineRequestTargets

public java.util.List determineRequestTargets(Request request)
                                       throws SipSendErrorResponseException
Determines target SIP URI(s) for request, using location service or other criteria. TODO: Forking (return more than one target)


processResponse

public void processResponse(ServerTransaction serverTransaction,
                            Response response)
Generic proxy response processing

Specified by:
processResponse in class MessageHandler

forwardResponse

public void forwardResponse(ServerTransaction txn,
                            Response response)