1/*2 * Copyright 2001-2013 The Apache Software Foundation.3 * 4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 *16 */17package org.apache.juddi.v3.client.cli;
1819import java.util.List;
20import org.apache.juddi.v3.client.config.UDDIClerk;
21import org.apache.juddi.v3.client.config.UDDIClient;
2223/**24 * This class show you how get all available Access Points/Endpoints for a25 * service. This is harder than it sounds due to the complexity of UDDI's data26 * structure. The output is the list of URLs given a service's key27 *28 * @author <a href="mailto:alexoree@apache.org">Alex O'Ree</a>29 */30publicclassUddiFindEndpoints {
3132privateUDDIClerk clerk = null;
3334publicUddiFindEndpoints() {
35try {
36// create a manager and read the config in the archive; 37// you can use your config file name38UDDIClient clerkManager = newUDDIClient("META-INF/simple-publish-uddi.xml");
39 clerk = clerkManager.getClerk("default");
40// a ClerkManager can be a client to multiple UDDI nodes, so 41// supply the nodeName (defined in your uddi.xml.42// The transport can be WS, inVM, RMI etc which is defined in the uddi.xml43 } catch (Exception e) {
44 e.printStackTrace();
45 }
46 }
4748publicvoid fire(String authtoken, String key) {
49try {
50if (key == null) {
51 key = "uddi:juddi.apache.org:services-inquiry";
52 }
5354 List<String> endpoints = clerk.getEndpoints(key);
55 System.out.println("Endpoints returned: " + endpoints.size());
56for (int i = 0; i < endpoints.size(); i++) {
57 System.out.println(endpoints.get(i));
58 }
5960 } catch (Exception e) {
61 e.printStackTrace();
62 }
63 }
6465publicstaticvoid main(String args[]) {
66UddiFindEndpoints sp = newUddiFindEndpoints();
67 sp.fire(null, null);
68 }
69 }