identityclientsocketfactory.java
来自「最新的关于精通rmi这本书的源码」· Java 代码 · 共 55 行
JAVA
55 行
/*
* Copyright 1999 by dreamBean Software,
* All rights reserved.
*/
package masteringrmi.hellosocket.interfaces;
import java.io.IOException;
import java.net.Socket;
import java.rmi.RemoteException;
import java.rmi.server.RMIClientSocketFactory;
/**
* This is the socket factory that creates the client sockets.
*
* It implements equals and hashCode so that it, and its connections,
* may be reused for multiple calls.
*
* @see IdentityServerSocketFactory
* @see IdentitySocket
* @author Rickard 謆erg
* @version $Revision:$
*/
public class IdentityClientSocketFactory
implements RMIClientSocketFactory, java.io.Serializable
{
// RMIClientSocketFactory implementation -------------------------
/**
* Create a remote object of this class. The default constructor
* of UnicastRemoteObject is automatically called, which causes
* this object to be exported on a default port.
*
* @exception IOException thrown if creation failed
* @return a new socket connected to host:port
*/
public Socket createSocket(String host, int port)
throws IOException
{
// Create a new IdentitySocket which can identiy this client for the server
return new IdentitySocket(host, port);
}
// Object overriders ---------------------------------------------
public boolean equals(Object obj)
{
return obj instanceof IdentityClientSocketFactory;
}
public int hashCode()
{
return getClass().toString().hashCode();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?