productserver.java
来自「经典教材:java核心技术卷1、卷2的所有源代码」· Java 代码 · 共 39 行
JAVA
39 行
/**
@version 1.20 2004-08-15
@author Cay Horstmann
*/
import java.rmi.*;
import java.rmi.server.*;
import javax.naming.*;
/**
This server program instantiates two remote objects,
registers them with the naming service, and waits for
clients to invoke methods on the remote objects.
*/
public class ProductServer
{
public static void main(String args[])
{
try
{
System.out.println("Constructing server implementations...");
ProductImpl p1 = new ProductImpl("Blackwell Toaster");
ProductImpl p2 = new ProductImpl("ZapXpress Microwave Oven");
System.out.println("Binding server implementations to registry...");
Context namingContext = new InitialContext();
namingContext.bind("rmi:toaster", p1);
namingContext.bind("rmi:microwave", p2);
System.out.println("Waiting for invocations from clients...");
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?