Update ooo320-m1
[ooovba.git] / javaunohelper / com / sun / star / comp / helper / SharedLibraryLoader.java
blob8cfa52b04d06779471ad9c17fd2f8fc465d07b4d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SharedLibraryLoader.java,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 package com.sun.star.comp.helper;
32 import com.sun.star.uno.UnoRuntime;
33 import com.sun.star.lang.XMultiServiceFactory;
34 import com.sun.star.lang.XSingleServiceFactory;
35 import com.sun.star.registry.XRegistryKey;
37 /**
38 * @deprecated use class Bootstrap bootstrapping a native UNO installation
39 * and use the shared library loader service.
41 * The <code>SharedLibraryLoader</code> class provides the functionality of the <code>com.sun.star.loader.SharedLibrary</code>
42 * service.
43 * <p>
44 * @see com.sun.star.loader.SharedLibrary
45 * @see com.sun.star.comp.servicemanager.ServiceManager
46 * @see com.sun.star.lang.ServiceManager
48 public class SharedLibraryLoader {
49 /**
50 * The default library which contains the SharedLibraryLoader component
52 public static final String DEFAULT_LIBRARY = "shlibloader.uno";
54 /**
55 * The default implementation name
57 public static final String DEFAULT_IMPLEMENTATION = "com.sun.star.comp.stoc.DLLComponentLoader";
59 static {
60 System.loadLibrary("juh");
63 private static native boolean component_writeInfo(
64 String libName, XMultiServiceFactory smgr, XRegistryKey regKey,
65 ClassLoader loader );
67 private static native Object component_getFactory(
68 String libName, String implName, XMultiServiceFactory smgr,
69 XRegistryKey regKey, ClassLoader loader );
71 /**
72 * Supplies the ServiceFactory of the default SharedLibraryLoader.
73 * The defaults are "shlibloader.uno"
74 * for the library and "com.sun.star.comp.stoc.DLLComponentLoader"
75 * for the component name.
76 * <p>
77 * @return the factory for the "com.sun.star.comp.stoc.DLLComponentLoader" component.
78 * @param smgr the ServiceManager
79 * @param regKey the root registry key
80 * @see com.sun.star.loader.SharedLibrary
81 * @see com.sun.star.lang.ServiceManager
82 * @see com.sun.star.registry.RegistryKey
84 public static XSingleServiceFactory getServiceFactory(
85 XMultiServiceFactory smgr,
86 XRegistryKey regKey )
88 return UnoRuntime.queryInterface(
89 XSingleServiceFactory.class,
90 component_getFactory(
91 DEFAULT_LIBRARY, DEFAULT_IMPLEMENTATION, smgr, regKey,
92 SharedLibraryLoader.class.getClassLoader() ) );
95 /**
96 * Loads and returns a specific factory for a given library and implementation name.
97 * <p>
98 * @return the factory of the component
99 * @param libName the name of the shared library
100 * @param impName the implementation name of the component
101 * @param smgr the ServiceManager
102 * @param regKey the root registry key
103 * @see com.sun.star.loader.SharedLibrary
104 * @see com.sun.star.lang.ServiceManager
105 * @see com.sun.star.registry.RegistryKey
107 public static XSingleServiceFactory getServiceFactory(
108 String libName,
109 String impName,
110 XMultiServiceFactory smgr,
111 XRegistryKey regKey )
113 return UnoRuntime.queryInterface(
114 XSingleServiceFactory.class,
115 component_getFactory(
116 libName, impName, smgr, regKey,
117 SharedLibraryLoader.class.getClassLoader() ) );
121 * Registers the SharedLibraryLoader under a RegistryKey.
122 * <p>
123 * @return true if the registration was successfull - otherwise false
124 * @param smgr the ServiceManager
125 * @param regKey the root key under that the component should be registered
126 * @see com.sun.star.loader.SharedLibrary
127 * @see com.sun.star.lang.ServiceManager
128 * @see com.sun.star.registry.RegistryKey
130 public static boolean writeRegistryServiceInfo(
131 com.sun.star.lang.XMultiServiceFactory smgr,
132 com.sun.star.registry.XRegistryKey regKey )
134 return component_writeInfo(
135 DEFAULT_LIBRARY, smgr, regKey,
136 SharedLibraryLoader.class.getClassLoader() );
140 * Registers the SharedLibraryLoader under a RegistryKey.
141 * <p>
142 * @return true if the registration was successfull - otherwise false
143 * @param libName name of the shared library
144 * @param smgr the ServiceManager
145 * @param regKey the root key under that the component should be registered
146 * @see com.sun.star.loader.SharedLibrary
147 * @see com.sun.star.lang.ServiceManager
148 * @see com.sun.star.registry.RegistryKey
150 public static boolean writeRegistryServiceInfo(
151 String libName,
152 com.sun.star.lang.XMultiServiceFactory smgr,
153 com.sun.star.registry.XRegistryKey regKey )
155 throws com.sun.star.registry.InvalidRegistryException,
156 com.sun.star.uno.RuntimeException
158 return component_writeInfo(
159 libName, smgr, regKey, SharedLibraryLoader.class.getClassLoader() );