This project has retired. For details please refer to its Attic page.
EmbeddedNoWeb xref
View Javadoc
1   /*
2    * Copyright 2020 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  package org.apache.juddi.example.juddi.embedded;
17  
18  import java.io.File;
19  import static org.apache.juddi.config.AppConfig.JUDDI_CONFIGURATION_FILE_SYSTEM_PROPERTY;
20  import org.apache.juddi.v3.client.UDDIConstants;
21  import org.apache.juddi.v3.client.config.UDDIClient;
22  import org.apache.juddi.v3.client.transport.Transport;
23  import org.uddi.api_v3.BusinessList;
24  import org.uddi.api_v3.FindBusiness;
25  import org.uddi.api_v3.Name;
26  import org.uddi.v3_service.UDDIInquiryPortType;
27  import org.uddi.v3_service.UDDISecurityPortType;
28  
29  /**
30   * This sample shows you how to interact with jUDDI without exposing any web
31   * services to the network. It's basically a standalone java process that can
32   * used for any purpose.
33   *
34   * @author Alex O'Ree
35   */
36  public class EmbeddedNoWeb {
37  
38      public static void main(String[] args) throws Exception {
39          
40  
41          //access the client as normal using invm transports
42          File cfg = new File("juddi-server.xml").getCanonicalFile();
43          System.setProperty(JUDDI_CONFIGURATION_FILE_SYSTEM_PROPERTY, cfg.getCanonicalPath());
44          cfg = new File("uddi-invm.xml");
45          UDDIClient uddiClientEmdded = new UDDIClient(cfg.getCanonicalPath());
46          uddiClientEmdded.start();
47          Transport transport = uddiClientEmdded.getTransport("default");
48          UDDISecurityPortType clientSecurity = transport.getUDDISecurityService();
49          UDDIInquiryPortType clientInquiry = transport.getUDDIInquiryService();
50  
51          System.out.println("started, verifying embedded access");
52          FindBusiness fb = new FindBusiness();
53          fb.setMaxRows(200);
54          fb.setListHead(0);
55          // fb.setAuthInfo(GetToken());
56          org.uddi.api_v3.FindQualifiers fq = new org.uddi.api_v3.FindQualifiers();
57          fq.getFindQualifier().add(UDDIConstants.CASE_INSENSITIVE_MATCH);
58          fq.getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
59          fq.getFindQualifier().add(UDDIConstants.SORT_BY_NAME_ASC);
60          fb.setFindQualifiers(fq);
61          Name searchname = new Name();
62          searchname.setLang("%");
63          searchname.setValue("%");
64          fb.getName().add(searchname);
65  
66          BusinessList result = clientInquiry.findBusiness(fb);
67          System.out.println(result.getBusinessInfos().getBusinessInfo().size() + " businesses available");
68          uddiClientEmdded.stop();
69          
70          //this appears to hang, there's a background thread spawned somewhere that doesn't die
71  
72      }
73  }