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
This commit is contained in:
@@ -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& ) { }
|
||||
|
@@ -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
|
||||
|
@@ -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& ) { }
|
||||
|
@@ -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);
|
||||
|
@@ -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");
|
||||
|
@@ -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);
|
||||
|
@@ -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& ) { }
|
||||
|
@@ -3150,6 +3150,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,offapi/com/sun/star/sdbc,\
|
||||
XCloseable \
|
||||
XColumnLocate \
|
||||
XConnection \
|
||||
XConnectionPool \
|
||||
XDataSource \
|
||||
XDatabaseMetaData \
|
||||
XDatabaseMetaData2 \
|
||||
|
@@ -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;
|
||||
|
||||
|
||||
}; }; }; };
|
||||
|
42
offapi/com/sun/star/sdbc/XConnectionPool.idl
Normal file
42
offapi/com/sun/star/sdbc/XConnectionPool.idl
Normal file
@@ -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: */
|
Reference in New Issue
Block a user