1 23 24 39 40 package com.sun.enterprise.admin.server.core.jmx.nonssl; 41 42 import com.sun.enterprise.config.serverbeans.AdminService; 43 import com.sun.enterprise.config.ConfigContext; 44 import com.sun.enterprise.config.ConfigException; 45 import com.sun.enterprise.config.serverbeans.ServerBeansFactory; 46 import com.sun.enterprise.config.serverbeans.Config; 47 import com.sun.enterprise.config.serverbeans.JmxConnector; 48 import com.sun.enterprise.server.ApplicationServer; 49 import com.sun.enterprise.server.ServerContext; 50 import java.rmi.server.RMIServerSocketFactory ; 51 import java.net.ServerSocket ; 52 import java.io.IOException ; 53 import java.net.InetAddress ; 54 import java.net.UnknownHostException ; 55 import java.rmi.server.RMIServerSocketFactory ; 56 import java.security.SecureRandom ; 57 import javax.management.remote.JMXConnector ; 58 59 66 public class RMIMultiHomedServerSocketFactory implements RMIServerSocketFactory { 67 68 private static final String DEFAULT_ADDRESS = "0.0.0.0"; 69 70 private String address = DEFAULT_ADDRESS; 71 72 public RMIMultiHomedServerSocketFactory(String host) { 73 address = host; 74 86 } 87 88 92 public ServerSocket createServerSocket(int port) throws IOException { 93 try { 94 InetAddress bindAddress = null; 95 ServerSocket ss = null; 96 if (address.equals(DEFAULT_ADDRESS)) 97 ss = new ServerSocket (port); 98 else { 99 bindAddress = InetAddress.getByName(address); 100 ss = new ServerSocket (port, 0, bindAddress); 101 } 102 debug(ss); 103 return (ss); 104 } catch (Exception e) { 105 throw new IOException (e.getMessage()); 106 } 107 } 108 109 114 public boolean equals(Object anotherFactory) { 115 116 if (anotherFactory != null && 117 anotherFactory.getClass().equals(this.getClass())) { 118 119 RMIMultiHomedServerSocketFactory rmhssf = 120 (RMIMultiHomedServerSocketFactory) anotherFactory; 121 122 if (this.address == null && rmhssf.address == null) return true; 123 if (this.address == null ^ rmhssf.address == null) return false; 124 return this.address.equals(rmhssf.address); 125 } 126 return false; 127 } 128 129 private void debug (ServerSocket sss) { 130 String prefix = "RMI/TLS Server Debug Message: " ; 132 boolean DEBUG = Boolean.getBoolean("Debug"); 133 if (sss != null) { 134 if (DEBUG) { 135 System.out.println(prefix + "ServerSocket local port = " + sss.getLocalPort()); 136 System.out.println(prefix + "ServerSocket host address = " + sss.getInetAddress().getHostAddress()); 137 System.out.println(prefix + "ServerSocket bound status = " + sss.isBound()); 138 } 139 } 140 else { 141 System.out.println(prefix + " Catastrophe: no server socket"); 142 } 143 } 144 } 145 | Popular Tags |