From f3051abde54e7a0bc3e2d184e31ac011e96d3e6b Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 21 Dec 2012 13:48:07 +0100 Subject: API CHANGE: Remove deprecated cppuhelper/servicefactory.hxx and Java equiv. ... com.sun.star.comp.helper.RegistryServiceFactory (juh.jar). Superseded by default bootstrap mechanisms. An aborting stub for non-inline cppu::createRegistryServiceFactory is left in cppuhelper/srouce/compat.cxx to avoid having to incompatibly change cppuhelper/soruce/gcc3.map. Change-Id: I590e50b8f57e86d4bb3e00d157c9e5907c02f267 --- javaunohelper/Jar_juh.mk | 1 - javaunohelper/Zip_juh.mk | 1 - .../star/comp/helper/RegistryServiceFactory.java | 176 --------------------- javaunohelper/source/javaunohelper.cxx | 91 ----------- .../comp/helper/RegistryServiceFactory_Test.java | 71 --------- 5 files changed, 340 deletions(-) delete mode 100644 javaunohelper/com/sun/star/comp/helper/RegistryServiceFactory.java delete mode 100644 javaunohelper/test/com/sun/star/comp/helper/RegistryServiceFactory_Test.java (limited to 'javaunohelper') diff --git a/javaunohelper/Jar_juh.mk b/javaunohelper/Jar_juh.mk index d95a8e5dddd6..02fb033498de 100644 --- a/javaunohelper/Jar_juh.mk +++ b/javaunohelper/Jar_juh.mk @@ -47,7 +47,6 @@ $(eval $(call gb_Jar_add_sourcefiles,juh,\ javaunohelper/com/sun/star/comp/helper/BootstrapException \ javaunohelper/com/sun/star/comp/helper/ComponentContext \ javaunohelper/com/sun/star/comp/helper/ComponentContextEntry \ - javaunohelper/com/sun/star/comp/helper/RegistryServiceFactory \ javaunohelper/com/sun/star/comp/helper/SharedLibraryLoader \ javaunohelper/com/sun/star/comp/helper/UnoInfo \ javaunohelper/com/sun/star/comp/juhtest/SmoketestCommandEnvironment \ diff --git a/javaunohelper/Zip_juh.mk b/javaunohelper/Zip_juh.mk index e59c4cec4d5c..c4a613924f18 100644 --- a/javaunohelper/Zip_juh.mk +++ b/javaunohelper/Zip_juh.mk @@ -33,7 +33,6 @@ $(eval $(call gb_Zip_add_files,juh_src,\ com/sun/star/comp/helper/BootstrapException.java \ com/sun/star/comp/helper/ComponentContext.java \ com/sun/star/comp/helper/ComponentContextEntry.java \ - com/sun/star/comp/helper/RegistryServiceFactory.java \ com/sun/star/comp/helper/SharedLibraryLoader.java \ com/sun/star/comp/helper/UnoInfo.java \ com/sun/star/comp/juhtest/SmoketestCommandEnvironment.java \ diff --git a/javaunohelper/com/sun/star/comp/helper/RegistryServiceFactory.java b/javaunohelper/com/sun/star/comp/helper/RegistryServiceFactory.java deleted file mode 100644 index 8f0bc291d750..000000000000 --- a/javaunohelper/com/sun/star/comp/helper/RegistryServiceFactory.java +++ /dev/null @@ -1,176 +0,0 @@ -// -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -package com.sun.star.comp.helper; - - -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.uno.RuntimeException; - -/** The class provides a set of methods which create instances of the - com.sun.star.lang.RegistryServiceManager service. - - @deprecated use class Bootstrap instead -*/ -public class RegistryServiceFactory { - static { - if (System.getProperty("java.vendor") == "The Android Project") { - // See corresponding code in - // javaunohelper/com/sun/star/comp/helper/Bootstrap.java for more - // comments. - - boolean disable_dynloading = false; - try { - System.loadLibrary("lo-bootstrap"); - } catch (UnsatisfiedLinkError e) { - disable_dynloading = true; - } - - if (!disable_dynloading) - System.loadLibrary("juh"); - } else - System.loadLibrary("juh"); - } - - private static native Object createRegistryServiceFactory( - String writeRegistryFile, - String readRegistryFile, - boolean readOnly, - ClassLoader loader); - - /** - * This bootstraps an initial service factory working on a registry. If the first or both - * parameters contain a value then the service factory is initialized with a simple registry - * or a nested registry. Otherwise the service factory must be initialized later with a valid - * registry. - *
- * @param writeRegistryFile file name of the simple registry or the first registry file of - * the nested registry which will be opened with read/write rights. This - * file will be created if necessary. - * @param readRegistryFile file name of the second registry file of the nested registry - * which will be opened with readonly rights. - * @return a new RegistryServiceFactory. - */ - public static XMultiServiceFactory create(String writeRegistryFile, String readRegistryFile) - throws com.sun.star.uno.Exception - { - return create(writeRegistryFile, readRegistryFile, false); - } - - /** - * This bootstraps an initial service factory working on a registry. If the first or both - * parameters contain a value then the service factory is initialized with a simple registry - * or a nested registry. Otherwise the service factory must be initialized later with a valid - * registry. - *
- * @param writeRegistryFile file name of the simple registry or the first registry file of - * the nested registry which will be opened with read/write rights. This - * file will be created if necessary. - * @param readRegistryFile file name of the second registry file of the nested registry - * which will be opened with readonly rights. - * @param readOnly flag which specify that the first registry file will be opened with - * readonly rights. Default is FALSE. If this flag is used the registry - * will not be created if not exist. - * - * @return a new RegistryServiceFactory - */ - public static XMultiServiceFactory create(String writeRegistryFile, String readRegistryFile, boolean readOnly) - throws com.sun.star.uno.Exception - { - // Ensure that we are on a native threads vm - // (binary UNO does use native threads). - String vm_info = System.getProperty("java.vm.info"); - if(vm_info != null && vm_info.indexOf("green") != -1) - throw new RuntimeException(RegistryServiceFactory.class.toString() + ".create - can't use binary UNO with green threads"); - - - if (writeRegistryFile == null && readRegistryFile == null) - throw new com.sun.star.uno.Exception("No registry is specified!"); - -// if (writeRegistryFile != null) { -// java.io.File file = new java.io.File(writeRegistryFile); - -// if (file.exists()) { -// if (!file.isFile()) -// throw new com.sun.star.uno.Exception(writeRegistryFile + " is not a file!"); -// } else -// throw new com.sun.star.uno.Exception(writeRegistryFile + " doese not exist!"); -// } - -// if (readRegistryFile != null) { -// java.io.File file = new java.io.File(readRegistryFile); - -// if (file.exists()) { -// if (!file.isFile()) -// throw new com.sun.star.uno.Exception(readRegistryFile + " is not a file!"); -// } else -// throw new com.sun.star.uno.Exception(readRegistryFile + " doese not exist!"); -// } - - Object obj = createRegistryServiceFactory( - writeRegistryFile, readRegistryFile, readOnly, - RegistryServiceFactory.class.getClassLoader() ); - return UnoRuntime.queryInterface( - XMultiServiceFactory.class, obj ); - } - - /** - * This bootstraps an initial service factory working on a registry file. - *
- * @param registryFile file name of the registry to use/ create; if this is an empty - * string, the default registry is used instead - * - * @return a new RegistryServiceFactory. - */ - public static XMultiServiceFactory create(String registryFile) - throws com.sun.star.uno.Exception - { - return create(registryFile, null, false); - } - - /** - * This bootstraps an initial service factory working on a registry file. - *
- * @param registryFile file name of the registry to use/ create; if this is an empty - * string, the default registry is used instead - * @param readOnly flag which specify that the registry file will be opened with - * readonly rights. Default is FALSE. If this flag is used the registry - * will not be created if not exist. - * - * @return a new RegistryServiceFactory. - */ - public static XMultiServiceFactory create(String registryFile, boolean readOnly) - throws com.sun.star.uno.Exception - { - return create(registryFile, null, readOnly); - } - - /** - * This bootstraps a service factory without initialize a registry. - *
- * @return a new RegistryServiceFactory. - */ - public static XMultiServiceFactory create() throws com.sun.star.uno.Exception { - return create( null, null, false ); - } -} - -// vim:set shiftwidth=4 softtabstop=4 expandtab: diff --git a/javaunohelper/source/javaunohelper.cxx b/javaunohelper/source/javaunohelper.cxx index 45c93926cbe3..c1afc4aba720 100644 --- a/javaunohelper/source/javaunohelper.cxx +++ b/javaunohelper/source/javaunohelper.cxx @@ -25,8 +25,6 @@ #include #include -#include -#include #include #include @@ -241,93 +239,4 @@ Java_com_sun_star_comp_helper_SharedLibraryLoader_component_1getFactory( return joSLL_cpp; } -/* - * Class: com_sun_star_comp_helper_RegistryServiceFactory - * Method: createRegistryServiceFactory - * Signature: (Ljava/lang/String;Ljava/lang/String;Z)Ljava/lang/Object; - */ -extern "C" SAL_JNI_EXPORT jobject JNICALL -Java_com_sun_star_comp_helper_RegistryServiceFactory_createRegistryServiceFactory( - JNIEnv * pJEnv, SAL_UNUSED_PARAMETER jclass, jstring jWriteRegFile, - jstring jReadRegFile, jboolean jbReadOnly, jobject loader ) -{ - jobject joRegServiceFac = 0; - - try - { - OUString aWriteRegFile; - OUString aReadRegFile; - - sal_Bool bReadOnly = jbReadOnly == JNI_FALSE ? sal_False : sal_True; - - if (jReadRegFile) { - const jchar* pjReadRegFile = pJEnv->GetStringChars(jReadRegFile, NULL); - aReadRegFile = OUString(pjReadRegFile); - pJEnv->ReleaseStringChars(jReadRegFile, pjReadRegFile); - } - - if (jWriteRegFile) { - const jchar * pjWriteRegFile = pJEnv->GetStringChars(jWriteRegFile, NULL); - aWriteRegFile = OUString(pjWriteRegFile); - pJEnv->ReleaseStringChars(jWriteRegFile, pjWriteRegFile); - } - - // bootstrap - Reference< lang::XMultiServiceFactory > rMSFac; - if (aReadRegFile.isEmpty()) - rMSFac = ::cppu::createRegistryServiceFactory( aWriteRegFile, bReadOnly); - else - rMSFac = ::cppu::createRegistryServiceFactory(aWriteRegFile, aReadRegFile, bReadOnly); - - Reference< beans::XPropertySet > xProps( - rMSFac, UNO_QUERY_THROW ); - Reference< XComponentContext > xContext( - xProps->getPropertyValue( OUSTR("DefaultContext") ), UNO_QUERY_THROW ); - - // create vm access - ::rtl::Reference< ::jvmaccess::UnoVirtualMachine > vm_access( - ::javaunohelper::create_vm_access( pJEnv, loader ) ); - // wrap vm singleton entry - xContext = ::javaunohelper::install_vm_singleton( xContext, vm_access ); - rMSFac.set( xContext->getServiceManager(), UNO_QUERY_THROW ); - - // get uno envs - OUString aCurrentEnv(RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME)); - OUString java_env_name = OUSTR(UNO_LB_JAVA); - Environment java_env, curr_env; - uno_getEnvironment((uno_Environment **)&curr_env, aCurrentEnv.pData, NULL); - uno_getEnvironment( (uno_Environment **)&java_env, java_env_name.pData, vm_access.get() ); - - Mapping curr_java(curr_env.get(), java_env.get()); - if (! curr_java.is()) - { - throw RuntimeException( - OUSTR("no C++ <-> Java mapping available!"), Reference< XInterface >() ); - } - - jobject joGlobalRegServiceFac = - (jobject)curr_java.mapInterface( - rMSFac.get(), - getCppuType((Reference< lang::XMultiServiceFactory > *)0) ); - joRegServiceFac = pJEnv->NewLocalRef( joGlobalRegServiceFac ); - pJEnv->DeleteGlobalRef(joGlobalRegServiceFac); - } - catch (Exception & exc) - { - jclass c = pJEnv->FindClass( "com/sun/star/uno/RuntimeException" ); - if (0 != c) - { - OString cstr( ::rtl::OUStringToOString( - exc.Message, RTL_TEXTENCODING_JAVA_UTF8 ) ); - OSL_TRACE( __FILE__": forwarding Exception: %s", cstr.getStr() ); - pJEnv->ThrowNew( c, cstr.getStr() ); - } - return 0; - } - - OSL_TRACE("javaunohelper.cxx: object %i", joRegServiceFac); - - return joRegServiceFac; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/javaunohelper/test/com/sun/star/comp/helper/RegistryServiceFactory_Test.java b/javaunohelper/test/com/sun/star/comp/helper/RegistryServiceFactory_Test.java deleted file mode 100644 index d541fbea1291..000000000000 --- a/javaunohelper/test/com/sun/star/comp/helper/RegistryServiceFactory_Test.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package com.sun.star.comp.helper; - -import com.sun.star.lang.XMultiServiceFactory; - -public class RegistryServiceFactory_Test { - - static public boolean test(String applicat) throws java.lang.Exception { - boolean passed = false; - System.err.println(); - System.out.println("*******************************************************************"); - System.err.println("RegistryServiceFactory - doing tests..."); - System.err.println(); - - try { - XMultiServiceFactory msf = RegistryServiceFactory.create( applicat ); - String services[] = msf.getAvailableServiceNames(); - System.out.println("Available services are:"); - System.err.println(); - if (services.length == 0) - System.out.println("No services avialable!"); - - else - for ( int i=0; i