1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef DBA_CORE_SHARED_CONNECTION_HXX 28 #define DBA_CORE_SHARED_CONNECTION_HXX 29 30 #ifndef _CONNECTIVITY_CONNECTIONWRAPPER_HXX_ 31 #include "connectivity/ConnectionWrapper.hxx" 32 #endif 33 #ifndef _CPPUHELPER_COMPONENT_HXX_ 34 #include <cppuhelper/component.hxx> 35 #endif 36 #ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ 37 #include <connectivity/CommonTools.hxx> 38 #endif 39 #ifndef _CPPUHELPER_COMPBASE1_HXX_ 40 #include <cppuhelper/compbase1.hxx> 41 #endif 42 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ 43 #include <com/sun/star/sdbc/XConnection.hpp> 44 #endif 45 #ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_ 46 #include <com/sun/star/sdbc/XWarningsSupplier.hpp> 47 #endif 48 #ifndef _COM_SUN_STAR_SDBC_SQLWARNING_HPP_ 49 #include <com/sun/star/sdbc/SQLWarning.hpp> 50 #endif 51 #ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ 52 #include <com/sun/star/beans/PropertyValue.hpp> 53 #endif 54 #ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSERFACTORY_HPP_ 55 #include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp> 56 #endif 57 #ifndef _COM_SUN_STAR_SDB_XCOMMANDPREPARATION_HPP_ 58 #include <com/sun/star/sdb/XCommandPreparation.hpp> 59 #endif 60 #ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ 61 #include <com/sun/star/sdbcx/XTablesSupplier.hpp> 62 #endif 63 #ifndef _COM_SUN_STAR_SDBCX_XVIEWSSUPPLIER_HPP_ 64 #include <com/sun/star/sdbcx/XViewsSupplier.hpp> 65 #endif 66 #ifndef _COM_SUN_STAR_SDB_XQUERIESSUPPLIER_HPP_ 67 #include <com/sun/star/sdb/XQueriesSupplier.hpp> 68 #endif 69 #ifndef _COMPHELPER_SEQUENCE_HXX_ 70 #include <comphelper/sequence.hxx> 71 #endif 72 73 74 namespace dbaccess 75 { 76 //======================================================================================= 77 //= OSharedConnection: This class implements a simple forwarding of connection calls. 78 //= All methods will be forwarded with exception of the set methods, which are not allowed 79 //= to be called on shared connections. Instances of this class will be created when the 80 //= datasource is asked for not isolated connection. 81 //======================================================================================= 82 typedef ::cppu::WeakComponentImplHelper1< ::com::sun::star::sdbc::XConnection 83 > OSharedConnection_BASE; 84 typedef ::connectivity::OConnectionWrapper OSharedConnection_BASE2; 85 86 class OSharedConnection : public ::comphelper::OBaseMutex 87 , public OSharedConnection_BASE 88 , public OSharedConnection_BASE2 89 { 90 protected: 91 virtual void SAL_CALL disposing(void); 92 virtual ~OSharedConnection(); 93 public: 94 OSharedConnection(::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation >& _rxProxyConnection); 95 96 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (::com::sun::star::uno::RuntimeException); 97 98 virtual void SAL_CALL acquire() throw() { OSharedConnection_BASE::acquire(); } 99 virtual void SAL_CALL release() throw() { OSharedConnection_BASE::release(); } 100 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw (::com::sun::star::uno::RuntimeException) 101 { 102 return ::comphelper::concatSequences( 103 OSharedConnection_BASE::getTypes(), 104 OSharedConnection_BASE2::getTypes() 105 ); 106 } 107 108 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException) 109 { 110 ::com::sun::star::uno::Any aReturn = OSharedConnection_BASE::queryInterface(_rType); 111 if ( !aReturn.hasValue() ) 112 aReturn = OSharedConnection_BASE2::queryInterface(_rType); 113 return aReturn; 114 } 115 // -------------------------------------------------------------------------------- 116 // XCloseable 117 virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 118 { 119 { 120 ::osl::MutexGuard aGuard( m_aMutex ); 121 ::connectivity::checkDisposed(rBHelper.bDisposed); 122 123 } 124 dispose(); 125 } 126 127 // XConnection 128 virtual void SAL_CALL setAutoCommit( sal_Bool /*autoCommit*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 129 { 130 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()); 131 } 132 virtual void SAL_CALL setReadOnly( sal_Bool /*readOnly*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 133 { 134 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 } 136 virtual void SAL_CALL setCatalog( const ::rtl::OUString& /*catalog*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 137 { 138 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 } 140 virtual void SAL_CALL setTransactionIsolation( sal_Int32 /*level*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 141 { 142 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 } 144 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) 145 { 146 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 } 148 // XConnection 149 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); 150 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); 151 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); 152 virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 153 virtual sal_Bool SAL_CALL getAutoCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 154 virtual void SAL_CALL commit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 155 virtual void SAL_CALL rollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 156 virtual sal_Bool SAL_CALL isClosed( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 157 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); 158 virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 159 virtual ::rtl::OUString SAL_CALL getCatalog( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 160 virtual sal_Int32 SAL_CALL getTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 161 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); 162 }; 163 164 #ifdef IMPLEMENT_GET_IMPLEMENTATION_ID 165 IMPLEMENT_GET_IMPLEMENTATION_ID( OSharedConnection ); 166 #endif 167 //........................................................................ 168 } // namespace dbaccess 169 //........................................................................ 170 #endif // DBA_CORE_SHARED_CONNECTION_HXX 171 172 173