Source Code Cross Referenced for ServerSocketFactory.java in  » Sevlet-Container » tomcat-connectors » org » apache » tomcat » util » net » 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 » Sevlet Container » tomcat connectors » org.apache.tomcat.util.net 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Copyright 1999-2004 The Apache Software Foundation
003:         *
004:         *  Licensed under the Apache License, Version 2.0 (the "License");
005:         *  you may not use this file except in compliance with the License.
006:         *  You may obtain a copy of the License at
007:         *
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         *  Unless required by applicable law or agreed to in writing, software
011:         *  distributed under the License is distributed on an "AS IS" BASIS,
012:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         *  See the License for the specific language governing permissions and
014:         *  limitations under the License.
015:         */
016:
017:        package org.apache.tomcat.util.net;
018:
019:        import java.io.IOException;
020:        import java.net.InetAddress;
021:        import java.net.ServerSocket;
022:        import java.net.Socket;
023:        import java.util.Hashtable;
024:
025:        /**
026:         * This class creates server sockets.  It may be subclassed by other
027:         * factories, which create particular types of server sockets.  This
028:         * provides a general framework for the addition of public socket-level
029:         * functionality.  It it is the server side analogue of a socket factory,
030:         * and similarly provides a way to capture a variety of policies related
031:         * to the sockets being constructed.
032:         *
033:         * <P> Like socket factories, Server Socket factory instances have two
034:         * categories of methods.  First are methods used to create sockets.
035:         * Second are methods which set properties used in the production of
036:         * sockets, such as networking options.  There is also an environment
037:         * specific default server socket factory; frameworks will often use
038:         * their own customized factory.
039:         * 
040:         * <P><hr><em> It may be desirable to move this interface into the
041:         * <b>java.net</b> package, so that is not an extension but the preferred
042:         * interface.  Should this be serializable, making it a JavaBean which can
043:         * be saved along with its networking configuration?
044:         * </em>   
045:         *
046:         * @author db@eng.sun.com
047:         * @author Harish Prabandham
048:         */
049:        public abstract class ServerSocketFactory implements  Cloneable {
050:
051:            //
052:            // NOTE:  JDK 1.1 bug in class GC, this can get collected
053:            // even though it's always accessible via getDefault().
054:            //
055:
056:            private static ServerSocketFactory theFactory;
057:            protected Hashtable attributes = new Hashtable();
058:
059:            /**
060:             * Constructor is used only by subclasses.
061:             */
062:
063:            protected ServerSocketFactory() {
064:                /* NOTHING */
065:            }
066:
067:            /** General mechanism to pass attributes from the
068:             *  ServerConnector to the socket factory.
069:             *
070:             *  Note that the "prefered" mechanism is to
071:             *  use bean setters and explicit methods, but
072:             *  this allows easy configuration via server.xml
073:             *  or simple Properties
074:             */
075:            public void setAttribute(String name, Object value) {
076:                if (name != null && value != null)
077:                    attributes.put(name, value);
078:            }
079:
080:            /**
081:             * Returns a copy of the environment's default socket factory.
082:             */
083:            public static synchronized ServerSocketFactory getDefault() {
084:                //
085:                // optimize typical case:  no synch needed
086:                //
087:
088:                if (theFactory == null) {
089:                    //
090:                    // Different implementations of this method could
091:                    // work rather differently.  For example, driving
092:                    // this from a system property, or using a different
093:                    // implementation than JavaSoft's.
094:                    //
095:
096:                    theFactory = new DefaultServerSocketFactory();
097:                }
098:
099:                try {
100:                    return (ServerSocketFactory) theFactory.clone();
101:                } catch (CloneNotSupportedException e) {
102:                    throw new RuntimeException(e.getMessage());
103:                }
104:            }
105:
106:            /**
107:             * Returns a server socket which uses all network interfaces on
108:             * the host, and is bound to a the specified port.  The socket is
109:             * configured with the socket options (such as accept timeout)
110:             * given to this factory.
111:             *
112:             * @param port the port to listen to
113:             * @exception IOException for networking errors
114:             * @exception InstantiationException for construction errors
115:             */
116:            public abstract ServerSocket createSocket(int port)
117:                    throws IOException, InstantiationException;
118:
119:            /**
120:             * Returns a server socket which uses all network interfaces on
121:             * the host, is bound to a the specified port, and uses the 
122:             * specified connection backlog.  The socket is configured with
123:             * the socket options (such as accept timeout) given to this factory.
124:             *
125:             * @param port the port to listen to
126:             * @param backlog how many connections are queued
127:             * @exception IOException for networking errors
128:             * @exception InstantiationException for construction errors
129:             */
130:
131:            public abstract ServerSocket createSocket(int port, int backlog)
132:                    throws IOException, InstantiationException;
133:
134:            /**
135:             * Returns a server socket which uses only the specified network
136:             * interface on the local host, is bound to a the specified port,
137:             * and uses the specified connection backlog.  The socket is configured
138:             * with the socket options (such as accept timeout) given to this factory.
139:             *
140:             * @param port the port to listen to
141:             * @param backlog how many connections are queued
142:             * @param ifAddress the network interface address to use
143:             * @exception IOException for networking errors
144:             * @exception InstantiationException for construction errors
145:             */
146:
147:            public abstract ServerSocket createSocket(int port, int backlog,
148:                    InetAddress ifAddress) throws IOException,
149:                    InstantiationException;
150:
151:            public void initSocket(Socket s) {
152:            }
153:
154:            /**
155:              Wrapper function for accept(). This allows us to trap and
156:              translate exceptions if necessary
157:            
158:              @exception IOException;
159:             */
160:            public abstract Socket acceptSocket(ServerSocket socket)
161:                    throws IOException;
162:
163:            /**
164:              Extra function to initiate the handshake. Sometimes necessary
165:              for SSL
166:            
167:              @exception IOException;
168:             */
169:            public abstract void handshake(Socket sock) throws IOException;
170:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.