summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-09-30 22:19:39 +0200
committerStephan Bergmann <sbergman@redhat.com>2020-10-01 09:45:22 +0200
commitd9ba652064ee760448d0344d07347480cb195b6e (patch)
tree65353fa601ba2ab8677a79b69dfd4467e5cd4556 /connectivity
parent1a1d432420646bcf129624a866fd6c754e25d195 (diff)
Use the new single-instance="true" attribute in connectivity
Change-Id: Ie49207b659214163f2f57051ac8f9de02fab36c7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103735 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/manager/mdrivermanager.cxx24
-rw-r--r--connectivity/source/manager/mdrivermanager.hxx3
-rw-r--r--connectivity/source/manager/sdbc2.component4
3 files changed, 4 insertions, 27 deletions
diff --git a/connectivity/source/manager/mdrivermanager.cxx b/connectivity/source/manager/mdrivermanager.cxx
index 71bcb6c9e816..ae1e226cd2fc 100644
--- a/connectivity/source/manager/mdrivermanager.cxx
+++ b/connectivity/source/manager/mdrivermanager.cxx
@@ -29,17 +29,13 @@
#include <tools/diagnose_ex.h>
#include <cppuhelper/implbase.hxx>
#include <cppuhelper/supportsservice.hxx>
+#include <cppuhelper/weak.hxx>
#include <osl/diagnose.h>
-#include <rtl/ref.hxx>
#include <algorithm>
#include <iterator>
#include <vector>
-static osl::Mutex g_InstanceGuard;
-static rtl::Reference<drivermanager::OSDBCDriverManager> g_Instance;
-static bool g_Disposed = false;
-
namespace drivermanager
{
@@ -259,15 +255,6 @@ OSDBCDriverManager::~OSDBCDriverManager()
{
}
-// XComponent
-void SAL_CALL OSDBCDriverManager::dispose()
-{
- OSDBCDriverManager_Base::dispose();
- osl::MutexGuard aGuard(g_InstanceGuard);
- g_Instance.clear();
- g_Disposed = true;
-}
-
void OSDBCDriverManager::bootstrapDrivers()
{
Reference< XContentEnumerationAccess > xEnumAccess( m_xContext->getServiceManager(), UNO_QUERY );
@@ -671,13 +658,8 @@ extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
connectivity_OSDBCDriverManager_get_implementation(
css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
{
- osl::MutexGuard aGuard(g_InstanceGuard);
- if (g_Disposed)
- return nullptr;
- if (!g_Instance)
- g_Instance.set(new drivermanager::OSDBCDriverManager(context));
- g_Instance->acquire();
- return static_cast<cppu::OWeakObject*>(g_Instance.get());
+ return cppu::acquire(
+ static_cast<cppu::OWeakObject*>(new drivermanager::OSDBCDriverManager(context)));
}
diff --git a/connectivity/source/manager/mdrivermanager.hxx b/connectivity/source/manager/mdrivermanager.hxx
index 20fc0a72df7b..09ccd11e05c3 100644
--- a/connectivity/source/manager/mdrivermanager.hxx
+++ b/connectivity/source/manager/mdrivermanager.hxx
@@ -81,9 +81,6 @@ namespace drivermanager
const css::uno::Reference< css::uno::XComponentContext >& _rxContext );
virtual ~OSDBCDriverManager() override;
- // XComponent
- virtual void SAL_CALL dispose() override;
-
// XDriverManager
virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection( const OUString& url ) override;
virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnectionWithInfo( const OUString& url, const css::uno::Sequence< css::beans::PropertyValue >& info ) override;
diff --git a/connectivity/source/manager/sdbc2.component b/connectivity/source/manager/sdbc2.component
index 8797ec80a27c..b9433256aabf 100644
--- a/connectivity/source/manager/sdbc2.component
+++ b/connectivity/source/manager/sdbc2.component
@@ -20,9 +20,7 @@
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
xmlns="http://openoffice.org/2010/uno-components">
<implementation name="com.sun.star.comp.sdbc.OSDBCDriverManager"
- constructor="connectivity_OSDBCDriverManager_get_implementation">
- <!-- fake singleton so the servicemanager shuts us down and we can clean up our global instance var -->
- <singleton name="com.sun.star.comp.sdbc.theOSDBCDriverManager"/>
+ constructor="connectivity_OSDBCDriverManager_get_implementation" single-instance="true">
<service name="com.sun.star.sdbc.DriverManager"/>
</implementation>
</component>