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 import com.sun.star.lang.XMultiServiceFactory;
24 import com.sun.star.lang.XSingleServiceFactory;
25 import com.sun.star.registry.XRegistryKey;
26 import com.sun.star.lang.XTypeProvider;
27 import com.sun.star.lang.XServiceInfo;
28 import com.sun.star.comp.loader.FactoryHelper;
29 
30 public class TestServiceProvider
31 {
32     public static XSingleServiceFactory __getServiceFactory(
33                                                 String implName,
34                                                 XMultiServiceFactory multiFactory,
35                                                 XRegistryKey regKey) {
36         XSingleServiceFactory xSingleServiceFactory = null;
37 
38         if (implName.equals( TestComponentA.class.getName()) )
39             xSingleServiceFactory = FactoryHelper.getServiceFactory(
40                 TestComponentA.class, TestComponentA.__serviceName,
41                 multiFactory, regKey);
42         else if (implName.equals(TestComponentB.class.getName()))
43             xSingleServiceFactory= FactoryHelper.getServiceFactory(
44                 TestComponentB.class, TestComponentB.__serviceName,
45                 multiFactory, regKey);
46         return xSingleServiceFactory;
47     }
48 
49     // This method not longer necessary since OOo 3.4 where the component registration
50     // was changed to passive component registration. For more details see
51     // http://wiki.services.openoffice.org/wiki/Passive_Component_Registration
52 
53 //     public static boolean __writeRegistryServiceInfo(XRegistryKey regKey){
54 //         boolean bregA= FactoryHelper.writeRegistryServiceInfo(
55 //             TestComponentA.class.getName(),
56 //             TestComponentA.__serviceName, regKey);
57 //         boolean bregB= FactoryHelper.writeRegistryServiceInfo(
58 //             TestComponentB.class.getName(),
59 //             TestComponentB.__serviceName, regKey);
60 //         return bregA && bregB;
61 //     }
62 }
63 
64 
65