📄 remoteobjectref.java
字号:
import java.lang.reflect.*;
import java.io.*;
import java.net.*;
import java.util.*;
public class RemoteObjectRef
{
String IP_adr;
int Port;
int Obj_Key; //tiko's note: Object key is generated in RORtbl.addObj() method.
String Remote_Interface_Name;
public RemoteObjectRef(String ip, int port, int obj_key, String riname)
{ IP_adr=ip;
Port=port;
Obj_Key=obj_key;
Remote_Interface_Name=riname;
}
// This method creates a stub.
//
Object localise()
{ // Implement this as you like.
// You should create a new stub object and return it.
// Assume the stub class has the name, e.g.,
//
// Remote_Interface_Name + "_stub".
//
// Then you can create a new stub as follows:
//
// Class c = Class.forName(Remote_Interface_Name + "_stub");
// Object o = c.newInstance()
//
// For this to work, your (hand-crafted) stub should have a constructor
// without arguments.
// The stub gives the client-side communication module (CM) all it's got
// (using the CM's static methods), including its method name, arguments,
// etc., in a marshalled form, and the CM sends it over to the server.
// SimpleRegistry exchange the fields of ror.
// Here let it return null.
Object rtn = null;
try
{ Class c = Class.forName(this.Remote_Interface_Name + "_stub");
Object o = c.newInstance();
// add ROR stub pairs to the Remote Reference Modules 2 hashtables
// ZipCodeServerImpl_stub .addStubRORMapping(this,o);
Tbl.StubRORMap(this,o);
rtn = o;
}
catch(Exception e)
{
System.out.print(e.getMessage());
System.exit(0);
}
return rtn;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -