summaryrefslogtreecommitdiff
path: root/cppuhelper/source/servicefactory.cxx
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 /cppuhelper/source/servicefactory.cxx
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
Diffstat (limited to 'cppuhelper/source/servicefactory.cxx')
-rw-r--r--cppuhelper/source/servicefactory.cxx339
1 files changed, 0 insertions, 339 deletions
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: */