summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2012-12-21 13:48:07 +0100
committerStephan Bergmann <sbergman@redhat.com>2012-12-21 15:56:44 +0100
commitf3051abde54e7a0bc3e2d184e31ac011e96d3e6b (patch)
tree3144aeb3b6acf6a0b49b4e739c067fd577d65b14
parentb1959dbfadc7483a8e4601310e327beed3c56dc6 (diff)
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
-rw-r--r--cppuhelper/Package_inc.mk1
-rw-r--r--cppuhelper/inc/cppuhelper/servicefactory.hxx116
-rw-r--r--cppuhelper/source/compat.cxx8
-rw-r--r--cppuhelper/source/servicefactory.cxx339
-rw-r--r--javaunohelper/Jar_juh.mk1
-rw-r--r--javaunohelper/Zip_juh.mk1
-rw-r--r--javaunohelper/com/sun/star/comp/helper/RegistryServiceFactory.java176
-rw-r--r--javaunohelper/source/javaunohelper.cxx91
-rw-r--r--javaunohelper/test/com/sun/star/comp/helper/RegistryServiceFactory_Test.java71
9 files changed, 8 insertions, 796 deletions
diff --git a/cppuhelper/Package_inc.mk b/cppuhelper/Package_inc.mk
index fb0688740214..af5a823c1d49 100644
--- a/cppuhelper/Package_inc.mk
+++ b/cppuhelper/Package_inc.mk
@@ -74,7 +74,6 @@ $(eval $(call gb_Package_add_file,cppuhelper_inc,inc/cppuhelper/propshlp.hxx,cpp
$(eval $(call gb_Package_add_file,cppuhelper_inc,inc/cppuhelper/proptypehlp.h,cppuhelper/proptypehlp.h))
$(eval $(call gb_Package_add_file,cppuhelper_inc,inc/cppuhelper/proptypehlp.hxx,cppuhelper/proptypehlp.hxx))
$(eval $(call gb_Package_add_file,cppuhelper_inc,inc/cppuhelper/queryinterface.hxx,cppuhelper/queryinterface.hxx))
-$(eval $(call gb_Package_add_file,cppuhelper_inc,inc/cppuhelper/servicefactory.hxx,cppuhelper/servicefactory.hxx))
$(eval $(call gb_Package_add_file,cppuhelper_inc,inc/cppuhelper/shlib.hxx,cppuhelper/shlib.hxx))
$(eval $(call gb_Package_add_file,cppuhelper_inc,inc/cppuhelper/supportsservice.hxx,cppuhelper/supportsservice.hxx))
$(eval $(call gb_Package_add_file,cppuhelper_inc,inc/cppuhelper/typeprovider.hxx,cppuhelper/typeprovider.hxx))
diff --git a/cppuhelper/inc/cppuhelper/servicefactory.hxx b/cppuhelper/inc/cppuhelper/servicefactory.hxx
deleted file mode 100644
index c52c42474aac..000000000000
--- a/cppuhelper/inc/cppuhelper/servicefactory.hxx
+++ /dev/null
@@ -1,116 +0,0 @@
-/* -*- Mode: C++; 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 .
- */
-#ifndef _CPPUHELPER_SERVICEFACTORY_HXX_
-#define _CPPUHELPER_SERVICEFACTORY_HXX_
-
-#include <rtl/ustring.hxx>
-
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/lang/XMultiComponentFactory.hpp>
-#include "cppuhelperdllapi.h"
-
-
-namespace cppu
-{
-
-/** Deprecated. Use cppuhelper/bootstrap.hxx functions instead.
-
- 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 rWriteRegistryFile
- 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 rReadRegistryFile
- file name of the second registry file of the nested registry
- which will be opened with readonly rights.
- @param bReadOnly
- 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.
- @param rBootstrapPath
- specifies a path where the bootstrap components could be find. If this
- parameter is an empty string the compoents will be searched in the system
- path.
- @deprecated
-*/
-CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
-SAL_CALL createRegistryServiceFactory(
- const ::rtl::OUString & rWriteRegistryFile,
- const ::rtl::OUString & rReadRegistryFile,
- sal_Bool bReadOnly = sal_False,
- const ::rtl::OUString & rBootstrapPath = ::rtl::OUString() )
- SAL_THROW( (::com::sun::star::uno::Exception) );
-
-
-/** Deprecated. Use cppuhelper/bootstrap.hxx functions instead.
-
- This bootstraps an initial service factory working on a registry file.
-
- @param rRegistryFile
- file name of the registry to use/ create; if this is an empty
- string, the default registry is used instead
- @param bReadOnly
- 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.
- @param rBootstrapPath
- specifies a path where the bootstrap components could be find. If this
- parameter is an empty string the compoents will be searched in the system
- path.
- @deprecated
-*/
-inline ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
-SAL_CALL createRegistryServiceFactory(
- const ::rtl::OUString & rRegistryFile,
- sal_Bool bReadOnly = sal_False,
- const ::rtl::OUString & rBootstrapPath = ::rtl::OUString() )
- SAL_THROW( (::com::sun::star::uno::Exception) )
-{
- return ::cppu::createRegistryServiceFactory(
- rRegistryFile, ::rtl::OUString(), bReadOnly, rBootstrapPath );
-}
-
-/** Deprecated. Use cppuhelper/bootstrap.hxx functions instead.
-
- This bootstraps a service factory without initialize a registry.
-
- @param rBootstrapPath
- specifies a path where the bootstrap components could be find. If this
- parameter is an empty string the compoents will be searched in the system
- path.
- @deprecated
-*/
-inline ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
-SAL_CALL createServiceFactory(
- const ::rtl::OUString & rBootstrapPath = ::rtl::OUString() )
- SAL_THROW( (::com::sun::star::uno::Exception) )
-{
- return ::cppu::createRegistryServiceFactory(
- ::rtl::OUString(), ::rtl::OUString(), sal_False, rBootstrapPath );
-}
-
-} // end namespace cppu
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppuhelper/source/compat.cxx b/cppuhelper/source/compat.cxx
index 70139548a8a8..a90d7e56f638 100644
--- a/cppuhelper/source/compat.cxx
+++ b/cppuhelper/source/compat.cxx
@@ -49,6 +49,14 @@ SAL_CALL createNestedRegistry(rtl::OUString const &) SAL_THROW(()) {
for (;;) { std::abort(); } // avoid "must return a value" warnings
}
+SAL_DLLPUBLIC_EXPORT css::uno::Reference< css::lang::XMultiServiceFactory >
+SAL_CALL createRegistryServiceFactory(
+ rtl::OUString const &, rtl::OUString const &, sal_Bool,
+ rtl::OUString const &) SAL_THROW((css::uno::Exception))
+{
+ for (;;) { std::abort(); } // avoid "must return a value" warnings
+}
+
SAL_DLLPUBLIC_EXPORT css::uno::Reference< css::registry::XSimpleRegistry >
SAL_CALL createSimpleRegistry(rtl::OUString const &) SAL_THROW(()) {
for (;;) { std::abort(); } // avoid "must return a value" warnings
diff --git a/cppuhelper/source/servicefactory.cxx b/cppuhelper/source/servicefactory.cxx
index d09bc20ba4bc..ac7e93f75099 100644
--- a/cppuhelper/source/servicefactory.cxx
+++ b/cppuhelper/source/servicefactory.cxx
@@ -30,7 +30,6 @@
#include "cppuhelper/shlib.hxx"
#include "cppuhelper/factory.hxx"
#include "cppuhelper/component_context.hxx"
-#include "cppuhelper/servicefactory.hxx"
#include "cppuhelper/bootstrap.hxx"
#include "com/sun/star/uno/DeploymentException.hpp"
@@ -87,72 +86,6 @@ static Reference< XInterface > SAL_CALL createInstance(
Reference< XInterface >() );
}
-namespace {
-
-Reference< registry::XSimpleRegistry > createSimpleRegistry(
- OUString const & rBootstrapPath )
- SAL_THROW(())
-{
- try
- {
- return Reference< registry::XSimpleRegistry >(
- createInstance(
- loadSharedLibComponentFactory(
- OUSTR("bootstrap.uno" SAL_DLLEXTENSION),
- rBootstrapPath.isEmpty()
- ? get_this_libpath() : rBootstrapPath,
- OUSTR("com.sun.star.comp.stoc.SimpleRegistry"),
- Reference< lang::XMultiServiceFactory >(),
- Reference< registry::XRegistryKey >() ) ),
- UNO_QUERY );
- }
- catch (Exception & exc)
- {
-#if OSL_DEBUG_LEVEL > 0
- OString cstr_msg(
- OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ) );
- OSL_ENSURE( !"### exception occurred:", cstr_msg.getStr() );
-#else
- (void) exc; // avoid warning about unused variable
-#endif
- }
-
- return Reference< registry::XSimpleRegistry >();
-}
-
-Reference< registry::XSimpleRegistry > createNestedRegistry(
- OUString const & rBootstrapPath )
- SAL_THROW(())
-{
- try
- {
- return Reference< registry::XSimpleRegistry >(
- createInstance(
- loadSharedLibComponentFactory(
- OUSTR("bootstrap.uno" SAL_DLLEXTENSION),
- rBootstrapPath.isEmpty()
- ? get_this_libpath() : rBootstrapPath,
- OUSTR("com.sun.star.comp.stoc.NestedRegistry"),
- Reference< lang::XMultiServiceFactory >(),
- Reference< registry::XRegistryKey >() ) ),
- UNO_QUERY );
- }
- catch (Exception & exc)
- {
-#if OSL_DEBUG_LEVEL > 0
- OString cstr_msg(
- OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ) );
- OSL_ENSURE( !"### exception occurred:", cstr_msg.getStr() );
-#else
- (void) exc; // avoid warning about unused variable
-#endif
- }
-
- return Reference< registry::XSimpleRegistry >();
-}
-
-}
-
/** bootstrap variables:
UNO_AC=<mode> [mandatory]
@@ -398,278 +331,6 @@ Reference< lang::XMultiComponentFactory > bootstrapInitialSF(
return xMgr;
}
-// returns context with UNinitialized smgr
-Reference< XComponentContext > bootstrapInitialContext(
- Reference< lang::XMultiComponentFactory > const & xSF,
- Reference< registry::XSimpleRegistry > const & types_xRegistry,
- Reference< registry::XSimpleRegistry > const & services_xRegistry,
- OUString const & rBootstrapPath, Bootstrap const & bootstrap )
- SAL_THROW( (Exception) )
-{
- Reference< lang::XInitialization > xSFInit( xSF, UNO_QUERY );
- if (! xSFInit.is())
- {
- throw RuntimeException(
- OUSTR("servicemanager does not support XInitialization!"),
- Reference< XInterface >() );
- }
-
- // basic context values
- ContextEntry_Init entry;
- ::std::vector< ContextEntry_Init > context_values;
- context_values.reserve( 14 );
-
- // macro expander singleton for loader
- entry.bLateInitService = true;
- entry.name = OUSTR("/singletons/com.sun.star.util.theMacroExpander");
- entry.value
- <<= cppuhelper::detail::create_bootstrap_macro_expander_factory();
- context_values.push_back( entry );
-
- // tdmgr singleton
- entry.bLateInitService = true;
- entry.name =
- OUSTR("/singletons/com.sun.star.reflection.theTypeDescriptionManager");
- entry.value <<= OUSTR("com.sun.star.comp.stoc.TypeDescriptionManager");
- context_values.push_back( entry );
-
- // read out singleton infos from registry
- if (services_xRegistry.is())
- {
- Reference< registry::XRegistryKey > xKey(
- services_xRegistry->getRootKey() );
- if (xKey.is())
- {
- xKey = xKey->openKey( OUSTR("/SINGLETONS") );
- if (xKey.is())
- {
- entry.bLateInitService = true;
-
- Sequence< Reference< registry::XRegistryKey > > keys(
- xKey->openKeys() );
- Reference< registry::XRegistryKey > const * pKeys =
- keys.getConstArray();
- for ( sal_Int32 nPos = keys.getLength(); nPos--; )
- {
- css::uno::Sequence< rtl::OUString > impls(
- css::uno::Reference< css::registry::XRegistryKey >(
- pKeys[nPos]->openKey(
- rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM(
- "REGISTERED_BY"))),
- css::uno::UNO_SET_THROW)->getAsciiListValue());
- switch (impls.getLength()) {
- case 0:
- throw css::uno::DeploymentException(
- (pKeys[nPos]->getKeyName() +
- rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM(
- "/REGISTERED_BY is empty"))),
- css::uno::Reference< css::uno::XInterface >());
- case 1:
- break;
- default:
- OSL_TRACE(
- ("arbitrarily chosing \"%s\" among multiple"
- " implementations for \"%s\""),
- rtl::OUStringToOString(
- impls[0], RTL_TEXTENCODING_UTF8).getStr(),
- rtl::OUStringToOString(
- pKeys[nPos]->getKeyName(),
- RTL_TEXTENCODING_UTF8).getStr());
- break;
- }
- context_values.push_back(
- ContextEntry_Init(
- (rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM("/singletons/")) +
- pKeys[nPos]->getKeyName().copy(
- RTL_CONSTASCII_LENGTH("/SINGLETONS/"))),
- css::uno::makeAny(impls[0]),
- true));
- }
- }
- }
- }
-
- // ac, policy:
- add_access_control_entries( &context_values, bootstrap );
-
- // smgr singleton
- entry.bLateInitService = false;
- entry.name = OUSTR("/singletons/com.sun.star.lang.theServiceManager");
- entry.value <<= xSF;
- context_values.push_back( entry );
-
- Reference< XComponentContext > xContext(
- createComponentContext(
- &context_values[ 0 ], context_values.size(),
- Reference< XComponentContext >() ) );
- // set default context
- Reference< beans::XPropertySet > xProps( xSF, UNO_QUERY );
- OSL_ASSERT( xProps.is() );
- if (xProps.is())
- {
- xProps->setPropertyValue(
- OUSTR("DefaultContext"), makeAny( xContext ) );
- }
-
- Reference< container::XHierarchicalNameAccess > xTDMgr;
-
- // get tdmgr singleton
- if (xContext->getValueByName(
- OUSTR("/singletons/"
- "com.sun.star.reflection.theTypeDescriptionManager") )
- >>= xTDMgr)
- {
- if (types_xRegistry.is()) // insert rdb provider?
- {
- // add registry td provider factory to smgr and instance to tdmgr
- Reference< lang::XSingleComponentFactory > xFac(
- loadSharedLibComponentFactory(
- OUSTR("bootstrap.uno" SAL_DLLEXTENSION),
- rBootstrapPath.isEmpty()
- ? get_this_libpath() : rBootstrapPath,
- OUSTR("com.sun.star.comp.stoc.RegistryTypeDescriptionProvider"),
- Reference< lang::XMultiServiceFactory >( xSF, UNO_QUERY ),
- Reference< registry::XRegistryKey >() ), UNO_QUERY );
- OSL_ASSERT( xFac.is() );
-
- // smgr
- Reference< container::XSet > xSet( xSF, UNO_QUERY );
- xSet->insert( makeAny( xFac ) );
- OSL_ENSURE(
- xSet->has( makeAny( xFac ) ),
- "### failed registering registry td provider at smgr!" );
- // tdmgr
- xSet.set( xTDMgr, UNO_QUERY );
- OSL_ASSERT( xSet.is() );
- Any types_RDB( makeAny( types_xRegistry ) );
- Any rdbtdp( makeAny( xFac->createInstanceWithArgumentsAndContext(
- Sequence< Any >( &types_RDB, 1 ), xContext ) ) );
- xSet->insert( rdbtdp );
- OSL_ENSURE(
- xSet->has( rdbtdp ),
- "### failed inserting registry td provider to tdmgr!" );
- }
- // install callback
- installTypeDescriptionManager( xTDMgr );
- }
-
- return xContext;
-}
-
-static Reference< lang::XMultiComponentFactory > createImplServiceFactory(
- const OUString & rWriteRegistry,
- const OUString & rReadRegistry,
- sal_Bool bReadOnly,
- const OUString & rBootstrapPath )
- SAL_THROW( (Exception) )
-{
- Reference< lang::XMultiComponentFactory > xSF(
- bootstrapInitialSF( rBootstrapPath ) );
-
- Reference< registry::XSimpleRegistry > xRegistry;
-
- // open a registry
- sal_Bool bRegistryShouldBeValid = sal_False;
- if (!rWriteRegistry.isEmpty() && rReadRegistry.isEmpty())
- {
- bRegistryShouldBeValid = sal_True;
- xRegistry.set( createSimpleRegistry( rBootstrapPath ) );
- if (xRegistry.is())
- {
- if (bReadOnly)
- {
- xRegistry->open( rWriteRegistry, sal_True, sal_False );
- }
- else
- {
- xRegistry->open( rWriteRegistry, sal_False, sal_True );
- }
- }
- }
- else if (!rWriteRegistry.isEmpty() && !rReadRegistry.isEmpty())
- {
- // default registry
- bRegistryShouldBeValid = sal_True;
- xRegistry.set( createNestedRegistry( rBootstrapPath ) );
-
- Reference< registry::XSimpleRegistry > xWriteReg(
- createSimpleRegistry( rBootstrapPath ) );
- if (xWriteReg.is())
- {
- if (bReadOnly)
- {
- try
- {
- xWriteReg->open( rWriteRegistry, sal_True, sal_False );
- }
- catch (registry::InvalidRegistryException &)
- {
- }
-
- if (! xWriteReg->isValid())
- {
- throw RuntimeException(
- OUSTR("specified first registry "
- "could not be open readonly!"),
- Reference< XInterface >() );
- }
- }
- else
- {
- xWriteReg->open( rWriteRegistry, sal_False, sal_True );
- }
- }
-
- Reference< registry::XSimpleRegistry > xReadReg(
- createSimpleRegistry( rBootstrapPath ) );
- if (xReadReg.is())
- {
- xReadReg->open( rReadRegistry, sal_True, sal_False );
- }
-
- Reference< lang::XInitialization > xInit( xRegistry, UNO_QUERY );
- Sequence< Any > aInitSeq( 2 );
- aInitSeq[ 0 ] <<= xWriteReg;
- aInitSeq[ 1 ] <<= xReadReg;
- xInit->initialize( aInitSeq );
- }
-
- if (bRegistryShouldBeValid && (!xRegistry.is() || !xRegistry->isValid()))
- {
- throw RuntimeException(
- OUSTR("specified registry could not be initialized"),
- Reference< XInterface >() );
- }
-
- Bootstrap bootstrap;
- Reference< XComponentContext > xContext(
- bootstrapInitialContext(
- xSF, xRegistry, xRegistry, rBootstrapPath, bootstrap ) );
-
- // initialize sf
- Reference< lang::XInitialization > xInit( xSF, UNO_QUERY );
- OSL_ASSERT( xInit.is() );
- Sequence< Any > aSFInit( 1 );
- aSFInit[ 0 ] <<= xRegistry;
- xInit->initialize( aSFInit );
-
- return xSF;
-}
-
-Reference< lang::XMultiServiceFactory > SAL_CALL createRegistryServiceFactory(
- const OUString & rWriteRegistry,
- const OUString & rReadRegistry,
- sal_Bool bReadOnly,
- const OUString & rBootstrapPath )
- SAL_THROW( (Exception) )
-{
- return Reference< lang::XMultiServiceFactory >( createImplServiceFactory(
- rWriteRegistry, rReadRegistry, bReadOnly, rBootstrapPath ), UNO_QUERY );
-}
-
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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.
- *<BR>
- * @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.
- *<BR>
- * @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.
- *<BR>
- * @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.
- *<BR>
- * @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.
- *<BR>
- * @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 <uno/mapping.hxx>
#include <cppuhelper/factory.hxx>
-#include <cppuhelper/servicefactory.hxx>
-#include <cppuhelper/component_context.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
@@ -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<services.length; i++ )
- System.out.println(services[i]);
-
- passed = true;
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- System.err.println();
- System.err.println("RegistryServiceFactory test passed? " + passed);
- System.out.println("*******************************************************************");
- System.err.println();
- return passed;
- }
-
- private static void usage() {
- System.out.println();
- System.out.println("usage:");
- System.out.println("java com.sun.star.comp.helper.RegistryServiceFactory [rdb-file]");
- System.out.println("example:");
- System.out.println("java com.sun.star.comp.helper.RegistryServiceFactory c:\\applicat.rdb");
- System.exit( -1 );
- }
-
- static public void main(String args[]) throws java.lang.Exception {
- if ( args.length != 1 )
- usage();
- System.exit( test(args[0]) == true ? 0: -1 );
- }
-}
-