Bump for 3.6-28
[LibreOffice.git] / connectivity / source / manager / mdrivermanager.hxx
blob2bd22dd6cf686ab49ff0138e6c5d5fbd84b3b2d6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef _CONNECTIVITY_DRIVERMANAGER_HXX_
30 #define _CONNECTIVITY_DRIVERMANAGER_HXX_
32 #include <com/sun/star/sdbc/XDriverManager.hpp>
33 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
34 #include <com/sun/star/container/XEnumerationAccess.hpp>
35 #include <com/sun/star/uno/XNamingService.hpp>
36 #include <com/sun/star/lang/XServiceInfo.hpp>
37 #include <com/sun/star/sdbc/XDriverAccess.hpp>
38 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
40 #include <cppuhelper/implbase5.hxx>
41 #include <comphelper/stl_types.hxx>
42 #include <comphelper/logging.hxx>
43 #include <comphelper/componentcontext.hxx>
44 #include <osl/mutex.hxx>
45 #include "connectivity/DriversConfig.hxx"
47 namespace drivermanager
50 //======================================================================
51 //= various
52 //======================================================================
53 typedef ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > SdbcDriver;
54 DECLARE_STL_USTRINGACCESS_MAP( SdbcDriver, DriverCollection );
56 typedef ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > DriverFactory;
57 struct DriverAccess
59 ::rtl::OUString sImplementationName; /// the implementation name of the driver
60 DriverFactory xComponentFactory; /// the factory to create the driver component (if not already done so)
61 SdbcDriver xDriver; /// the driver itself
64 //==========================================================================
65 //= OSDBCDriverManager - the one-instance service for managing SDBC drivers
66 //==========================================================================
67 typedef ::cppu::WeakImplHelper5 < ::com::sun::star::sdbc::XDriverManager
68 , ::com::sun::star::sdbc::XDriverAccess
69 , ::com::sun::star::container::XEnumerationAccess
70 , ::com::sun::star::lang::XServiceInfo
71 , ::com::sun::star::uno::XNamingService
72 > OSDBCDriverManager_Base;
74 class OSDBCDriverManager : public OSDBCDriverManager_Base
76 friend class ODriverEnumeration;
78 ::osl::Mutex m_aMutex;
79 ::comphelper::ComponentContext m_aContext;
80 ::comphelper::EventLogger m_aEventLogger;
82 DECLARE_STL_VECTOR(DriverAccess, DriverAccessArray);
83 DriverAccessArray m_aDriversBS;
85 // for drivers registered at runtime (not bootstrapped) we don't require an XServiceInfo interface,
86 // so we have to remember their impl-name in another way
87 DECLARE_STL_USTRINGACCESS_MAP(SdbcDriver, DriverCollection);
88 DriverCollection m_aDriversRT;
90 ::connectivity::DriversConfig m_aDriverConfig;
91 sal_Int32 m_nLoginTimeout;
93 private:
94 OSDBCDriverManager(
95 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext );
96 ~OSDBCDriverManager();
98 public:
100 // XDriverManager
101 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( const ::rtl::OUString& url ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
102 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnectionWithInfo( const ::rtl::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);
103 virtual void SAL_CALL setLoginTimeout( sal_Int32 seconds ) throw(::com::sun::star::uno::RuntimeException);
104 virtual sal_Int32 SAL_CALL getLoginTimeout( ) throw(::com::sun::star::uno::RuntimeException);
106 // XDriverAccess
107 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > SAL_CALL getDriverByURL( const ::rtl::OUString& url ) throw(::com::sun::star::uno::RuntimeException);
109 // XEnumerationAccess
110 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration( ) throw(::com::sun::star::uno::RuntimeException);
112 // XElementAccess
113 virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException);
114 virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException);
116 // XServiceInfo
117 virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
118 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
119 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
121 // XServiceInfo - static methods
122 static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw(::com::sun::star::uno::RuntimeException);
123 static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static( ) throw(::com::sun::star::uno::RuntimeException);
124 static ::rtl::OUString SAL_CALL getSingletonName_static( ) throw(::com::sun::star::uno::RuntimeException);
125 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 );
127 // XNamingService
128 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getRegisteredObject( const ::rtl::OUString& Name ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
129 virtual void SAL_CALL registerObject( const ::rtl::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);
130 virtual void SAL_CALL revokeObject( const ::rtl::OUString& Name ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
132 protected:
133 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > implGetDriverForURL(const ::rtl::OUString& _rURL);
135 /** retrieve the driver order preferences from the configuration and
136 sort m_aDriversBS accordingly.
138 void initializeDriverPrecedence();
140 void bootstrapDrivers();
143 } // namespace drivermanager
145 #endif // _CONNECTIVITY_DRIVERMANAGER_HXX_
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */