summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2012-04-18 14:58:51 +0200
committerStephan Bergmann <sbergman@redhat.com>2012-04-18 14:58:51 +0200
commitfcc9611770e55b0c6ff0f23d2345f3e4f0ef7838 (patch)
tree2a1e6567d7277e988c9799dd05d2aa3b6aca0992 /desktop
parentc2c2a056aa49f49236c3260aeda88a6da747240a (diff)
Do all of componentLiveInsertion/Removal at the root context
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/deployment/registry/component/dp_component.cxx137
1 files changed, 73 insertions, 64 deletions
diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx
index 7a97fbb09ad8..8bfcbd5b44e4 100644
--- a/desktop/source/deployment/registry/component/dp_component.cxx
+++ b/desktop/source/deployment/registry/component/dp_component.cxx
@@ -354,6 +354,8 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
void componentLiveRemoval(ComponentBackendDb::Data const & data);
+ css::uno::Reference< css::uno::XComponentContext > getRootContext() const;
+
public:
BackendImpl( Sequence<Any> const & args,
Reference<XComponentContext> const & xComponentContext );
@@ -1252,8 +1254,10 @@ void BackendImpl::componentLiveInsertion(
std::vector< css::uno::Reference< css::uno::XInterface > > const &
factories)
{
+ css::uno::Reference< css::uno::XComponentContext > rootContext(
+ getRootContext());
css::uno::Reference< css::container::XSet > set(
- getComponentContext()->getServiceManager(), css::uno::UNO_QUERY_THROW);
+ rootContext->getServiceManager(), css::uno::UNO_QUERY_THROW);
std::vector< css::uno::Reference< css::uno::XInterface > >::const_iterator
factory(factories.begin());
for (t_stringlist::const_iterator i(data.implementationNames.begin());
@@ -1268,54 +1272,49 @@ void BackendImpl::componentLiveInsertion(
}
}
if (!data.singletons.empty()) {
- css::uno::Reference< css::container::XNameContainer >
- rootContext(
- getComponentContext()->getValueByName(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_root"))),
- css::uno::UNO_QUERY);
- if (rootContext.is()) {
- for (t_stringpairvec::const_iterator i(data.singletons.begin());
- i != data.singletons.end(); ++i)
- {
- rtl::OUString name(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/singletons/")) +
- i->first);
- try {
- rootContext->removeByName(
- name +
- rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM("/arguments")));
- } catch (const container::NoSuchElementException &) {}
- try {
- rootContext->insertByName(
- (name +
- rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM("/service"))),
- css::uno::Any(i->second));
- } catch (const container::ElementExistException &) {
- rootContext->replaceByName(
- (name +
- rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM("/service"))),
- css::uno::Any(i->second));
- }
- try {
- rootContext->insertByName(name, css::uno::Any());
- } catch (const container::ElementExistException &) {
- OSL_TRACE(
- "singleton %s already registered",
- rtl::OUStringToOString(
- i->first, RTL_TEXTENCODING_UTF8).getStr());
- rootContext->replaceByName(name, css::uno::Any());
- }
+ css::uno::Reference< css::container::XNameContainer > cont(
+ rootContext, css::uno::UNO_QUERY_THROW);
+ for (t_stringpairvec::const_iterator i(data.singletons.begin());
+ i != data.singletons.end(); ++i)
+ {
+ rtl::OUString name(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/singletons/")) +
+ i->first);
+ //TODO: Update should be atomic:
+ try {
+ cont->removeByName(
+ name +
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/arguments")));
+ } catch (const container::NoSuchElementException &) {}
+ try {
+ cont->insertByName(
+ (name +
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/service"))),
+ css::uno::Any(i->second));
+ } catch (const container::ElementExistException &) {
+ cont->replaceByName(
+ (name +
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/service"))),
+ css::uno::Any(i->second));
+ }
+ try {
+ cont->insertByName(name, css::uno::Any());
+ } catch (const container::ElementExistException &) {
+ OSL_TRACE(
+ "singleton %s already registered",
+ rtl::OUStringToOString(
+ i->first, RTL_TEXTENCODING_UTF8).getStr());
+ cont->replaceByName(name, css::uno::Any());
}
}
}
}
void BackendImpl::componentLiveRemoval(ComponentBackendDb::Data const & data) {
+ css::uno::Reference< css::uno::XComponentContext > rootContext(
+ getRootContext());
css::uno::Reference< css::container::XSet > set(
- getComponentContext()->getServiceManager(), css::uno::UNO_QUERY_THROW);
+ rootContext->getServiceManager(), css::uno::UNO_QUERY_THROW);
for (t_stringlist::const_iterator i(data.implementationNames.begin());
i != data.implementationNames.end(); ++i)
{
@@ -1326,32 +1325,42 @@ void BackendImpl::componentLiveRemoval(ComponentBackendDb::Data const & data) {
}
}
if (!data.singletons.empty()) {
- css::uno::Reference< css::container::XNameContainer > rootContext(
- getComponentContext()->getValueByName(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_root"))),
- css::uno::UNO_QUERY);
- if (rootContext.is()) {
- for (t_stringpairvec::const_iterator i(data.singletons.begin());
- i != data.singletons.end(); ++i)
- {
- rtl::OUString name(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/singletons/")) +
- i->first);
- try {
- rootContext->removeByName(
- name +
- rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM("/arguments")));
- rootContext->removeByName(
- name +
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/service")));
- rootContext->removeByName(name);
- } catch (const container::NoSuchElementException &) {}
- }
+ css::uno::Reference< css::container::XNameContainer > cont(
+ rootContext, css::uno::UNO_QUERY_THROW);
+ for (t_stringpairvec::const_iterator i(data.singletons.begin());
+ i != data.singletons.end(); ++i)
+ {
+ rtl::OUString name(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/singletons/")) +
+ i->first);
+ //TODO: Removal should be atomic:
+ try {
+ cont->removeByName(name);
+ } catch (const container::NoSuchElementException &) {}
+ try {
+ cont->removeByName(
+ name +
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/service")));
+ } catch (const container::NoSuchElementException &) {}
+ try {
+ cont->removeByName(
+ name +
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/arguments")));
+ } catch (const container::NoSuchElementException &) {}
}
}
}
+css::uno::Reference< css::uno::XComponentContext > BackendImpl::getRootContext()
+ const
+{
+ css::uno::Reference< css::uno::XComponentContext > rootContext(
+ getComponentContext()->getValueByName(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_root"))),
+ css::uno::UNO_QUERY);
+ return rootContext.is() ? rootContext : getComponentContext();
+}
+
//______________________________________________________________________________
void BackendImpl::releaseObject( OUString const & id )
{