xref: /trunk/main/connectivity/source/cpool/ZPoolCollection.cxx (revision a3cdc23e488c57f3433f22cd4458e65c27aa499c)
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 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_connectivity.hxx"
24 #include "ZPoolCollection.hxx"
25 #include "ZDriverWrapper.hxx"
26 #include "ZConnectionPool.hxx"
27 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
28 #include <com/sun/star/beans/PropertyValue.hpp>
29 #include <comphelper/extract.hxx>
30 #include <com/sun/star/beans/XPropertySet.hpp>
31 #include "diagnose_ex.h"
32 
33 using namespace ::com::sun::star::uno;
34 using namespace ::com::sun::star::lang;
35 using namespace ::com::sun::star::sdbc;
36 using namespace ::com::sun::star::beans;
37 using namespace ::com::sun::star::container;
38 using namespace ::com::sun::star::reflection;
39 using namespace ::osl;
40 using namespace connectivity;
41 
42 //--------------------------------------------------------------------
43 static const ::rtl::OUString& getConnectionPoolNodeName()
44 {
45     static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("org.openoffice.Office.DataAccess/ConnectionPool");
46     return s_sNodeName;
47 }
48 //--------------------------------------------------------------------
49 static const ::rtl::OUString& getEnablePoolingNodeName()
50 {
51     static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("EnablePooling");
52     return s_sNodeName;
53 }
54 //--------------------------------------------------------------------
55 static const ::rtl::OUString& getDriverNameNodeName()
56 {
57     static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("DriverName");
58     return s_sNodeName;
59 }
60 // -----------------------------------------------------------------------------
61 static const ::rtl::OUString& getDriverSettingsNodeName()
62 {
63     static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("DriverSettings");
64     return s_sNodeName;
65 }
66 //--------------------------------------------------------------------------
67 static const ::rtl::OUString& getEnableNodeName()
68 {
69     static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("Enable");
70     return s_sNodeName;
71 }
72 
73 //--------------------------------------------------------------------
74 OPoolCollection::OPoolCollection(const Reference< XMultiServiceFactory >&   _rxFactory)
75     :m_xServiceFactory(_rxFactory)
76 {
77     // bootstrap all objects supporting the .sdb.Driver service
78     m_xManager = Reference< XDriverManager >(m_xServiceFactory->createInstance(::rtl::OUString::createFromAscii("com.sun.star.sdbc.DriverManager") ), UNO_QUERY);
79     m_xDriverAccess = Reference< XDriverAccess >(m_xManager, UNO_QUERY);
80     OSL_ENSURE(m_xDriverAccess.is(), "have no (or an invalid) driver manager!");
81 
82     m_xProxyFactory = Reference< XProxyFactory >(
83         m_xServiceFactory->createInstance(
84             ::rtl::OUString::createFromAscii("com.sun.star.reflection.ProxyFactory")),
85         UNO_QUERY);
86     OSL_ENSURE(m_xProxyFactory.is(), "OConnectionPool::OConnectionPool: could not create a proxy factory!");
87 
88     Reference<XPropertySet> xProp(getConfigPoolRoot(),UNO_QUERY);
89     if ( xProp.is() )
90         xProp->addPropertyChangeListener(getEnablePoolingNodeName(),this);
91     // attach as desktop listener to know when we have to release our pools
92     osl_incrementInterlockedCount( &m_refCount );
93     {
94 
95         m_xDesktop = Reference< ::com::sun::star::frame::XDesktop>( m_xServiceFactory->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop") ), UNO_QUERY);
96         if ( m_xDesktop.is() )
97             m_xDesktop->addTerminateListener(this);
98 
99     }
100     osl_decrementInterlockedCount( &m_refCount );
101 }
102 // -----------------------------------------------------------------------------
103 OPoolCollection::~OPoolCollection()
104 {
105     clearConnectionPools(sal_False);
106 }
107 // -----------------------------------------------------------------------------
108 Reference< XConnection > SAL_CALL OPoolCollection::getConnection( const ::rtl::OUString& _rURL ) throw(SQLException, RuntimeException)
109 {
110     return getConnectionWithInfo(_rURL,Sequence< PropertyValue >());
111 }
112 // -----------------------------------------------------------------------------
113 Reference< XConnection > SAL_CALL OPoolCollection::getConnectionWithInfo( const ::rtl::OUString& _rURL, const Sequence< PropertyValue >& _rInfo ) throw(SQLException, RuntimeException)
114 {
115     MutexGuard aGuard(m_aMutex);
116     Reference< XConnection > xConnection;
117     Reference< XDriver > xDriver;
118     Reference< XInterface > xDriverNode;
119     ::rtl::OUString sImplName;
120     if(isPoolingEnabledByUrl(_rURL,xDriver,sImplName,xDriverNode) && xDriver.is())
121     {
122         OConnectionPool* pConnectionPool = getConnectionPool(sImplName,xDriver,xDriverNode);
123 
124         if(pConnectionPool)
125             xConnection = pConnectionPool->getConnectionWithInfo(_rURL,_rInfo);
126     }
127     else if(xDriver.is())
128         xConnection = xDriver->connect(_rURL,_rInfo);
129 
130     return xConnection;
131 }
132 // -----------------------------------------------------------------------------
133 void SAL_CALL OPoolCollection::setLoginTimeout( sal_Int32 seconds ) throw(RuntimeException)
134 {
135     MutexGuard aGuard(m_aMutex);
136     m_xManager->setLoginTimeout(seconds);
137 }
138 // -----------------------------------------------------------------------------
139 sal_Int32 SAL_CALL OPoolCollection::getLoginTimeout(  ) throw(RuntimeException)
140 {
141     MutexGuard aGuard(m_aMutex);
142     return m_xManager->getLoginTimeout();
143 }
144 // -----------------------------------------------------------------------------
145 ::rtl::OUString SAL_CALL OPoolCollection::getImplementationName(  ) throw(RuntimeException)
146 {
147     MutexGuard aGuard(m_aMutex);
148     return getImplementationName_Static();
149 }
150 
151 //--------------------------------------------------------------------------
152 sal_Bool SAL_CALL OPoolCollection::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
153 {
154     Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
155     const ::rtl::OUString* pSupported = aSupported.getConstArray();
156     const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
157     for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
158         ;
159 
160     return pSupported != pEnd;
161 }
162 
163 //--------------------------------------------------------------------------
164 Sequence< ::rtl::OUString > SAL_CALL OPoolCollection::getSupportedServiceNames(  ) throw(RuntimeException)
165 {
166     return getSupportedServiceNames_Static();
167 }
168 
169 //---------------------------------------OPoolCollection----------------------------------
170 Reference< XInterface > SAL_CALL OPoolCollection::CreateInstance(const Reference< XMultiServiceFactory >& _rxFactory)
171 {
172     return static_cast<XDriverManager*>(new OPoolCollection(_rxFactory));
173 }
174 
175 //--------------------------------------------------------------------------
176 ::rtl::OUString SAL_CALL OPoolCollection::getImplementationName_Static(  ) throw(RuntimeException)
177 {
178     return ::rtl::OUString::createFromAscii("com.sun.star.sdbc.OConnectionPool");
179 }
180 
181 //--------------------------------------------------------------------------
182 Sequence< ::rtl::OUString > SAL_CALL OPoolCollection::getSupportedServiceNames_Static(  ) throw(RuntimeException)
183 {
184     Sequence< ::rtl::OUString > aSupported(1);
185     aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.ConnectionPool");
186     return aSupported;
187 }
188 // -----------------------------------------------------------------------------
189 Reference< XDriver > SAL_CALL OPoolCollection::getDriverByURL( const ::rtl::OUString& _rURL ) throw(RuntimeException)
190 {
191     // returns the original driver when no connection pooling is enabled else it returns the proxy
192     MutexGuard aGuard(m_aMutex);
193 
194     Reference< XDriver > xDriver;
195     Reference< XInterface > xDriverNode;
196     ::rtl::OUString sImplName;
197     if(isPoolingEnabledByUrl(_rURL,xDriver,sImplName,xDriverNode))
198     {
199         Reference< XDriver > xExistentProxy;
200         // look if we already have a proxy for this driver
201         for (   ConstMapDriver2DriverRefIterator aLookup = m_aDriverProxies.begin();
202                 aLookup != m_aDriverProxies.end();
203                 ++aLookup
204             )
205         {
206             // hold the proxy alive as long as we're in this loop round
207             xExistentProxy = aLookup->second;
208 
209             if (xExistentProxy.is() && (aLookup->first.get() == xDriver.get()))
210                 // already created a proxy for this
211                 break;
212         }
213         if (xExistentProxy.is())
214         {
215             xDriver = xExistentProxy;
216         }
217         else
218         {   // create a new proxy for the driver
219             // this allows us to control the connections created by it
220             if (m_xProxyFactory.is())
221             {
222                 Reference< XAggregation > xDriverProxy = m_xProxyFactory->createProxy(xDriver.get());
223                 OSL_ENSURE(xDriverProxy.is(), "OConnectionPool::getDriverByURL: invalid proxy returned by the proxy factory!");
224 
225                 OConnectionPool* pConnectionPool = getConnectionPool(sImplName,xDriver,xDriverNode);
226                 xDriver = new ODriverWrapper(xDriverProxy, pConnectionPool);
227             }
228             else
229                 OSL_ENSURE(sal_False, "OConnectionPool::getDriverByURL: could not instantiate a proxy factory!");
230         }
231     }
232 
233     return xDriver;
234 }
235 // -----------------------------------------------------------------------------
236 sal_Bool OPoolCollection::isDriverPoolingEnabled(const ::rtl::OUString& _sDriverImplName,
237                                                  Reference< XInterface >& _rxDriverNode)
238 {
239     sal_Bool bEnabled = sal_False;
240     Reference<XInterface> xConnectionPoolRoot = getConfigPoolRoot();
241     // then look for which of them settings are stored in the configuration
242     Reference< XNameAccess > xDirectAccess(openNode(getDriverSettingsNodeName(),xConnectionPoolRoot),UNO_QUERY);
243 
244     if(xDirectAccess.is())
245     {
246         Sequence< ::rtl::OUString > aDriverKeys = xDirectAccess->getElementNames();
247         const ::rtl::OUString* pDriverKeys = aDriverKeys.getConstArray();
248         const ::rtl::OUString* pDriverKeysEnd = pDriverKeys + aDriverKeys.getLength();
249         for (;pDriverKeys != pDriverKeysEnd; ++pDriverKeys)
250         {
251             // the name of the driver in this round
252             if(_sDriverImplName == *pDriverKeys)
253             {
254                 _rxDriverNode = openNode(*pDriverKeys,xDirectAccess);
255                 if(_rxDriverNode.is())
256                     getNodeValue(getEnableNodeName(),_rxDriverNode) >>= bEnabled;
257                 break;
258             }
259         }
260     }
261     return bEnabled;
262 }
263 // -----------------------------------------------------------------------------
264 sal_Bool OPoolCollection::isPoolingEnabled()
265 {
266     // the config node where all pooling relevant info are stored under
267     Reference<XInterface> xConnectionPoolRoot = getConfigPoolRoot();
268 
269     // the global "enabled" flag
270     sal_Bool bEnabled = sal_False;
271     if(xConnectionPoolRoot.is())
272         getNodeValue(getEnablePoolingNodeName(),xConnectionPoolRoot) >>= bEnabled;
273     return bEnabled;
274 }
275 // -----------------------------------------------------------------------------
276 Reference<XInterface> OPoolCollection::getConfigPoolRoot()
277 {
278     if(!m_xConfigNode.is())
279         m_xConfigNode = createWithServiceFactory(getConnectionPoolNodeName());
280     return m_xConfigNode;
281 }
282 // -----------------------------------------------------------------------------
283 sal_Bool OPoolCollection::isPoolingEnabledByUrl(const ::rtl::OUString& _sUrl,
284                                                 Reference< XDriver >& _rxDriver,
285                                                 ::rtl::OUString& _rsImplName,
286                                                 Reference< XInterface >& _rxDriverNode)
287 {
288     sal_Bool bEnabled = sal_False;
289     if (m_xDriverAccess.is())
290     {
291         _rxDriver = m_xDriverAccess->getDriverByURL(_sUrl);
292         if (_rxDriver.is() && isPoolingEnabled())
293         {
294             Reference< XServiceInfo > xSerivceInfo(_rxDriver,UNO_QUERY);
295             OSL_ENSURE(xSerivceInfo.is(),"Each driver should have a XServiceInfo interface!");
296 
297             if(xSerivceInfo.is())
298             {
299                 // look for the implementation name of the driver
300                 _rsImplName = xSerivceInfo->getImplementationName();
301                 bEnabled = isDriverPoolingEnabled(_rsImplName,_rxDriverNode);
302             }
303         }
304     }
305     return bEnabled;
306 }
307 // -----------------------------------------------------------------------------
308 void OPoolCollection::clearConnectionPools(sal_Bool _bDispose)
309 {
310     OConnectionPools::const_iterator aIter = m_aPools.begin();
311     while(aIter != m_aPools.end())
312     {
313         aIter->second->clear(_bDispose);
314         aIter->second->release();
315         ::rtl::OUString sKeyValue = aIter->first;
316         ++aIter;
317         m_aPools.erase(sKeyValue);
318     }
319 }
320 // -----------------------------------------------------------------------------
321 OConnectionPool* OPoolCollection::getConnectionPool(const ::rtl::OUString& _sImplName,
322                                                     const Reference< XDriver >& _xDriver,
323                                                     const Reference< XInterface >& _xDriverNode)
324 {
325     OConnectionPool *pRet = 0;
326     OConnectionPools::const_iterator aFind = m_aPools.find(_sImplName);
327     if (aFind != m_aPools.end())
328         pRet = aFind->second;
329     else if (_xDriver.is() && _xDriverNode.is())
330     {
331         Reference<XPropertySet> xProp(_xDriverNode,UNO_QUERY);
332         if(xProp.is())
333             xProp->addPropertyChangeListener(getEnableNodeName(),this);
334         OConnectionPool* pConnectionPool = new OConnectionPool(_xDriver,_xDriverNode,m_xProxyFactory);
335         pConnectionPool->acquire();
336         aFind = m_aPools.insert(OConnectionPools::value_type(_sImplName,pConnectionPool)).first;
337         pRet = aFind->second;
338     }
339 
340     OSL_ENSURE(pRet, "Could not query DriverManager from ConnectionPool!");
341 
342     return pRet;
343 }
344 // -----------------------------------------------------------------------------
345 Reference< XInterface > OPoolCollection::createWithServiceFactory(const ::rtl::OUString& _rPath) const
346 {
347     Reference< XInterface > xInterface;
348     try
349     {
350         Reference< XInterface > xProvider = m_xServiceFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationProvider")));
351         OSL_ENSURE(xProvider.is(), "OConfigurationTreeRoot::createWithServiceFactory: could not instantiate the config provider service!");
352         Reference< XMultiServiceFactory > xProviderAsFac(xProvider, UNO_QUERY);
353         OSL_ENSURE(xProviderAsFac.is() || !xProvider.is(), "OConfigurationTreeRoot::createWithServiceFactory: the provider is missing an interface!");
354         if (xProviderAsFac.is())
355             xInterface = createWithProvider(xProviderAsFac, _rPath);
356     }
357     catch(const Exception&)
358     {
359         OSL_ENSURE(sal_False, "createWithServiceFactory: error while instantiating the provider service!");
360     }
361     return xInterface;
362 }
363 //------------------------------------------------------------------------
364 Reference< XInterface > OPoolCollection::createWithProvider(const Reference< XMultiServiceFactory >& _rxConfProvider,
365                             const ::rtl::OUString& _rPath) const
366 {
367     OSL_ENSURE(_rxConfProvider.is(), "createWithProvider: invalid provider!");
368 
369     Reference< XInterface > xInterface;
370 #ifdef DBG_UTIL
371     if (_rxConfProvider.is())
372     {
373         try
374         {
375             Reference< XServiceInfo > xSI(_rxConfProvider, UNO_QUERY);
376             if (!xSI.is())
377             {
378                 OSL_ENSURE(sal_False, "::createWithProvider: no XServiceInfo interface on the provider!");
379             }
380             else
381             {
382                 OSL_ENSURE(xSI->supportsService(::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")),
383                     "::createWithProvider: sure this is a provider? Missing the ConfigurationProvider service!");
384             }
385         }
386         catch(const Exception&)
387         {
388             OSL_ENSURE(sal_False, "::createWithProvider: unable to check the service conformance of the provider given!");
389         }
390     }
391 #endif
392 
393     if (_rxConfProvider.is())
394     {
395         try
396         {
397             Sequence< Any > aCreationArgs(3);
398             aCreationArgs[0] = makeAny(PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")), 0, makeAny(_rPath), PropertyState_DIRECT_VALUE));
399             aCreationArgs[1] = makeAny(PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("depth")), 0, makeAny((sal_Int32)-1), PropertyState_DIRECT_VALUE));
400             aCreationArgs[2] = makeAny(PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("lazywrite")), 0, makeAny(sal_True), PropertyState_DIRECT_VALUE));
401 
402             static ::rtl::OUString sAccessService = ::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationAccess");
403 
404             xInterface = _rxConfProvider->createInstanceWithArguments(sAccessService, aCreationArgs);
405             OSL_ENSURE(xInterface.is(), "::createWithProvider: could not create the node access!");
406         }
407         catch(Exception&)
408         {
409             OSL_ENSURE(sal_False, "OConfigurationTreeRoot::createWithProvider: caught an exception while creating the access object!");
410         }
411     }
412     return xInterface;
413 }
414 // -----------------------------------------------------------------------------
415 Reference<XInterface> OPoolCollection::openNode(const ::rtl::OUString& _rPath,const Reference<XInterface>& _xTreeNode) const throw()
416 {
417     Reference< XHierarchicalNameAccess > xHierarchyAccess(_xTreeNode, UNO_QUERY);
418     Reference< XNameAccess > xDirectAccess(_xTreeNode, UNO_QUERY);
419     Reference< XInterface > xNode;
420 
421     try
422     {
423         if (xDirectAccess.is() && xDirectAccess->hasByName(_rPath))
424         {
425             if (!::cppu::extractInterface(xNode, xDirectAccess->getByName(_rPath)))
426                 OSL_ENSURE(sal_False, "OConfigurationNode::openNode: could not open the node!");
427         }
428         else if (xHierarchyAccess.is())
429         {
430             if (!::cppu::extractInterface(xNode, xHierarchyAccess->getByHierarchicalName(_rPath)))
431                 OSL_ENSURE(sal_False, "OConfigurationNode::openNode: could not open the node!");
432         }
433 
434     }
435     catch(const NoSuchElementException&)
436     {
437         OSL_ENSURE(sal_False,
438                     ::rtl::OString("::openNode: there is no element named ")
439                 +=  ::rtl::OString(_rPath.getStr(), _rPath.getLength(), RTL_TEXTENCODING_ASCII_US)
440                 +=  ::rtl::OString("!"));
441     }
442     catch(Exception&)
443     {
444         OSL_ENSURE(sal_False, "OConfigurationNode::openNode: caught an exception while retrieving the node!");
445     }
446     return xNode;
447 }
448 // -----------------------------------------------------------------------------
449 Any OPoolCollection::getNodeValue(const ::rtl::OUString& _rPath,const Reference<XInterface>& _xTreeNode) throw()
450 {
451     Reference< XHierarchicalNameAccess > xHierarchyAccess(_xTreeNode, UNO_QUERY);
452     Reference< XNameAccess > xDirectAccess(_xTreeNode, UNO_QUERY);
453     Any aReturn;
454     try
455     {
456         if (xDirectAccess.is() && xDirectAccess->hasByName(_rPath) )
457         {
458             aReturn = xDirectAccess->getByName(_rPath);
459         }
460         else if (xHierarchyAccess.is())
461         {
462             aReturn = xHierarchyAccess->getByHierarchicalName(_rPath);
463         }
464     }
465     catch(NoSuchElementException& e)
466     {
467         OSL_UNUSED( e ); // make compiler happy
468         OSL_ENSURE(sal_False,
469             ::rtl::OString("::getNodeValue: caught a NoSuchElementException while trying to open ")
470         +=  ::rtl::OString(e.Message.getStr(), e.Message.getLength(), RTL_TEXTENCODING_ASCII_US)
471         +=  ::rtl::OString("!"));
472     }
473     return aReturn;
474 }
475 // -----------------------------------------------------------------------------
476 void SAL_CALL OPoolCollection::queryTermination( const EventObject& /*Event*/ ) throw (::com::sun::star::frame::TerminationVetoException, RuntimeException)
477 {
478 }
479 // -----------------------------------------------------------------------------
480 void SAL_CALL OPoolCollection::notifyTermination( const EventObject& /*Event*/ ) throw (RuntimeException)
481 {
482     clearDesktop();
483 }
484 // -----------------------------------------------------------------------------
485 void SAL_CALL OPoolCollection::disposing( const EventObject& Source ) throw (RuntimeException)
486 {
487     MutexGuard aGuard(m_aMutex);
488     if ( m_xDesktop == Source.Source )
489     {
490         clearDesktop();
491     }
492     else
493     {
494         try
495         {
496             Reference<XPropertySet> xProp(Source.Source,UNO_QUERY);
497             if(Source.Source == m_xConfigNode)
498             {
499                 if ( xProp.is() )
500                     xProp->removePropertyChangeListener(getEnablePoolingNodeName(),this);
501             m_xConfigNode.clear();
502             }
503             else if ( xProp.is() )
504                 xProp->removePropertyChangeListener(getEnableNodeName(),this);
505         }
506         catch(const Exception&)
507         {
508             OSL_ENSURE(0,"Exception caught");
509         }
510     }
511 }
512 // -----------------------------------------------------------------------------
513 void SAL_CALL OPoolCollection::propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (RuntimeException)
514 {
515     MutexGuard aGuard(m_aMutex);
516     if(evt.Source == m_xConfigNode)
517     {
518         sal_Bool bEnabled = sal_True;
519         evt.NewValue >>= bEnabled;
520         if(!bEnabled )
521         {
522             m_aDriverProxies.clear();
523             m_aDriverProxies = MapDriver2DriverRef();
524             OConnectionPools::iterator aIter = m_aPools.begin();
525             for(;aIter != m_aPools.end();++aIter)
526             {
527                 aIter->second->clear(sal_False);
528                 aIter->second->release();
529             }
530             m_aPools.clear();
531             m_aPools         = OConnectionPools();
532         }
533     }
534     else if(evt.Source.is())
535     {
536         sal_Bool bEnabled = sal_True;
537         evt.NewValue >>= bEnabled;
538         if(!bEnabled)
539         {
540             ::rtl::OUString sThisDriverName;
541             getNodeValue(getDriverNameNodeName(),evt.Source) >>= sThisDriverName;
542             // First release the driver
543             // look if we already have a proxy for this driver
544             MapDriver2DriverRefIterator aLookup = m_aDriverProxies.begin();
545             while(  aLookup != m_aDriverProxies.end())
546             {
547                 MapDriver2DriverRefIterator aFind = aLookup;
548                 Reference<XServiceInfo> xInfo(aLookup->first,UNO_QUERY);
549                 ++aLookup;
550                 if(xInfo.is() && xInfo->getImplementationName() == sThisDriverName)
551                     m_aDriverProxies.erase(aFind);
552             }
553 
554             // 2nd clear the connectionpool
555             OConnectionPools::iterator aFind = m_aPools.find(sThisDriverName);
556             if(aFind != m_aPools.end() && aFind->second)
557             {
558                 aFind->second->clear(sal_False);
559                 aFind->second->release();
560                 m_aPools.erase(aFind);
561             }
562         }
563     }
564 }
565 // -----------------------------------------------------------------------------
566 void OPoolCollection::clearDesktop()
567 {
568     clearConnectionPools(sal_True);
569     if ( m_xDesktop.is() )
570         m_xDesktop->removeTerminateListener(this);
571 m_xDesktop.clear();
572 }
573 // -----------------------------------------------------------------------------
574 
575 /* vim: set noet sw=4 ts=4: */
576