Line data Source code
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 : #ifndef DBA_CORE_SHARED_CONNECTION_HXX
20 : #define DBA_CORE_SHARED_CONNECTION_HXX
21 :
22 : #include "connectivity/ConnectionWrapper.hxx"
23 : #include <cppuhelper/component.hxx>
24 : #include <connectivity/CommonTools.hxx>
25 : #include <cppuhelper/compbase1.hxx>
26 : #include <com/sun/star/sdbc/XConnection.hpp>
27 : #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
28 : #include <com/sun/star/sdbc/SQLWarning.hpp>
29 : #include <com/sun/star/beans/PropertyValue.hpp>
30 : #include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
31 : #include <com/sun/star/sdb/XCommandPreparation.hpp>
32 : #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
33 : #include <com/sun/star/sdbcx/XViewsSupplier.hpp>
34 : #include <com/sun/star/sdb/XQueriesSupplier.hpp>
35 : #include <comphelper/sequence.hxx>
36 :
37 :
38 : namespace dbaccess
39 : {
40 : //=======================================================================================
41 : //= OSharedConnection: This class implements a simple forwarding of connection calls.
42 : //= All methods will be forwarded with exception of the set methods, which are not allowed
43 : //= to be called on shared connections. Instances of this class will be created when the
44 : //= datasource is asked for not isolated connection.
45 : //=======================================================================================
46 : typedef ::cppu::WeakComponentImplHelper1< ::com::sun::star::sdbc::XConnection
47 : > OSharedConnection_BASE;
48 : typedef ::connectivity::OConnectionWrapper OSharedConnection_BASE2;
49 :
50 : class OSharedConnection : public ::comphelper::OBaseMutex
51 : , public OSharedConnection_BASE
52 : , public OSharedConnection_BASE2
53 : {
54 : protected:
55 : virtual void SAL_CALL disposing(void);
56 : virtual ~OSharedConnection();
57 : public:
58 : OSharedConnection(::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation >& _rxProxyConnection);
59 :
60 : virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (::com::sun::star::uno::RuntimeException);
61 :
62 0 : virtual void SAL_CALL acquire() throw() { OSharedConnection_BASE::acquire(); }
63 0 : virtual void SAL_CALL release() throw() { OSharedConnection_BASE::release(); }
64 0 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw (::com::sun::star::uno::RuntimeException)
65 : {
66 : return ::comphelper::concatSequences(
67 : OSharedConnection_BASE::getTypes(),
68 : OSharedConnection_BASE2::getTypes()
69 0 : );
70 : }
71 :
72 0 : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException)
73 : {
74 0 : ::com::sun::star::uno::Any aReturn = OSharedConnection_BASE::queryInterface(_rType);
75 0 : if ( !aReturn.hasValue() )
76 0 : aReturn = OSharedConnection_BASE2::queryInterface(_rType);
77 0 : return aReturn;
78 : }
79 :
80 : // XCloseable
81 0 : virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
82 : {
83 : {
84 0 : ::osl::MutexGuard aGuard( m_aMutex );
85 0 : ::connectivity::checkDisposed(rBHelper.bDisposed);
86 : }
87 0 : dispose();
88 0 : }
89 :
90 : // XConnection
91 0 : virtual void SAL_CALL setAutoCommit( sal_Bool /*autoCommit*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
92 : {
93 0 : throw ::com::sun::star::sdbc::SQLException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("This call is not allowed when sharing connections.")),*this,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S10000")),0,::com::sun::star::uno::Any());
94 : }
95 0 : virtual void SAL_CALL setReadOnly( sal_Bool /*readOnly*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
96 : {
97 0 : throw ::com::sun::star::sdbc::SQLException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("This call is not allowed when sharing connections.")),*this,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S10000")),0,::com::sun::star::uno::Any());
98 : }
99 0 : virtual void SAL_CALL setCatalog( const ::rtl::OUString& /*catalog*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
100 : {
101 0 : throw ::com::sun::star::sdbc::SQLException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("This call is not allowed when sharing connections.")),*this,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S10000")),0,::com::sun::star::uno::Any());
102 : }
103 0 : virtual void SAL_CALL setTransactionIsolation( sal_Int32 /*level*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
104 : {
105 0 : throw ::com::sun::star::sdbc::SQLException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("This call is not allowed when sharing connections.")),*this,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S10000")),0,::com::sun::star::uno::Any());
106 : }
107 0 : virtual void SAL_CALL setTypeMap( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
108 : {
109 0 : throw ::com::sun::star::sdbc::SQLException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("This call is not allowed when sharing connections.")),*this,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S10000")),0,::com::sun::star::uno::Any());
110 : }
111 : // XConnection
112 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > SAL_CALL createStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
113 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
114 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
115 : virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
116 : virtual sal_Bool SAL_CALL getAutoCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
117 : virtual void SAL_CALL commit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
118 : virtual void SAL_CALL rollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
119 : virtual sal_Bool SAL_CALL isClosed( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
120 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
121 : virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
122 : virtual ::rtl::OUString SAL_CALL getCatalog( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
123 : virtual sal_Int32 SAL_CALL getTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
124 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTypeMap( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
125 : };
126 :
127 : #ifdef IMPLEMENT_GET_IMPLEMENTATION_ID
128 0 : IMPLEMENT_GET_IMPLEMENTATION_ID( OSharedConnection );
129 : #endif
130 :
131 : } // namespace dbaccess
132 :
133 : #endif // DBA_CORE_SHARED_CONNECTION_HXX
134 :
135 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|