update dev300-m58
[ooovba.git] / dbaccess / source / core / dataaccess / SharedConnection.hxx
blob4ff9f8ff5f2b09a216d1494a50d8292cbd21fb37
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SharedConnection.hxx,v $
10 * $Revision: 1.7 $
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 ************************************************************************/
30 #ifndef DBA_CORE_SHARED_CONNECTION_HXX
31 #define DBA_CORE_SHARED_CONNECTION_HXX
33 #ifndef _CONNECTIVITY_CONNECTIONWRAPPER_HXX_
34 #include "connectivity/ConnectionWrapper.hxx"
35 #endif
36 #ifndef _CPPUHELPER_COMPONENT_HXX_
37 #include <cppuhelper/component.hxx>
38 #endif
39 #ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
40 #include <connectivity/CommonTools.hxx>
41 #endif
42 #ifndef _CPPUHELPER_COMPBASE1_HXX_
43 #include <cppuhelper/compbase1.hxx>
44 #endif
45 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
46 #include <com/sun/star/sdbc/XConnection.hpp>
47 #endif
48 #ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_
49 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
50 #endif
51 #ifndef _COM_SUN_STAR_SDBC_SQLWARNING_HPP_
52 #include <com/sun/star/sdbc/SQLWarning.hpp>
53 #endif
54 #ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
55 #include <com/sun/star/beans/PropertyValue.hpp>
56 #endif
57 #ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSERFACTORY_HPP_
58 #include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
59 #endif
60 #ifndef _COM_SUN_STAR_SDB_XCOMMANDPREPARATION_HPP_
61 #include <com/sun/star/sdb/XCommandPreparation.hpp>
62 #endif
63 #ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
64 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
65 #endif
66 #ifndef _COM_SUN_STAR_SDBCX_XVIEWSSUPPLIER_HPP_
67 #include <com/sun/star/sdbcx/XViewsSupplier.hpp>
68 #endif
69 #ifndef _COM_SUN_STAR_SDB_XQUERIESSUPPLIER_HPP_
70 #include <com/sun/star/sdb/XQueriesSupplier.hpp>
71 #endif
72 #ifndef _COMPHELPER_SEQUENCE_HXX_
73 #include <comphelper/sequence.hxx>
74 #endif
77 namespace dbaccess
79 //=======================================================================================
80 //= OSharedConnection: This class implements a simple forwarding of connection calls.
81 //= All methods will be forwarded with exception of the set methods, which are not allowed
82 //= to be called on shared connections. Instances of this class will be created when the
83 //= datasource is asked for not isolated connection.
84 //=======================================================================================
85 typedef ::cppu::WeakComponentImplHelper1< ::com::sun::star::sdbc::XConnection
86 > OSharedConnection_BASE;
87 typedef ::connectivity::OConnectionWrapper OSharedConnection_BASE2;
89 class OSharedConnection : public ::comphelper::OBaseMutex
90 , public OSharedConnection_BASE
91 , public OSharedConnection_BASE2
93 protected:
94 virtual void SAL_CALL disposing(void);
95 virtual ~OSharedConnection();
96 public:
97 OSharedConnection(::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation >& _rxProxyConnection);
99 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (::com::sun::star::uno::RuntimeException);
101 virtual void SAL_CALL acquire() throw() { OSharedConnection_BASE::acquire(); }
102 virtual void SAL_CALL release() throw() { OSharedConnection_BASE::release(); }
103 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw (::com::sun::star::uno::RuntimeException)
105 return ::comphelper::concatSequences(
106 OSharedConnection_BASE::getTypes(),
107 OSharedConnection_BASE2::getTypes()
111 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException)
113 ::com::sun::star::uno::Any aReturn = OSharedConnection_BASE::queryInterface(_rType);
114 if ( !aReturn.hasValue() )
115 aReturn = OSharedConnection_BASE2::queryInterface(_rType);
116 return aReturn;
118 // --------------------------------------------------------------------------------
119 // XCloseable
120 virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
123 ::osl::MutexGuard aGuard( m_aMutex );
124 ::connectivity::checkDisposed(rBHelper.bDisposed);
127 dispose();
130 // XConnection
131 virtual void SAL_CALL setAutoCommit( sal_Bool /*autoCommit*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
133 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());
135 virtual void SAL_CALL setReadOnly( sal_Bool /*readOnly*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
137 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());
139 virtual void SAL_CALL setCatalog( const ::rtl::OUString& /*catalog*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
141 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());
143 virtual void SAL_CALL setTransactionIsolation( sal_Int32 /*level*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
145 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());
147 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)
149 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());
151 // XConnection
152 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);
153 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);
154 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);
155 virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
156 virtual sal_Bool SAL_CALL getAutoCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
157 virtual void SAL_CALL commit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
158 virtual void SAL_CALL rollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
159 virtual sal_Bool SAL_CALL isClosed( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
160 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);
161 virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
162 virtual ::rtl::OUString SAL_CALL getCatalog( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
163 virtual sal_Int32 SAL_CALL getTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
164 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);
167 #ifdef IMPLEMENT_GET_IMPLEMENTATION_ID
168 IMPLEMENT_GET_IMPLEMENTATION_ID( OSharedConnection );
169 #endif
170 //........................................................................
171 } // namespace dbaccess
172 //........................................................................
173 #endif // DBA_CORE_SHARED_CONNECTION_HXX