package mxdx1; import java.util.List; //服务信息模型 public class ServiceInfo { private String serviceName; // 服务名称 private String host; // 主机地址 private int port; // 端口号 // 构造方法、getter和setter public ServiceInfo(String serviceName, String host, int port) { this.serviceName = serviceName; this.host = host; this.port = port; } public String getHost() { return host; } public int getPort() { return port; } public String getServiceName() { return serviceName; } // getter和setter省略... } //服务观察者接口(观察者模式) public interface ServiceObserver { void onServiceChanged(String serviceName, List serviceInfos); }