update dev300-m58
[ooovba.git] / connectivity / source / cpool / ZPoolCollection.hxx
blobddef9e317fbb0029f1443cbe5184ca50fe533875
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ZPoolCollection.hxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef CONNECTIVITY_POOLCOLLECTION_HXX
31 #define CONNECTIVITY_POOLCOLLECTION_HXX
33 #include <cppuhelper/implbase5.hxx>
34 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
35 #include <com/sun/star/sdbc/XDriverManager.hpp>
36 #include <com/sun/star/sdbc/XDriver.hpp>
37 #include <com/sun/star/sdbc/XDriverAccess.hpp>
38 #include <com/sun/star/sdbc/XPooledConnection.hpp>
39 #include <com/sun/star/sdbc/XConnection.hpp>
40 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
41 #include <com/sun/star/lang/XServiceInfo.hpp>
42 #include <com/sun/star/lang/XEventListener.hpp>
43 #include <com/sun/star/frame/XDesktop.hpp>
44 #include <com/sun/star/frame/XTerminateListener.hpp>
45 #include <com/sun/star/reflection/XProxyFactory.hpp>
46 #include <comphelper/stl_types.hxx>
47 #include <osl/mutex.hxx>
49 namespace connectivity
51 class OConnectionPool;
52 //==========================================================================
53 //= OPoolCollection - the one-instance service for PooledConnections
54 //= manages the active connections and the connections in the pool
55 //==========================================================================
56 typedef ::cppu::WeakImplHelper5< ::com::sun::star::sdbc::XDriverManager,
57 ::com::sun::star::sdbc::XDriverAccess,
58 ::com::sun::star::lang::XServiceInfo,
59 ::com::sun::star::frame::XTerminateListener,
60 ::com::sun::star::beans::XPropertyChangeListener
61 > OPoolCollection_Base;
63 /// OPoolCollection: controll the whole connection pooling for oo
64 class OPoolCollection : public OPoolCollection_Base
67 //==========================================================================
68 typedef ::comphelper::OInterfaceCompare< ::com::sun::star::sdbc::XDriver > ODriverCompare;
69 DECLARE_STL_USTRINGACCESS_MAP(OConnectionPool*, OConnectionPools);
71 DECLARE_STL_MAP(
72 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver >,
73 ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDriver >,
74 ODriverCompare,
75 MapDriver2DriverRef );
77 MapDriver2DriverRef m_aDriverProxies;
78 ::osl::Mutex m_aMutex;
79 OConnectionPools m_aPools; // the driver pools
80 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceFactory;
81 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriverManager > m_xManager;
82 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriverAccess > m_xDriverAccess;
83 ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XProxyFactory > m_xProxyFactory;
84 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xConfigNode; // config node for generel connection pooling
85 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDesktop> m_xDesktop;
87 private:
88 OPoolCollection(); // never implemented
89 OPoolCollection(const OPoolCollection&); // never implemented
90 int operator= (const OPoolCollection&); // never implemented
92 OPoolCollection(
93 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory);
95 // some configuration helper methods
96 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createWithServiceFactory(const ::rtl::OUString& _rPath) const;
97 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getConfigPoolRoot();
98 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createWithProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxConfProvider,
99 const ::rtl::OUString& _rPath) const;
100 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > openNode( const ::rtl::OUString& _rPath,
101 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xTreeNode) const throw();
102 sal_Bool isPoolingEnabled();
103 sal_Bool isDriverPoolingEnabled(const ::rtl::OUString& _sDriverImplName,
104 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxDriverNode);
105 sal_Bool isPoolingEnabledByUrl( const ::rtl::OUString& _sUrl,
106 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver >& _rxDriver,
107 ::rtl::OUString& _rsImplName,
108 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxDriverNode);
110 OConnectionPool* getConnectionPool( const ::rtl::OUString& _sImplName,
111 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver >& _xDriver,
112 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxDriverNode);
113 void clearConnectionPools(sal_Bool _bDispose);
114 void clearDesktop();
115 protected:
116 virtual ~OPoolCollection();
117 public:
119 static ::com::sun::star::uno::Any getNodeValue( const ::rtl::OUString& _rPath,
120 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _xTreeNode)throw();
122 // XDriverManager
123 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( const ::rtl::OUString& url ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
124 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnectionWithInfo( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
125 virtual void SAL_CALL setLoginTimeout( sal_Int32 seconds ) throw(::com::sun::star::uno::RuntimeException);
126 virtual sal_Int32 SAL_CALL getLoginTimeout( ) throw(::com::sun::star::uno::RuntimeException);
128 //XDriverAccess
129 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > SAL_CALL getDriverByURL( const ::rtl::OUString& url ) throw (::com::sun::star::uno::RuntimeException);
130 // XServiceInfo
131 virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
132 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
133 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
135 // XServiceInfo - static methods
136 static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL CreateInstance(const::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&);
137 static ::rtl::OUString SAL_CALL getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException);
138 static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_Static( ) throw(::com::sun::star::uno::RuntimeException);
140 // XEventListener
141 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
142 // XPropertyChangeListener
143 virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException);
145 // XTerminateListener
146 virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& Event ) throw (::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException);
147 virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException);
150 #endif // CONNECTIVITY_POOLCOLLECTION_HXX