From a242da96dcd112e05ce9fa7f309d6618c61994f9 Mon Sep 17 00:00:00 2001 From: Jörg Budischewski Date: Fri, 22 Jun 2001 15:21:02 +0000 Subject: #67468# Added unloading and context support --- stoc/source/defaultregistry/defaultregistry.cxx | 145 +++++++++++------------- stoc/source/defaultregistry/makefile.mk | 6 +- 2 files changed, 70 insertions(+), 81 deletions(-) (limited to 'stoc/source/defaultregistry') diff --git a/stoc/source/defaultregistry/defaultregistry.cxx b/stoc/source/defaultregistry/defaultregistry.cxx index bb2c1fdaa64c..e11702f9eac3 100644 --- a/stoc/source/defaultregistry/defaultregistry.cxx +++ b/stoc/source/defaultregistry/defaultregistry.cxx @@ -2,9 +2,9 @@ * * $RCSfile: defaultregistry.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jsc $ $Date: 2001-03-19 12:40:58 $ + * last change: $Author: jbu $ $Date: 2001-06-22 16:20:56 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -81,6 +81,9 @@ #ifndef _CPPUHELPER_IMPLBASE3_HXX_ #include #endif +#ifndef _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_ +#include +#endif #ifndef _REGISTRY_REGISTRY_HXX_ #include @@ -101,11 +104,43 @@ using namespace osl; using namespace rtl; -#define NESTED_SERVICENAME "com.sun.star.registry.NestedRegistry" -#define NESTED_IMPLNAME "com.sun.star.comp.stoc.NestedRegistry" +#define SERVICENAME "com.sun.star.registry.NestedRegistry" +#define IMPLNAME "com.sun.star.comp.stoc.NestedRegistry" namespace stoc_defreg { +rtl_StandardModuleCount g_moduleCount = MODULE_COUNT_INIT; + +static Sequence< OUString > defreg_getSupportedServiceNames() +{ + static Sequence < OUString > *pNames = 0; + if( ! pNames ) + { + MutexGuard guard( Mutex::getGlobalMutex() ); + if( !pNames ) + { + static Sequence< OUString > seqNames(1); + seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICENAME)); + pNames = &seqNames; + } + } + return *pNames; +} + +OUString defreg_getImplementationName() +{ + static OUString *pImplName = 0; + if( ! pImplName ) + { + MutexGuard guard( Mutex::getGlobalMutex() ); + if( ! pImplName ) + { + static OUString implName( RTL_CONSTASCII_USTRINGPARAM( IMPLNAME ) ); + pImplName = &implName; + } + } + return *pImplName; +} //************************************************************************* // NestedRegistryImpl @@ -115,11 +150,7 @@ class NestedKeyImpl; class NestedRegistryImpl : public WeakAggImplHelper3 < XSimpleRegistry, XInitialization, XServiceInfo > { public: - NestedRegistryImpl( const Reference & rXSMgr ); - - NestedRegistryImpl( const Reference & rXSMgr, - Reference& localReg, - Reference& systemReg ); + NestedRegistryImpl( ); ~NestedRegistryImpl(); @@ -127,8 +158,6 @@ public: virtual OUString SAL_CALL getImplementationName( ) throw(RuntimeException); virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException); virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(RuntimeException); - static OUString SAL_CALL getImplementationName_Static( ); - static Sequence< OUString > SAL_CALL getSupportedServiceNames_Static( ); // XInitialization virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) @@ -151,8 +180,6 @@ protected: Reference m_localReg; Reference m_defaultReg; -private: - Reference m_xSMgr; }; //************************************************************************* @@ -1174,32 +1201,23 @@ OUString SAL_CALL NestedKeyImpl::getResolvedName( const OUString& aKeyName ) // DefaultRegistry Implementation // //************************************************************************* -NestedRegistryImpl::NestedRegistryImpl( const Reference & rSMgr ) +NestedRegistryImpl::NestedRegistryImpl( ) : m_state(0) - , m_xSMgr(rSMgr) -{ -} - -NestedRegistryImpl::NestedRegistryImpl( const Reference & rSMgr, - Reference& localReg, - Reference& defaultReg) - : m_state(0) - , m_localReg(localReg) - , m_defaultReg(defaultReg) - , m_xSMgr(rSMgr) { + g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt ); } //************************************************************************* NestedRegistryImpl::~NestedRegistryImpl() { + g_moduleCount.modCnt.release( &g_moduleCount.modCnt ); } //************************************************************************* OUString SAL_CALL NestedRegistryImpl::getImplementationName( ) throw(RuntimeException) { - return OUString::createFromAscii( NESTED_IMPLNAME ); + return defreg_getImplementationName(); } //************************************************************************* @@ -1219,14 +1237,7 @@ sal_Bool SAL_CALL NestedRegistryImpl::supportsService( const OUString& ServiceNa Sequence SAL_CALL NestedRegistryImpl::getSupportedServiceNames( ) throw(RuntimeException) { - return getSupportedServiceNames_Static(); -} - -//************************************************************************* -Sequence SAL_CALL NestedRegistryImpl::getSupportedServiceNames_Static( ) -{ - OUString aStr( OUString::createFromAscii( NESTED_SERVICENAME ) ); - return Sequence< OUString >( &aStr, 1 ); + return defreg_getSupportedServiceNames(); } //************************************************************************* @@ -1360,11 +1371,11 @@ void SAL_CALL NestedRegistryImpl::mergeKey( const OUString& aKeyName, const OUSt } //************************************************************************* -Reference SAL_CALL NestedRegistry_CreateInstance( const Reference& rSMgr ) +Reference SAL_CALL NestedRegistry_CreateInstance( const Reference& xCtx ) throw(Exception) { Reference xRet; - XSimpleRegistry *pRegistry = (XSimpleRegistry*) new NestedRegistryImpl(rSMgr); + XSimpleRegistry *pRegistry = (XSimpleRegistry*) new NestedRegistryImpl; if (pRegistry) { @@ -1376,8 +1387,26 @@ Reference SAL_CALL NestedRegistry_CreateInstance( const Reference xNewKey( - reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( - OUString::createFromAscii( "/" NESTED_IMPLNAME "/UNO/SERVICES" ) ) ); - - Sequence< OUString > & rSNL = ::stoc_defreg::NestedRegistryImpl::getSupportedServiceNames_Static(); - const OUString * pArray = rSNL.getConstArray(); - for ( sal_Int32 nPos = rSNL.getLength(); nPos--; ) - xNewKey->createKey( pArray[nPos] ); - - return sal_True; - } - catch (InvalidRegistryException &) - { - OSL_ENSURE( sal_False, "### InvalidRegistryException!" ); - } - } - return sal_False; + return component_writeInfoHelper( pServiceManager, pRegistryKey, g_entries ); } //================================================================================================== void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) { - void * pRet = 0; - if ( rtl_str_compare( pImplName, NESTED_IMPLNAME ) == 0 ) - { - Reference< XSingleServiceFactory > xFactory( createSingleFactory( - reinterpret_cast< XMultiServiceFactory * >( pServiceManager ), - OUString::createFromAscii( pImplName ), - ::stoc_defreg::NestedRegistry_CreateInstance, - ::stoc_defreg::NestedRegistryImpl::getSupportedServiceNames_Static() ) ); - - if (xFactory.is()) - { - xFactory->acquire(); - pRet = xFactory.get(); - } - } - - return pRet; + return component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey , g_entries ); } } - - - diff --git a/stoc/source/defaultregistry/makefile.mk b/stoc/source/defaultregistry/makefile.mk index 35ec135e6d7d..689e103c0013 100644 --- a/stoc/source/defaultregistry/makefile.mk +++ b/stoc/source/defaultregistry/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.8 $ +# $Revision: 1.9 $ # -# last change: $Author: obo $ $Date: 2001-05-07 13:50:42 $ +# last change: $Author: jbu $ $Date: 2001-06-22 16:20:56 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -88,13 +88,13 @@ SHL1STDLIBS= \ $(CPPUHELPERLIB) \ $(SALLIB) +SHL1VERSIONMAP= $(TARGET).map SHL1DEPN= SHL1IMPLIB= i$(TARGET) SHL1LIBS= $(SLB)$/$(TARGET).lib SHL1DEF= $(MISC)$/$(SHL1TARGET).def DEF1NAME= $(SHL1TARGET) -DEF1EXPORTFILE= exports.dxp # --- Targets ------------------------------------------------------ -- cgit