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;
19import java.util.HashSet;
20import java.util.Set;
21import org.apache.juddi.Registry;
22import org.apache.juddi.api.impl.JUDDIApiImpl;
23import org.apache.juddi.api.impl.UDDICustodyTransferImpl;
24import org.apache.juddi.api.impl.UDDIInquiryImpl;
25import org.apache.juddi.api.impl.UDDIPublicationImpl;
26import org.apache.juddi.api.impl.UDDISecurityImpl;
27import org.apache.juddi.api.impl.UDDISubscriptionImpl;
28import org.apache.juddi.api.impl.UDDIValueSetCachingImpl;
29import org.apache.juddi.api.impl.UDDIValueSetValidationImpl;
30importstatic org.apache.juddi.config.AppConfig.JUDDI_CONFIGURATION_FILE_SYSTEM_PROPERTY;
31import org.apache.juddi.v3.client.UDDIConstants;
32import org.uddi.api_v3.BusinessList;
33import org.uddi.api_v3.FindBusiness;
34import org.uddi.api_v3.Name;
3536/**37 * In this case, we are not using juddi's client/clerk/transport apis, just38 * using the instance classes directly39 *40 * @author Alex O'Ree41 */42publicclassEmbeddedNoWebNoClerk {
4344publicstaticvoid main(String[] args) throws Exception {
45//tell juddi to load this server configuration file from disk46 File cfg = new File("juddi-server.xml").getCanonicalFile();
47 System.setProperty(JUDDI_CONFIGURATION_FILE_SYSTEM_PROPERTY, cfg.getCanonicalPath());
4849//start up the services50 Registry.start();
51//note these instance classes will be used to server web requests52//do not share embedded access with web access classes due to context53//sharing issues.54 JUDDIApiImpl juddi = new JUDDIApiImpl();
55 UDDIPublicationImpl publish = new UDDIPublicationImpl();
56 UDDIInquiryImpl inquiry = new UDDIInquiryImpl();
57 UDDISecurityImpl security = new UDDISecurityImpl();
58 UDDISubscriptionImpl subscription = new UDDISubscriptionImpl();
59 UDDICustodyTransferImpl custody = new UDDICustodyTransferImpl();
60 UDDIValueSetCachingImpl cache = new UDDIValueSetCachingImpl();
61 UDDIValueSetValidationImpl validation = new UDDIValueSetValidationImpl();
6263//clients within this process can use invm transport64 {
65 System.out.println("started, verifying embedded access");
66 FindBusiness fb = new FindBusiness();
67 fb.setMaxRows(200);
68 fb.setListHead(0);
69// fb.setAuthInfo(GetToken());70 org.uddi.api_v3.FindQualifiers fq = new org.uddi.api_v3.FindQualifiers();
71 fq.getFindQualifier().add(UDDIConstants.CASE_INSENSITIVE_MATCH);
72 fq.getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
73 fq.getFindQualifier().add(UDDIConstants.SORT_BY_NAME_ASC);
74 fb.setFindQualifiers(fq);
75 Name searchname = new Name();
76 searchname.setLang("%");
77 searchname.setValue("%");
78 fb.getName().add(searchname);
7980 BusinessList result = inquiry.findBusiness(fb);
81 System.out.println(result.getBusinessInfos().getBusinessInfo().size() + " businesses available");
82//uddiClientHttp.stop();83 }
8485//for cases that require authentication...86//the authenticator should work the same as it is in tomcat87//except if you use http style authentication. in this case, you'll have 88//to do this....89//Set<String> roles = new HashSet<String>();90//Note: juddi doesn't use servlet container roles91//publish.setContext(new MyWebContext("uddi", roles));9293 System.out.println("ready, press enter to stop");
94// System.console().readLine();9596//shutdown97 Registry.stop();
98 }
99 }