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


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