Today's Source code analysing series I will dive into java.rmi.server.RMISocketFactory, First the UML Diagram:
This Diagram containing 1 abstract Class: RMISocketFactory, and 3 Interface: RMIClientSocketFactory, RMIServerSocketFactory, RMIFailureHandler.
RMIServerSocketFactory only has one method createServerSocket(int port), through this method we can create a server socket on the specified port. RMIServerSocketFactory instance is used by the RMI runtime in order to obtain server sockets for RMI calls. Usually RMIServerSocketFactory associated with a remote object is used to obtain the ServerSocket which accept incoming calls from clients. The Sorce Code:
import java.io.*;
import java.net.*;
public interface RMIServerSocketFactory {
public ServerSocket createServerSocket(int port)throws IOException;
}
RMIClientSocketFactory also has one method createSocket(String host, int port), through this method we can create a client socket connected to the specified host and port. Like the RMIServerSocketFactory, RMIClientSocketFactory instance is also used by the RMI runtime in order to obtain client sockets for RMI calls. The Socket RMIClientSocketFactory create can establish a connection with the ServerSoket, This connection use to transmit info between Client and Server. Also the Source Code:
import java.io.*;
import java.net.*;
public interface RMIClientSocketFactory {
public Socket createSocket(String host, int port)throws IOException;
}
RMIFailureHandler defined a method failure(Exception ex), While the RMI Runtime is unable to create a ServerSocket via the RMISocketFactory, the failure callback will be invoked. There are no any implemetaion in JDK, if you wanna use this handler mechenism you must impementing yourseves handler. If no failure handler is installed, the default behavior is to attempt to re-create the ServerSocket. the handler can be installed through RMISocketFacotry.setFailureHandler, we will see later. The failure method returns a boolean indicating whether the runtime should attempt to re-create the ServerSocket. The Source Code:
public interface RMIFailureHandler {
public boolean failure(Exception ex);
}
RMISocketFactory is an abstract Class, has 3 private stataic atrributes, implementing both RMIClientSocketFactory and RMIClientSocketFactory interface, RMISocketFactory make this 2 interfaces method abstract, the user implement by themself. RMISocketFactory instance is used by the RMI runtime in order to obtain client and server sockets for RMI calls. An application may use the setSocketFactory method to request that the RMI runtime use its socket factory instance instead of the default implementation. The Source Code:
import java.io.*;
import java.net.*;
public abstract class RMISocketFactory implements RMIClientSocketFactory, RMIServerSocketFactory{
private static RMISocketFactory factory = null;
private static RMISocketFactory defaultSocketFactory;
private static RMIFailureHandler handler = null;
public RMISocketFactory() {
super();
}
public abstract Socket createSocket(String host, int port) throws IOException;
public abstract ServerSocket createServerSocket(int port) throws IOException;
public synchronized static void setSocketFactory(RMISocketFactory fac) throws IOException {
if (factory != null) {
throw new SocketException("factory already defined");
}
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkSetFactory();
}
factory = fac;
}
public synchronized static RMISocketFactory getSocketFactory() {
return factory;
}
public synchronized static RMISocketFactory getDefaultSocketFactory() {
if (defaultSocketFactory == null) {
defaultSocketFactory = new sun.rmi.transport.proxy.RMIMasterSocketFactory();
}
return defaultSocketFactory;
}
public synchronized static void setFailureHandler(RMIFailureHandler fh) {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkSetFactory();
}
handler = fh;
}
public synchronized static RMIFailureHandler getFailureHandler() {
return handler;
}
}
Inspiration From this Code:
--will be put later
- 大小: 19.3 KB
分享到:
相关推荐
2.将下载的两个JAR文件复制到:JDK安装目录\jre\lib\ext下,例如我的就是D:\Program Files (x86)\java\JDK1.6\jre\lib\ext 3.打开java.security文件:在JDK安装目录\jre\lib\security下的java.security文件。
Java RMI (Remote Method Invocation 远程方法调用)是用Java在JDK1.1中实现的,它大大增强了Java开发分布式应用的能力。
bcprov-ext-jdk15on-1.54.jar和bcprov-jdk15on-1.54.jar压缩文件
JDK是 Java 语言的软件开发工具包,主要用于移动设备、嵌入式设备上的java应用程序。JDK是整个java开发的核心,它包含了JAVA的运行环境(JVM+Java系统类库)和JAVA工具. JDK是学好Java的第一步。不管是你要学习java...
Wrox.Professional.Java.JDK.6.Edition.Jan.2007.rar
bcprov-jdk15on-1.54.jarr和bcprov-ext-jdk15on-1.54.jar和教程 win10 64位 java1.8连接SQL Server2008报错 驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接
ECC 加密工具jar包 bcprov-jdk15on-1.64.jarbcprov-jdk15on-1.64.jarbcprov-jdk15on-1.64.jarbcprov-jdk15on-1.64.jarbcprov-jdk15on-1.64.jar
jdk 17需要 新增 配置 如下 jvm参数 --add-opens=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED --add-opens=java.base/jdk.internal.org.objectweb.asm.tree=ALL-UNNAMED
解决java.lang.RuntimeException: Could not generate DH keypair。这个的Jar包
jdk_8.0.1310.11_64——(JDK8版本,对应Java1.8,64位)
jdk_8.0.1310.11_64.exe -64位 可用! !!!!!!!
新增和增强的 API:JDK 17.0.7 包含了许多新的和增强的 Java API,例如 Java 媒体框架、Java 加密框架、Java 容器平台等,为开发人员提供了更多的工具和功能。 更好的安全性:JDK 17.0.7 包括许多安全改进,例如增强...
JDK8.0,含tools.jar和dt.jar,可能直接安装,里面有JRE,只要设置好环境变量,就可以进行开发。
bcprov-ext-jdk15on-164.jar:支持java5-11。将jar包放置在%java_home%/jre/lib/ext目录。
最新版的JAVA加密算法包。 The Bouncy Castle Crypto package is a Java implementation of... This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.5 to JDK 1.8.
bcprov-ext-jdk15on-1.60、bcprov-jdk15on-1.60两个包放到jre下的$JAVA_HOME/jre/lib/ext的路径下,然后配置$JAVA_HOME/jre/lib/security/java.security,找到security.provider.9,然后在这句话下面加上:security....
Java1.8中文API(google翻译版) 文件名:jdk api 1.8_google.CHM 文件大小:40.8M
JDK是 Java 语言的软件开发工具包,主要用于移动设备、嵌入式设备上的java应用程序。JDK是整个java开发的核心,它包含了JAVA的运行环境(JVM+Java系统类库)和JAVA工具。
maven 加载不了 jdktool的 可以直接下在相应的jar,在maven路径下配置好,改好名字,重新更新maven
压缩包内包含jdk1.6.0_37 for linux 和 jdk-6u45-windows-x64 两个版本。