com.alibaba.dubbo.registry.support.AbstractRegistryFactory Java Examples

The following examples show how to use com.alibaba.dubbo.registry.support.AbstractRegistryFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DubboShutdownHook.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
/**
     * Destroy all the resources, including registries and protocols.
     */
    public void destroyAll() {
//        自旋锁,保证只处理一次,一般在项目中多线程情况下做线程开关很好用
        if (!destroyed.compareAndSet(false, true)) {
            return;
        }
        // destroy all the registries 销毁所有注册信息=》
        AbstractRegistryFactory.destroyAll();
        // destroy all the protocols 销毁所有协议信息
        ExtensionLoader<Protocol> loader = ExtensionLoader.getExtensionLoader(Protocol.class);
        for (String protocolName : loader.getLoadedExtensions()) {
            try {
                Protocol protocol = loader.getLoadedExtension(protocolName);
                if (protocol != null) {
//                    销毁协议
                    protocol.destroy();
                }
            } catch (Throwable t) {
                logger.warn(t.getMessage(), t);
            }
        }
    }
 
Example #2
Source File: RegistryStatusChecker.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Override
public Status check() {
    Collection<Registry> registries = AbstractRegistryFactory.getRegistries();
    if (registries.isEmpty()) {
        return new Status(Status.Level.UNKNOWN);
    }
    Status.Level level = Status.Level.OK;
    StringBuilder buf = new StringBuilder();
    for (Registry registry : registries) {
        if (buf.length() > 0) {
            buf.append(",");
        }
        buf.append(registry.getUrl().getAddress());
        if (!registry.isAvailable()) {
            level = Status.Level.ERROR;
            buf.append("(disconnected)");
        } else {
            buf.append("(connected)");
        }
    }
    return new Status(level, buf.toString());
}
 
Example #3
Source File: RegistryStatusChecker.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public Status check() {
    Collection<Registry> regsitries = AbstractRegistryFactory.getRegistries();
    if (regsitries == null || regsitries.size() == 0) {
        return new Status(Status.Level.UNKNOWN);
    }
    Status.Level level = Status.Level.OK;
    StringBuilder buf = new StringBuilder();
    for (Registry registry : regsitries) {
        if (buf.length() > 0) {
            buf.append(",");
        }
        buf.append(registry.getUrl().getAddress());
        if (! registry.isAvailable()) {
            level = Status.Level.ERROR;
            buf.append("(disconnected)");
        } else {
            buf.append("(connected)");
        }
    }
    return new Status(level, buf.toString());
}
 
Example #4
Source File: AbstractTracingCollectorFactory.java    From dubbo-plus with Apache License 2.0 6 votes vote down vote up
@Override
public TracingCollector getTracingCollector() {
    Collection<Registry> registries =  AbstractRegistryFactory.getRegistries();
    List<URL> urls = new ArrayList<URL>();
    for(Registry registry:registries){
        URL url = registry.getUrl();
        String protocolName = url.getProtocol();
        url=url.setProtocol(Constants.REGISTRY_PROTOCOL);
        url=url.addParameter(Constants.REGISTRY_KEY,protocolName);
        url=url.setPath(TracingCollector.class.getName());
        url=url.addParameter(Constants.INTERFACE_KEY,TracingCollector.class.getName());
        url=url.addParameter(Constants.REFERENCE_FILTER_KEY,"-dst");
        urls.add(url);
    }
    return createTracingCollector(urls);
}
 
Example #5
Source File: RegistryStatusChecker.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public Status check() {
    Collection<Registry> regsitries = AbstractRegistryFactory.getRegistries();
    if (regsitries == null || regsitries.size() == 0) {
        return new Status(Status.Level.UNKNOWN);
    }
    Status.Level level = Status.Level.OK;
    StringBuilder buf = new StringBuilder();
    for (Registry registry : regsitries) {
        if (buf.length() > 0) {
            buf.append(",");
        }
        buf.append(registry.getUrl().getAddress());
        if (! registry.isAvailable()) {
            level = Status.Level.ERROR;
            buf.append("(disconnected)");
        } else {
            buf.append("(connected)");
        }
    }
    return new Status(level, buf.toString());
}
 
Example #6
Source File: DubboRegistryStatusHealthCheck.java    From watcher with Apache License 2.0 6 votes vote down vote up
@Override
protected Result check() throws Exception {
	Collection<Registry> regsitries = AbstractRegistryFactory.getRegistries();
	if (regsitries.size() == 0) {
		return Result.healthy("no registry found");
	}
	boolean isOK = true;
	StringBuilder buf = new StringBuilder();
	for (Registry registry : regsitries) {
		if (buf.length() > 0) {
			buf.append(",");
		}
		buf.append(registry.getUrl().getAddress());
		if (!registry.isAvailable()) {
			isOK = false;
			buf.append("(disconnected)");
		} else {
			buf.append("(connected)");
		}
	}
	if (isOK) {
		return Result.healthy();
	} else {
		return Result.unhealthy(buf.toString());
	}
}
 
