LibreOffice Module dbaccess (master) 1
SharedConnection.hxx
Go to the documentation of this file.
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#pragma once
20
25#include <com/sun/star/sdbc/SQLException.hpp>
26#include <com/sun/star/sdbc/XConnection.hpp>
28
29namespace dbaccess
30{
31 // OSharedConnection: This class implements a simple forwarding of connection calls.
32 // All methods will be forwarded with exception of the set methods, which are not allowed
33 // to be called on shared connections. Instances of this class will be created when the
34 // datasource is asked for not isolated connection.
35 typedef ::cppu::WeakComponentImplHelper< css::sdbc::XConnection
38
42 {
43 protected:
44 virtual void SAL_CALL disposing() override;
45 virtual ~OSharedConnection() override;
46 public:
47 explicit OSharedConnection(css::uno::Reference< css::uno::XAggregation >& _rxProxyConnection);
48
49 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override;
50
51 virtual void SAL_CALL acquire() noexcept override { OSharedConnection_BASE::acquire(); }
52 virtual void SAL_CALL release() noexcept override { OSharedConnection_BASE::release(); }
53 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override
54 {
55 return ::comphelper::concatSequences(
56 OSharedConnection_BASE::getTypes(),
58 );
59 }
60
61 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& _rType ) override
62 {
63 css::uno::Any aReturn = OSharedConnection_BASE::queryInterface(_rType);
64 if ( !aReturn.hasValue() )
66 return aReturn;
67 }
68
69 // XCloseable
70 virtual void SAL_CALL close( ) override
71 {
72 {
73 ::osl::MutexGuard aGuard( m_aMutex );
74 ::connectivity::checkDisposed(rBHelper.bDisposed);
75 }
76 dispose();
77 }
78
79 // XConnection
80 virtual void SAL_CALL setAutoCommit( sal_Bool /*autoCommit*/ ) override
81 {
82 throw css::sdbc::SQLException("This call is not allowed when sharing connections.",*this,"S10000",0,css::uno::Any());
83 }
84 virtual void SAL_CALL setReadOnly( sal_Bool /*readOnly*/ ) override
85 {
86 throw css::sdbc::SQLException("This call is not allowed when sharing connections.",*this,"S10000",0,css::uno::Any());
87 }
88 virtual void SAL_CALL setCatalog( const OUString& /*catalog*/ ) override
89 {
90 throw css::sdbc::SQLException("This call is not allowed when sharing connections.",*this,"S10000",0,css::uno::Any());
91 }
92 virtual void SAL_CALL setTransactionIsolation( sal_Int32 /*level*/ ) override
93 {
94 throw css::sdbc::SQLException("This call is not allowed when sharing connections.",*this,"S10000",0,css::uno::Any());
95 }
96 virtual void SAL_CALL setTypeMap( const css::uno::Reference< css::container::XNameAccess >& /*typeMap*/ ) override
97 {
98 throw css::sdbc::SQLException("This call is not allowed when sharing connections.",*this,"S10000",0,css::uno::Any());
99 }
100 // XConnection
101 virtual css::uno::Reference< css::sdbc::XStatement > SAL_CALL createStatement( ) override;
102 virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const OUString& sql ) override;
103 virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareCall( const OUString& sql ) override;
104 virtual OUString SAL_CALL nativeSQL( const OUString& sql ) override;
105 virtual sal_Bool SAL_CALL getAutoCommit( ) override;
106 virtual void SAL_CALL commit( ) override;
107 virtual void SAL_CALL rollback( ) override;
108 virtual sal_Bool SAL_CALL isClosed( ) override;
109 virtual css::uno::Reference< css::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) override;
110 virtual sal_Bool SAL_CALL isReadOnly( ) override;
111 virtual OUString SAL_CALL getCatalog( ) override;
112 virtual sal_Int32 SAL_CALL getTransactionIsolation( ) override;
113 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTypeMap( ) override;
114 };
115
116} // namespace dbaccess
117
118/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &_rType) override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
mutable::osl::Mutex m_aMutex
virtual OUString SAL_CALL nativeSQL(const OUString &sql) override
virtual void SAL_CALL setTransactionIsolation(sal_Int32) override
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTypeMap() override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &_rType) override
virtual sal_Bool SAL_CALL isReadOnly() override
virtual void SAL_CALL setCatalog(const OUString &) override
virtual void SAL_CALL commit() override
virtual OUString SAL_CALL getCatalog() override
virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareCall(const OUString &sql) override
virtual void SAL_CALL disposing() override
virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareStatement(const OUString &sql) override
virtual sal_Bool SAL_CALL getAutoCommit() override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual sal_Bool SAL_CALL isClosed() override
virtual css::uno::Reference< css::sdbc::XDatabaseMetaData > SAL_CALL getMetaData() override
virtual ~OSharedConnection() override
OSharedConnection(css::uno::Reference< css::uno::XAggregation > &_rxProxyConnection)
virtual void SAL_CALL close() override
virtual void SAL_CALL rollback() override
virtual sal_Int32 SAL_CALL getTransactionIsolation() override
virtual void SAL_CALL acquire() noexcept override
virtual void SAL_CALL setTypeMap(const css::uno::Reference< css::container::XNameAccess > &) override
virtual css::uno::Reference< css::sdbc::XStatement > SAL_CALL createStatement() override
virtual void SAL_CALL setReadOnly(sal_Bool) override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
virtual void SAL_CALL setAutoCommit(sal_Bool) override
virtual void SAL_CALL release() noexcept override
::connectivity::OConnectionWrapper OSharedConnection_BASE2
::cppu::WeakComponentImplHelper< css::sdbc::XConnection > OSharedConnection_BASE
void dispose()
unsigned char sal_Bool