1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package com.sun.star.comp.helper;
25 
26 import com.sun.star.comp.loader.JavaLoader;
27 
28 import com.sun.star.comp.servicemanager.ServiceManager;
29 import com.sun.star.uno.UnoRuntime;
30 
31 import com.sun.star.container.XSet;
32 import com.sun.star.container.XContentEnumerationAccess;
33 import com.sun.star.container.XEnumeration;
34 import com.sun.star.container.XEnumerationAccess;
35 import com.sun.star.container.XElementAccess;
36 
37 import com.sun.star.lang.XComponent;
38 
39 import com.sun.star.lang.XServiceInfo;
40 import com.sun.star.lang.XMultiServiceFactory;
41 import com.sun.star.lang.XSingleServiceFactory;
42 import com.sun.star.lang.XInitialization;
43 
44 import com.sun.star.loader.XImplementationLoader;
45 
46 import com.sun.star.registry.XSimpleRegistry;
47 
48 public class RegistryServiceFactory_Test {
49 
test(String applicat)50 	static public boolean test(String applicat) throws java.lang.Exception {
51 		boolean passed = false;
52 		System.err.println();
53 		System.out.println("*******************************************************************");
54 		System.err.println("RegistryServiceFactory - doing tests...");
55 		System.err.println();
56 
57 		try {
58 			XMultiServiceFactory msf = RegistryServiceFactory.create( applicat );
59 			String services[] = msf.getAvailableServiceNames();
60 			System.out.println("Available services are:");
61 			System.err.println();
62 			if (services.length == 0)
63 				System.out.println("No services avialable!");
64 
65 			else
66 				for ( int i=0; i<services.length; i++ )
67 					System.out.println(services[i]);
68 
69 			passed = true;
70 		}
71 		catch (Exception e) {
72 			e.printStackTrace();
73 		}
74 		System.err.println();
75 		System.err.println("RegistryServiceFactory test passed? " + passed);
76 		System.out.println("*******************************************************************");
77 		System.err.println();
78 		return passed;
79 	}
80 
usage()81 	private static void usage() {
82 		System.out.println();
83 		System.out.println("usage:");
84 		System.out.println("java com.sun.star.comp.helper.RegistryServiceFactory [rdb-file]");
85 		System.out.println("example:");
86 		System.out.println("java com.sun.star.comp.helper.RegistryServiceFactory c:\\applicat.rdb");
87 		System.exit( -1 );
88 	}
89 
main(String args[])90 	static public void main(String args[]) throws java.lang.Exception {
91 		if ( args.length != 1 )
92 			usage();
93 		System.exit( test(args[0]) == true ? 0: -1 );
94 	}
95 }
96 
97