1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
29 package com
.sun
.star
.comp
.helper
;
32 import com
.sun
.star
.lang
.XMultiServiceFactory
;
33 import com
.sun
.star
.uno
.UnoRuntime
;
34 import com
.sun
.star
.uno
.RuntimeException
;
36 /** The class provides a set of methods which create instances of the
37 com.sun.star.lang.RegistryServiceManager service.
39 @deprecated use class Bootstrap instead
41 public class RegistryServiceFactory
{
43 System
.loadLibrary("juh");
46 private static native Object
createRegistryServiceFactory(
47 String writeRegistryFile
,
48 String readRegistryFile
,
53 * This bootstraps an initial service factory working on a registry. If the first or both
54 * parameters contain a value then the service factory is initialized with a simple registry
55 * or a nested registry. Otherwise the service factory must be initialized later with a valid
58 * @param writeRegistryFile file name of the simple registry or the first registry file of
59 * the nested registry which will be opened with read/write rights. This
60 * file will be created if necessary.
61 * @param readRegistryFile file name of the second registry file of the nested registry
62 * which will be opened with readonly rights.
63 * @return a new RegistryServiceFactory.
65 public static XMultiServiceFactory
create(String writeRegistryFile
, String readRegistryFile
)
66 throws com
.sun
.star
.uno
.Exception
68 return create(writeRegistryFile
, readRegistryFile
, false);
72 * This bootstraps an initial service factory working on a registry. If the first or both
73 * parameters contain a value then the service factory is initialized with a simple registry
74 * or a nested registry. Otherwise the service factory must be initialized later with a valid
77 * @param writeRegistryFile file name of the simple registry or the first registry file of
78 * the nested registry which will be opened with read/write rights. This
79 * file will be created if necessary.
80 * @param readRegistryFile file name of the second registry file of the nested registry
81 * which will be opened with readonly rights.
82 * @param readOnly flag which specify that the first registry file will be opened with
83 * readonly rights. Default is FALSE. If this flag is used the registry
84 * will not be created if not exist.
86 * @return a new RegistryServiceFactory
88 public static XMultiServiceFactory
create(String writeRegistryFile
, String readRegistryFile
, boolean readOnly
)
89 throws com
.sun
.star
.uno
.Exception
91 // Ensure that we are on a native threads vm
92 // (binary UNO does use native threads).
93 String vm_info
= System
.getProperty("java.vm.info");
94 if(vm_info
!= null && vm_info
.indexOf("green") != -1)
95 throw new RuntimeException(RegistryServiceFactory
.class.toString() + ".create - can't use binary UNO with green threads");
98 if (writeRegistryFile
== null && readRegistryFile
== null)
99 throw new com
.sun
.star
.uno
.Exception("No registry is specified!");
101 // if (writeRegistryFile != null) {
102 // java.io.File file = new java.io.File(writeRegistryFile);
104 // if (file.exists()) {
105 // if (!file.isFile())
106 // throw new com.sun.star.uno.Exception(writeRegistryFile + " is not a file!");
108 // throw new com.sun.star.uno.Exception(writeRegistryFile + " doese not exist!");
111 // if (readRegistryFile != null) {
112 // java.io.File file = new java.io.File(readRegistryFile);
114 // if (file.exists()) {
115 // if (!file.isFile())
116 // throw new com.sun.star.uno.Exception(readRegistryFile + " is not a file!");
118 // throw new com.sun.star.uno.Exception(readRegistryFile + " doese not exist!");
121 Object obj
= createRegistryServiceFactory(
122 writeRegistryFile
, readRegistryFile
, readOnly
,
123 RegistryServiceFactory
.class.getClassLoader() );
124 return UnoRuntime
.queryInterface(
125 XMultiServiceFactory
.class, obj
);
129 * This bootstraps an initial service factory working on a registry file.
131 * @param registryFile file name of the registry to use/ create; if this is an empty
132 * string, the default registry is used instead
134 * @return a new RegistryServiceFactory.
136 public static XMultiServiceFactory
create(String registryFile
)
137 throws com
.sun
.star
.uno
.Exception
139 return create(registryFile
, null, false);
143 * This bootstraps an initial service factory working on a registry file.
145 * @param registryFile file name of the registry to use/ create; if this is an empty
146 * string, the default registry is used instead
147 * @param readOnly flag which specify that the registry file will be opened with
148 * readonly rights. Default is FALSE. If this flag is used the registry
149 * will not be created if not exist.
151 * @return a new RegistryServiceFactory.
153 public static XMultiServiceFactory
create(String registryFile
, boolean readOnly
)
154 throws com
.sun
.star
.uno
.Exception
156 return create(registryFile
, null, readOnly
);
160 * This bootstraps a service factory without initialize a registry.
162 * @return a new RegistryServiceFactory.
164 public static XMultiServiceFactory
create() throws com
.sun
.star
.uno
.Exception
{
165 return create( null, null, false );