[Libreoffice-commits] core.git: Branch 'private/hcvcastro/preinit' - cppuhelper/source

Henry Castro hcastro at collabora.com
Mon Sep 7 17:34:14 PDT 2015


 cppuhelper/source/defaultbootstrap.cxx |    2 
 cppuhelper/source/servicemanager.cxx   |  100 ++-------------------------------
 cppuhelper/source/servicemanager.hxx   |    2 
 3 files changed, 11 insertions(+), 93 deletions(-)

New commits:
commit da26d6dcb8f95986b309cc14b96f3cfa6d44bd16
Author: Henry Castro <hcastro at collabora.com>
Date:   Mon Sep 7 20:27:40 2015 -0400

    cppuhelper: method 2 for loading services.
    
    This method is simplified, but we cannot set flag
    SAL_LOADMODULE_NOW
    
    Change-Id: Ieb7b90f4f43f980e15d66d490505147e166bf772

diff --git a/cppuhelper/source/defaultbootstrap.cxx b/cppuhelper/source/defaultbootstrap.cxx
index 602fdfb..9e9aa8e 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 8be70aa..aba6745 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 ddf85965f..571f857 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() {}


More information about the Libreoffice-commits mailing list