Example #7
Source File: RegistryStatusChecker.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
public Status check() {
    Collection<Registry> regsitries = AbstractRegistryFactory.getRegistries();
    if (regsitries == null || regsitries.size() == 0) {
        return new Status(Status.Level.UNKNOWN);
    }
    Status.Level level = Status.Level.OK;
    StringBuilder buf = new StringBuilder();
    for (Registry registry : regsitries) {
        if (buf.length() > 0) {
            buf.append(",");
        }
        buf.append(registry.getUrl().getAddress());
        if (! registry.isAvailable()) {
            level = Status.Level.ERROR;
            buf.append("(disconnected)");
        } else {
            buf.append("(connected)");
        }
    }
    return new Status(level, buf.toString());
}
 
Example #8
Source File: RegistryStatusChecker.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public Status check() {
    Collection<Registry> regsitries = AbstractRegistryFactory.getRegistries();
    if (regsitries == null || regsitries.size() == 0) {
        return new Status(Status.Level.UNKNOWN);
    }
    Status.Level level = Status.Level.OK;
    StringBuilder buf = new StringBuilder();
    for (Registry registry : regsitries) {
        if (buf.length() > 0) {
            buf.append(",");
        }
        buf.append(registry.getUrl().getAddress());
        if (! registry.isAvailable()) {
            level = Status.Level.ERROR;
            buf.append("(disconnected)");
        } else {
            buf.append("(connected)");
        }
    }
    return new Status(level, buf.toString());
}
 
Example #9
Source File: RegistryStatusChecker.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
public Status check() {
    Collection<Registry> regsitries = AbstractRegistryFactory.getRegistries();
    if (regsitries == null || regsitries.size() == 0) {
        return new Status(Status.Level.UNKNOWN);
    }
    Status.Level level = Status.Level.OK;
    StringBuilder buf = new StringBuilder();
    for (Registry registry : regsitries) {
        if (buf.length() > 0) {
            buf.append(",");
        }
        buf.append(registry.getUrl().getAddress());
        if (! registry.isAvailable()) {
            level = Status.Level.ERROR;
            buf.append("(disconnected)");
        } else {
            buf.append("(connected)");
        }
    }
    return new Status(level, buf.toString());
}
 
Example #10
Source File: RegistriesPageHandler.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #11
Source File: RegistriesPageHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #12
Source File: ProtocolConfig.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
public static void destroyAll() {
    AbstractRegistryFactory.destroyAll();
    ExtensionLoader<Protocol> loader = ExtensionLoader.getExtensionLoader(Protocol.class);
    for (String protocolName : loader.getLoadedExtensions()) {
        try {
            Protocol protocol = loader.getLoadedExtension(protocolName);
            if (protocol != null) {
                protocol.destroy();
            }
        } catch (Throwable t) {
            logger.warn(t.getMessage(), t);
        }
    }
}
 
Example #13
Source File: RegistriesPageHandler.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #14
Source File: ProtocolConfig.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public static void destroyAll() {
    AbstractRegistryFactory.destroyAll();
    ExtensionLoader<Protocol> loader = ExtensionLoader.getExtensionLoader(Protocol.class);
    for (String protocolName : loader.getLoadedExtensions()) {
        try {
            Protocol protocol = loader.getLoadedExtension(protocolName);
            if (protocol != null) {
                protocol.destroy();
            }
        } catch (Throwable t) {
            logger.warn(t.getMessage(), t);
        }
    }
}
 
Example #15
Source File: RegistriesPageHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #16
Source File: DubboRegistryStatusMetrics.java    From watcher with Apache License 2.0 5 votes vote down vote up
@Override
public Object doMonitor(Map<String, Object> params) throws Throwable {
	Map<String, Object> result = Maps.newHashMap();
	
	Collection<Registry> regsitries = AbstractRegistryFactory.getRegistries();
	if (regsitries.size() == 0) {
		throw WatcherException.throwIt("no registry found");
	}
	for (Registry registry : regsitries) {
		result.put(registry.getUrl().getAddress(), registry.isAvailable());
	}
	return result;
}
 
Example #17
Source File: ProtocolConfig.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public static void destroyAll() {
    AbstractRegistryFactory.destroyAll();
    ExtensionLoader<Protocol> loader = ExtensionLoader.getExtensionLoader(Protocol.class);
    for (String protocolName : loader.getLoadedExtensions()) {
        try {
            Protocol protocol = loader.getLoadedExtension(protocolName);
            if (protocol != null) {
                protocol.destroy();
            }
        } catch (Throwable t) {
            logger.warn(t.getMessage(), t);
        }
    }
}
 
Example #18
Source File: ProtocolConfig.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
public static void destroyAll() {
    AbstractRegistryFactory.destroyAll();
    ExtensionLoader<Protocol> loader = ExtensionLoader.getExtensionLoader(Protocol.class);
    for (String protocolName : loader.getLoadedExtensions()) {
        try {
            Protocol protocol = loader.getLoadedExtension(protocolName);
            if (protocol != null) {
                protocol.destroy();
            }
        } catch (Throwable t) {
            logger.warn(t.getMessage(), t);
        }
    }
}
 
