⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rortbl.java

📁 一个java的rmi实例
💻 JAVA
字号:


import java.util.*;

// This table stores (ROR, object) pairs, and will be maintained by
// your RMI on the server side, so that the server side can dispatch
// the object (or its skeleton) corresponding to a given ROR.
// ROR needs a new object key for each remote object (or its skeleton). 
// The sequence numbers for this puspose can be generated, for example,
// using a counter.
// We assume that each remote object implements only one interface,
// which is a remote interface.

public class RORtbl
{
    	int objKey;    
    	Hashtable table;	
 	
    	// Construct a new table. 
    	public RORtbl()
    	{	objKey = 0; 
		table = new Hashtable();
    	}

    	// The folowing method adds a remote object (with its ROR) to the table. 
    	// The host and port are not used unless it is exported outside,
    	// but it is better to have them for uniformity.
    	public int addObj(String host, int port, Object o)
    	{	objKey++; 
		table.put(objKey + "", o);           
		return objKey; 
     	}

    	// Given an ror, find the corresponding object.
    	public Object findObj(RemoteObjectRef ror)
	{	// If you use a hash table this is straightforward.
            Object o = table.get(new Integer(ror.Obj_Key).toString());
            if(o == null)
                return null;  //An object would be returned in general.
            else 
                return o;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -