1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: mdrivermanager.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _CONNECTIVITY_DRIVERMANAGER_HXX_
32 #define _CONNECTIVITY_DRIVERMANAGER_HXX_
34 #include <com/sun/star/sdbc/XDriverManager.hpp>
35 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
36 #include <com/sun/star/container/XEnumerationAccess.hpp>
37 #include <com/sun/star/uno/XNamingService.hpp>
38 #include <com/sun/star/lang/XServiceInfo.hpp>
39 #include <com/sun/star/sdbc/XDriverAccess.hpp>
40 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
42 #include <cppuhelper/implbase5.hxx>
43 #include <comphelper/stl_types.hxx>
44 #include <comphelper/logging.hxx>
45 #include <comphelper/componentcontext.hxx>
46 #include <osl/mutex.hxx>
47 #include "connectivity/DriversConfig.hxx"
49 namespace drivermanager
52 //======================================================================
54 //======================================================================
55 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XDriver
> SdbcDriver
;
56 DECLARE_STL_USTRINGACCESS_MAP( SdbcDriver
, DriverCollection
);
58 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XSingleServiceFactory
> DriverFactory
;
61 ::rtl::OUString sImplementationName
; /// the implementation name of the driver
62 DriverFactory xComponentFactory
; /// the factory to create the driver component (if not already done so)
63 SdbcDriver xDriver
; /// the driver itself
66 //==========================================================================
67 //= OSDBCDriverManager - the one-instance service for managing SDBC drivers
68 //==========================================================================
69 typedef ::cppu::WeakImplHelper5
< ::com::sun::star::sdbc::XDriverManager
70 , ::com::sun::star::sdbc::XDriverAccess
71 , ::com::sun::star::container::XEnumerationAccess
72 , ::com::sun::star::lang::XServiceInfo
73 , ::com::sun::star::uno::XNamingService
74 > OSDBCDriverManager_Base
;
76 class OSDBCDriverManager
: public OSDBCDriverManager_Base
78 friend class ODriverEnumeration
;
80 ::osl::Mutex m_aMutex
;
81 ::comphelper::ComponentContext m_aContext
;
82 ::comphelper::EventLogger m_aEventLogger
;
84 DECLARE_STL_VECTOR(DriverAccess
, DriverAccessArray
);
85 DriverAccessArray m_aDriversBS
;
87 // for drivers registered at runtime (not bootstrapped) we don't require an XServiceInfo interface,
88 // so we have to remember their impl-name in another way
89 DECLARE_STL_USTRINGACCESS_MAP(SdbcDriver
, DriverCollection
);
90 DriverCollection m_aDriversRT
;
92 ::connectivity::DriversConfig m_aDriverConfig
;
93 sal_Int32 m_nLoginTimeout
;
97 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& _rxContext
);
98 ~OSDBCDriverManager();
103 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
);
104 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
);
105 virtual void SAL_CALL
setLoginTimeout( sal_Int32 seconds
) throw(::com::sun::star::uno::RuntimeException
);
106 virtual sal_Int32 SAL_CALL
getLoginTimeout( ) throw(::com::sun::star::uno::RuntimeException
);
109 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XDriver
> SAL_CALL
getDriverByURL( const ::rtl::OUString
& url
) throw(::com::sun::star::uno::RuntimeException
);
111 // XEnumerationAccess
112 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XEnumeration
> SAL_CALL
createEnumeration( ) throw(::com::sun::star::uno::RuntimeException
);
115 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType( ) throw(::com::sun::star::uno::RuntimeException
);
116 virtual sal_Bool SAL_CALL
hasElements( ) throw(::com::sun::star::uno::RuntimeException
);
119 virtual ::rtl::OUString SAL_CALL
getImplementationName( ) throw(::com::sun::star::uno::RuntimeException
);
120 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
) throw(::com::sun::star::uno::RuntimeException
);
121 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException
);
123 // XServiceInfo - static methods
124 static ::rtl::OUString SAL_CALL
getImplementationName_static( ) throw(::com::sun::star::uno::RuntimeException
);
125 static ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames_static( ) throw(::com::sun::star::uno::RuntimeException
);
126 static ::rtl::OUString SAL_CALL
getSingletonName_static( ) throw(::com::sun::star::uno::RuntimeException
);
127 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
);
130 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
);
131 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
);
132 virtual void SAL_CALL
revokeObject( const ::rtl::OUString
& Name
) throw(::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
);
135 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XDriver
> implGetDriverForURL(const ::rtl::OUString
& _rURL
);
137 /** retrieve the driver order preferences from the configuration and
138 sort m_aDriversBS accordingly.
140 void initializeDriverPrecedence();
142 void bootstrapDrivers();
145 } // namespace drivermanager
147 #endif // _CONNECTIVITY_DRIVERMANAGER_HXX_