summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-07-13 16:11:18 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-07-14 09:09:04 +0200
commitc69a54ebb232f22e6a07d5a2ec06f9097fce45a6 (patch)
tree0d2dabf101525f22b1bb91d183186ffecac69085 /connectivity
parentd1b37f5ff3d69e60355612899043bbc202a15735 (diff)
connectivity/jdbc: create instances with uno constructors
See tdf#74608 for motivation. Change-Id: Id268f9780400e5d0940f378cd8ee91f86662bf55 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98684 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/Library_jdbc.mk1
-rw-r--r--connectivity/source/drivers/jdbc/JDriver.cxx28
-rw-r--r--connectivity/source/drivers/jdbc/jdbc.component5
-rw-r--r--connectivity/source/drivers/jdbc/jservices.cxx106
-rw-r--r--connectivity/source/inc/java/sql/Driver.hxx8
5 files changed, 11 insertions, 137 deletions
diff --git a/connectivity/Library_jdbc.mk b/connectivity/Library_jdbc.mk
index fea943cd77c3..396369e8fc5b 100644
--- a/connectivity/Library_jdbc.mk
+++ b/connectivity/Library_jdbc.mk
@@ -65,7 +65,6 @@ $(eval $(call gb_Library_add_exception_objects,jdbc,\
connectivity/source/drivers/jdbc/String \
connectivity/source/drivers/jdbc/Throwable \
connectivity/source/drivers/jdbc/Timestamp \
- connectivity/source/drivers/jdbc/jservices \
connectivity/source/drivers/jdbc/JBigDecimal \
connectivity/source/drivers/jdbc/tools \
connectivity/source/drivers/jdbc/ContextClassLoader \
diff --git a/connectivity/source/drivers/jdbc/JDriver.cxx b/connectivity/source/drivers/jdbc/JDriver.cxx
index 3ec181bb305d..661d9ea67d35 100644
--- a/connectivity/source/drivers/jdbc/JDriver.cxx
+++ b/connectivity/source/drivers/jdbc/JDriver.cxx
@@ -46,31 +46,13 @@ java_sql_Driver::~java_sql_Driver()
{
}
-// static ServiceInfo
-
-OUString java_sql_Driver::getImplementationName_Static( )
+OUString SAL_CALL java_sql_Driver::getImplementationName( )
{
return "com.sun.star.comp.sdbc.JDBCDriver";
// this name is referenced in the configuration and in the jdbc.xml
// Please take care when changing it.
}
-Sequence< OUString > java_sql_Driver::getSupportedServiceNames_Static( )
-{
- Sequence<OUString> aSNS { "com.sun.star.sdbc.Driver" };
- return aSNS;
-}
-
-css::uno::Reference< css::uno::XInterface > connectivity::java_sql_Driver_CreateInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxFactory)
-{
- return *(new java_sql_Driver( comphelper::getComponentContext(_rxFactory)));
-}
-
-OUString SAL_CALL java_sql_Driver::getImplementationName( )
-{
- return getImplementationName_Static();
-}
-
sal_Bool SAL_CALL java_sql_Driver::supportsService( const OUString& _rServiceName )
{
return cppu::supportsService(this, _rServiceName);
@@ -79,7 +61,7 @@ sal_Bool SAL_CALL java_sql_Driver::supportsService( const OUString& _rServiceNam
Sequence< OUString > SAL_CALL java_sql_Driver::getSupportedServiceNames( )
{
- return getSupportedServiceNames_Static();
+ return { "com.sun.star.sdbc.Driver" };
}
Reference< XConnection > SAL_CALL java_sql_Driver::connect( const OUString& url, const
@@ -242,5 +224,11 @@ sal_Int32 SAL_CALL java_sql_Driver::getMinorVersion( )
return 0;
}
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+connectivity_java_sql_Driver_get_implementation(
+ css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
+{
+ return cppu::acquire(new java_sql_Driver(context));
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/jdbc/jdbc.component b/connectivity/source/drivers/jdbc/jdbc.component
index 07fd03c68467..86a6a079b41e 100644
--- a/connectivity/source/drivers/jdbc/jdbc.component
+++ b/connectivity/source/drivers/jdbc/jdbc.component
@@ -28,9 +28,10 @@
-->
<component loader="com.sun.star.loader.SharedLibrary"
- environment="@CPPU_ENV@:affine" prefix="jdbc"
+ environment="@CPPU_ENV@:affine"
xmlns="http://openoffice.org/2010/uno-components">
- <implementation name="com.sun.star.comp.sdbc.JDBCDriver">
+ <implementation name="com.sun.star.comp.sdbc.JDBCDriver"
+ constructor="connectivity_java_sql_Driver_get_implementation">
<service name="com.sun.star.sdbc.Driver"/>
</implementation>
</component>
diff --git a/connectivity/source/drivers/jdbc/jservices.cxx b/connectivity/source/drivers/jdbc/jservices.cxx
deleted file mode 100644
index 63ae84c8ebfb..000000000000
--- a/connectivity/source/drivers/jdbc/jservices.cxx
+++ /dev/null
@@ -1,106 +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 <java/sql/Driver.hxx>
-#include <cppuhelper/factory.hxx>
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-
-using namespace connectivity;
-using ::com::sun::star::uno::Reference;
-using ::com::sun::star::uno::Sequence;
-using ::com::sun::star::lang::XSingleServiceFactory;
-using ::com::sun::star::lang::XMultiServiceFactory;
-
-typedef Reference< XSingleServiceFactory > (*createFactoryFunc)
- (
- const Reference< XMultiServiceFactory > & rServiceManager,
- const OUString & rComponentName,
- ::cppu::ComponentInstantiation pCreateFunction,
- const Sequence< OUString > & rServiceNames,
- rtl_ModuleCount*
- );
-
-namespace {
-
-struct ProviderRequest
-{
- Reference< XSingleServiceFactory > xRet;
- Reference< XMultiServiceFactory > const xServiceManager;
- OUString const sImplementationName;
-
- ProviderRequest(
- void* pServiceManager,
- char const* pImplementationName
- )
- : xServiceManager(static_cast<XMultiServiceFactory*>(pServiceManager))
- , sImplementationName(OUString::createFromAscii(pImplementationName))
- {
- }
-
- bool CREATE_PROVIDER(
- const OUString& Implname,
- const Sequence< OUString > & Services,
- ::cppu::ComponentInstantiation Factory,
- createFactoryFunc creator
- )
- {
- if (!xRet.is() && (Implname == sImplementationName))
- {
- try
- {
- xRet = creator( xServiceManager, sImplementationName,Factory, Services,nullptr);
- }
- catch(...)
- {
- }
- }
- return xRet.is();
- }
-
- void* getProvider() const { return xRet.get(); }
-};
-
-}
-
-extern "C" SAL_DLLPUBLIC_EXPORT void* jdbc_component_getFactory(
- const char* pImplementationName,
- void* pServiceManager,
- void* /*pRegistryKey*/)
-{
- void* pRet = nullptr;
- if (pServiceManager)
- {
- ProviderRequest aReq(pServiceManager,pImplementationName);
-
- aReq.CREATE_PROVIDER(
- java_sql_Driver::getImplementationName_Static(),
- java_sql_Driver::getSupportedServiceNames_Static(),
- java_sql_Driver_CreateInstance,
- ::cppu::createSingleFactory);
-
- if(aReq.xRet.is())
- aReq.xRet->acquire();
- pRet = aReq.getProvider();
- }
-
- return pRet;
-}
-
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/inc/java/sql/Driver.hxx b/connectivity/source/inc/java/sql/Driver.hxx
index f50d9a3f55d0..3deba1b9887d 100644
--- a/connectivity/source/inc/java/sql/Driver.hxx
+++ b/connectivity/source/inc/java/sql/Driver.hxx
@@ -29,9 +29,6 @@
namespace connectivity
{
- /// @throws css::uno::Exception
- css::uno::Reference< css::uno::XInterface > java_sql_Driver_CreateInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxFactory);
-
class java_sql_Driver : public ::cppu::WeakImplHelper< css::sdbc::XDriver,css::lang::XServiceInfo>
{
css::uno::Reference<css::uno::XComponentContext> m_aContext;
@@ -43,11 +40,6 @@ namespace connectivity
public:
java_sql_Driver(const css::uno::Reference< css::uno::XComponentContext >& _rxContext);
- /// @throws css::uno::RuntimeException
- static OUString getImplementationName_Static( );
- /// @throws css::uno::RuntimeException
- static css::uno::Sequence< OUString > getSupportedServiceNames_Static( );
-
// XServiceInfo
virtual OUString SAL_CALL getImplementationName( ) override;
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;