Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / connectivity / source / cpool / ZPooledConnection.cxx
blob42e8d6c02db71c37017572a1ba908eead1eb7958
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #include "ZPooledConnection.hxx"
21 #include "ZConnectionWrapper.hxx"
22 #include <comphelper/types.hxx>
24 using namespace ::com::sun::star::uno;
25 using namespace ::com::sun::star::lang;
26 using namespace ::com::sun::star::sdbc;
27 using namespace ::com::sun::star::container;
28 using namespace ::com::sun::star::reflection;
29 using namespace connectivity;
30 using namespace ::osl;
32 OPooledConnection::OPooledConnection(const Reference< XConnection >& _xConnection,
33 const Reference< css::reflection::XProxyFactory >& _rxProxyFactory)
34 : OPooledConnection_Base(m_aMutex)
35 ,m_xRealConnection(_xConnection)
36 ,m_xProxyFactory(_rxProxyFactory)
41 // OComponentHelper
42 void SAL_CALL OPooledConnection::disposing()
44 MutexGuard aGuard(m_aMutex);
45 if (m_xComponent.is())
46 m_xComponent->removeEventListener(this);
47 m_xComponent.clear();
48 ::comphelper::disposeComponent(m_xRealConnection);
51 // XEventListener
52 void SAL_CALL OPooledConnection::disposing( const EventObject& /*Source*/ )
54 m_xComponent.clear();
57 //XPooledConnection
58 Reference< XConnection > OPooledConnection::getConnection()
60 if(!m_xComponent.is() && m_xRealConnection.is())
62 Reference< XAggregation > xConProxy = m_xProxyFactory->createProxy(m_xRealConnection);
63 m_xComponent = new OConnectionWeakWrapper(xConProxy);
64 // register as event listener for the new connection
65 if (m_xComponent.is())
66 m_xComponent->addEventListener(this);
68 return Reference< XConnection >(m_xComponent,UNO_QUERY);
72 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */