Bump for 3.6-28
[LibreOffice.git] / connectivity / source / manager / mdrivermanager.cxx
blob096c7304de87fe1b513af888c6cb7d148fae1a52
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include <stdio.h>
32 #include "mdrivermanager.hxx"
33 #include <com/sun/star/configuration/theDefaultProvider.hpp>
34 #include <com/sun/star/sdbc/XDriver.hpp>
35 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
36 #include <com/sun/star/container/ElementExistException.hpp>
37 #include <com/sun/star/beans/NamedValue.hpp>
39 #include <tools/diagnose_ex.h>
40 #include <comphelper/extract.hxx>
41 #include <comphelper/stl_types.hxx>
42 #include <cppuhelper/implbase1.hxx>
43 #include <cppuhelper/weakref.hxx>
44 #include <osl/diagnose.h>
46 #include <algorithm>
48 #include <o3tl/compat_functional.hxx>
50 namespace drivermanager
53 using namespace ::com::sun::star::uno;
54 using namespace ::com::sun::star::lang;
55 using namespace ::com::sun::star::sdbc;
56 using namespace ::com::sun::star::beans;
57 using namespace ::com::sun::star::container;
58 using namespace ::com::sun::star::logging;
59 using namespace ::osl;
61 #define SERVICE_SDBC_DRIVER ::rtl::OUString("com.sun.star.sdbc.Driver")
63 void throwNoSuchElementException() throw(NoSuchElementException)
65 throw NoSuchElementException();
68 //==========================================================================
69 //= ODriverEnumeration
70 //==========================================================================
71 class ODriverEnumeration : public ::cppu::WeakImplHelper1< XEnumeration >
73 friend class OSDBCDriverManager;
75 DECLARE_STL_VECTOR( SdbcDriver, DriverArray );
76 DriverArray m_aDrivers;
77 ConstDriverArrayIterator m_aPos;
78 // order matters!
80 protected:
81 virtual ~ODriverEnumeration();
82 public:
83 ODriverEnumeration(const DriverArray& _rDriverSequence);
85 // XEnumeration
86 virtual sal_Bool SAL_CALL hasMoreElements( ) throw(RuntimeException);
87 virtual Any SAL_CALL nextElement( ) throw(NoSuchElementException, WrappedTargetException, RuntimeException);
90 //--------------------------------------------------------------------------
91 ODriverEnumeration::ODriverEnumeration(const DriverArray& _rDriverSequence)
92 :m_aDrivers( _rDriverSequence )
93 ,m_aPos( m_aDrivers.begin() )
97 //--------------------------------------------------------------------------
98 ODriverEnumeration::~ODriverEnumeration()
102 //--------------------------------------------------------------------------
103 sal_Bool SAL_CALL ODriverEnumeration::hasMoreElements( ) throw(RuntimeException)
105 return m_aPos != m_aDrivers.end();
108 //--------------------------------------------------------------------------
109 Any SAL_CALL ODriverEnumeration::nextElement( ) throw(NoSuchElementException, WrappedTargetException, RuntimeException)
111 if ( !hasMoreElements() )
112 throwNoSuchElementException();
114 return makeAny( *m_aPos++ );
117 //=====================================================================
118 //= helper
119 //=====================================================================
121 /// an STL functor which ensures that a SdbcDriver described by a DriverAccess is loaded
122 struct EnsureDriver : public ::std::unary_function< DriverAccess, DriverAccess >
124 const DriverAccess& operator()( const DriverAccess& _rDescriptor ) const
126 if ( !_rDescriptor.xDriver.is() )
127 // we did not load this driver, yet
128 if ( _rDescriptor.xComponentFactory.is() )
129 // we have a factory for it
130 const_cast< DriverAccess& >( _rDescriptor ).xDriver = _rDescriptor.xDriver.query( _rDescriptor.xComponentFactory->createInstance() );
131 return _rDescriptor;
135 /// an STL functor which extracts a SdbcDriver from a DriverAccess
136 struct ExtractDriverFromAccess : public ::std::unary_function< DriverAccess, SdbcDriver >
138 SdbcDriver operator()( const DriverAccess& _rAccess ) const
140 return _rAccess.xDriver;
144 typedef ::o3tl::unary_compose< ExtractDriverFromAccess, EnsureDriver > ExtractAfterLoad_BASE;
145 /// an STL functor which loads a driver described by a DriverAccess, and extracts the SdbcDriver
146 struct ExtractAfterLoad : public ExtractAfterLoad_BASE
148 ExtractAfterLoad() : ExtractAfterLoad_BASE( ExtractDriverFromAccess(), EnsureDriver() ) { }
151 struct ExtractDriverFromCollectionElement : public ::std::unary_function< DriverCollection::value_type, SdbcDriver >
153 SdbcDriver operator()( const DriverCollection::value_type& _rElement ) const
155 return _rElement.second;
159 // predicate for checking whether or not a driver accepts a given URL
160 class AcceptsURL : public ::std::unary_function< SdbcDriver, bool >
162 protected:
163 const ::rtl::OUString& m_rURL;
165 public:
166 // ctor
167 AcceptsURL( const ::rtl::OUString& _rURL ) : m_rURL( _rURL ) { }
169 //.................................................................
170 bool operator()( const SdbcDriver& _rDriver ) const
172 // ask the driver
173 if ( _rDriver.is() && _rDriver->acceptsURL( m_rURL ) )
174 return true;
176 // does not accept ...
177 return false;
181 static sal_Int32 lcl_getDriverPrecedence( const ::comphelper::ComponentContext& _rContext, Sequence< ::rtl::OUString >& _rPrecedence )
183 _rPrecedence.realloc( 0 );
186 // some strings we need
187 const ::rtl::OUString sDriverManagerConfigLocation( "org.openoffice.Office.DataAccess/DriverManager" );
188 const ::rtl::OUString sDriverPreferenceLocation( "DriverPrecedence" );
189 const ::rtl::OUString sNodePathArgumentName( "nodepath" );
190 const ::rtl::OUString sNodeAccessServiceName( "com.sun.star.configuration.ConfigurationAccess" );
192 // create a configuration provider
193 Reference< XMultiServiceFactory > xConfigurationProvider(
194 com::sun::star::configuration::theDefaultProvider::get(
195 _rContext.getUNOContext() ) );
197 // one argument for creating the node access: the path to the configuration node
198 Sequence< Any > aCreationArgs(1);
199 aCreationArgs[0] <<= NamedValue( sNodePathArgumentName, makeAny( sDriverManagerConfigLocation ) );
201 // create the node access
202 Reference< XNameAccess > xDriverManagerNode(xConfigurationProvider->createInstanceWithArguments(sNodeAccessServiceName, aCreationArgs), UNO_QUERY);
204 OSL_ENSURE(xDriverManagerNode.is(), "lcl_getDriverPrecedence: could not open my configuration node!");
205 if (xDriverManagerNode.is())
207 // obtain the preference list
208 Any aPreferences = xDriverManagerNode->getByName(sDriverPreferenceLocation);
209 #if OSL_DEBUG_LEVEL > 0
210 sal_Bool bSuccess =
211 #endif
212 aPreferences >>= _rPrecedence;
213 OSL_ENSURE(bSuccess || !aPreferences.hasValue(), "lcl_getDriverPrecedence: invalid value for the preferences node (no string sequence but not NULL)!");
216 catch( const Exception& )
218 DBG_UNHANDLED_EXCEPTION();
221 return _rPrecedence.getLength();
224 /// an STL argorithm compatible predicate comparing two DriverAccess instances by their implementation names
225 struct CompareDriverAccessByName : public ::std::binary_function< DriverAccess, DriverAccess, bool >
227 //.................................................................
228 bool operator()( const DriverAccess& lhs, const DriverAccess& rhs )
230 return lhs.sImplementationName < rhs.sImplementationName ? true : false;
234 /// and STL argorithm compatible predicate comparing a DriverAccess' impl name to a string
235 struct EqualDriverAccessToName : public ::std::binary_function< DriverAccess, ::rtl::OUString, bool >
237 ::rtl::OUString m_sImplName;
238 EqualDriverAccessToName(const ::rtl::OUString& _sImplName) : m_sImplName(_sImplName){}
239 //.................................................................
240 bool operator()( const DriverAccess& lhs)
242 return lhs.sImplementationName.equals(m_sImplName);
246 //==========================================================================
247 //= OSDBCDriverManager
248 //==========================================================================
249 //--------------------------------------------------------------------------
250 OSDBCDriverManager::OSDBCDriverManager( const Reference< XComponentContext >& _rxContext )
251 :m_aContext( _rxContext )
252 ,m_aEventLogger( _rxContext, "org.openoffice.logging.sdbc.DriverManager" )
253 ,m_aDriverConfig(m_aContext.getLegacyServiceFactory())
254 ,m_nLoginTimeout(0)
256 // bootstrap all objects supporting the .sdb.Driver service
257 bootstrapDrivers();
259 // initialize the drivers order
260 initializeDriverPrecedence();
263 //---------------------------------------------------------------------
264 OSDBCDriverManager::~OSDBCDriverManager()
268 void OSDBCDriverManager::bootstrapDrivers()
270 Reference< XContentEnumerationAccess > xEnumAccess( m_aContext.getLegacyServiceFactory(), UNO_QUERY );
271 Reference< XEnumeration > xEnumDrivers;
272 if (xEnumAccess.is())
273 xEnumDrivers = xEnumAccess->createContentEnumeration(SERVICE_SDBC_DRIVER);
275 OSL_ENSURE( xEnumDrivers.is(), "OSDBCDriverManager::bootstrapDrivers: no enumeration for the drivers available!" );
276 if (xEnumDrivers.is())
278 Reference< XSingleServiceFactory > xFactory;
279 Reference< XServiceInfo > xSI;
280 while (xEnumDrivers->hasMoreElements())
282 ::cppu::extractInterface( xFactory, xEnumDrivers->nextElement() );
283 OSL_ENSURE( xFactory.is(), "OSDBCDriverManager::bootstrapDrivers: no factory extracted" );
285 if ( xFactory.is() )
287 // we got a factory for the driver
288 DriverAccess aDriverDescriptor;
289 sal_Bool bValidDescriptor = sal_False;
291 // can it tell us something about the implementation name?
292 xSI = xSI.query( xFactory );
293 if ( xSI.is() )
294 { // yes -> no need to load the driver immediately (load it later when needed)
295 aDriverDescriptor.sImplementationName = xSI->getImplementationName();
296 aDriverDescriptor.xComponentFactory = xFactory;
297 bValidDescriptor = sal_True;
299 m_aEventLogger.log( LogLevel::CONFIG,
300 "found SDBC driver $1$, no need to load it",
301 aDriverDescriptor.sImplementationName
304 else
306 // no -> create the driver
307 Reference< XDriver > xDriver( xFactory->createInstance(), UNO_QUERY );
308 OSL_ENSURE( xDriver.is(), "OSDBCDriverManager::bootstrapDrivers: a driver which is no driver?!" );
310 if ( xDriver.is() )
312 aDriverDescriptor.xDriver = xDriver;
313 // and obtain it's implementation name
314 xSI = xSI.query( xDriver );
315 OSL_ENSURE( xSI.is(), "OSDBCDriverManager::bootstrapDrivers: a driver without service info?" );
316 if ( xSI.is() )
318 aDriverDescriptor.sImplementationName = xSI->getImplementationName();
319 bValidDescriptor = sal_True;
321 m_aEventLogger.log( LogLevel::CONFIG,
322 "found SDBC driver $1$, needed to load it",
323 aDriverDescriptor.sImplementationName
329 if ( bValidDescriptor )
331 m_aDriversBS.push_back( aDriverDescriptor );
338 //--------------------------------------------------------------------------
339 void OSDBCDriverManager::initializeDriverPrecedence()
341 if ( m_aDriversBS.empty() )
342 // nothing to do
343 return;
347 // get the precedence of the drivers from the configuration
348 Sequence< ::rtl::OUString > aDriverOrder;
349 if ( 0 == lcl_getDriverPrecedence( m_aContext, aDriverOrder ) )
350 // nothing to do
351 return;
353 // aDriverOrder now is the list of driver implementation names in the order they should be used
355 if ( m_aEventLogger.isLoggable( LogLevel::CONFIG ) )
357 sal_Int32 nOrderedCount = aDriverOrder.getLength();
358 for ( sal_Int32 i=0; i<nOrderedCount; ++i )
359 m_aEventLogger.log( LogLevel::CONFIG,
360 "configuration's driver order: driver $1$ of $2$: $3$",
361 (sal_Int32)(i + 1), nOrderedCount, aDriverOrder[i]
365 // sort our bootstrapped drivers
366 ::std::sort( m_aDriversBS.begin(), m_aDriversBS.end(), CompareDriverAccessByName() );
368 // loop through the names in the precedence order
369 const ::rtl::OUString* pDriverOrder = aDriverOrder.getConstArray();
370 const ::rtl::OUString* pDriverOrderEnd = pDriverOrder + aDriverOrder.getLength();
372 // the first driver for which there is no preference
373 DriverAccessArrayIterator aNoPrefDriversStart = m_aDriversBS.begin();
374 // at the moment this is the first of all drivers we know
376 for ( ; ( pDriverOrder < pDriverOrderEnd ) && ( aNoPrefDriversStart != m_aDriversBS.end() ); ++pDriverOrder )
378 DriverAccess driver_order;
379 driver_order.sImplementationName = *pDriverOrder;
381 // look for the impl name in the DriverAccess array
382 ::std::pair< DriverAccessArrayIterator, DriverAccessArrayIterator > aPos =
383 ::std::equal_range( aNoPrefDriversStart, m_aDriversBS.end(), driver_order, CompareDriverAccessByName() );
385 if ( aPos.first != aPos.second )
386 { // we have a DriverAccess with this impl name
388 OSL_ENSURE( ::std::distance( aPos.first, aPos.second ) == 1,
389 "OSDBCDriverManager::initializeDriverPrecedence: more than one driver with this impl name? How this?" );
390 // move the DriverAccess pointed to by aPos.first to the position pointed to by aNoPrefDriversStart
392 if ( aPos.first != aNoPrefDriversStart )
393 { // if this does not hold, the DriverAccess alread has the correct position
395 // rotate the range [aNoPrefDriversStart, aPos.second) right 1 element
396 ::std::rotate( aNoPrefDriversStart, aPos.second - 1, aPos.second );
399 // next round we start searching and pos right
400 ++aNoPrefDriversStart;
404 catch (Exception&)
406 OSL_FAIL("OSDBCDriverManager::initializeDriverPrecedence: caught an exception while sorting the drivers!");
410 //--------------------------------------------------------------------------
411 Reference< XConnection > SAL_CALL OSDBCDriverManager::getConnection( const ::rtl::OUString& _rURL ) throw(SQLException, RuntimeException)
413 MutexGuard aGuard(m_aMutex);
415 m_aEventLogger.log( LogLevel::INFO,
416 "connection requested for URL $1$",
417 _rURL
420 Reference< XConnection > xConnection;
421 Reference< XDriver > xDriver = implGetDriverForURL(_rURL);
422 if (xDriver.is())
424 // TODO : handle the login timeout
425 xConnection = xDriver->connect(_rURL, Sequence< PropertyValue >());
426 // may throw an exception
427 m_aEventLogger.log( LogLevel::INFO,
428 "connection retrieved for URL $1$",
429 _rURL
433 return xConnection;
436 //--------------------------------------------------------------------------
437 Reference< XConnection > SAL_CALL OSDBCDriverManager::getConnectionWithInfo( const ::rtl::OUString& _rURL, const Sequence< PropertyValue >& _rInfo ) throw(SQLException, RuntimeException)
439 MutexGuard aGuard(m_aMutex);
441 m_aEventLogger.log( LogLevel::INFO,
442 "connection with info requested for URL $1$",
443 _rURL
446 Reference< XConnection > xConnection;
447 Reference< XDriver > xDriver = implGetDriverForURL(_rURL);
448 if (xDriver.is())
450 // TODO : handle the login timeout
451 xConnection = xDriver->connect(_rURL, _rInfo);
452 // may throw an exception
453 m_aEventLogger.log( LogLevel::INFO,
454 "connection with info retrieved for URL $1$",
455 _rURL
459 return xConnection;
462 //--------------------------------------------------------------------------
463 void SAL_CALL OSDBCDriverManager::setLoginTimeout( sal_Int32 seconds ) throw(RuntimeException)
465 MutexGuard aGuard(m_aMutex);
466 m_nLoginTimeout = seconds;
469 //--------------------------------------------------------------------------
470 sal_Int32 SAL_CALL OSDBCDriverManager::getLoginTimeout( ) throw(RuntimeException)
472 MutexGuard aGuard(m_aMutex);
473 return m_nLoginTimeout;
476 //--------------------------------------------------------------------------
477 Reference< XEnumeration > SAL_CALL OSDBCDriverManager::createEnumeration( ) throw(RuntimeException)
479 MutexGuard aGuard(m_aMutex);
481 ODriverEnumeration::DriverArray aDrivers;
483 // ensure that all our bootstrapped drivers are instantiated
484 ::std::for_each( m_aDriversBS.begin(), m_aDriversBS.end(), EnsureDriver() );
486 // copy the bootstrapped drivers
487 ::std::transform(
488 m_aDriversBS.begin(), // "copy from" start
489 m_aDriversBS.end(), // "copy from" end
490 ::std::back_inserter( aDrivers ), // insert into
491 ExtractDriverFromAccess() // transformation to apply (extract a driver from a driver access)
494 // append the runtime drivers
495 ::std::transform(
496 m_aDriversRT.begin(), // "copy from" start
497 m_aDriversRT.end(), // "copy from" end
498 ::std::back_inserter( aDrivers ), // insert into
499 ExtractDriverFromCollectionElement() // transformation to apply (extract a driver from a driver access)
502 return new ODriverEnumeration( aDrivers );
505 //--------------------------------------------------------------------------
506 ::com::sun::star::uno::Type SAL_CALL OSDBCDriverManager::getElementType( ) throw(::com::sun::star::uno::RuntimeException)
508 return ::getCppuType(static_cast< Reference< XDriver >* >(NULL));
511 //--------------------------------------------------------------------------
512 sal_Bool SAL_CALL OSDBCDriverManager::hasElements( ) throw(::com::sun::star::uno::RuntimeException)
514 MutexGuard aGuard(m_aMutex);
515 return !(m_aDriversBS.empty() && m_aDriversRT.empty());
518 //--------------------------------------------------------------------------
519 ::rtl::OUString SAL_CALL OSDBCDriverManager::getImplementationName( ) throw(RuntimeException)
521 return getImplementationName_static();
524 //--------------------------------------------------------------------------
525 sal_Bool SAL_CALL OSDBCDriverManager::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
527 Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
528 const ::rtl::OUString* pSupported = aSupported.getConstArray();
529 const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
530 for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
533 return pSupported != pEnd;
536 //--------------------------------------------------------------------------
537 Sequence< ::rtl::OUString > SAL_CALL OSDBCDriverManager::getSupportedServiceNames( ) throw(RuntimeException)
539 return getSupportedServiceNames_static();
542 //--------------------------------------------------------------------------
543 Reference< XInterface > SAL_CALL OSDBCDriverManager::Create( const Reference< XMultiServiceFactory >& _rxFactory )
545 ::comphelper::ComponentContext aContext( _rxFactory );
546 return *( new OSDBCDriverManager( aContext.getUNOContext() ) );
549 //--------------------------------------------------------------------------
550 ::rtl::OUString SAL_CALL OSDBCDriverManager::getImplementationName_static( ) throw(RuntimeException)
552 return ::rtl::OUString("com.sun.star.comp.sdbc.OSDBCDriverManager");
555 //--------------------------------------------------------------------------
556 Sequence< ::rtl::OUString > SAL_CALL OSDBCDriverManager::getSupportedServiceNames_static( ) throw(RuntimeException)
558 Sequence< ::rtl::OUString > aSupported(1);
559 aSupported[0] = getSingletonName_static();
560 return aSupported;
563 //--------------------------------------------------------------------------
564 ::rtl::OUString SAL_CALL OSDBCDriverManager::getSingletonName_static( ) throw(RuntimeException)
566 return ::rtl::OUString( "com.sun.star.sdbc.DriverManager" );
569 //--------------------------------------------------------------------------
570 Reference< XInterface > SAL_CALL OSDBCDriverManager::getRegisteredObject( const ::rtl::OUString& _rName ) throw(Exception, RuntimeException)
572 MutexGuard aGuard(m_aMutex);
573 ConstDriverCollectionIterator aSearch = m_aDriversRT.find(_rName);
574 if (aSearch == m_aDriversRT.end())
575 throwNoSuchElementException();
577 return aSearch->second.get();
580 //--------------------------------------------------------------------------
581 void SAL_CALL OSDBCDriverManager::registerObject( const ::rtl::OUString& _rName, const Reference< XInterface >& _rxObject ) throw(Exception, RuntimeException)
583 MutexGuard aGuard(m_aMutex);
585 m_aEventLogger.log( LogLevel::INFO,
586 "attempt to register new driver for name $1$",
587 _rName
590 ConstDriverCollectionIterator aSearch = m_aDriversRT.find(_rName);
591 if (aSearch == m_aDriversRT.end())
593 Reference< XDriver > xNewDriver(_rxObject, UNO_QUERY);
594 if (xNewDriver.is())
595 m_aDriversRT.insert(DriverCollection::value_type(_rName, xNewDriver));
596 else
597 throw IllegalArgumentException();
599 else
600 throw ElementExistException();
602 m_aEventLogger.log( LogLevel::INFO,
603 "new driver registered for name $1$",
604 _rName
608 //--------------------------------------------------------------------------
609 void SAL_CALL OSDBCDriverManager::revokeObject( const ::rtl::OUString& _rName ) throw(Exception, RuntimeException)
611 MutexGuard aGuard(m_aMutex);
613 m_aEventLogger.log( LogLevel::INFO,
614 "attempt to revoke driver for name $1$",
615 _rName
618 DriverCollectionIterator aSearch = m_aDriversRT.find(_rName);
619 if (aSearch == m_aDriversRT.end())
620 throwNoSuchElementException();
622 m_aDriversRT.erase(aSearch); // we already have the iterator so we could use it
624 m_aEventLogger.log( LogLevel::INFO,
625 "driver revoked for name $1$",
626 _rName
630 //--------------------------------------------------------------------------
631 Reference< XDriver > SAL_CALL OSDBCDriverManager::getDriverByURL( const ::rtl::OUString& _rURL ) throw(RuntimeException)
633 m_aEventLogger.log( LogLevel::INFO,
634 "driver requested for URL $1$",
635 _rURL
638 Reference< XDriver > xDriver( implGetDriverForURL( _rURL ) );
640 if ( xDriver.is() )
641 m_aEventLogger.log( LogLevel::INFO,
642 "driver obtained for URL $1$",
643 _rURL
646 return xDriver;
649 //--------------------------------------------------------------------------
650 Reference< XDriver > OSDBCDriverManager::implGetDriverForURL(const ::rtl::OUString& _rURL)
652 Reference< XDriver > xReturn;
655 const ::rtl::OUString sDriverFactoryName = m_aDriverConfig.getDriverFactoryName(_rURL);
657 EqualDriverAccessToName aEqual(sDriverFactoryName);
658 DriverAccessArray::iterator aFind = ::std::find_if(m_aDriversBS.begin(),m_aDriversBS.end(),aEqual);
659 if ( aFind == m_aDriversBS.end() )
661 // search all bootstrapped drivers
662 aFind = ::std::find_if(
663 m_aDriversBS.begin(), // begin of search range
664 m_aDriversBS.end(), // end of search range
665 o3tl::unary_compose< AcceptsURL, ExtractAfterLoad >( AcceptsURL( _rURL ), ExtractAfterLoad() )
666 // compose two functors: extract the driver from the access, then ask the resulting driver for acceptance
668 } // if ( m_aDriversBS.find(sDriverFactoryName ) == m_aDriversBS.end() )
669 else
671 EnsureDriver aEnsure;
672 aEnsure(*aFind);
675 // found something?
676 if ( m_aDriversBS.end() != aFind && aFind->xDriver.is() && aFind->xDriver->acceptsURL(_rURL) )
677 xReturn = aFind->xDriver;
680 if ( !xReturn.is() )
682 // no -> search the runtime drivers
683 DriverCollectionIterator aPos = ::std::find_if(
684 m_aDriversRT.begin(), // begin of search range
685 m_aDriversRT.end(), // end of search range
686 o3tl::unary_compose< AcceptsURL, ExtractDriverFromCollectionElement >( AcceptsURL( _rURL ), ExtractDriverFromCollectionElement() )
687 // compose two functors: extract the driver from the access, then ask the resulting driver for acceptance
690 if ( m_aDriversRT.end() != aPos )
691 xReturn = aPos->second;
694 return xReturn;
697 } // namespace drivermanager
699 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */