summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJörg Barfurth <jb@openoffice.org>2001-06-22 07:26:18 +0000
committerJörg Barfurth <jb@openoffice.org>2001-06-22 07:26:18 +0000
commit29d8f05dab8c10309f16fcc899a9ce138893473f (patch)
tree0418084a3ec5594bb69f394fcc2fa212eddf27de
parent54074824c3f21ec13dda885d71d83a08a63af1d2 (diff)
Correct argument-dependent caching of providers
-rw-r--r--configmgr/source/misc/bootstrap.cxx95
-rw-r--r--configmgr/source/misc/providerfactory.cxx72
-rw-r--r--configmgr/source/misc/providerfactory.hxx19
3 files changed, 138 insertions, 48 deletions
diff --git a/configmgr/source/misc/bootstrap.cxx b/configmgr/source/misc/bootstrap.cxx
index d503ca2eec44..53f184ed78b5 100644
--- a/configmgr/source/misc/bootstrap.cxx
+++ b/configmgr/source/misc/bootstrap.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: bootstrap.cxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: dg $ $Date: 2001-06-14 10:04:33 $
+ * last change: $Author: jb $ $Date: 2001-06-22 08:26:18 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -70,7 +70,10 @@
#ifndef _RTL_USTRING_HXX_
#include <rtl/ustring.hxx>
#endif
-#ifndef _RTL_USTRING_HXX_
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+#ifndef _RTL_STRING_HXX_
#include <rtl/string.hxx>
#endif
#ifndef _OSL_FILE_HXX_
@@ -1204,6 +1207,92 @@ namespace configmgr
{}
// ---------------------------------------------------------------------------------------
+// caching helpers
+//---------------------------------------------------------------------------------------
+ OUString buildConnectString(const ConnectionSettings& _rSettings)
+ {
+ OSL_ENSURE(_rSettings.isComplete(),"WARNING: creating connect string for incomplete settings");
+
+ rtl::OUStringBuffer sConnect = _rSettings.getSessionType();
+
+ if (_rSettings.isServiceRequired())
+ {
+ sConnect.append(sal_Unicode(":"));
+ sConnect.append(_rSettings.getService());
+ }
+
+ if (_rSettings.isLocalSession())
+ {
+ if (_rSettings.isSourcePathValid())
+ {
+ sConnect.appendAscii(RTL_CONSTASCII_STRINGPARAM(":share@"));
+ sConnect.append(_rSettings.getSourcePath());
+ }
+ if (_rSettings.isUpdatePathValid())
+ {
+ sConnect.appendAscii(RTL_CONSTASCII_STRINGPARAM(":user@"));
+ sConnect.append(_rSettings.getUpdatePath());
+ }
+ // maybe consider user here as well ?
+ }
+ else if (_rSettings.isRemoteSession())
+ {
+ if (_rSettings.hasServer() || _rSettings.hasPort())
+ {
+ sConnect.append(sal_Unicode("@"));
+
+ if ( _rSettings.hasServer())
+ {
+ sConnect.append(_rSettings.getServer());
+ }
+
+ if ( _rSettings.hasPort())
+ {
+ sConnect.append(sal_Unicode(":"));
+ sConnect.append(_rSettings.getPort());
+ }
+ }
+
+ if (_rSettings.hasUser())
+ {
+ sConnect.appendAscii(RTL_CONSTASCII_STRINGPARAM(";user="));
+ sConnect.append(_rSettings.getUser());
+ }
+ if (_rSettings.hasPassword())
+ {
+ sConnect.appendAscii(RTL_CONSTASCII_STRINGPARAM(";pwd="));
+ sConnect.append(_rSettings.getPassword());
+ }
+ if (_rSettings.hasTimeout())
+ {
+ sConnect.appendAscii(RTL_CONSTASCII_STRINGPARAM(";timeout="));
+ sConnect.append( _rSettings.getTimeout());
+ }
+ }
+ else
+ {
+ OSL_ENSURE(false, "Unknown session type");
+ }
+
+ if (_rSettings.hasLocale())
+ {
+ sConnect.appendAscii(RTL_CONSTASCII_STRINGPARAM(";locale="));
+ sConnect.append(_rSettings.getLocale());
+ }
+ if (_rSettings.hasAsyncSetting())
+ {
+ sConnect.appendAscii(RTL_CONSTASCII_STRINGPARAM(";async="));
+ sConnect.append(_rSettings.getAsyncSetting());
+ }
+ if (_rSettings.hasReinitializeFlag() && _rSettings.getReinitializeFlag())
+ {
+ sConnect.appendAscii(RTL_CONSTASCII_STRINGPARAM(";reinitialize="));
+ sConnect.append(_rSettings.getReinitializeFlag());
+ }
+
+ return sConnect.makeStringAndClear();
+ }
+// ---------------------------------------------------------------------------------------
// - helper
// ---------------------------------------------------------------------------------------
namespace {
diff --git a/configmgr/source/misc/providerfactory.cxx b/configmgr/source/misc/providerfactory.cxx
index 69c40988492d..2ad7cc2480cb 100644
--- a/configmgr/source/misc/providerfactory.cxx
+++ b/configmgr/source/misc/providerfactory.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: providerfactory.cxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: jb $ $Date: 2001-05-22 07:42:07 $
+ * last change: $Author: jb $ $Date: 2001-06-22 08:26:18 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -165,41 +165,37 @@ namespace configmgr
}
//---------------------------------------------------------------------------------------
- static bool checkForOptions(const ConnectionSettings& _rSettings)
+ static bool isReusableConnection(const ConnectionSettings& _rSettings)
{
- return _rSettings.hasLocale() ||
- _rSettings.hasAsyncSetting();
+ // #78409
+ // if a provider is queried with a password, we always create a new instance for it,
+ // as don't wan't to remember the passwords for the user.
+
+ if ( _rSettings.hasPassword() && !_rSettings.isLocalSession())
+ return false;
+
+ if (_rSettings.hasReinitializeFlag() && _rSettings.getReinitializeFlag())
+ return false;
+
+ return true;
}
//---------------------------------------------------------------------------------------
- Reference< XInterface > OProviderFactory::implGetProvider(const ConnectionSettings& _rSettings, sal_Bool _bCanReuse)
- {
- // the providers for the given session type
- UserSpecificProviders& rProviders = m_aProviders[_rSettings.getSessionType()];
-
- // the user to retrieve the provider for
- ::rtl::OUString sUser;
- if (_rSettings.hasUser())
- sUser = _rSettings.getUser();
+ extern OUString buildConnectString(const ConnectionSettings& _rSettings);
- if (checkForOptions(_rSettings))
- _bCanReuse = false;
+ //---------------------------------------------------------------------------------------
+ Reference< XInterface > OProviderFactory::implGetProvider(const ConnectionSettings& _rSettings)
+ {
+ OUString const sConnectString = buildConnectString(_rSettings);
Reference< XInterface > xReturn;
- if (_bCanReuse)
+
+ ProviderCacheIterator aExistentProviderPos = m_aProviders.find(sConnectString);
+ if (m_aProviders.end() != aExistentProviderPos)
{
- UserSpecificProvidersIterator aExistentProvider = rProviders.find(sUser);
- if (rProviders.end() != aExistentProvider)
- {
- // should check for differing parameters here
- xReturn = aExistentProvider->second;
- }
+ xReturn = aExistentProviderPos->second;
}
- // #78409
- // if a provider is queried with a password, we always create a new instance for it,
- // as don't wan't to remember the passwords for the user.
-
if (!xReturn.is())
{
// create and connect the provider (may still throw exceptions)
@@ -215,19 +211,19 @@ namespace configmgr
}
// remember it for later usage
- if (_bCanReuse)
- rProviders[sUser] = xReturn;
+ if (isReusableConnection(_rSettings))
+ m_aProviders[sConnectString] = xReturn;
}
return xReturn;
}
//---------------------------------------------------------------------------------------
- Reference< XInterface > OProviderFactory::implCreateProviderWithSettings(const ConnectionSettings& _rSettings, bool _bRequiresBootstrap, bool _bCanReuse)
+ Reference< XInterface > OProviderFactory::implCreateProviderWithSettings(const ConnectionSettings& _rSettings, bool _bRequiresBootstrap)
{
try
{
- return implGetProvider(_rSettings, _bCanReuse);
+ return implGetProvider(_rSettings);
}
catch(uno::Exception& e)
{
@@ -259,7 +255,7 @@ namespace configmgr
aThisRoundSettings.validate();
OSL_ENSURE(aThisRoundSettings.isComplete(), "Incomplete Data for creating a ConfigurationProvider");
- m_xDefaultProvider = implCreateProviderWithSettings(aThisRoundSettings,true,true);
+ m_xDefaultProvider = implCreateProviderWithSettings(aThisRoundSettings,true);
// register disposing listener
Reference<com::sun::star::lang::XComponent> xComponent(m_xDefaultProvider, UNO_QUERY);
@@ -332,7 +328,11 @@ namespace configmgr
try
{
aThisRoundSettings.setSessionType(sLocalSessionIdentifier, Settings::SO_ADJUSTMENT);
- return implGetProvider(aThisRoundSettings,true);
+
+ Reference< XInterface > xLocalProvider
+ = implGetProvider(aThisRoundSettings);
+
+ if (xLocalProvider.is()) return xLocalProvider;
}
catch(Exception&)
{
@@ -358,8 +358,7 @@ namespace configmgr
OSL_ENSURE(aThisRoundSettings.isComplete(), "Incomplete Data for creating a ConfigurationProvider");
Reference< XInterface > xProvider =
- implCreateProviderWithSettings( aThisRoundSettings,bUseBootstrapData,
- !aThisRoundSettings.hasPassword() );
+ implCreateProviderWithSettings( aThisRoundSettings,bUseBootstrapData);
return xProvider;
}
@@ -416,6 +415,9 @@ namespace configmgr
/*************************************************************************
* history:
* $Log: not supported by cvs2svn $
+ * Revision 1.10 2001/05/22 07:42:07 jb
+ * #81412# Erroneous handling of default provider
+ *
* Revision 1.9 2001/05/18 16:16:52 jb
* #81412# Cleaned up bootstrap settings handling; Added recognition of bootstrap errors
*
diff --git a/configmgr/source/misc/providerfactory.hxx b/configmgr/source/misc/providerfactory.hxx
index 9b907d34c79d..c2d0b05749bc 100644
--- a/configmgr/source/misc/providerfactory.hxx
+++ b/configmgr/source/misc/providerfactory.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: providerfactory.hxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: jb $ $Date: 2001-05-18 16:16:52 $
+ * last change: $Author: jb $ $Date: 2001-06-22 08:26:18 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -127,9 +127,8 @@ namespace configmgr
BootstrapSettings const* m_pPureSettings;
typedef uno::WeakReference< uno::XInterface > ProviderReference;
- DECLARE_STL_USTRINGACCESS_MAP(ProviderReference, UserSpecificProviders);
- DECLARE_STL_USTRINGACCESS_MAP(UserSpecificProviders, SessionSpecificProviders);
- SessionSpecificProviders m_aProviders;
+ DECLARE_STL_USTRINGACCESS_MAP(ProviderReference, ProviderCache);
+ ProviderCache m_aProviders;
public:
OProviderFactory(
@@ -148,12 +147,9 @@ namespace configmgr
void ensureDefaultProvider();
void ensureBootstrapSettings();
- uno::Reference< uno::XInterface > implCreateProviderWithSettings(const ConnectionSettings& _rSettings, bool bRequiresBootstrap, bool _bReusable);
+ uno::Reference< uno::XInterface > implCreateProviderWithSettings(const ConnectionSettings& _rSettings, bool bRequiresBootstrap);
// from the given map, extract a provider for the given user. (if necessary, create one and insert it into the map)
- uno::Reference< uno::XInterface > implGetProvider(
- const ConnectionSettings& _rSettings,
- sal_Bool _bReusable
- );
+ uno::Reference< uno::XInterface > implGetProvider( const ConnectionSettings& _rSettings );
// to be called with m:aMutex locked
void disposing(com::sun::star::lang::EventObject const& rEvt) throw();
@@ -168,6 +164,9 @@ namespace configmgr
/*************************************************************************
* history:
* $Log: not supported by cvs2svn $
+ * Revision 1.5 2001/05/18 16:16:52 jb
+ * #81412# Cleaned up bootstrap settings handling; Added recognition of bootstrap errors
+ *
* Revision 1.4 2001/04/03 16:33:58 jb
* Local AdministrationProvider now mapped to Setup-session
*