1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
19 #ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_MYSQL_YDRIVER_HXX
20 #define INCLUDED_CONNECTIVITY_SOURCE_INC_MYSQL_YDRIVER_HXX
22 #include <sal/config.h>
26 #include <com/sun/star/sdbc/XDriver.hpp>
27 #include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
28 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <com/sun/star/uno/XComponentContext.hpp>
31 #include <cppuhelper/compbase3.hxx>
32 #include <comphelper/uno3.hxx>
33 #include <comphelper/broadcasthelper.hxx>
34 #include <connectivity/CommonTools.hxx>
37 namespace connectivity
41 class OMetaConnection
;
45 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> SAL_CALL
ODriverDelegator_CreateInstance(const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& _rxMSF
) throw( ::com::sun::star::uno::Exception
);
47 typedef ::cppu::WeakComponentImplHelper3
< ::com::sun::star::sdbc::XDriver
48 , ::com::sun::star::sdbcx::XDataDefinitionSupplier
49 , ::com::sun::star::lang::XServiceInfo
50 > ODriverDelegator_BASE
;
52 typedef ::std::pair
< ::com::sun::star::uno::WeakReferenceHelper
,OMetaConnection
*> TWeakConnectionPair
;
53 typedef ::std::pair
< ::com::sun::star::uno::WeakReferenceHelper
,TWeakConnectionPair
> TWeakPair
;
54 typedef ::std::vector
< TWeakPair
> TWeakPairVector
;
55 typedef std::map
< OUString
, ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XDriver
> > TJDBCDrivers
;
57 /** delegates all calls to the orignal driver and extend the existing one with the SDBCX layer.
60 class ODriverDelegator
: public ::comphelper::OBaseMutex
61 ,public ODriverDelegator_BASE
63 TJDBCDrivers m_aJdbcDrivers
; // all jdbc drivers
64 TWeakPairVector m_aConnections
; // vector containing a list
65 // of all the Connection objects
67 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XDriver
> m_xODBCDriver
;
68 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XDriver
> m_xNativeDriver
;
69 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> m_xContext
;
71 /** load the driver we want to delegate.
72 The <member>m_xODBCDriver</member> or <member>m_xDBCDriver</member> may be <NULL/> if the driver could not be loaded.
76 The property info contains which driver we have to delegate.
78 The driver which was currently selected.
80 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XDriver
> loadDriver( const OUString
& url
, const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& info
);
83 /** creates a new delegator for a mysql driver
85 ODriverDelegator(const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& _rxContext
);
88 DECLARE_SERVICE_INFO();
89 static OUString
getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException
);
90 static ::com::sun::star::uno::Sequence
< OUString
> getSupportedServiceNames_Static( ) throw (::com::sun::star::uno::RuntimeException
);
93 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
> SAL_CALL
connect( 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
;
94 virtual sal_Bool SAL_CALL
acceptsURL( const OUString
& url
) throw (::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
95 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::sdbc::DriverPropertyInfo
> SAL_CALL
getPropertyInfo( 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
;
96 virtual sal_Int32 SAL_CALL
getMajorVersion( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
97 virtual sal_Int32 SAL_CALL
getMinorVersion( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
99 // XDataDefinitionSupplier
100 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbcx::XTablesSupplier
> SAL_CALL
getDataDefinitionByConnection( const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& connection
) throw (::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
101 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbcx::XTablesSupplier
> SAL_CALL
getDataDefinitionByURL( 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
;
104 virtual ~ODriverDelegator();
106 virtual void SAL_CALL
disposing() SAL_OVERRIDE
;
111 } // namespace connectivity
113 #endif // INCLUDED_CONNECTIVITY_SOURCE_INC_MYSQL_YDRIVER_HXX
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */