bump product version to 6.3.0.0.beta1
[LibreOffice.git] / connectivity / source / cpool / ZPooledConnection.cxx
blob8bbde8889ec921fe45b605d9eaba4e25c9aa5536
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 <connectivity/ConnectionWrapper.hxx>
23 #include <com/sun/star/sdbc/XCloseable.hpp>
24 #include <comphelper/types.hxx>
25 #include <cppuhelper/component.hxx>
27 using namespace ::com::sun::star::uno;
28 using namespace ::com::sun::star::lang;
29 using namespace ::com::sun::star::sdbc;
30 using namespace ::com::sun::star::container;
31 using namespace ::com::sun::star::reflection;
32 using namespace connectivity;
33 using namespace ::osl;
35 OPooledConnection::OPooledConnection(const Reference< XConnection >& _xConnection,
36 const Reference< css::reflection::XProxyFactory >& _rxProxyFactory)
37 : OPooledConnection_Base(m_aMutex)
38 ,m_xRealConnection(_xConnection)
39 ,m_xProxyFactory(_rxProxyFactory)
44 // OComponentHelper
45 void SAL_CALL OPooledConnection::disposing()
47 MutexGuard aGuard(m_aMutex);
48 if (m_xComponent.is())
49 m_xComponent->removeEventListener(this);
50 m_xComponent.clear();
51 ::comphelper::disposeComponent(m_xRealConnection);
54 // XEventListener
55 void SAL_CALL OPooledConnection::disposing( const EventObject& /*Source*/ )
57 m_xComponent.clear();
60 //XPooledConnection
61 Reference< XConnection > OPooledConnection::getConnection()
63 if(!m_xComponent.is() && m_xRealConnection.is())
65 Reference< XAggregation > xConProxy = m_xProxyFactory->createProxy(m_xRealConnection.get());
66 m_xComponent = new OConnectionWeakWrapper(xConProxy);
67 // register as event listener for the new connection
68 if (m_xComponent.is())
69 m_xComponent->addEventListener(this);
71 return Reference< XConnection >(m_xComponent,UNO_QUERY);
75 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */