FileDocCategorySizeDatePackage
NistSipMessageFactoryImpl.javaAPI DocphoneME MR2 API (J2ME)6070Wed May 02 18:00:42 BST 2007gov.nist.siplite

NistSipMessageFactoryImpl

public class NistSipMessageFactoryImpl extends Object implements SIPStackMessageFactory
Implements all the support classes that are necessary for the nist-sip stack on which the jain-sip stack has been based. This is a mapping class to map from the NIST-SIP abstractions to the JAIN abstractions. (i.e. It is the glue code that ties the NIST-SIP event model and the JAIN-SIP event model together. When a SIP Request or SIP Response is read from the corresponding messageChannel, the NIST-SIP stack calls the SIPStackMessageFactory implementation that has been registered with it to process the request.)
version
JAIN-SIP-1.1 This code is in the public domain.

Fields Summary
private SipStack
sipStackImpl
Current SIP stack context.
Constructors Summary
public NistSipMessageFactoryImpl(SipStack sipStackImpl)
Contrictor.

param
sipStackImpl current SIP stack context

        this.sipStackImpl = sipStackImpl;
    
Methods Summary
public SIPServerRequestInterfacenewSIPServerRequest(Request sipRequest, MessageChannel messageChannel)
Constructs a new SIP Server Request.

param
sipRequest is the Request from which the SIPServerRequest is to be constructed.
param
messageChannel is the MessageChannel abstraction for this SIPServerRequest.
return
a new SIP Server Request handle


        if (messageChannel == null || sipRequest == null)  {
            throw new IllegalArgumentException("Null Arg!");
        }
        
        NistSipMessageHandlerImpl retval = new NistSipMessageHandlerImpl();
        if (messageChannel instanceof Transaction) {
            // If the transaction has already been created
            // then set the transaction channel.
            retval.transactionChannel = (Transaction)messageChannel;
        }
        SIPTransactionStack theStack =
                (SIPTransactionStack) messageChannel.getSIPStack();

        /*
         * IMPL_NOTE :
         * May not need to initialize listeningPoint like this. Please refer to
         * processRequest() method in NistSipMessageHandlerImpl
         */
        retval.listeningPoint =
                messageChannel.getMessageProcessor().getListeningPoint();
        
        if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
            Logging.report(Logging.INFORMATION, LogChannels.LC_JSR180,
                "Returning request interface for " +
                sipRequest.getFirstLine() + " " + retval +
                " messageChannel = " + messageChannel);
        }
        
        return  retval;
    
public SIPServerResponseInterfacenewSIPServerResponse(Response sipResponse, MessageChannel messageChannel)
Generates a new server response for the stack.

param
sipResponse is the Request from which the SIPServerRequest is to be constructed.
param
messageChannel is the MessageChannel abstraction for this SIPServerResponse
return
a new SIP Server Response handle

        try {
            NistSipMessageHandlerImpl retval = new NistSipMessageHandlerImpl();
            SIPTransactionStack theStack = (SIPTransactionStack)
            messageChannel.getSIPStack();
            SipStack sipStackImpl = (SipStack) theStack;
            // Tr is null if a transaction is not mapped.
            Transaction tr =
                    (Transaction)
                    ((SIPTransactionStack)theStack).
                    findTransaction(sipResponse, false);
            
            retval.transactionChannel = tr;
            
            if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
                Logging.report(Logging.INFORMATION, LogChannels.LC_JSR180,
                    "Found Transaction " + tr + " for " + sipResponse);
                Logging.report(Logging.INFORMATION, LogChannels.LC_JSR180,
                    "MessageProcessor = " +
                    messageChannel.getMessageProcessor() + "/" +
                    messageChannel.getMessageProcessor().getListeningPoint());
            }
            
            ListeningPoint lp =
                    messageChannel.getMessageProcessor().getListeningPoint();
            
            retval.listeningPoint = lp;
            return  retval;
            
        } catch (RuntimeException ex) {
            if (Logging.REPORT_LEVEL <= Logging.ERROR) {
                Logging.report(Logging.ERROR, LogChannels.LC_JSR180,
                    "runtime exception caught!");
                ex.printStackTrace();
            }
            return null;
        }