Example #19
Source File: ProtocolConfig.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public static void destroyAll() {
    AbstractRegistryFactory.destroyAll();
    ExtensionLoader<Protocol> loader = ExtensionLoader.getExtensionLoader(Protocol.class);
    for (String protocolName : loader.getLoadedExtensions()) {
        try {
            Protocol protocol = loader.getLoadedExtension(protocolName);
            if (protocol != null) {
                protocol.destroy();
            }
        } catch (Throwable t) {
            logger.warn(t.getMessage(), t);
        }
    }
}
 
Example #20
Source File: RegistriesController.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/subscribed", method = RequestMethod.GET)
public String subscribed(@RequestParam String registry, Model model) {
	Collection<Registry> registries = AbstractRegistryFactory.getRegistries();
	Registry reg = null;
	if (registries.size() > 0) {
		for (Registry r : registries) {
			String sp = r.getUrl().getAddress();
			if (((registry == null || registry.length() == 0) && reg == null) || sp.equals(registry)) {
				reg = r;
			}
		}
	}

	List<String> rows = new ArrayList<String>();

	if (reg instanceof AbstractRegistry) {
		Set<URL> services = ((AbstractRegistry) reg).getSubscribed().keySet();
		if (services.size() > 0) {
			for (URL u : services) {
				rows.add(u.toFullString());
			}
		}
	}

	model.addAttribute("registry", registry);
	model.addAttribute("rows", rows);
	return "registry/subscribed";
}
 
Example #21
Source File: RegistriesController.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/registered", method = RequestMethod.GET)
public String registered(@RequestParam String registry, Model model) {
	Collection<Registry> registries = AbstractRegistryFactory.getRegistries();
	Registry reg = null;
	if (registries.size() > 0) {
		for (Registry r : registries) {
			String sp = r.getUrl().getAddress();
			if (((registry == null || registry.length() == 0) && reg == null) || sp.equals(registry)) {
				reg = r;
			}
		}
	}

	List<String> rows = new ArrayList<String>();

	if (reg instanceof AbstractRegistry) {
		Set<URL> services = ((AbstractRegistry) reg).getRegistered();
		if (services != null && services.size() > 0) {
			for (URL u : services) {
				rows.add(u.toFullString());
			}
		}
	}

	model.addAttribute("registry", registry);
	model.addAttribute("rows", rows);
	return "registry/registered";
}
 
Example #22
Source File: RegistriesPageHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #23
Source File: SubscribedPageHandler.java    From dubbox with Apache License 2.0 4 votes vote down vote up
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(" &gt; " + registry.getUrl().getAddress());
        } else {
            select.append(" &gt; <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("<", "&lt;").replace(">", "&gt;"));
                rows.add(row);
            }
        }
    }
    return new Page("<a href=\"registries.html\">Registries</a>" + select.toString() + " &gt; <a href=\"registered.html?registry=" + registryAddress + "\">Registered</a> | Subscribed", "Subscribed (" + rows.size() + ")",
            new String[] { "Consumer URL:" }, rows);
}
 
Example #24
Source File: RegistryStatusCheckerTest.java    From dubbo-2.6.5 with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
    AbstractRegistryFactory.destroyAll();
}
 
Example #25
Source File: RegisteredPageHandler.java    From dubbox with Apache License 2.0 4 votes vote down vote up
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(" &gt; " + registry.getUrl().getAddress());
        } else {
            select.append(" &gt; <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("<", "&lt;").replace(">", "&gt;"));
                rows.add(row);
            }
        }
    }
    return new Page("<a href=\"registries.html\">Registries</a>" + select.toString() + " &gt; Registered | <a href=\"subscribed.html?registry=" + registryAddress + "\">Subscribed</a>", "Registered (" + rows.size() + ")",
            new String[] { "Provider URL:" }, rows);
}
 
Example #26
Source File: SubscribedPageHandler.java    From dubbox with Apache License 2.0 4 votes vote down vote up
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(" &gt; " + registry.getUrl().getAddress());
        } else {
            select.append(" &gt; <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("<", "&lt;").replace(">", "&gt;"));
                rows.add(row);
            }
        }
    }
    return new Page("<a href=\"registries.html\">Registries</a>" + select.toString() + " &gt; <a href=\"registered.html?registry=" + registryAddress + "\">Registered</a> | Subscribed", "Subscribed (" + rows.size() + ")",
            new String[] { "Consumer URL:" }, rows);
}
 
Example #27
Source File: RegistryConfig.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public static void destroyAll() {
    AbstractRegistryFactory.destroyAll();
}
 
Example #28
Source File: RegistryStatusCheckerTest.java    From dubbox with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
    AbstractRegistryFactory.destroyAll();
}
 
Example #29
Source File: RegistryConfig.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public static void destroyAll() {
    AbstractRegistryFactory.destroyAll();
}
 
Example #30
Source File: RegistryStatusCheckerTest.java    From dubbox with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
    AbstractRegistryFactory.destroyAll();
}