public Page handle(URL url) {
String port = url.getParameter("port");
int p = port == null || port.length() == 0 ? 0 : Integer.parseInt(port);
Collection<ExchangeServer> servers = DubboProtocol.getDubboProtocol().getServers();
ExchangeServer server = null;
StringBuilder select = new StringBuilder();
if (servers != null && servers.size() > 0) {
if (servers.size() == 1) {
server = servers.iterator().next();
String address = server.getUrl().getAddress();
select.append(" > " + NetUtils.getHostName(address) + "/" + address);
} else {
select.append(" > <select onchange=\"window.location.href='clients.html?port=' + this.value;\">");
for (ExchangeServer s : servers) {
int sp = s.getUrl().getPort();
select.append("<option value=\">");
select.append(sp);
if (p == 0 && server == null || p == sp) {
server = s;
select.append("\" selected=\"selected");
}
select.append("\">");
select.append(s.getUrl().getAddress());
select.append("</option>");
}
select.append("</select>");
}
}
List<List<String>> rows = new ArrayList<List<String>>();
if (server != null) {
Collection<ExchangeChannel> channels = server.getExchangeChannels();
for (ExchangeChannel c : channels) {
List<String> row = new ArrayList<String>();
String address = NetUtils.toAddressString(c.getRemoteAddress());
row.add(NetUtils.getHostName(address) + "/" + address);
rows.add(row);