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 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 */16package org.apache.juddi.example.juddi.embedded;
1718import java.io.File;
19importstatic org.apache.juddi.config.AppConfig.JUDDI_CONFIGURATION_FILE_SYSTEM_PROPERTY;
20import org.apache.juddi.v3.client.UDDIConstants;
21import org.apache.juddi.v3.client.config.UDDIClient;
22import org.apache.juddi.v3.client.transport.Transport;
23import org.uddi.api_v3.BusinessList;
24import org.uddi.api_v3.FindBusiness;
25import org.uddi.api_v3.Name;
26import org.uddi.v3_service.UDDIInquiryPortType;
27import org.uddi.v3_service.UDDISecurityPortType;
2829/**30 * This sample shows you how to interact with jUDDI without exposing any web31 * services to the network. It's basically a standalone java process that can32 * used for any purpose.33 *34 * @author Alex O'Ree35 */36publicclassEmbeddedNoWeb {
3738publicstaticvoid main(String[] args) throws Exception {
394041//access the client as normal using invm transports42 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");
45UDDIClient uddiClientEmdded = newUDDIClient(cfg.getCanonicalPath());
46 uddiClientEmdded.start();
47Transport transport = uddiClientEmdded.getTransport("default");
48UDDISecurityPortType clientSecurity = transport.getUDDISecurityService();
49UDDIInquiryPortType clientInquiry = transport.getUDDIInquiryService();
5051 System.out.println("started, verifying embedded access");
52FindBusiness fb = newFindBusiness();
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);
61Name searchname = newName();
62 searchname.setLang("%");
63 searchname.setValue("%");
64 fb.getName().add(searchname);
6566BusinessList result = clientInquiry.findBusiness(fb);
67 System.out.println(result.getBusinessInfos().getBusinessInfo().size() + " businesses available");
68 uddiClientEmdded.stop();
6970//this appears to hang, there's a background thread spawned somewhere that doesn't die7172 }
73 }