summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2012-12-03 13:16:26 +0200
committerNoel Grandin <noel@peralex.com>2012-12-10 08:05:31 +0200
commitd01fba6afc39092ae3ae85c38ac21bb7d26d63e2 (patch)
tree7f33e692f5adbe75a2192bf2f573be5be124d604
parentb8a403467e6209437c3c113ff2df95df6ffec61a (diff)
fdo#46808, Adapt sdbc::ConnectionPool UNO service to new style
ConnectionPool was already a new-style service, but since it was not exposing all of it's interfaces properly I had to create a unified interface XConnectionPool. Change-Id: Idfa3fa3335173ceeab1785b4049422874b6c9d5a
-rw-r--r--connectivity/source/commontools/dbtools.cxx2
-rw-r--r--connectivity/source/cpool/ZPoolCollection.hxx8
-rw-r--r--dbaccess/source/core/dataaccess/datasource.cxx2
-rw-r--r--dbaccess/source/inc/stringconstants.hrc1
-rw-r--r--dbaccess/source/inc/stringconstants.inc1
-rw-r--r--dbaccess/source/ui/dlg/DbAdminImpl.cxx13
-rw-r--r--dbaccess/source/ui/uno/copytablewizard.cxx3
-rw-r--r--offapi/UnoApi_offapi.mk1
-rw-r--r--offapi/com/sun/star/sdbc/ConnectionPool.idl4
-rw-r--r--offapi/com/sun/star/sdbc/XConnectionPool.idl42
10 files changed, 58 insertions, 19 deletions
diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx
index a33e4a47529f..e00d7383c51b 100644
--- a/connectivity/source/commontools/dbtools.cxx
+++ b/connectivity/source/commontools/dbtools.cxx
@@ -417,7 +417,7 @@ SharedConnection lcl_connectRowSet(const Reference< XRowSet>& _rxRowSet, const R
else if (!sURL.isEmpty())
{ // the row set has no data source, but a connection url set
// -> try to connection with that url
- Reference< XDriverManager > xDriverManager;
+ Reference< XConnectionPool > xDriverManager;
try {
xDriverManager = ConnectionPool::create( _rxContext );
} catch( const Exception& ) { }
diff --git a/connectivity/source/cpool/ZPoolCollection.hxx b/connectivity/source/cpool/ZPoolCollection.hxx
index 4a2394d65f5f..20108fd87b08 100644
--- a/connectivity/source/cpool/ZPoolCollection.hxx
+++ b/connectivity/source/cpool/ZPoolCollection.hxx
@@ -19,11 +19,10 @@
#ifndef CONNECTIVITY_POOLCOLLECTION_HXX
#define CONNECTIVITY_POOLCOLLECTION_HXX
-#include <cppuhelper/implbase5.hxx>
+#include <cppuhelper/implbase4.hxx>
#include <com/sun/star/beans/XPropertyChangeListener.hpp>
-#include <com/sun/star/sdbc/XDriverManager.hpp>
#include <com/sun/star/sdbc/XDriver.hpp>
-#include <com/sun/star/sdbc/XDriverAccess.hpp>
+#include <com/sun/star/sdbc/XConnectionPool.hpp>
#include <com/sun/star/sdbc/XPooledConnection.hpp>
#include <com/sun/star/sdbc/XConnection.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
@@ -42,8 +41,7 @@ namespace connectivity
//= OPoolCollection - the one-instance service for PooledConnections
//= manages the active connections and the connections in the pool
//==========================================================================
- typedef ::cppu::WeakImplHelper5< ::com::sun::star::sdbc::XDriverManager,
- ::com::sun::star::sdbc::XDriverAccess,
+ typedef ::cppu::WeakImplHelper4< ::com::sun::star::sdbc::XConnectionPool,
::com::sun::star::lang::XServiceInfo,
::com::sun::star::frame::XTerminateListener,
::com::sun::star::beans::XPropertyChangeListener
diff --git a/dbaccess/source/core/dataaccess/datasource.cxx b/dbaccess/source/core/dataaccess/datasource.cxx
index 7d7bc995cf16..926c118482a3 100644
--- a/dbaccess/source/core/dataaccess/datasource.cxx
+++ b/dbaccess/source/core/dataaccess/datasource.cxx
@@ -641,7 +641,7 @@ Reference< XConnection > ODatabaseSource::buildLowLevelConnection(const ::rtl::O
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::buildLowLevelConnection" );
Reference< XConnection > xReturn;
- Reference< XDriverManager > xManager;
+ Reference< XConnectionPool > xManager;
try {
xManager.set( ConnectionPool::create( m_pImpl->m_aContext.getUNOContext() ) );
} catch( const Exception& ) { }
diff --git a/dbaccess/source/inc/stringconstants.hrc b/dbaccess/source/inc/stringconstants.hrc
index 6926f607788e..902eba94abc4 100644
--- a/dbaccess/source/inc/stringconstants.hrc
+++ b/dbaccess/source/inc/stringconstants.hrc
@@ -370,7 +370,6 @@ DECLARE_CONSTASCII_USTRING(SERVICE_SDBCX_COLUMNS);
DECLARE_CONSTASCII_USTRING(SERVICE_SDBCX_TABLES);
DECLARE_CONSTASCII_USTRING(SERVICE_SDB_QUERIES);
DECLARE_CONSTASCII_USTRING(SERVICE_SDBC_DRIVERMANAGER);
-DECLARE_CONSTASCII_USTRING(SERVICE_SDBC_CONNECTIONPOOL);
DECLARE_CONSTASCII_USTRING(SERVICE_FRAME_DESKTOP);
DECLARE_CONSTASCII_USTRING(SERVICE_UI_FOLDERPICKER);
DECLARE_CONSTASCII_USTRING(SERVICE_I18N_COLLATOR);
diff --git a/dbaccess/source/inc/stringconstants.inc b/dbaccess/source/inc/stringconstants.inc
index 010fd637e952..4b1434de4309 100644
--- a/dbaccess/source/inc/stringconstants.inc
+++ b/dbaccess/source/inc/stringconstants.inc
@@ -207,7 +207,6 @@ IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDBCX_COLUMNS, "com.sun.star.sdbcx.Columns"
IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDBCX_TABLES, "com.sun.star.sdbcx.Tables");
IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDB_QUERIES, "com.sun.star.sdb.Queries");
IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDBC_DRIVERMANAGER, "com.sun.star.sdbc.DriverManager");
-IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDBC_CONNECTIONPOOL, "com.sun.star.sdbc.ConnectionPool");
IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDBCX_INDEXCOLUMN, "com.sun.star.sdbcx.IndexColumn");
IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDBCX_KEYCOLUMN, "com.sun.star.sdbcx.KeyColumn");
IMPLEMENT_CONSTASCII_USTRING(SERVICE_FRAME_DESKTOP, "com.sun.star.frame.Desktop");
diff --git a/dbaccess/source/ui/dlg/DbAdminImpl.cxx b/dbaccess/source/ui/dlg/DbAdminImpl.cxx
index 80f6051b010e..a548f2f4dec6 100644
--- a/dbaccess/source/ui/dlg/DbAdminImpl.cxx
+++ b/dbaccess/source/ui/dlg/DbAdminImpl.cxx
@@ -43,6 +43,7 @@
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/sdb/DatabaseContext.hpp>
#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdbc/ConnectionPool.hpp>
#include <com/sun/star/sdbc/XDriver.hpp>
#include <com/sun/star/sdbc/XDriverAccess.hpp>
#include <com/sun/star/task/InteractionHandler.hpp>
@@ -388,14 +389,14 @@ Reference< XDriver > ODbDataSourceAdministrationHelper::getDriver()
Reference< XDriver > ODbDataSourceAdministrationHelper::getDriver(const ::rtl::OUString& _sURL)
{
// get the global DriverManager
- Reference< XDriverAccess > xDriverManager;
+ Reference< XConnectionPool > xDriverManager;
+
String sCurrentActionError = String(ModuleRes(STR_COULDNOTCREATE_DRIVERMANAGER));
- // in case an error occures
- sCurrentActionError.SearchAndReplaceAscii("#servicename#", (::rtl::OUString)SERVICE_SDBC_CONNECTIONPOOL);
+ sCurrentActionError.SearchAndReplaceAscii("#servicename#", OUString("com.sun.star.sdbc.ConnectionPool"));
+
try
{
- xDriverManager = Reference< XDriverAccess >(getORB()->createInstance(SERVICE_SDBC_CONNECTIONPOOL), UNO_QUERY);
- OSL_ENSURE(xDriverManager.is(), "ODbDataSourceAdministrationHelper::getDriver: could not instantiate the driver manager, or it does not provide the necessary interface!");
+ xDriverManager.set( ConnectionPool::create( comphelper::getComponentContext(getORB()) ) );
}
catch (const Exception& e)
{
@@ -403,8 +404,6 @@ Reference< XDriver > ODbDataSourceAdministrationHelper::getDriver(const ::rtl::O
SQLException aSQLWrapper(e.Message, getORB(), ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")), 0, Any());
throw SQLException(sCurrentActionError, getORB(), ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")), 0, makeAny(aSQLWrapper));
}
- if (!xDriverManager.is())
- throw SQLException(sCurrentActionError, getORB(), ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")), 0, Any());
Reference< XDriver > xDriver = xDriverManager->getDriverByURL(_sURL);
diff --git a/dbaccess/source/ui/uno/copytablewizard.cxx b/dbaccess/source/ui/uno/copytablewizard.cxx
index 7618f336e35c..15e9cde96d0b 100644
--- a/dbaccess/source/ui/uno/copytablewizard.cxx
+++ b/dbaccess/source/ui/uno/copytablewizard.cxx
@@ -129,6 +129,7 @@ namespace dbaui
using ::com::sun::star::sdbc::SQLException;
using ::com::sun::star::sdb::SQLContext;
using ::com::sun::star::sdbc::ConnectionPool;
+ using ::com::sun::star::sdbc::XConnectionPool;
using ::com::sun::star::sdbc::XDriverManager;
using ::com::sun::star::beans::PropertyValue;
/** === end UNO using === **/
@@ -953,7 +954,7 @@ SharedConnection CopyTableWizard::impl_extractConnection_throw( const Reference<
if ( xPSI->hasPropertyByName( PROPERTY_CONNECTION_INFO ) )
OSL_VERIFY( _rxDataSourceDescriptor->getPropertyValue( PROPERTY_CONNECTION_INFO ) >>= aConnectionInfo );
- Reference< XDriverManager > xDriverManager;
+ Reference< XConnectionPool > xDriverManager;
try {
xDriverManager.set( ConnectionPool::create( m_aContext.getUNOContext() ) );
} catch( const Exception& ) { }
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index 295cc9042caa..eab0bf35086a 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -3150,6 +3150,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,offapi/com/sun/star/sdbc,\
XCloseable \
XColumnLocate \
XConnection \
+ XConnectionPool \
XDataSource \
XDatabaseMetaData \
XDatabaseMetaData2 \
diff --git a/offapi/com/sun/star/sdbc/ConnectionPool.idl b/offapi/com/sun/star/sdbc/ConnectionPool.idl
index b9c9e7a2226a..0a3028427ef9 100644
--- a/offapi/com/sun/star/sdbc/ConnectionPool.idl
+++ b/offapi/com/sun/star/sdbc/ConnectionPool.idl
@@ -21,7 +21,7 @@
module com { module sun { module star { module sdbc {
- published interface XDriverManager;
+ published interface XConnectionPool;
/** is the basic service for pooling SDBC connections.
@@ -38,7 +38,7 @@
@see com::sun::star::sdbc::XDriver
@see com::sun::star::sdbc::XConnection
*/
-published service ConnectionPool: XDriverManager;
+published service ConnectionPool: XConnectionPool;
}; }; }; };
diff --git a/offapi/com/sun/star/sdbc/XConnectionPool.idl b/offapi/com/sun/star/sdbc/XConnectionPool.idl
new file mode 100644
index 000000000000..2cb87f5d7f52
--- /dev/null
+++ b/offapi/com/sun/star/sdbc/XConnectionPool.idl
@@ -0,0 +1,42 @@
+/* -*- 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 __com_sun_star_sdbc_XConnectionPool_idl__
+#define __com_sun_star_sdbc_XConnectionPool_idl__
+
+#include <com/sun/star/sdbc/XDriverManager.idl>
+#include <com/sun/star/sdbc/XDriverAccess.idl>
+
+module com { module sun { module star { module sdbc {
+
+/*
+ @since LibreOffice 4.1
+*/
+published interface XConnectionPool
+{
+ interface XDriverManager;
+ interface XDriverAccess;
+};
+
+
+}; }; }; };
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */