1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <comphelper/uno3.hxx>
26 #include <cppuhelper/component.hxx>
27 #include <cppuhelper/compbase1.hxx>
29 using namespace ::com::sun::star::uno
;
30 using namespace ::com::sun::star::lang
;
31 using namespace ::com::sun::star::sdbc
;
32 using namespace ::com::sun::star::container
;
33 using namespace ::com::sun::star::reflection
;
34 using namespace connectivity
;
35 using namespace ::osl
;
37 OPooledConnection::OPooledConnection(const Reference
< XConnection
>& _xConnection
,
38 const Reference
< ::com::sun::star::reflection::XProxyFactory
>& _rxProxyFactory
)
39 : OPooledConnection_Base(m_aMutex
)
40 ,m_xRealConnection(_xConnection
)
41 ,m_xProxyFactory(_rxProxyFactory
)
47 void SAL_CALL
OPooledConnection::disposing()
49 MutexGuard
aGuard(m_aMutex
);
50 if (m_xComponent
.is())
51 m_xComponent
->removeEventListener(this);
53 ::comphelper::disposeComponent(m_xRealConnection
);
57 void SAL_CALL
OPooledConnection::disposing( const EventObject
& /*Source*/ ) throw (RuntimeException
, std::exception
)
63 Reference
< XConnection
> OPooledConnection::getConnection() throw(SQLException
, RuntimeException
, std::exception
)
65 if(!m_xComponent
.is() && m_xRealConnection
.is())
67 Reference
< XAggregation
> xConProxy
= m_xProxyFactory
->createProxy(m_xRealConnection
.get());
68 m_xComponent
= new OConnectionWeakWrapper(xConProxy
);
69 // register as event listener for the new connection
70 if (m_xComponent
.is())
71 m_xComponent
->addEventListener(this);
73 return Reference
< XConnection
>(m_xComponent
,UNO_QUERY
);
77 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */