summaryrefslogtreecommitdiff
path: root/desktop/source/deployment
diff options
context:
space:
mode:
authorJoachim Lingner <jl@openoffice.org>2009-12-03 15:59:55 +0100
committerJoachim Lingner <jl@openoffice.org>2009-12-03 15:59:55 +0100
commitfc3b2f779806d8846936ee2d5c51a58800d2ede7 (patch)
tree472839af64230a8f249cbc632b5643a415847186 /desktop/source/deployment
parent00a423a2fd2171e17fdd745fc667926a69de25af (diff)
jl145: #i99257# Extension Manager prevents running of multiple instances which acces the same shared data
Diffstat (limited to 'desktop/source/deployment')
-rw-r--r--desktop/source/deployment/manager/dp_manager.cxx14
-rw-r--r--desktop/source/deployment/registry/component/dp_component.cxx123
2 files changed, 103 insertions, 34 deletions
diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx
index aff8ada634..5f9ec21c35 100644
--- a/desktop/source/deployment/manager/dp_manager.cxx
+++ b/desktop/source/deployment/manager/dp_manager.cxx
@@ -313,19 +313,7 @@ Reference<deployment::XPackageManager> PackageManagerImpl::create(
that->m_readOnly = true;
}
}
-
- //Workaround. See issue http://www.openoffice.org/issues/show_bug.cgi?id=99257
- //This prevents the copying of the common.rdbf and native rdbs. It disables the
- //feature to add shared extensions in a running office.
- if (!that->m_readOnly && context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("shared") ))
- {
- OUString sNoRdb;
- ::rtl::Bootstrap::get(OUSTR("NORDBCOPY"), sNoRdb);
- if (sNoRdb.equalsIgnoreAsciiCase(OUSTR("true"))
- && dp_misc::office_is_running())
- that->m_readOnly = true;
- }
-
+
if (!that->m_readOnly && logFile.getLength() > 0)
{
const Any any_logFile(logFile);
diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx
index 3f2def05d7..38d334cbe8 100644
--- a/desktop/source/deployment/registry/component/dp_component.cxx
+++ b/desktop/source/deployment/registry/component/dp_component.cxx
@@ -147,6 +147,10 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
const Reference<registry::XSimpleRegistry> getRDB() const;
+ //Provides the read-only registry (e.g. not the one based on the duplicated
+ //rdb files
+ const Reference<registry::XSimpleRegistry> getRDB_RO() const;
+
public:
inline ComponentPackageImpl(
::rtl::Reference<PackageRegistryBackend> const & myBackend,
@@ -224,8 +228,21 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
OUString m_commonRDB;
OUString m_nativeRDB;
+
+ //URLs of the read-only rdbs (e.g. not the ones of the duplicated files)
+ OUString m_commonRDB_RO;
+ OUString m_nativeRDB_RO;
+
+ //These rdbs are for writing new service entries. The rdb files are copies
+ //which are created when services are added or removed.
Reference<registry::XSimpleRegistry> m_xCommonRDB;
Reference<registry::XSimpleRegistry> m_xNativeRDB;
+
+ //These rdbs are created on the read-only rdbs which are already used
+ //by UNO since the startup of the current session.
+ Reference<registry::XSimpleRegistry> m_xCommonRDB_RO;
+ Reference<registry::XSimpleRegistry> m_xNativeRDB_RO;
+
void unorc_verify_init( Reference<XCommandEnvironment> const & xCmdEnv );
void unorc_flush( Reference<XCommandEnvironment> const & xCmdEnv );
@@ -255,6 +272,9 @@ public:
//Will be called from ComponentPackageImpl
void initServiceRdbFiles();
+
+ //Creates the READ ONLY registries (m_xCommonRDB_RO,m_xNativeRDB_RO)
+ void initServiceRdbFiles_RO();
};
//______________________________________________________________________________
@@ -262,12 +282,12 @@ const Reference<registry::XSimpleRegistry>
BackendImpl::ComponentPackageImpl::getRDB() const
{
BackendImpl * that = getMyBackend();
+
//Late "initialization" of the services rdb files
//This is to prevent problems when running several
//instances of OOo with root rights in parallel. This
//would otherwise cause problems when copying the rdbs.
- //Now this code is only performed if isRegistered or processPackage
- //is called.
+ //See http://qa.openoffice.org/issues/show_bug.cgi?id=99257
{
const ::osl::MutexGuard guard( getMutex() );
if (!that->bSwitchedRdbFiles)
@@ -276,7 +296,6 @@ BackendImpl::ComponentPackageImpl::getRDB() const
that->initServiceRdbFiles();
}
}
-
if (m_loader.equalsAsciiL(
RTL_CONSTASCII_STRINGPARAM("com.sun.star.loader.SharedLibrary") ))
return that->m_xNativeRDB;
@@ -284,6 +303,19 @@ BackendImpl::ComponentPackageImpl::getRDB() const
return that->m_xCommonRDB;
}
+//Returns the read only RDB.
+const Reference<registry::XSimpleRegistry>
+BackendImpl::ComponentPackageImpl::getRDB_RO() const
+{
+ BackendImpl * that = getMyBackend();
+
+ if (m_loader.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("com.sun.star.loader.SharedLibrary") ))
+ return that->m_xNativeRDB_RO;
+ else
+ return that->m_xCommonRDB_RO;
+}
+
BackendImpl * BackendImpl::ComponentPackageImpl::getMyBackend() const
{
BackendImpl * pBackend = static_cast<BackendImpl *>(m_myBackend.get());
@@ -345,20 +377,22 @@ void BackendImpl::disposing()
void BackendImpl::initServiceRdbFiles()
{
const Reference<XCommandEnvironment> xCmdEnv;
- if (! m_readOnly) {
+ if (! m_readOnly)
+ {
::ucbhelper::Content cacheDir( getCachePath(), xCmdEnv );
::ucbhelper::Content oldRDB;
// switch common rdb:
- if (m_commonRDB.getLength() > 0)
+ if (m_commonRDB_RO.getLength() > 0)
+ {
create_ucb_content(
- &oldRDB, makeURL( getCachePath(), m_commonRDB ),
- xCmdEnv, false /* no throw */ );
- m_commonRDB = m_commonRDB.equalsAsciiL(
+ &oldRDB, makeURL( getCachePath(), m_commonRDB_RO),
+ xCmdEnv, false /* no throw */ );
+ }
+ m_commonRDB = m_commonRDB_RO.equalsAsciiL(
RTL_CONSTASCII_STRINGPARAM("common.rdb") )
- ? OUSTR("common_.rdb") : OUSTR("common.rdb");
+ ? OUSTR("common_.rdb") : OUSTR("common.rdb");
if (oldRDB.get().is())
{
-
if (! cacheDir.transferContent(
oldRDB, ::ucbhelper::InsertOperation_COPY,
m_commonRDB, NameClash::OVERWRITE ))
@@ -370,13 +404,15 @@ void BackendImpl::initServiceRdbFiles()
oldRDB = ::ucbhelper::Content();
}
// switch native rdb:
- if (m_nativeRDB.getLength() > 0)
+ if (m_nativeRDB_RO.getLength() > 0)
+ {
create_ucb_content(
- &oldRDB, makeURL( getCachePath(), m_nativeRDB ),
- xCmdEnv, false /* no throw */ );
+ &oldRDB, makeURL(getCachePath(), m_nativeRDB_RO),
+ xCmdEnv, false /* no throw */ );
+ }
const OUString plt_rdb( getPlatformString() + OUSTR(".rdb") );
const OUString plt_rdb_( getPlatformString() + OUSTR("_.rdb") );
- m_nativeRDB = m_nativeRDB.equals( plt_rdb ) ? plt_rdb_ : plt_rdb;
+ m_nativeRDB = m_nativeRDB_RO.equals( plt_rdb ) ? plt_rdb_ : plt_rdb;
if (oldRDB.get().is())
{
if (! cacheDir.transferContent(
@@ -414,6 +450,37 @@ void BackendImpl::initServiceRdbFiles()
}
}
+void BackendImpl::initServiceRdbFiles_RO()
+{
+ const Reference<XCommandEnvironment> xCmdEnv;
+
+ // common rdb for java, native rdb for shared lib components
+ if (m_commonRDB_RO.getLength() > 0)
+ {
+ m_xCommonRDB_RO.set(
+ m_xComponentContext->getServiceManager()
+ ->createInstanceWithContext(
+ OUSTR("com.sun.star.registry.SimpleRegistry"),
+ m_xComponentContext), UNO_QUERY_THROW);
+ m_xCommonRDB_RO->open(
+ makeURL(expandUnoRcUrl(getCachePath()), m_commonRDB_RO),
+ sal_True, //read-only
+ sal_True); // create data source if necessary
+ }
+ if (m_nativeRDB_RO.getLength() > 0)
+ {
+ m_xNativeRDB_RO.set(
+ m_xComponentContext->getServiceManager()
+ ->createInstanceWithContext(
+ OUSTR("com.sun.star.registry.SimpleRegistry"),
+ m_xComponentContext), UNO_QUERY_THROW);
+ m_xNativeRDB_RO->open(
+ makeURL(expandUnoRcUrl(getCachePath()), m_nativeRDB_RO),
+ sal_True, //read-only
+ sal_True); // create data source if necessary
+ }
+}
+
//______________________________________________________________________________
BackendImpl::BackendImpl(
Sequence<Any> const & args,
@@ -492,7 +559,12 @@ BackendImpl::BackendImpl(
}
else
{
+ //do this before initServiceRdbFiles_RO, because it determines
+ //m_commonRDB and m_nativeRDB
unorc_verify_init( xCmdEnv );
+
+ initServiceRdbFiles_RO();
+
}
}
@@ -687,7 +759,7 @@ void BackendImpl::unorc_verify_init(
sal_Int32 start = sizeof ("UNO_SERVICES=?$ORIGIN/") - 1;
sal_Int32 sep = line.indexOf( ' ', start );
OSL_ASSERT( sep > 0 );
- m_commonRDB = line.copy( start, sep - start );
+ m_commonRDB_RO = line.copy( start, sep - start );
}
// native rc:
@@ -697,7 +769,7 @@ void BackendImpl::unorc_verify_init(
xCmdEnv, false /* no throw */ )) {
if (readLine( &line, OUSTR("UNO_SERVICES="), ucb_content,
RTL_TEXTENCODING_UTF8 )) {
- m_nativeRDB = line.copy(
+ m_nativeRDB_RO = line.copy(
sizeof ("UNO_SERVICES=?$ORIGIN/") - 1 );
}
}
@@ -763,12 +835,19 @@ void BackendImpl::unorc_flush( Reference<XCommandEnvironment> const & xCmdEnv )
}
buf.append(LF);
}
- if (m_commonRDB.getLength() > 0 || m_nativeRDB.getLength() > 0)
+
+ // If we duplicated the common or native rdb then we must use those urls
+ //otherwise we use those of the original files. That is, m_commonRDB_RO and
+ //m_nativeRDB_RO;
+ OUString sCommonRDB(m_commonRDB.getLength() > 0 ? m_commonRDB : m_commonRDB_RO);
+ OUString sNativeRDB(m_nativeRDB.getLength() > 0 ? m_nativeRDB : m_nativeRDB_RO);
+
+ if (sCommonRDB.getLength() > 0 || sNativeRDB.getLength() > 0)
{
buf.append( RTL_CONSTASCII_STRINGPARAM("UNO_SERVICES=?$ORIGIN/") );
buf.append( ::rtl::OUStringToOString(
- m_commonRDB, RTL_TEXTENCODING_ASCII_US ) );
- if (m_nativeRDB.getLength() > 0)
+ sCommonRDB, RTL_TEXTENCODING_ASCII_US ) );
+ if (sNativeRDB.getLength() > 0)
{
buf.append( RTL_CONSTASCII_STRINGPARAM(
" ${$ORIGIN/${_OS}_${_ARCH}rc:UNO_SERVICES}") );
@@ -778,7 +857,7 @@ void BackendImpl::unorc_flush( Reference<XCommandEnvironment> const & xCmdEnv )
::rtl::OStringBuffer buf2;
buf2.append( RTL_CONSTASCII_STRINGPARAM("UNO_SERVICES=?$ORIGIN/") );
buf2.append( ::rtl::OUStringToOString(
- m_nativeRDB, RTL_TEXTENCODING_ASCII_US ) );
+ sNativeRDB, RTL_TEXTENCODING_ASCII_US ) );
buf2.append(LF);
const Reference<io::XInputStream> xData(
@@ -1026,7 +1105,7 @@ BackendImpl::ComponentPackageImpl::isRegistered_(
if (m_registered == REG_UNINIT)
{
m_registered = REG_NOT_REGISTERED;
- const Reference<registry::XSimpleRegistry> xRDB( getRDB() );
+ const Reference<registry::XSimpleRegistry> xRDB( getRDB_RO() );
if (xRDB.is())
{
// lookup rdb for location URL:
@@ -1071,6 +1150,8 @@ void BackendImpl::ComponentPackageImpl::processPackage_(
Reference<XCommandEnvironment> const & xCmdEnv )
{
BackendImpl * that = getMyBackend();
+
+
const bool java = m_loader.equalsAsciiL(
RTL_CONSTASCII_STRINGPARAM("com.sun.star.loader.Java2") );
const OUString url( getURL() );