1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef DBA_CORE_SHARED_CONNECTION_HXX 24 #define DBA_CORE_SHARED_CONNECTION_HXX 25 26 #ifndef _CONNECTIVITY_CONNECTIONWRAPPER_HXX_ 27 #include "connectivity/ConnectionWrapper.hxx" 28 #endif 29 #ifndef _CPPUHELPER_COMPONENT_HXX_ 30 #include <cppuhelper/component.hxx> 31 #endif 32 #ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ 33 #include <connectivity/CommonTools.hxx> 34 #endif 35 #ifndef _CPPUHELPER_COMPBASE1_HXX_ 36 #include <cppuhelper/compbase1.hxx> 37 #endif 38 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ 39 #include <com/sun/star/sdbc/XConnection.hpp> 40 #endif 41 #ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_ 42 #include <com/sun/star/sdbc/XWarningsSupplier.hpp> 43 #endif 44 #ifndef _COM_SUN_STAR_SDBC_SQLWARNING_HPP_ 45 #include <com/sun/star/sdbc/SQLWarning.hpp> 46 #endif 47 #ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ 48 #include <com/sun/star/beans/PropertyValue.hpp> 49 #endif 50 #ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSERFACTORY_HPP_ 51 #include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp> 52 #endif 53 #ifndef _COM_SUN_STAR_SDB_XCOMMANDPREPARATION_HPP_ 54 #include <com/sun/star/sdb/XCommandPreparation.hpp> 55 #endif 56 #ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ 57 #include <com/sun/star/sdbcx/XTablesSupplier.hpp> 58 #endif 59 #ifndef _COM_SUN_STAR_SDBCX_XVIEWSSUPPLIER_HPP_ 60 #include <com/sun/star/sdbcx/XViewsSupplier.hpp> 61 #endif 62 #ifndef _COM_SUN_STAR_SDB_XQUERIESSUPPLIER_HPP_ 63 #include <com/sun/star/sdb/XQueriesSupplier.hpp> 64 #endif 65 #ifndef _COMPHELPER_SEQUENCE_HXX_ 66 #include <comphelper/sequence.hxx> 67 #endif 68 69 70 namespace dbaccess 71 { 72 //======================================================================================= 73 //= OSharedConnection: This class implements a simple forwarding of connection calls. 74 //= All methods will be forwarded with exception of the set methods, which are not allowed 75 //= to be called on shared connections. Instances of this class will be created when the 76 //= datasource is asked for not isolated connection. 77 //======================================================================================= 78 typedef ::cppu::WeakComponentImplHelper1< ::com::sun::star::sdbc::XConnection 79 > OSharedConnection_BASE; 80 typedef ::connectivity::OConnectionWrapper OSharedConnection_BASE2; 81 82 class OSharedConnection : public ::comphelper::OBaseMutex 83 , public OSharedConnection_BASE 84 , public OSharedConnection_BASE2 85 { 86 protected: 87 virtual void SAL_CALL disposing(void); 88 virtual ~OSharedConnection(); 89 public: 90 OSharedConnection(::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation >& _rxProxyConnection); 91 92 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (::com::sun::star::uno::RuntimeException); 93 acquire()94 virtual void SAL_CALL acquire() throw() { OSharedConnection_BASE::acquire(); } release()95 virtual void SAL_CALL release() throw() { OSharedConnection_BASE::release(); } getTypes()96 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw (::com::sun::star::uno::RuntimeException) 97 { 98 return ::comphelper::concatSequences( 99 OSharedConnection_BASE::getTypes(), 100 OSharedConnection_BASE2::getTypes() 101 ); 102 } 103 queryInterface(const::com::sun::star::uno::Type & _rType)104 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException) 105 { 106 ::com::sun::star::uno::Any aReturn = OSharedConnection_BASE::queryInterface(_rType); 107 if ( !aReturn.hasValue() ) 108 aReturn = OSharedConnection_BASE2::queryInterface(_rType); 109 return aReturn; 110 } 111 // -------------------------------------------------------------------------------- 112 // XCloseable close()113 virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 114 { 115 { 116 ::osl::MutexGuard aGuard( m_aMutex ); 117 ::connectivity::checkDisposed(rBHelper.bDisposed); 118 119 } 120 dispose(); 121 } 122 123 // XConnection setAutoCommit(sal_Bool)124 virtual void SAL_CALL setAutoCommit( sal_Bool /*autoCommit*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 125 { 126 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()); 127 } setReadOnly(sal_Bool)128 virtual void SAL_CALL setReadOnly( sal_Bool /*readOnly*/ ) 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 } setCatalog(const::rtl::OUString &)132 virtual void SAL_CALL setCatalog( const ::rtl::OUString& /*catalog*/ ) 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 } setTransactionIsolation(sal_Int32)136 virtual void SAL_CALL setTransactionIsolation( sal_Int32 /*level*/ ) 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 } setTypeMap(const::com::sun::star::uno::Reference<::com::sun::star::container::XNameAccess> &)140 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) 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 // XConnection 145 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); 146 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); 147 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); 148 virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 149 virtual sal_Bool SAL_CALL getAutoCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 150 virtual void SAL_CALL commit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 151 virtual void SAL_CALL rollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 152 virtual sal_Bool SAL_CALL isClosed( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 153 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); 154 virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 155 virtual ::rtl::OUString SAL_CALL getCatalog( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 156 virtual sal_Int32 SAL_CALL getTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 157 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); 158 }; 159 160 #ifdef IMPLEMENT_GET_IMPLEMENTATION_ID 161 IMPLEMENT_GET_IMPLEMENTATION_ID( OSharedConnection ); 162 #endif 163 //........................................................................ 164 } // namespace dbaccess 165 //........................................................................ 166 #endif // DBA_CORE_SHARED_CONNECTION_HXX 167 168 169