Examples of DiscoveryClient


Examples of org.wso2.carbon.discovery.client.DiscoveryClient

            String msg = "No Discovery proxy has been configured at tenant level or global level";
            log.error(msg);
            throw new CarbonException(msg);
        }

        DiscoveryClient discoveryClient;
        try {
            discoveryClient = new DiscoveryClient(clientCfgCtx, proxyURLString);
        } catch (DiscoveryException e) {
            handleException("Error while initializing a Discovery client for the URL: " +
                        proxyURLString, e);
            return null;
        }

        Set<String> urlList = new HashSet<String>();
        Exception ex = null;

        try {
            TargetService[] services = discoveryClient.probe(types, scopes, matchingRule);
            if (services != null) {
                // The probe may have returned multiple services
                // Need to extract URLs from each of them
                for (TargetService service : services) {
                    if (service.getXAddresses() != null) {
                        for (URI uri : service.getXAddresses()) {
                            urlList.add(uri.toString());
                        }
                    }
                }
            }

        } catch (DiscoveryException e) {
            ex = e;
        } finally {
            try {
                discoveryClient.cleanup();
            } catch (DiscoveryException ignored) {
                // This one we let go by - We have completed the probe so we can return the URLs
                log.warn("Error while cleaning up the discovery client to URL: " + proxyURLString);
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.