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 .
21 #include <connectivity/ConnectionWrapper.hxx>
22 #include <connectivity/CommonTools.hxx>
23 #include <cppuhelper/compbase.hxx>
24 #include <cppuhelper/basemutex.hxx>
25 #include <com/sun/star/sdbc/SQLException.hpp>
26 #include <com/sun/star/sdbc/XConnection.hpp>
27 #include <comphelper/sequence.hxx>
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
36 > OSharedConnection_BASE
;
37 typedef ::connectivity::OConnectionWrapper OSharedConnection_BASE2
;
39 class OSharedConnection
: public ::cppu::BaseMutex
40 , public OSharedConnection_BASE
41 , public OSharedConnection_BASE2
44 virtual void SAL_CALL
disposing() override
;
45 virtual ~OSharedConnection() override
;
47 explicit OSharedConnection(css::uno::Reference
< css::uno::XAggregation
>& _rxProxyConnection
);
49 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId( ) override
;
51 virtual void SAL_CALL
acquire() throw() override
{ OSharedConnection_BASE::acquire(); }
52 virtual void SAL_CALL
release() throw() override
{ OSharedConnection_BASE::release(); }
53 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes( ) override
55 return ::comphelper::concatSequences(
56 OSharedConnection_BASE::getTypes(),
57 OSharedConnection_BASE2::getTypes()
61 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& _rType
) override
63 css::uno::Any aReturn
= OSharedConnection_BASE::queryInterface(_rType
);
64 if ( !aReturn
.hasValue() )
65 aReturn
= OSharedConnection_BASE2::queryInterface(_rType
);
70 virtual void SAL_CALL
close( ) override
73 ::osl::MutexGuard
aGuard( m_aMutex
);
74 ::connectivity::checkDisposed(rBHelper
.bDisposed
);
80 virtual void SAL_CALL
setAutoCommit( sal_Bool
/*autoCommit*/ ) override
82 throw css::sdbc::SQLException("This call is not allowed when sharing connections.",*this,"S10000",0,css::uno::Any());
84 virtual void SAL_CALL
setReadOnly( sal_Bool
/*readOnly*/ ) override
86 throw css::sdbc::SQLException("This call is not allowed when sharing connections.",*this,"S10000",0,css::uno::Any());
88 virtual void SAL_CALL
setCatalog( const OUString
& /*catalog*/ ) override
90 throw css::sdbc::SQLException("This call is not allowed when sharing connections.",*this,"S10000",0,css::uno::Any());
92 virtual void SAL_CALL
setTransactionIsolation( sal_Int32
/*level*/ ) override
94 throw css::sdbc::SQLException("This call is not allowed when sharing connections.",*this,"S10000",0,css::uno::Any());
96 virtual void SAL_CALL
setTypeMap( const css::uno::Reference
< css::container::XNameAccess
>& /*typeMap*/ ) override
98 throw css::sdbc::SQLException("This call is not allowed when sharing connections.",*this,"S10000",0,css::uno::Any());
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
;
116 } // namespace dbaccess
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */