Source Code Cross Referenced for ProtocolObjects.java in  » 6.0-JDK-Modules » Java-Advanced-Imaging » test » tck » msgflow » callflows » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » Java Advanced Imaging » test.tck.msgflow.callflows 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package test.tck.msgflow.callflows;
002:
003:        import java.util.HashSet;
004:        import java.util.Iterator;
005:        import java.util.Properties;
006:
007:        import javax.sip.ObjectInUseException;
008:        import javax.sip.SipException;
009:        import javax.sip.SipFactory;
010:        import javax.sip.SipProvider;
011:        import javax.sip.SipStack;
012:        import javax.sip.address.AddressFactory;
013:        import javax.sip.header.HeaderFactory;
014:        import javax.sip.message.MessageFactory;
015:
016:        /**
017:         * @author M. Ranganathan
018:         * 
019:         */
020:        public class ProtocolObjects {
021:            public final AddressFactory addressFactory;
022:
023:            public final MessageFactory messageFactory;
024:
025:            public final HeaderFactory headerFactory;
026:
027:            public final SipStack sipStack;
028:
029:            public int logLevel = 0;
030:
031:            String logFileDirectory = "logs/";
032:
033:            public final String transport;
034:
035:            private boolean isStarted;
036:
037:            public ProtocolObjects(String stackname, String pathname,
038:                    String transport, boolean autoDialog) {
039:
040:                this .transport = transport;
041:                SipFactory sipFactory = SipFactory.getInstance();
042:                sipFactory.resetFactory();
043:                sipFactory.setPathName(pathname);
044:                Properties properties = new Properties();
045:                properties.setProperty("javax.sip.STACK_NAME", stackname);
046:
047:                // The following properties are specific to nist-sip
048:                // and are not necessarily part of any other jain-sip
049:                // implementation.
050:                properties.setProperty("gov.nist.javax.sip.DEBUG_LOG",
051:                        logFileDirectory + stackname + "debuglog.txt");
052:                properties.setProperty("gov.nist.javax.sip.SERVER_LOG",
053:                        logFileDirectory + stackname + "log.txt");
054:
055:                properties.setProperty("javax.sip.AUTOMATIC_DIALOG_SUPPORT",
056:                        (autoDialog ? "on" : "off"));
057:
058:                // For the forked subscribe notify test
059:                properties.setProperty("javax.sip.FORKABLE_EVENTS", "foo");
060:
061:                //For the TelUrlRouter test.
062:                properties.setProperty("javax.sip.ROUTER_PATH",
063:                        NonSipUriRouter.class.getName());
064:
065:                // Dont use the router for all requests.
066:                properties.setProperty("javax.sip.USE_ROUTER_FOR_ALL_URIS",
067:                        "false");
068:
069:                properties.setProperty("gov.nist.javax.sip.THREAD_POOL_SIZE",
070:                        "1");
071:
072:                // Set to 0 in your production code for max speed.
073:                // You need 16 for logging traces. 32 for debug + traces.
074:                // Your code will limp at 32 but it is best for debugging.
075:                properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL",
076:                        new Integer(logLevel).toString());
077:
078:                try {
079:                    // Create SipStack object
080:                    sipStack = sipFactory.createSipStack(properties);
081:
082:                    NonSipUriRouter router = (NonSipUriRouter) sipStack
083:                            .getRouter();
084:
085:                    router.setMyPort(5080);
086:
087:                    System.out.println("createSipStack " + sipStack);
088:                } catch (Exception e) {
089:                    // could not find
090:                    // gov.nist.jain.protocol.ip.sip.SipStackImpl
091:                    // in the classpath
092:                    e.printStackTrace();
093:                    System.err.println(e.getMessage());
094:                    throw new RuntimeException("Stack failed to initialize");
095:                }
096:
097:                try {
098:                    headerFactory = sipFactory.createHeaderFactory();
099:                    addressFactory = sipFactory.createAddressFactory();
100:                    messageFactory = sipFactory.createMessageFactory();
101:                } catch (SipException ex) {
102:                    ex.printStackTrace();
103:                    throw new RuntimeException(ex);
104:                }
105:            }
106:
107:            public synchronized void destroy() {
108:
109:                HashSet hashSet = new HashSet();
110:
111:                for (Iterator it = sipStack.getSipProviders(); it.hasNext();) {
112:
113:                    SipProvider sipProvider = (SipProvider) it.next();
114:                    hashSet.add(sipProvider);
115:                }
116:
117:                for (Iterator it = hashSet.iterator(); it.hasNext();) {
118:                    SipProvider sipProvider = (SipProvider) it.next();
119:
120:                    for (int j = 0; j < 5; j++) {
121:                        try {
122:                            sipStack.deleteSipProvider(sipProvider);
123:                        } catch (ObjectInUseException ex) {
124:                            try {
125:                                Thread.sleep(1000);
126:                            } catch (Exception e) {
127:                            }
128:
129:                        }
130:                    }
131:                }
132:
133:                sipStack.stop();
134:            }
135:
136:            public void start() throws Exception {
137:                if (this .isStarted)
138:                    return;
139:                sipStack.start();
140:                this .isStarted = true;
141:
142:            }
143:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.