#82313# Added 'nocache' parameter to providers' createInstanceWithArguments()

This commit is contained in:
Jörg Barfurth 2000-12-19 10:14:08 +00:00
parent 94597e6399
commit 1328e8fbfc
3 changed files with 75 additions and 17 deletions

View file

@ -2,9 +2,9 @@
*
* $RCSfile: confproviderimpl2.cxx,v $
*
* $Revision: 1.14 $
* $Revision: 1.15 $
*
* last change: $Author: jb $ $Date: 2000-12-11 11:06:37 $
* last change: $Author: jb $ $Date: 2000-12-19 11:14:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -115,11 +115,14 @@ namespace configmgr
// extract the args
::rtl::OUString sUser, sPath, sLocale;
sal_Int32 nLevels;
OProviderImpl::FactoryArguments::extractArgs(aArgs, sPath, sUser, sLocale, nLevels);
bool bNoCache;
OProviderImpl::FactoryArguments::extractArgs(aArgs, sPath, sUser, sLocale, nLevels, bNoCache);
vos::ORef<OOptions> xOptions = new OOptions(getDefaultOptions());
xOptions->setUser(sUser);
xOptions->setLocale(sLocale);
xOptions->setNoCache(bNoCache);
CFG_TRACE_INFO_NI("config provider: node accessor extracted from the args is %s", OUSTRING2ASCII(sPath));
CFG_TRACE_INFO_NI("config provider: level depth extracted from the args is %i", nLevels);
@ -159,11 +162,14 @@ namespace configmgr
// extract the args
::rtl::OUString sUser, sPath, sLocale;
sal_Int32 nLevels;
OProviderImpl::FactoryArguments::extractArgs(aArgs, sPath, sUser, sLocale, nLevels);
bool bNoCache;
OProviderImpl::FactoryArguments::extractArgs(aArgs, sPath, sUser, sLocale, nLevels, bNoCache);
vos::ORef<OOptions> xOptions = new OOptions(getDefaultOptions());
xOptions->setUser(sUser);
xOptions->setLocale(sLocale);
xOptions->setNoCache(bNoCache);
CFG_TRACE_INFO_NI("config provider: node accessor extracted from the args is %s", OUSTRING2ASCII(sPath));
CFG_TRACE_INFO_NI("config provider: level depth extracted from the args is %i", nLevels);

View file

