复制代码
- //:PerfectTime.java
- //TheimplementationofthePerfectTime
- //remoteobject
- packagec15.ptime;
- importjava.rmi.*;
- importjava.rmi.server.*;
- importjava.rmi.registry.*;
- importjava.net.*;
- publicclassPerfectTime
- extendsUnicastRemoteObject
- implementsPerfectTimeI{
- //Implementationoftheinterface:
- publiclonggetPerfectTime()
- throwsRemoteException{
- returnSystem.currentTimeMillis();
- }
- //Mustimplementconstructortothrow
- //RemoteException:
- publicPerfectTime()throwsRemoteException{
- //super();//Calledautomatically
- }
- //RegistrationforRMIserving:
- publicstaticvoidmain(String[]args){
- System.setSecurityManager(
- newRMISecurityManager());
- try{
- PerfectTimept=newPerfectTime();
- Naming.bind(
- "//colossus:2005/PerfectTime",pt);
- System.out.println("Readytodotime");
- }catch(Exceptione){
- e.printStackTrace();
- }
- }
- }///:~
欢迎光临 仓酷云 (http://www.ckuyun.com/) | Powered by Discuz! X3.2 |