Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package test.tck.msgflow.callflows;
  
  import java.util.HashSet;
  import java.util.Iterator;
  

Author(s):
M. Ranganathan
 
 public class ProtocolObjects {
     public final AddressFactory addressFactory;
 
     public final MessageFactory messageFactory;
 
     public final HeaderFactory headerFactory;
 
     public final SipStack sipStack;
 
     public int logLevel = 32;
 
     String logFileDirectory = "logs/";
 
     public final String transport;
 
     private boolean isStarted;
 
 	public boolean autoDialog;
 	
 
     public ProtocolObjects(String stacknameString pathnameString transport,
             boolean autoDialogboolean isBackToBackUserAgent) {
 
     	this. = autoDialog;
         this. = transport;
         SipFactory sipFactory = SipFactory.getInstance();
         sipFactory.resetFactory();
         sipFactory.setPathName(pathname);
         Properties properties = new Properties();
         properties.setProperty("javax.sip.STACK_NAME"stackname);
 
         // The following properties are specific to nist-sip
         // and are not necessarily part of any other jain-sip
         // implementation.
         properties.setProperty("gov.nist.javax.sip.DEBUG_LOG"
                 + stackname + "debuglog.txt");
         properties.setProperty("gov.nist.javax.sip.SERVER_LOG",
                  + stackname + "log.txt");
 
         properties.setProperty("javax.sip.AUTOMATIC_DIALOG_SUPPORT",
                 (autoDialog ? "on" : "off"));
 
         // For the forked subscribe notify test
         properties.setProperty("javax.sip.FORKABLE_EVENTS""foo");
 
         //For the TelUrlRouter test.
         properties.setProperty("javax.sip.ROUTER_PATH"NonSipUriRouter.class.getName());
 
         // Dont use the router for all requests.
         properties.setProperty("javax.sip.USE_ROUTER_FOR_ALL_URIS""false");
 
 
         properties.setProperty("gov.nist.javax.sip.THREAD_POOL_SIZE""1");
         
         properties.setProperty("gov.nist.javax.sip.IS_BACK_TO_BACK_USER_AGENT", Boolean.toString(isBackToBackUserAgent));
         
         properties.setProperty("gov.nist.javax.sip.DELIVER_RETRANSMITTED_ACK_TO_LISTENER""true");
 
 
 
         // Set to 0 in your production code for max speed.
         // You need 16 for logging traces. 32 for debug + traces.
         // Your code will limp at 32 but it is best for debugging.
         properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL"new Integer(
                 ).toString());
 
         try {
             // Create SipStack object
              = sipFactory.createSipStack(properties);
 
             NonSipUriRouter router = (NonSipUriRouter.getRouter();
 
             router.setMyPort(5080);
 
             ..println("createSipStack " + );
         } catch (Exception e) {
             // could not find
             // gov.nist.jain.protocol.ip.sip.SipStackImpl
             // in the classpath
             e.printStackTrace();
            ..println(e.getMessage());
            throw new RuntimeException("Stack failed to initialize");
        }
        try {
             = sipFactory.createHeaderFactory();
             = sipFactory.createAddressFactory();
             = sipFactory.createMessageFactory();
        } catch (SipException ex) {
            ex.printStackTrace();
            throw new RuntimeException(ex);
        }
    }
    public synchronized void destroy() {
        HashSet hashSet = new HashSet();
        for (Iterator it = .getSipProviders(); it.hasNext();) {
            SipProvider sipProvider = (SipProviderit.next();
            hashSet.add(sipProvider);
        }
        for ( Iterator it = hashSet.iterator(); it.hasNext();) {
            SipProvider sipProvider = (SipProviderit.next();
            for (int j = 0; j < 5; j++) {
                try {
                    .deleteSipProvider(sipProvider);
                } catch (ObjectInUseException ex) {
                    try {
                        Thread.sleep(1000);
                    } catch (Exception e) {
                    }
                }
            }
        }
        .stop();
    }
    public void start() throws Exception {
        if (this.)
            return;
        .start();
        this. = true;
    }
New to GrepCode? Check out our FAQ X