bump product version to 5.0.4.1
[LibreOffice.git] / connectivity / source / manager / mdrivermanager.hxx
blobec4dea8baeb2782c1a869757d0b687e460bdd32f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_CONNECTIVITY_SOURCE_MANAGER_MDRIVERMANAGER_HXX
21 #define INCLUDED_CONNECTIVITY_SOURCE_MANAGER_MDRIVERMANAGER_HXX
23 #include <sal/config.h>
25 #include <map>
26 #include <vector>
28 #include <com/sun/star/sdbc/XDriverManager2.hpp>
29 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
30 #include <com/sun/star/uno/XNamingService.hpp>
31 #include <com/sun/star/lang/XServiceInfo.hpp>
32 #include <com/sun/star/sdbc/XDriverAccess.hpp>
33 #include <com/sun/star/lang/XSingleComponentFactory.hpp>
35 #include <cppuhelper/implbase3.hxx>
36 #include <comphelper/logging.hxx>
37 #include <osl/mutex.hxx>
38 #include <connectivity/DriversConfig.hxx>
40 namespace drivermanager
43 typedef std::map< OUString, css::uno::Reference< css::sdbc::XDriver > > DriverCollection;
45 struct DriverAccess
47 OUString sImplementationName; /// the implementation name of the driver
48 css::uno::Reference< css::sdbc::XDriver > xDriver; /// the driver itself
49 css::uno::Reference< css::lang::XSingleComponentFactory > xComponentFactory; /// the factory to create the driver component (if not already done so)
53 // OSDBCDriverManager - the one-instance service for managing SDBC drivers
55 typedef ::cppu::WeakImplHelper3 < ::com::sun::star::sdbc::XDriverManager2
56 , ::com::sun::star::lang::XServiceInfo
57 , ::com::sun::star::uno::XNamingService
58 > OSDBCDriverManager_Base;
60 class OSDBCDriverManager : public OSDBCDriverManager_Base
62 friend class ODriverEnumeration;
64 ::osl::Mutex m_aMutex;
65 css::uno::Reference<css::uno::XComponentContext> m_xContext;
66 ::comphelper::EventLogger m_aEventLogger;
68 typedef std::vector<DriverAccess> DriverAccessArray;
69 DriverAccessArray m_aDriversBS;
71 // for drivers registered at runtime (not bootstrapped) we don't require an XServiceInfo interface,
72 // so we have to remember their impl-name in another way
73 typedef std::map< OUString, css::uno::Reference< css::sdbc::XDriver > > DriverCollection;
74 DriverCollection m_aDriversRT;
76 ::connectivity::DriversConfig m_aDriverConfig;
77 sal_Int32 m_nLoginTimeout;
79 private:
80 OSDBCDriverManager(
81 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext );
82 virtual ~OSDBCDriverManager();
84 public:
86 // XDriverManager
87 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( const OUString& url ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
88 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnectionWithInfo( const OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
89 virtual void SAL_CALL setLoginTimeout( sal_Int32 seconds ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
90 virtual sal_Int32 SAL_CALL getLoginTimeout( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
92 // XDriverAccess
93 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > SAL_CALL getDriverByURL( const OUString& url ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
95 // XEnumerationAccess
96 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
98 // XElementAccess
99 virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
100 virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
102 // XServiceInfo
103 virtual OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
104 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
105 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
107 // XServiceInfo - static methods
108 static OUString SAL_CALL getImplementationName_static( ) throw(::com::sun::star::uno::RuntimeException);
109 static ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames_static( ) throw(::com::sun::star::uno::RuntimeException);
110 static OUString SAL_CALL getSingletonName_static( ) throw(::com::sun::star::uno::RuntimeException);
111 static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL Create( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxContext );
113 // XNamingService
114 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getRegisteredObject( const OUString& Name ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
115 virtual void SAL_CALL registerObject( const OUString& Name, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Object ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
116 virtual void SAL_CALL revokeObject( const OUString& Name ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
118 protected:
119 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > implGetDriverForURL(const OUString& _rURL);
121 /** retrieve the driver order preferences from the configuration and
122 sort m_aDriversBS accordingly.
124 void initializeDriverPrecedence();
126 void bootstrapDrivers();
129 } // namespace drivermanager
131 #endif // INCLUDED_CONNECTIVITY_SOURCE_MANAGER_MDRIVERMANAGER_HXX
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */