connectivity/dbpool2: create instances with uno constructors
See tdf#74608 for motivation. Change-Id: Ib621b48f9c542a8cdeea6d7627770784abbd44fc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98689 Tested-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
parent
d1038da54d
commit
30ee17749a
5 changed files with 14 additions and 95 deletions
|
@ -38,7 +38,6 @@ $(eval $(call gb_Library_add_exception_objects,dbpool2,\
|
|||
connectivity/source/cpool/ZPooledConnection \
|
||||
connectivity/source/cpool/ZConnectionPool \
|
||||
connectivity/source/cpool/ZPoolCollection \
|
||||
connectivity/source/cpool/Zregistration \
|
||||
))
|
||||
|
||||
# vim: set noet sw=4 ts=4:
|
||||
|
|
|
@ -136,7 +136,7 @@ sal_Int32 SAL_CALL OPoolCollection::getLoginTimeout( )
|
|||
|
||||
OUString SAL_CALL OPoolCollection::getImplementationName( )
|
||||
{
|
||||
return getImplementationName_Static();
|
||||
return "com.sun.star.sdbc.OConnectionPool";
|
||||
}
|
||||
|
||||
sal_Bool SAL_CALL OPoolCollection::supportsService( const OUString& _rServiceName )
|
||||
|
@ -147,26 +147,7 @@ sal_Bool SAL_CALL OPoolCollection::supportsService( const OUString& _rServiceNam
|
|||
|
||||
Sequence< OUString > SAL_CALL OPoolCollection::getSupportedServiceNames( )
|
||||
{
|
||||
return getSupportedServiceNames_Static();
|
||||
}
|
||||
|
||||
//---------------------------------------OPoolCollection----------------------------------
|
||||
Reference< XInterface > OPoolCollection::CreateInstance(const Reference< XMultiServiceFactory >& _rxFactory)
|
||||
{
|
||||
return static_cast<XDriverManager*>(new OPoolCollection(comphelper::getComponentContext(_rxFactory)));
|
||||
}
|
||||
|
||||
|
||||
OUString OPoolCollection::getImplementationName_Static( )
|
||||
{
|
||||
return "com.sun.star.sdbc.OConnectionPool";
|
||||
}
|
||||
|
||||
|
||||
Sequence< OUString > OPoolCollection::getSupportedServiceNames_Static( )
|
||||
{
|
||||
Sequence< OUString > aSupported { "com.sun.star.sdbc.ConnectionPool" };
|
||||
return aSupported;
|
||||
return { "com.sun.star.sdbc.ConnectionPool" };
|
||||
}
|
||||
|
||||
Reference< XDriver > SAL_CALL OPoolCollection::getDriverByURL( const OUString& _rURL )
|
||||
|
@ -478,5 +459,12 @@ void OPoolCollection::clearDesktop()
|
|||
m_xDesktop.clear();
|
||||
}
|
||||
|
||||
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
|
||||
connectivity_OPoolCollection_get_implementation(
|
||||
css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
|
||||
{
|
||||
return cppu::acquire(new OPoolCollection(context));
|
||||
}
|
||||
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
|
|
@ -73,13 +73,14 @@ namespace connectivity
|
|||
css::uno::Reference< css::uno::XInterface > m_xConfigNode; // config node for general connection pooling
|
||||
css::uno::Reference< css::frame::XDesktop2> m_xDesktop;
|
||||
|
||||
private:
|
||||
public:
|
||||
OPoolCollection(const OPoolCollection&) = delete;
|
||||
int operator= (const OPoolCollection&) = delete;
|
||||
|
||||
explicit OPoolCollection(
|
||||
const css::uno::Reference< css::uno::XComponentContext >& _rxContext);
|
||||
|
||||
private:
|
||||
// some configuration helper methods
|
||||
css::uno::Reference< css::uno::XInterface > const & getConfigPoolRoot();
|
||||
static css::uno::Reference< css::uno::XInterface > createWithProvider( const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxConfProvider,
|
||||
|
@ -119,13 +120,6 @@ namespace connectivity
|
|||
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
|
||||
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
|
||||
|
||||
// XServiceInfo - static methods
|
||||
static css::uno::Reference< css::uno::XInterface > CreateInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >&);
|
||||
/// @throws css::uno::RuntimeException
|
||||
static OUString getImplementationName_Static( );
|
||||
/// @throws css::uno::RuntimeException
|
||||
static css::uno::Sequence< OUString > getSupportedServiceNames_Static( );
|
||||
|
||||
// XEventListener
|
||||
virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
|
||||
// XPropertyChangeListener
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
/* -*- 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 .
|
||||
*/
|
||||
|
||||
|
||||
#include <cppuhelper/factory.hxx>
|
||||
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
|
||||
#include "ZPoolCollection.hxx"
|
||||
|
||||
|
||||
using namespace ::com::sun::star::uno;
|
||||
using namespace ::com::sun::star::lang;
|
||||
using namespace ::com::sun::star::registry;
|
||||
using namespace connectivity;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
|
||||
SAL_DLLPUBLIC_EXPORT void* dbpool2_component_getFactory(const char* _pImplName, void * _pServiceManager, void* /*_pRegistryKey*/)
|
||||
{
|
||||
void* pRet = nullptr;
|
||||
|
||||
if (OPoolCollection::getImplementationName_Static().equalsAscii(_pImplName))
|
||||
{
|
||||
Reference< XSingleServiceFactory > xFactory(
|
||||
::cppu::createOneInstanceFactory(
|
||||
static_cast<css::lang::XMultiServiceFactory *>(
|
||||
_pServiceManager),
|
||||
OPoolCollection::getImplementationName_Static(),
|
||||
OPoolCollection::CreateInstance,
|
||||
OPoolCollection::getSupportedServiceNames_Static()
|
||||
)
|
||||
);
|
||||
if (xFactory.is())
|
||||
{
|
||||
xFactory->acquire();
|
||||
pRet = xFactory.get();
|
||||
}
|
||||
}
|
||||
|
||||
return pRet;
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
|
@ -18,8 +18,9 @@
|
|||
-->
|
||||
|
||||
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
|
||||
prefix="dbpool2" xmlns="http://openoffice.org/2010/uno-components">
|
||||
<implementation name="com.sun.star.sdbc.OConnectionPool">
|
||||
xmlns="http://openoffice.org/2010/uno-components">
|
||||
<implementation name="com.sun.star.sdbc.OConnectionPool"
|
||||
constructor="connectivity_OPoolCollection_get_implementation">
|
||||
<service name="com.sun.star.sdbc.ConnectionPool"/>
|
||||
</implementation>
|
||||
</component>
|
||||
|
|
Loading…
Reference in a new issue