FileDocCategorySizeDatePackage
RMIMultiHomedServerSocketFactory.javaAPI DocGlassfish v2 API7036Fri May 04 22:33:54 BST 2007com.sun.enterprise.admin.server.core.jmx.nonssl

RMIMultiHomedServerSocketFactory

public class RMIMultiHomedServerSocketFactory extends Object implements RMIServerSocketFactory
This is the custom RMI server socket factory that helps bind RMI servers to a specific IP interface as has been specified in the domain->config->admin-service->jmx-connector->address in domain.xml. In the absence of a specific entry, the default RMI behavior of binding to all IP interfaces on the host is observed.
author
Nandini.Ektare@sun.com
since
Sun Java System Application Server 8.1 UR 2

Fields Summary
private static final String
DEFAULT_ADDRESS
private final String
address
Constructors Summary
public RMIMultiHomedServerSocketFactory(String host)


        
	address = host;
        /*ServerContext serverCtx = ApplicationServer.getServerContext();
	if (serverCtx != null) {
	    try {
                ConfigContext configCtx = serverCtx.getConfigContext();
                Config config = ServerBeansFactory.getConfigBean(configCtx);	
                AdminService as = config.getAdminService();
                JmxConnector[] jc = as.getJmxConnector();
                address = jc[0].getAddress(); 
            } catch (ConfigException ex) {
                return null;
            }
	}*/
    
Methods Summary
public java.net.ServerSocketcreateServerSocket(int port)
Implementation of the only method in {@link RMIServerSocketFactory}. This method is called for creating the server socket.

return
instance of ServerSocket

        try {
            InetAddress bindAddress = null;
            ServerSocket ss = null;        
            if (address.equals(DEFAULT_ADDRESS))             
                ss = new ServerSocket(port);        
            else {            
                bindAddress = InetAddress.getByName(address);             
                ss = new ServerSocket(port, 0, bindAddress);        
            }
            debug(ss);
            return (ss);
        } catch (Exception e) {
            throw new IOException(e.getMessage());
        }
    
private voiddebug(java.net.ServerSocket sss)

        // prints the debug information - suppress after beta
        String prefix = "RMI/TLS Server Debug Message: " ;
        boolean DEBUG = Boolean.getBoolean("Debug");
        if (sss != null) {
            if (DEBUG) {
                System.out.println(prefix + "ServerSocket local port = " + sss.getLocalPort());
                System.out.println(prefix + "ServerSocket host address = " + sss.getInetAddress().getHostAddress());
                System.out.println(prefix + "ServerSocket bound status = " + sss.isBound());
            }
        }
        else {
            System.out.println(prefix + " Catastrophe: no server socket");
        }
    
public booleanequals(java.lang.Object anotherFactory)
Overriding the base class method here to ensure that when a functionally equivalent instance of server socket factory is passed, the same factory is reused instead of creating new objects

        
        if (anotherFactory != null && 
       	    anotherFactory.getClass().equals(this.getClass())) {
    
            RMIMultiHomedServerSocketFactory rmhssf = 
                (RMIMultiHomedServerSocketFactory) anotherFactory;
    
            if (this.address == null && rmhssf.address == null) return true;
            if (this.address == null ^ rmhssf.address == null) return false;
	    return this.address.equals(rmhssf.address);
        }
        return false;
    
public inthashCode()

        return super.hashCode() ^ address.hashCode();