This project has retired. For details please refer to its Attic page.
UddiFindEndpoints xref
View Javadoc
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 at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * 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 and
14   * limitations under the License.
15   *
16   */
17  package org.apache.juddi.v3.client.cli;
18  
19  import java.util.List;
20  import org.apache.juddi.v3.client.config.UDDIClerk;
21  import org.apache.juddi.v3.client.config.UDDIClient;
22  
23  /**
24   * This class show you how get all available Access Points/Endpoints for a
25   * service. This is harder than it sounds due to the complexity of UDDI's data
26   * structure. The output is the list of URLs given a service's key
27   *
28   * @author <a href="mailto:alexoree@apache.org">Alex O'Ree</a>
29   */
30  public class UddiFindEndpoints {
31  
32          private UDDIClerk clerk = null;
33  
34          public UddiFindEndpoints() {
35                  try {
36              // create a manager and read the config in the archive; 
37                          // you can use your config file name
38                          UDDIClient clerkManager = new UDDIClient("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.xml
43                  } catch (Exception e) {
44                          e.printStackTrace();
45                  }
46          }
47  
48          public void fire(String authtoken, String key) {
49                  try {
50                          if (key == null) {
51                                  key = "uddi:juddi.apache.org:services-inquiry";
52                          }
53  
54                          List<String> endpoints = clerk.getEndpoints(key);
55                          System.out.println("Endpoints returned: " + endpoints.size());
56                          for (int i = 0; i < endpoints.size(); i++) {
57                                  System.out.println(endpoints.get(i));
58                          }
59  
60                  } catch (Exception e) {
61                          e.printStackTrace();
62                  }
63          }
64  
65          public static void main(String args[]) {
66                  UddiFindEndpoints sp = new UddiFindEndpoints();
67                  sp.fire(null, null);
68          }
69  }