1 7 8 package java.rmi.server; 9 10 import java.io.*; 11 import java.net.*; 12 13 33 public abstract class RMISocketFactory 34 implements RMIClientSocketFactory , RMIServerSocketFactory 35 { 36 37 38 private static RMISocketFactory factory = null; 39 40 private static RMISocketFactory defaultSocketFactory; 41 42 private static RMIFailureHandler handler = null; 43 44 48 public RMISocketFactory() { 49 super(); 50 } 51 52 60 public abstract Socket createSocket(String host, int port) 61 throws IOException; 62 63 72 public abstract ServerSocket createServerSocket(int port) 73 throws IOException; 74 75 90 public synchronized static void setSocketFactory(RMISocketFactory fac) 91 throws IOException 92 { 93 if (factory != null) { 94 throw new SocketException("factory already defined"); 95 } 96 SecurityManager security = System.getSecurityManager(); 97 if (security != null) { 98 security.checkSetFactory(); 99 } 100 factory = fac; 101 } 102 103 111 public synchronized static RMISocketFactory getSocketFactory() 112 { 113 return factory; 114 } 115 116 124 public synchronized static RMISocketFactory getDefaultSocketFactory() { 125 if (defaultSocketFactory == null) { 126 defaultSocketFactory = 127 new sun.rmi.transport.proxy.RMIMasterSocketFactory(); 128 } 129 return defaultSocketFactory; 130 } 131 132 151 public synchronized static void setFailureHandler(RMIFailureHandler fh) 152 { 153 SecurityManager security = System.getSecurityManager(); 154 if (security != null) { 155 security.checkSetFactory(); 156 } 157 handler = fh; 158 } 159 160 167 public synchronized static RMIFailureHandler getFailureHandler() 168 { 169 return handler; 170 } 171 } 172 | Popular Tags |