@ -2,9 +2,9 @@
*
* $RCSfile: providerimpl.cxx,v $
*
* $Revision: 1.14 $
* $Revision: 1.15 $
*
* last change: $Author: jb $ $Date: 2000-12-14 16:12:44 $
* last change: $Author: jb $ $Date: 2000-12-19 11:12:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -60,10 +60,11 @@
************************************************************************/
#include <stdio.h>
#include "providerimpl.hxx"
#include "options.hxx"
#include "apifactoryimpl.hxx"
#include "apitreeimplobj.hxx"
#include "apitreeaccess.hxx"
#include "providerimpl.hxx"
#include "roottree.hxx"
#include "noderef.hxx"
#include "objectregistry.hxx"
@ -84,6 +85,7 @@
#ifndef _CONFIGMGR_TRACER_HXX_
#include "tracer.hxx"
#endif
#include <osl/interlck.h>
#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
#include <com/sun/star/beans/PropertyValue.hpp>
@ -434,6 +436,7 @@ namespace configmgr
rtl::OUString OProviderImpl::FactoryArguments::sNodePath(ASCII("nodepath"));
rtl::OUString OProviderImpl::FactoryArguments::sDepth(ASCII("depth"));
rtl::OUString OProviderImpl::FactoryArguments::sLocale(ASCII("locale"));
rtl::OUString OProviderImpl::FactoryArguments::sNoCache(ASCII("nocache"));
#ifdef DBG_UTIL
//-----------------------------------------------------------------------------
@ -447,6 +450,7 @@ namespace configmgr
aArgs.insert(OProviderImpl::FactoryArguments::sNodePath);
aArgs.insert(OProviderImpl::FactoryArguments::sDepth);
aArgs.insert(OProviderImpl::FactoryArguments::sLocale);
aArgs.insert(OProviderImpl::FactoryArguments::sNoCache);
}
HashSet::const_iterator it = aArgs.find(rName);
@ -492,7 +496,8 @@ namespace configmgr
OUString& /* [out] */ _rNodeAccessor,
OUString& /* [out] */ _rUser,
OUString& /* [out] */ _rLocale,
sal_Int32& /* [out] */ _nLevels)
sal_Int32& /* [out] */ _nLevels,
bool& /* [out] */ _bNoCache)
throw (lang::IllegalArgumentException)
{
@ -501,6 +506,7 @@ namespace configmgr
#endif
::rtl::OUString sUser, sPath, sLocale;
sal_Int32 nLevelDepth = ITreeProvider::ALL_LEVELS;
sal_Bool bNoCache = sal_False;
// the args have to be a sequence of property values, currently three property names are recognized
beans::PropertyValue aCurrent;
@ -519,6 +525,8 @@ namespace configmgr
bExtractSuccess = (aCurrent.Value >>= nLevelDepth);
else if (aCurrent.Name.equalsIgnoreCase(OProviderImpl::FactoryArguments::sLocale))
bExtractSuccess = (aCurrent.Value >>= sLocale);
else if (aCurrent.Name.equalsIgnoreCase(OProviderImpl::FactoryArguments::sNoCache))
bExtractSuccess = (aCurrent.Value >>= bNoCache);
/*
#ifdef DBG_UTIL
else
@ -567,6 +575,35 @@ namespace configmgr
_nLevels = nLevelDepth;
_rLocale = sLocale;
_rUser = sUser;
_bNoCache = (bNoCache != sal_False);
}
// class OOptions
//..........................................................................
static sal_Int32 getNextCacheID()
{
static oslInterlockedCount nNextID = 0;
oslInterlockedCount nNewID = osl_incrementInterlockedCount(&nNextID);
if (nNewID == 0)
{
CFG_TRACE_WARNING("Cache ID overflow - restarting sequence !");
OSL_ENSURE(false, "Cache ID overflow - restarting sequence !");
}
return static_cast<sal_Int32>(nNewID);
}
void OOptions::setNoCache(bool _bNoCache)
{
if (_bNoCache)
{
m_nCacheID = getNextCacheID();
}
else
{
m_nCacheID = 0;
}
}
} // namespace configmgr

View file

@ -2,9 +2,9 @@
*
* $RCSfile: options.hxx,v $
*
* $Revision: 1.5 $
* $Revision: 1.6 $
*
* last change: $Author: dg $ $Date: 2000-12-04 19:47:18 $
* last change: $Author: jb $ $Date: 2000-12-19 11:14:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -97,20 +97,28 @@ namespace configmgr
rtl::OUString m_sDefaultLocale; // default locale set for a user
rtl::OUString m_sUser; // user key used (could be empty)
rtl::OUString m_sDefaultUser; // user key used (could be empty)
sal_Int32 m_nCacheID; // set if data should not be fetched from the cache, but reloaded
public:
OOptions(const uno::Reference< script::XTypeConverter >& _xConverter)
:m_xConverter(_xConverter) {}
:m_xConverter(_xConverter)
,m_nCacheID(0)
{}
OOptions(const OOptions& _rOptions)
:m_xConverter(_rOptions.getTypeConverter())
,m_sDefaultLocale(_rOptions.getDefaultLocale())
,m_sDefaultUser(_rOptions.getDefaultUser())
,m_sLocale(_rOptions.m_sLocale)
,m_sUser(_rOptions.m_sUser){}
,m_sUser(_rOptions.m_sUser)
,m_nCacheID(0) // cache identity is not copied
{
if (!_rOptions.canUseCache()) this->setNoCache();
}
uno::Reference< script::XTypeConverter > getTypeConverter() const {return m_xConverter;}
bool canUseCache() const { return m_nCacheID != 0; }
rtl::OUString getLocale() const {return m_sLocale.getLength() ? m_sLocale : m_sDefaultLocale;}
const rtl::OUString& getDefaultLocale() const {return m_sDefaultLocale;}
sal_Bool hasDefaultLocale() const {return !m_sLocale.getLength() || m_sLocale == m_sDefaultLocale;}
@ -119,10 +127,14 @@ namespace configmgr
const rtl::OUString& getDefaultUser() const {return m_sDefaultUser;}
sal_Bool hasDefaultUser() const {return !m_sUser.getLength() || m_sUser == m_sDefaultUser;}
void setNoCache(bool _bNoCache = true);
void setUser(const rtl::OUString& _rUser) {m_sUser = _rUser;}
void setDefaultUser(const rtl::OUString& _rUser) {m_sDefaultUser = _rUser;}
void setLocale(const rtl::OUString& _rLocale) {m_sLocale = _rLocale;}
void setDefaultLocale(const rtl::OUString& _rLocale) {m_sDefaultLocale = _rLocale;}
friend sal_Int32 compareCacheIdentity(OOptions const& lhs, OOptions const& rhs)
{ return rhs.m_nCacheID - lhs.m_nCacheID; }
};
struct ltOptions
@ -130,10 +142,13 @@ namespace configmgr
bool operator()(const ::vos::ORef<OOptions> &o1, const ::vos::ORef<OOptions> &o2) const
{
sal_Int32 nLt = o1->getUser().compareTo(o2->getUser());
if (!nLt)
return o1->getLocale().compareTo(o2->getLocale()) < 0 ? true : false;
else
return nLt < 0 ? true : false;
if (nLt == 0)
nLt = o1->getLocale().compareTo(o2->getLocale());
if (nLt == 0)
nLt = compareCacheIdentity(*o1,*o2);
return nLt < 0 ? true : false;
}
};
} // namespace