LibreOffice Module connectivity (master) 1
mdrivermanager.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#pragma once
21
22#include <sal/config.h>
23
24#include <map>
25#include <vector>
26
27#include <com/sun/star/sdbc/XDriverManager2.hpp>
28#include <com/sun/star/uno/XNamingService.hpp>
29#include <com/sun/star/lang/XServiceInfo.hpp>
30#include <com/sun/star/lang/XSingleComponentFactory.hpp>
31
36
37namespace drivermanager
38{
39
40 typedef std::map< OUString, css::uno::Reference< css::sdbc::XDriver > > DriverCollection;
41
43 {
45 css::uno::Reference< css::sdbc::XDriver > xDriver;
46 css::uno::Reference< css::lang::XSingleComponentFactory > xComponentFactory;
47 };
48
49
50 // OSDBCDriverManager - the one-instance service for managing SDBC drivers
51
52 typedef ::cppu::WeakComponentImplHelper< css::sdbc::XDriverManager2
53 , css::lang::XServiceInfo
54 , css::uno::XNamingService
56
58 {
59 friend class ODriverEnumeration;
60
61 css::uno::Reference<css::uno::XComponentContext> m_xContext;
63
64 typedef std::vector<DriverAccess> DriverAccessArray;
66
67 // for drivers registered at runtime (not bootstrapped) we don't require an XServiceInfo interface,
68 // so we have to remember their impl-name in another way
69 typedef std::map< OUString, css::uno::Reference< css::sdbc::XDriver > > DriverCollection;
71
73 sal_Int32 m_nLoginTimeout;
74
75 public:
76
77 explicit OSDBCDriverManager(
78 const css::uno::Reference< css::uno::XComponentContext >& _rxContext );
79 virtual ~OSDBCDriverManager() override;
80
81 // XDriverManager
82 virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection( const OUString& url ) override;
83 virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnectionWithInfo( const OUString& url, const css::uno::Sequence< css::beans::PropertyValue >& info ) override;
84 virtual void SAL_CALL setLoginTimeout( sal_Int32 seconds ) override;
85 virtual sal_Int32 SAL_CALL getLoginTimeout( ) override;
86
87 // XDriverAccess
88 virtual css::uno::Reference< css::sdbc::XDriver > SAL_CALL getDriverByURL( const OUString& url ) override;
89
90 // XEnumerationAccess
91 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration( ) override;
92
93 // XElementAccess
94 virtual css::uno::Type SAL_CALL getElementType( ) override;
95 virtual sal_Bool SAL_CALL hasElements( ) override;
96
97 // XServiceInfo
98 virtual OUString SAL_CALL getImplementationName( ) override;
99 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
100 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
101
102 // XNamingService
103 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getRegisteredObject( const OUString& Name ) override;
104 virtual void SAL_CALL registerObject( const OUString& Name, const css::uno::Reference< css::uno::XInterface >& Object ) override;
105 virtual void SAL_CALL revokeObject( const OUString& Name ) override;
106
107 private:
108 css::uno::Reference< css::sdbc::XDriver > implGetDriverForURL(const OUString& _rURL);
109
114
115 void bootstrapDrivers();
116 };
117
118} // namespace drivermanager
119
120
121/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnectionWithInfo(const OUString &url, const css::uno::Sequence< css::beans::PropertyValue > &info) override
css::uno::Reference< css::sdbc::XDriver > implGetDriverForURL(const OUString &_rURL)
css::uno::Reference< css::uno::XComponentContext > m_xContext
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual void SAL_CALL setLoginTimeout(sal_Int32 seconds) override
::comphelper::EventLogger m_aEventLogger
void initializeDriverPrecedence()
retrieve the driver order preferences from the configuration and sort m_aDriversBS accordingly.
virtual sal_Bool SAL_CALL hasElements() override
std::map< OUString, css::uno::Reference< css::sdbc::XDriver > > DriverCollection
virtual css::uno::Type SAL_CALL getElementType() override
::connectivity::DriversConfig m_aDriverConfig
virtual void SAL_CALL revokeObject(const OUString &Name) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection(const OUString &url) override
virtual void SAL_CALL registerObject(const OUString &Name, const css::uno::Reference< css::uno::XInterface > &Object) override
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Reference< css::sdbc::XDriver > SAL_CALL getDriverByURL(const OUString &url) override
OSDBCDriverManager(const css::uno::Reference< css::uno::XComponentContext > &_rxContext)
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getRegisteredObject(const OUString &Name) override
std::vector< DriverAccess > DriverAccessArray
virtual sal_Int32 SAL_CALL getLoginTimeout() override
::cppu::WeakComponentImplHelper< css::sdbc::XDriverManager2, css::lang::XServiceInfo, css::uno::XNamingService > OSDBCDriverManager_Base
std::map< OUString, css::uno::Reference< css::sdbc::XDriver > > DriverCollection
css::uno::Reference< css::lang::XSingleComponentFactory > xComponentFactory
the driver itself
css::uno::Reference< css::sdbc::XDriver > xDriver
the implementation name of the driver
unsigned char sal_Bool