myrmiimpl.java

来自「Long-distance rmi transfers java to real」· Java 代码 · 共 57 行

JAVA
57
字号
package com.antbang.rmilab;/* * To change this template, choose Tools | Templates * and open the template in the editor. *//** * * @author GAGA */import java.rmi.*;import java.rmi.server.UnicastRemoteObject;import java.util.Date;import java.util.Properties;public class MyRMIImpl extends UnicastRemoteObject implements MyRMIInterface{    public MyRMIImpl(String name) throws RemoteException    {        super();        try        {            Naming.rebind(name, this);        } catch (Exception e)        {            System.out.println("Exception occurred: " + e);        }    }    public Date getDate()    {        return new java.util.Date();    }    public String getDiscription()    {        StringBuilder hostDescription = new StringBuilder();        Properties properties=System.getProperties();        for (Object key : properties.keySet())        {            if(properties.get(key).toString().length()>30)                continue;            hostDescription.append(key+""+" : ");            hostDescription.append(properties.get(key)+"\n");        }        return hostDescription.toString();    }    public void sendMessage(Message message) throws RemoteException    {        System.out.println(message);    }}

⌨️ 快捷键说明

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