summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2015-09-07 20:27:40 -0400
committerHenry Castro <hcastro@collabora.com>2015-09-13 18:53:37 -0400
commit56a20f98a66aa5f81be7cdd35d1532e8655a4bd0 (patch)
tree88d1be73c8da7a39d1f17a6202eecb632b2623a2
parentc22ddbf7ca5b1c94dedb87ea4e93b25415fc64e1 (diff)
cppuhelper: method 2, load implementations to invoke component factoryprivate/hcvcastro/preinit
In the preinit stage, method 2 is simplified, looping all registered services, and for each service load implementation is called. The disadvantages using this method, it cannot load the module with flag SAL_LOADMODULE_NOW set, to ensure all symbols are resolved. But we still can set the flag LD_BIND_NOW=1 in the parent process. Change-Id: Ieb7b90f4f43f980e15d66d490505147e166bf772
-rw-r--r--cppuhelper/source/defaultbootstrap.cxx2
-rw-r--r--cppuhelper/source/servicemanager.cxx100
-rw-r--r--cppuhelper/source/servicemanager.hxx2
3 files changed, 11 insertions, 93 deletions
diff --git a/cppuhelper/source/defaultbootstrap.cxx b/cppuhelper/source/defaultbootstrap.cxx
index 602fdfbcb081..9e9aa8e34767 100644
--- a/cppuhelper/source/defaultbootstrap.cxx
+++ b/cppuhelper/source/defaultbootstrap.cxx
@@ -125,6 +125,6 @@ cppu::preInitBootstrap(css::uno::Reference< css::uno::XComponentContext > const
// 1) defaultBootstrap_InitialComponentContext()
// 2) comphelper::setProcessServiceFactory(xSFactory);
// 3) InitVCL()
- aService->loadImplementations();
+ aService->loadImplementations(xContext);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppuhelper/source/servicemanager.cxx b/cppuhelper/source/servicemanager.cxx
index 8be70aa1d935..aba6745dc69f 100644
--- a/cppuhelper/source/servicemanager.cxx
+++ b/cppuhelper/source/servicemanager.cxx
@@ -881,110 +881,28 @@ void cppuhelper::ServiceManager::loadImplementation(
}
}
-void cppuhelper::ServiceManager::loadImplementations()
+void cppuhelper::ServiceManager::loadImplementations(css::uno::Reference< css::uno::XComponentContext > const & context)
{
- rtl::OUString aUri;
osl::MutexGuard g(rBHelper.rMutex);
- css::uno::Environment aSourceEnv(css::uno::Environment::getCurrent());
// loop all implementations
for (Data::NamedImplementations::const_iterator iterator(
data_.namedImplementations.begin());
iterator != data_.namedImplementations.end(); ++iterator)
{
- try
- {
- // expand absolute URI implementation component library
- aUri = cppu::bootstrap_expandUri(iterator->second->info->uri);
- }
- catch (css::lang::IllegalArgumentException& aError)
- {
- throw css::uno::DeploymentException(
- "Cannot expand URI" + iterator->second->info->uri + ": " + aError.Message,
- static_cast< cppu::OWeakObject * >(this));
- }
-
if (iterator->second->info->loader == "com.sun.star.loader.SharedLibrary" &&
iterator->second->status != Data::Implementation::STATUS_LOADED)
{
- // load component library
- osl::Module aModule(aUri, SAL_LOADMODULE_NOW | SAL_LOADMODULE_GLOBAL);
- SAL_INFO("lok", "loaded component library " << aUri << ( aModule.is() ? " ok" : " no"));
-
- if (aModule.is() &&
- !iterator->second->info->environment.isEmpty())
+ SAL_INFO("lok", "loading component library " +iterator->second->info->uri);
+ boost::shared_ptr< cppuhelper::ServiceManager::Data::Implementation > impl = iterator->second;
+ try
{
- OUString aSymFactory;
- oslGenericFunction fpFactory;
- css::uno::Environment aTargetEnv;
- css::uno::Reference<css::uno::XInterface> xFactory;
-
- if(iterator->second->info->constructor.isEmpty())
- {
- // expand full name component factory symbol
- if (iterator->second->info->prefix == "direct")
- aSymFactory = iterator->second->info->name.replace('.', '_') + "_" COMPONENT_GETFACTORY;
- else if (!iterator->second->info->prefix.isEmpty())
- aSymFactory = iterator->second->info->prefix + "_" COMPONENT_GETFACTORY;
- else
- aSymFactory = COMPONENT_GETFACTORY;
-
- // get function symbol component factory
- fpFactory = aModule.getFunctionSymbol(aSymFactory);
- if (fpFactory == 0)
- {
- throw css::loader::CannotActivateFactoryException(
- ("no factory symbol \"" + aSymFactory + "\" in component library :" + aUri),
- css::uno::Reference<css::uno::XInterface>());
- }
-
- aTargetEnv = cppuhelper::detail::getEnvironment(iterator->second->info->environment, iterator->second->info->name);
- component_getFactoryFunc fpComponentFactory = reinterpret_cast<component_getFactoryFunc>(fpFactory);
-
- if (aSourceEnv.get() == aTargetEnv.get())
- {
- // invoke function component factory
- OString aImpl(rtl::OUStringToOString(iterator->second->info->name, RTL_TEXTENCODING_ASCII_US));
- xFactory.set(css::uno::Reference<css::uno::XInterface>(static_cast<css::uno::XInterface *>(
- (*fpComponentFactory)(aImpl.getStr(), this, 0)), SAL_NO_ACQUIRE));
- }
- }
- else
- {
- // get function symbol component factory
- fpFactory = aModule.getFunctionSymbol(iterator->second->info->constructor);
- }
-
- css::uno::Reference<css::lang::XSingleComponentFactory> xSCFactory;
- css::uno::Reference<css::lang::XSingleServiceFactory> xSSFactory;
-
- // query interface XSingleComponentFactory or XSingleServiceFactory
- if (xFactory.is())
- {
- xSCFactory.set(xFactory, css::uno::UNO_QUERY);
- if (!xSCFactory.is())
- {
- xSSFactory.set(xFactory, css::uno::UNO_QUERY);
- if (!xSSFactory.is())
- {
- throw css::uno::DeploymentException(
- ("Implementation " + iterator->second->info->name
- + " does not provide a constructor or factory"),
- static_cast< cppu::OWeakObject * >(this));
- }
- }
- }
-
- if (!iterator->second->info->constructor.isEmpty() && fpFactory)
- iterator->second->constructor = reinterpret_cast<ImplementationConstructorFn *>(fpFactory);
-
- iterator->second->factory1 = xSCFactory;
- iterator->second->factory2 = xSSFactory;
- iterator->second->status = Data::Implementation::STATUS_LOADED;
-
+ loadImplementation(context, impl);
+ }
+ catch (css::uno::RuntimeException & aError)
+ {
+ SAL_WARN("lok", aError.Message);
}
- // leak aModule
- aModule.release();
}
}
}
diff --git a/cppuhelper/source/servicemanager.hxx b/cppuhelper/source/servicemanager.hxx
index ddf85965fda2..571f857a0ca3 100644
--- a/cppuhelper/source/servicemanager.hxx
+++ b/cppuhelper/source/servicemanager.hxx
@@ -203,7 +203,7 @@ public:
css::uno::Reference< css::uno::XComponentContext > const & context,
boost::shared_ptr< Data::Implementation > & implementation);
- void loadImplementations();
+ void loadImplementations(css::uno::Reference< css::uno::XComponentContext > const & context);
private:
virtual ~ServiceManager() {}