1 17 18 package org.apache.tomcat.util.net; 19 20 import java.io.IOException ; 21 import java.net.InetAddress ; 22 import java.net.ServerSocket ; 23 import java.net.Socket ; 24 import java.util.Hashtable ; 25 26 50 public abstract class ServerSocketFactory implements Cloneable { 51 52 57 private static ServerSocketFactory theFactory; 58 protected Hashtable attributes=new Hashtable (); 59 60 63 64 protected ServerSocketFactory () { 65 66 } 67 68 76 public void setAttribute( String name, Object value ) { 77 if( name!=null && value !=null) 78 attributes.put( name, value ); 79 } 80 81 84 public static synchronized ServerSocketFactory getDefault () { 85 89 if (theFactory == null) { 90 97 theFactory = new DefaultServerSocketFactory (); 98 } 99 100 try { 101 return (ServerSocketFactory) theFactory.clone (); 102 } catch (CloneNotSupportedException e) { 103 throw new RuntimeException (e.getMessage ()); 104 } 105 } 106 107 117 public abstract ServerSocket createSocket (int port) 118 throws IOException , InstantiationException ; 119 120 131 132 public abstract ServerSocket createSocket (int port, int backlog) 133 throws IOException , InstantiationException ; 134 135 147 148 public abstract ServerSocket createSocket (int port, 149 int backlog, InetAddress ifAddress) 150 throws IOException , InstantiationException ; 151 152 public void initSocket( Socket s ) { 153 } 154 155 161 public abstract Socket acceptSocket(ServerSocket socket) 162 throws IOException ; 163 164 170 public abstract void handshake(Socket sock) 171 throws IOException ; 172 } 173 174 | Popular Tags |