use of com.alibaba.dubbo.registry.support.AbstractRegistry in project dubbo by alibaba.
the class SubscribedPageHandler method handle.
public Page handle(URL url) {
String registryAddress = url.getParameter("registry", "");
List<List<String>> rows = new ArrayList<List<String>>();
Collection<Registry> registries = AbstractRegistryFactory.getRegistries();
StringBuilder select = new StringBuilder();
Registry registry = null;
if (registries != null && registries.size() > 0) {
if (registries.size() == 1) {
registry = registries.iterator().next();
select.append(" > " + registry.getUrl().getAddress());
} else {
select.append(" > <select onchange=\"window.location.href='subscribed.html?registry=' + this.value;\">");
for (Registry r : registries) {
String sp = r.getUrl().getAddress();
select.append("<option value=\">");
select.append(sp);
if (((registryAddress == null || registryAddress.length() == 0) && registry == null) || registryAddress.equals(sp)) {
registry = r;
select.append("\" selected=\"selected");
}
select.append("\">");
select.append(sp);
select.append("</option>");
}
select.append("</select>");
}
}
if (registry instanceof AbstractRegistry) {
Set<URL> services = ((AbstractRegistry) registry).getSubscribed().keySet();
if (services != null && services.size() > 0) {
for (URL u : services) {
List<String> row = new ArrayList<String>();
row.add(u.toFullString().replace("<", "<").replace(">", ">"));
rows.add(row);
}
}
}
return new Page("<a href=\"registries.html\">Registries</a>" + select.toString() + " > <a href=\"registered.html?registry=" + registryAddress + "\">Registered</a> | Subscribed", "Subscribed (" + rows.size() + ")", new String[] { "Consumer URL:" }, rows);
}
use of com.alibaba.dubbo.registry.support.AbstractRegistry in project dubbo by alibaba.
the class RegisteredPageHandler method handle.
public Page handle(URL url) {
String registryAddress = url.getParameter("registry", "");
List<List<String>> rows = new ArrayList<List<String>>();
Collection<Registry> registries = AbstractRegistryFactory.getRegistries();
StringBuilder select = new StringBuilder();
Registry registry = null;
if (registries != null && registries.size() > 0) {
if (registries.size() == 1) {
registry = registries.iterator().next();
select.append(" > " + registry.getUrl().getAddress());
} else {
select.append(" > <select onchange=\"window.location.href='registered.html?registry=' + this.value;\">");
for (Registry r : registries) {
String sp = r.getUrl().getAddress();
select.append("<option value=\">");
select.append(sp);
if (((registryAddress == null || registryAddress.length() == 0) && registry == null) || registryAddress.equals(sp)) {
registry = r;
select.append("\" selected=\"selected");
}
select.append("\">");
select.append(sp);
select.append("</option>");
}
select.append("</select>");
}
}
if (registry instanceof AbstractRegistry) {
Set<URL> services = ((AbstractRegistry) registry).getRegistered();
if (services != null && services.size() > 0) {
for (URL u : services) {
List<String> row = new ArrayList<String>();
row.add(u.toFullString().replace("<", "<").replace(">", ">"));
rows.add(row);
}
}
}
return new Page("<a href=\"registries.html\">Registries</a>" + select.toString() + " > Registered | <a href=\"subscribed.html?registry=" + registryAddress + "\">Subscribed</a>", "Registered (" + rows.size() + ")", new String[] { "Provider URL:" }, rows);
}
use of com.alibaba.dubbo.registry.support.AbstractRegistry in project dubbo by alibaba.
the class RegistriesPageHandler method handle.
public Page handle(URL url) {
List<List<String>> rows = new ArrayList<List<String>>();
Collection<Registry> registries = AbstractRegistryFactory.getRegistries();
int registeredCount = 0;
int subscribedCount = 0;
if (registries != null && registries.size() > 0) {
for (Registry registry : registries) {
String server = registry.getUrl().getAddress();
List<String> row = new ArrayList<String>();
row.add(NetUtils.getHostName(server) + "/" + server);
if (registry.isAvailable()) {
row.add("<font color=\"green\">Connected</font>");
} else {
row.add("<font color=\"red\">Disconnected</font>");
}
int registeredSize = 0;
int subscribedSize = 0;
if (registry instanceof AbstractRegistry) {
registeredSize = ((AbstractRegistry) registry).getRegistered().size();
registeredCount += registeredSize;
subscribedSize = ((AbstractRegistry) registry).getSubscribed().size();
subscribedCount += subscribedSize;
}
row.add("<a href=\"registered.html?registry=" + server + "\">Registered(" + registeredSize + ")</a>");
row.add("<a href=\"subscribed.html?registry=" + server + "\">Subscribed(" + subscribedSize + ")</a>");
rows.add(row);
}
}
return new Page("Registries", "Registries (" + rows.size() + ")", new String[] { "Registry Address:", "Status", "Registered(" + registeredCount + ")", "Subscribed(" + subscribedCount + ")" }, rows);
}