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.test.deployment.active_java;
25 
26 import com.sun.star.lang.XSingleComponentFactory;
27 import com.sun.star.lib.uno.helper.Factory;
28 import com.sun.star.registry.InvalidRegistryException;
29 import com.sun.star.registry.XRegistryKey;
30 
31 public final class Services {
Services()32     private Services() {}
33 
__getComponentFactory( String implementation)34     public static XSingleComponentFactory __getComponentFactory(
35         String implementation)
36     {
37         if (implementation.equals(Dispatch.implementationName)) {
38             return Factory.createComponentFactory(
39                 Dispatch.class, Dispatch.implementationName,
40                 Dispatch.serviceNames);
41         } else if (implementation.equals(Provider.implementationName)) {
42             return Factory.createComponentFactory(
43                 Provider.class, Provider.implementationName,
44                 Provider.serviceNames);
45         } else {
46             return null;
47         }
48     }
49 
__writeRegistryServiceInfo(XRegistryKey key)50     public static boolean __writeRegistryServiceInfo(XRegistryKey key) {
51         if (!(Factory.writeRegistryServiceInfo(
52                   Dispatch.implementationName, Dispatch.serviceNames, key) &&
53               Factory.writeRegistryServiceInfo(
54                   Provider.implementationName, Provider.serviceNames, key)))
55         {
56             return false;
57         }
58         try {
59             key.
60                 createKey(
61                     "/" + Dispatch.implementationName +
62                     "/UNO/SINGLETONS/" +
63                     "com.sun.star.test.deployment.active_java_singleton").
64                 setStringValue(Dispatch.implementationName);
65         } catch (InvalidRegistryException e) {
66             return false;
67         }
68         return true;
69     }
70 }
71