Source Code Cross Referenced for InternalConnectorImpl.java in  » 6.0-JDK-Modules » j2me » com » sun » cdc » io » 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 » j2me » com.sun.cdc.io 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright  1990-2006 Sun Microsystems, Inc. All Rights Reserved.  
003:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER  
004:         *   
005:         * This program is free software; you can redistribute it and/or  
006:         * modify it under the terms of the GNU General Public License version  
007:         * 2 only, as published by the Free Software Foundation.   
008:         *   
009:         * This program is distributed in the hope that it will be useful, but  
010:         * WITHOUT ANY WARRANTY; without even the implied warranty of  
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU  
012:         * General Public License version 2 for more details (a copy is  
013:         * included at /legal/license.txt).   
014:         *   
015:         * You should have received a copy of the GNU General Public License  
016:         * version 2 along with this work; if not, write to the Free Software  
017:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  
018:         * 02110-1301 USA   
019:         *   
020:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa  
021:         * Clara, CA 95054 or visit www.sun.com if you need additional  
022:         * information or have any questions. 
023:         *
024:         */
025:        package com.sun.cdc.io;
026:
027:        import java.io.*;
028:        import javax.microedition.io.*;
029:        import sun.security.action.GetPropertyAction;
030:
031:        public class InternalConnectorImpl implements  InternalConnector {
032:            protected ClassLoader protocolClassLoader;
033:            protected String classRoot;
034:
035:            protected String getClassRoot() {
036:                if (classRoot != null) {
037:                    return classRoot;
038:                }
039:
040:                String profileTemp = null;
041:
042:                try {
043:                    /*
044:                     * Check to see if there is a property override for the dynamic
045:                     * building of class root.
046:                     */
047:                    classRoot = (String) java.security.AccessController
048:                            .doPrivileged(new GetPropertyAction(
049:                                    "javax.microedition.io.Connector.protocolpath"));
050:                } catch (Throwable t) {
051:                    // do nothing
052:                }
053:
054:                if (classRoot == null) {
055:                    classRoot = "com.sun.cdc.io";
056:                }
057:
058:                return classRoot;
059:            }
060:
061:            protected ClassLoader getProtocolClassLoader() {
062:                if (protocolClassLoader != null) {
063:                    return protocolClassLoader;
064:                }
065:
066:                protocolClassLoader = this .getClass().getClassLoader();
067:                return protocolClassLoader;
068:            }
069:
070:            /**
071:             * Create and open a Connection.
072:             *
073:             * @param string           The URL for the connection
074:             * @param mode             The access mode
075:             * @param timeouts         A flag to indicate that the caller
076:             *                         wants timeout exceptions
077:             * @param platform         Platform name
078:             * @return                 A new Connection object
079:             *
080:             * @exception ClassNotFoundException  If the protocol cannot be found.
081:             * @exception IllegalArgumentException If a parameter is invalid.
082:             * @exception ConnectionNotFoundException If the target of the
083:             *   name cannot be found, or if the requested protocol type
084:             *   is not supported.
085:             * @exception IOException If some other kind of I/O error occurs.
086:             * @exception IllegalArgumentException If a parameter is invalid.
087:             */
088:
089:            public Connection open(String name, int mode, boolean timeouts)
090:                    throws IOException {
091:                /* Test for null argument */
092:                if (name == null) {
093:                    throw new IllegalArgumentException("Null URL");
094:                }
095:
096:                /* Look for : as in "http:", "file:", or whatever */
097:                int colon = name.indexOf(':');
098:
099:                /* Test for null argument */
100:                if (colon < 1) {
101:                    throw new IllegalArgumentException("no ':' in URL");
102:                }
103:                try {
104:                    String protocol;
105:
106:                    /* Strip off the protocol name */
107:                    protocol = name.substring(0, colon);
108:
109:                    /* Strip off the rest of the string */
110:                    name = name.substring(colon + 1);
111:
112:                    /*
113:                     * Convert all the '-' characters in the protocol
114:                     * name to '_' characters (dashes are not allowed
115:                     * in class names).  This operation creates garbage
116:                     * only if the protocol name actually contains dashes
117:                     */
118:                    protocol = protocol.replace('-', '_');
119:
120:                    String className = (String) java.security.AccessController
121:                            .doPrivileged(new GetPropertyAction("j2me."
122:                                    + protocol + ".Protocol"));
123:                    /*
124:                     * Use the platform and protocol names to look up
125:                     * a class to implement the connection
126:                     */
127:                    if (className == null) {
128:                        className = getClassRoot() + "." + "j2me" + "."
129:                                + protocol + ".Protocol";
130:                    }
131:                    Class clazz = Class.forName(className, true,
132:                            getProtocolClassLoader());
133:
134:                    /* Construct a new instance of the protocol */
135:                    ConnectionBaseInterface uc = (ConnectionBaseInterface) clazz
136:                            .newInstance();
137:
138:                    /* Open the connection, and return it */
139:                    return uc.openPrim(name, mode, timeouts);
140:                } catch (InstantiationException x) {
141:                    throw new IOException(x.toString());
142:                } catch (IllegalAccessException x) {
143:                    throw new IOException(x.toString());
144:                } catch (ClassCastException x) {
145:                    throw new IOException(x.toString());
146:                } catch (ClassNotFoundException x) {
147:                    throw new ConnectionNotFoundException(
148:                            "The requested protocol does not exist " + name);
149:                }
150:            }
151:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.