diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2012-04-20 22:46:42 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-04-20 22:57:32 +0200 |
commit | c2fd9b533cfad18735df212cc7fd61443628dc0c (patch) | |
tree | 92417b3365012a8e405982302d5fcffd4f03e4e9 /stoc/source/simpleregistry | |
parent | b2fdaed46509127ec3ac2fb87404bc1b51d77778 (diff) |
New cppu::defaultBootstrap_InitialComponentContext implementation
...that no longer uses XSimpleRegistry structures for the service data and thus
is potentially more performant.
* Registry-based functions from cppuhelper/bootstrap are deprecated now, client
code should always use defaultBootstrap_InitialComponentContext.
* References to the obsolete UNO_WRITERDB have been removed.
* Some of the functions in cppuhelper/source that are used from multiple .cxx
but had not been properly placed into .hxx have been cleaned up.
* css.lang.ServiceManager XSet insert/remove now support special
sequence<NamedValue> to improve live deployment/removal of XML-based extension
components data.
* 09524d410bbaad2a0b9b39811cb5cc16621b1396 "stoc: accelerate opening of multiple
XML .rdb files in a directory" and its follow-up
cb5c881a7f179391ee853f76e159254c97d776a3 "avoid using the new rdb reading
logic for empty/non-existent directories" have been obsoleted by this change
and have been reverted again.
Diffstat (limited to 'stoc/source/simpleregistry')
-rw-r--r-- | stoc/source/simpleregistry/simpleregistry.cxx | 94 | ||||
-rw-r--r-- | stoc/source/simpleregistry/textualservices.cxx | 11 | ||||
-rw-r--r-- | stoc/source/simpleregistry/textualservices.hxx | 3 |
3 files changed, 16 insertions, 92 deletions
diff --git a/stoc/source/simpleregistry/simpleregistry.cxx b/stoc/source/simpleregistry/simpleregistry.cxx index 9eebb4f087a1..f09b204e19fb 100644 --- a/stoc/source/simpleregistry/simpleregistry.cxx +++ b/stoc/source/simpleregistry/simpleregistry.cxx @@ -48,7 +48,6 @@ #include "cppuhelper/implbase2.hxx" #include "cppuhelper/weak.hxx" #include "osl/mutex.hxx" -#include "osl/file.hxx" #include "registry/registry.hxx" #include "registry/regtype.h" #include "rtl/ref.hxx" @@ -85,12 +84,6 @@ public: private: virtual rtl::OUString SAL_CALL getURL() throw (css::uno::RuntimeException); - virtual void SAL_CALL openRdb( - rtl::OUString const & rURL, sal_Bool bReadOnly, sal_Bool bCreate) - throw ( - css::registry::InvalidRegistryException, - css::uno::RuntimeException); - virtual void SAL_CALL open( rtl::OUString const & rURL, sal_Bool bReadOnly, sal_Bool bCreate) throw ( @@ -1137,17 +1130,27 @@ rtl::OUString Key::getResolvedName(rtl::OUString const & aKeyName) return resolved; } -rtl::OUString SimpleRegistry::getURL() throw (css::uno::RuntimeException) -{ +rtl::OUString SimpleRegistry::getURL() throw (css::uno::RuntimeException) { osl::MutexGuard guard(mutex_); return textual_.get() == 0 ? registry_.getName() : textual_->getUri(); } -void SimpleRegistry::openRdb( +void SimpleRegistry::open( rtl::OUString const & rURL, sal_Bool bReadOnly, sal_Bool bCreate) throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) { osl::MutexGuard guard(mutex_); + if (textual_.get() != 0) { + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry.open(")) + + rURL + + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "): instance already open"))), + static_cast< OWeakObject * >(this)); + } RegError err = (rURL.isEmpty() && bCreate) ? REG_REGISTRY_NOT_EXISTS : registry_.open(rURL, bReadOnly ? REG_READONLY : REG_READWRITE); @@ -1159,10 +1162,7 @@ void SimpleRegistry::openRdb( break; case REG_INVALID_REGISTRY: if (bReadOnly && !bCreate) { - if (!textual_.get()) - textual_.reset(new stoc::simpleregistry::TextualServices(rURL)); - else - textual_->merge(rURL); + textual_.reset(new stoc::simpleregistry::TextualServices(rURL)); break; } // fall through @@ -1180,72 +1180,6 @@ void SimpleRegistry::openRdb( } } -void SimpleRegistry::open( - rtl::OUString const & rURL, sal_Bool bReadOnly, sal_Bool bCreate) - throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) -{ - osl::MutexGuard guard(mutex_); - - osl::DirectoryItem aItem; - osl::FileBase::RC eErr; - osl::FileStatus aStatus(osl_FileStatus_Mask_Type); - - // FIXME: busts the 'create' mode ... - if ((eErr = osl::DirectoryItem::get( rURL, aItem )) != osl::FileBase::E_None || - (eErr = aItem.getFileStatus( aStatus )) != osl::FileBase::E_None || - !aStatus.isDirectory()) - { - if (textual_.get() != 0) - throw css::registry::InvalidRegistryException( - (rtl::OUString("com.sun.star.registry.SimpleRegistry.open(") + - rURL + rtl::OUString("): instance already open")), - static_cast< OWeakObject * >(this)); - openRdb (rURL, bReadOnly, bCreate); - } - else - { - osl::Directory dir(rURL); - eErr = dir.open(); - if (eErr != osl::FileBase::E_None) - goto err_throw; - - for (;;) { - osl::DirectoryItem i; - if (dir.getNextItem(i, SAL_MAX_UINT32) != osl::FileBase::E_None) - break; - osl::FileStatus stat(osl_FileStatus_Mask_Type | osl_FileStatus_Mask_FileName | - osl_FileStatus_Mask_FileURL); - if (i.getFileStatus(stat) != osl::FileBase::E_None) - throw css::uno::RuntimeException( - (rtl::OUString("cannot stat in directory ") + rURL ), - css::uno::Reference< css::uno::XInterface >()); - - rtl::OUString aName = stat.getFileName(); - - // Ignore backup files - to allow people to edit their - // services/ without extremely confusing behaviour - if (aName.toChar() == '.' || aName.endsWithAsciiL("~", 1)) - continue; - - if (stat.getFileType() != osl::FileStatus::Directory) - openRdb(stat.getFileURL(), bReadOnly, bCreate); - } - } - return; - -err_throw: - throw css::registry::InvalidRegistryException( - (rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.registry.SimpleRegistry.open(")) + - rURL + - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "): error statting url = ")) + - rtl::OUString::valueOf(static_cast< sal_Int32 >(eErr))), - static_cast< OWeakObject * >(this)); -} - sal_Bool SimpleRegistry::isValid() throw (css::uno::RuntimeException) { osl::MutexGuard guard(mutex_); return textual_.get() != 0 || registry_.isValid(); diff --git a/stoc/source/simpleregistry/textualservices.cxx b/stoc/source/simpleregistry/textualservices.cxx index 2491f55cb39b..ad24a4454550 100644 --- a/stoc/source/simpleregistry/textualservices.cxx +++ b/stoc/source/simpleregistry/textualservices.cxx @@ -1236,15 +1236,6 @@ css::uno::Sequence< rtl::OUString > Key::getChildren() { TextualServices::TextualServices(rtl::OUString const & uri): uri_(uri), data_(new Data) { - merge(uri); -} - -TextualServices::~TextualServices() {} - -// load and merge registry contents from uri -void TextualServices::merge(const rtl::OUString &uri) - throw (com::sun::star::registry::InvalidRegistryException) -{ try { Parser(uri, data_); } catch (css::container::NoSuchElementException &) { @@ -1256,6 +1247,8 @@ void TextualServices::merge(const rtl::OUString &uri) } } +TextualServices::~TextualServices() {} + css::uno::Reference< css::registry::XRegistryKey > TextualServices::getRootKey() { return new Key(data_, std::vector< rtl::OUString >()); diff --git a/stoc/source/simpleregistry/textualservices.hxx b/stoc/source/simpleregistry/textualservices.hxx index 0341c15d5d34..286eb922a1b4 100644 --- a/stoc/source/simpleregistry/textualservices.hxx +++ b/stoc/source/simpleregistry/textualservices.hxx @@ -53,9 +53,6 @@ public: virtual ~TextualServices(); - void merge(const rtl::OUString &uri) - throw (com::sun::star::registry::InvalidRegistryException); - inline rtl::OUString getUri() { return uri_; } com::sun::star::uno::Reference< com::sun::star::registry::XRegistryKey > |