diff options
author | Jörg Budischewski <jbu@openoffice.org> | 2001-06-22 15:39:16 +0000 |
---|---|---|
committer | Jörg Budischewski <jbu@openoffice.org> | 2001-06-22 15:39:16 +0000 |
commit | e03c41fe2e1b4c564e83128499020343e9f1047c (patch) | |
tree | c7210bedf386848c6fcedc8280c8ba786e696990 /remotebridges | |
parent | 4409e1cfb5d33e57c1eba238bd5ab9d153cbbacd (diff) |
#67468# Added unloading and context support
Diffstat (limited to 'remotebridges')
-rw-r--r-- | remotebridges/source/bridge/bridge_connection.cxx | 10 | ||||
-rw-r--r-- | remotebridges/source/bridge/bridge_connection.hxx | 5 | ||||
-rw-r--r-- | remotebridges/source/bridge/bridge_provider.cxx | 6 | ||||
-rw-r--r-- | remotebridges/source/bridge/makefile.mk | 6 | ||||
-rw-r--r-- | remotebridges/source/bridge/remote_bridge.cxx | 83 | ||||
-rw-r--r-- | remotebridges/source/bridge/remote_bridge.hxx | 6 | ||||
-rw-r--r-- | remotebridges/source/bridge/remotebridge.map | 10 | ||||
-rw-r--r-- | remotebridges/source/factory/brdgfctr.map | 10 | ||||
-rw-r--r-- | remotebridges/source/factory/bridgefactory.cxx | 121 | ||||
-rw-r--r-- | remotebridges/source/factory/bridgeimpl.cxx | 13 | ||||
-rw-r--r-- | remotebridges/source/factory/bridgeimpl.hxx | 5 | ||||
-rw-r--r-- | remotebridges/source/factory/makefile.mk | 6 | ||||
-rw-r--r-- | remotebridges/source/unourl_resolver/makefile.mk | 6 | ||||
-rw-r--r-- | remotebridges/source/unourl_resolver/unourl_resolver.cxx | 142 | ||||
-rw-r--r-- | remotebridges/source/unourl_resolver/uuresolver.map | 10 |
15 files changed, 249 insertions, 190 deletions
diff --git a/remotebridges/source/bridge/bridge_connection.cxx b/remotebridges/source/bridge/bridge_connection.cxx index 4a1744e3d3ae..7f12efa6731c 100644 --- a/remotebridges/source/bridge/bridge_connection.cxx +++ b/remotebridges/source/bridge/bridge_connection.cxx @@ -2,9 +2,9 @@ * * $RCSfile: bridge_connection.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: jbu $ $Date: 2000-09-28 08:47:30 $ + * last change: $Author: jbu $ $Date: 2001-06-22 16:39:16 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,6 +59,7 @@ * ************************************************************************/ #include "bridge_connection.hxx" +#include "remote_bridge.hxx" #include <rtl/byteseq.hxx> #include <string.h> @@ -71,6 +72,7 @@ namespace remotebridges_bridge m_r( r ), m_nRef( 0 ) { + g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt ); acquire = thisAcquire; release = thisRelease; read = thisRead; @@ -79,6 +81,10 @@ namespace remotebridges_bridge close = thisClose; } + OConnectionWrapper::~OConnectionWrapper() + { + g_moduleCount.modCnt.release( &g_moduleCount.modCnt ); +} void OConnectionWrapper::thisAcquire( remote_Connection *p) { diff --git a/remotebridges/source/bridge/bridge_connection.hxx b/remotebridges/source/bridge/bridge_connection.hxx index d6f190c13d16..0bfcfe06647d 100644 --- a/remotebridges/source/bridge/bridge_connection.hxx +++ b/remotebridges/source/bridge/bridge_connection.hxx @@ -2,9 +2,9 @@ * * $RCSfile: bridge_connection.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: jbu $ $Date: 2000-09-28 08:47:30 $ + * last change: $Author: jbu $ $Date: 2001-06-22 16:39:16 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -73,6 +73,7 @@ namespace remotebridges_bridge public: OConnectionWrapper( const ::com::sun::star::uno::Reference < ::com::sun::star::connection::XConnection > & ); + ~OConnectionWrapper(); static void SAL_CALL thisAcquire( remote_Connection *); static void SAL_CALL thisRelease( remote_Connection *); diff --git a/remotebridges/source/bridge/bridge_provider.cxx b/remotebridges/source/bridge/bridge_provider.cxx index b505f13c0ca2..27a409e84eef 100644 --- a/remotebridges/source/bridge/bridge_provider.cxx +++ b/remotebridges/source/bridge/bridge_provider.cxx @@ -2,9 +2,9 @@ * * $RCSfile: bridge_provider.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: jbu $ $Date: 2001-05-03 06:32:08 $ + * last change: $Author: jbu $ $Date: 2001-06-22 16:39:16 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -84,6 +84,7 @@ namespace remotebridges_bridge m_pBridgeCallback( pBridgeCallback ), m_nRef( 0 ) { + g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt ); acquire = thisAcquire; release = thisRelease; getInstance = thisGetInstance; @@ -91,6 +92,7 @@ namespace remotebridges_bridge OInstanceProviderWrapper::~OInstanceProviderWrapper() { + g_moduleCount.modCnt.release( &g_moduleCount.modCnt ); } void OInstanceProviderWrapper::thisAcquire( remote_InstanceProvider *p ) diff --git a/remotebridges/source/bridge/makefile.mk b/remotebridges/source/bridge/makefile.mk index 396f141f3c83..5ad1600fe531 100644 --- a/remotebridges/source/bridge/makefile.mk +++ b/remotebridges/source/bridge/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.4 $ +# $Revision: 1.5 $ # -# last change: $Author: obo $ $Date: 2001-05-07 14:00:43 $ +# last change: $Author: jbu $ $Date: 2001-06-22 16:39:16 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -84,6 +84,7 @@ SLOFILES= \ $(SLO)$/bridge_connection.obj\ $(SLO)$/bridge_provider.obj SHL1TARGET= $(TARGET) +SHL1VERSIONMAP= $(TARGET).map SHL1STDLIBS= \ $(SALLIB) \ @@ -97,7 +98,6 @@ SHL1LIBS= $(SLB)$/$(TARGET).lib SHL1DEF= $(MISC)$/$(SHL1TARGET).def DEF1NAME= $(SHL1TARGET) -DEF1EXPORTFILE= exports.dxp # --- Targets ------------------------------------------------------ .INCLUDE : target.mk diff --git a/remotebridges/source/bridge/remote_bridge.cxx b/remotebridges/source/bridge/remote_bridge.cxx index 08ed60856475..8d3dfb06b1a7 100644 --- a/remotebridges/source/bridge/remote_bridge.cxx +++ b/remotebridges/source/bridge/remote_bridge.cxx @@ -2,9 +2,9 @@ * * $RCSfile: remote_bridge.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: tbe $ $Date: 2001-05-11 10:56:30 $ + * last change: $Author: jbu $ $Date: 2001-06-22 16:39:16 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,6 +62,7 @@ #include "remote_bridge.hxx" #include "bridge_connection.hxx" +#include <cppuhelper/implementationentry.hxx> #include <com/sun/star/lang/IllegalArgumentException.hpp> #include <com/sun/star/bridge/BridgeExistsException.hpp> @@ -80,11 +81,14 @@ using namespace ::com::sun::star::connection; namespace remotebridges_bridge { + rtl_StandardModuleCount g_moduleCount = MODULE_COUNT_INIT; + ORemoteBridge::ORemoteBridge() : OComponentHelper( m_mutex ), m_pContext( 0 ), m_pEnvRemote(0 ) { + g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt ); remote_DisposingListener::acquire = thisAcquire; remote_DisposingListener::release = thisRelease; remote_DisposingListener::disposing = thisDisposing; @@ -100,6 +104,7 @@ namespace remotebridges_bridge { m_pEnvRemote->release( m_pEnvRemote ); } + g_moduleCount.modCnt.release( &g_moduleCount.modCnt ); } void ORemoteBridge::objectMappedSuccesfully() @@ -419,11 +424,27 @@ namespace remotebridges_bridge //--------------------------------- // //--------------------------------- - Reference< XInterface > SAL_CALL CreateInstance( const Reference< XMultiServiceFactory > &) + Reference< XInterface > SAL_CALL CreateInstance( const Reference< XComponentContext > &) { return Reference< XInterface > ( ( OWeakObject * ) new ORemoteBridge ); } + OUString getImplementationName() + { + static OUString *pImplName = 0; + if( ! pImplName ) + { + MutexGuard guard( Mutex::getGlobalMutex() ); + if( ! pImplName ) + { + static OUString implName( + RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) ); + pImplName = &implName; + } + } + return *pImplName; + } + Sequence< OUString > getSupportedServiceNames() { static Sequence < OUString > *pNames = 0; @@ -446,8 +467,23 @@ namespace remotebridges_bridge using namespace remotebridges_bridge; +static struct ImplementationEntry g_entries[] = +{ + { + remotebridges_bridge::CreateInstance, remotebridges_bridge::getImplementationName, + remotebridges_bridge::getSupportedServiceNames, createSingleComponentFactory, + &g_moduleCount.modCnt , 0 + }, + { 0, 0, 0, 0, 0, 0 } +}; + extern "C" { +sal_Bool SAL_CALL component_canUnload( TimeValue *pTime ) +{ + return g_moduleCount.canUnload( &g_moduleCount , pTime ); +} + //================================================================================================== void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv ) @@ -458,52 +494,17 @@ void SAL_CALL component_getImplementationEnvironment( sal_Bool SAL_CALL component_writeInfo( void * pServiceManager, void * pRegistryKey ) { - if (pRegistryKey) - { - try - { - Reference< XRegistryKey > xNewKey( - reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( - OUString::createFromAscii( "/" IMPLEMENTATION_NAME "/UNO/SERVICES" ) ) ); - - const Sequence< OUString > & rSNL = getSupportedServiceNames(); - 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 (pServiceManager && rtl_str_compare( pImplName, IMPLEMENTATION_NAME ) == 0) - { - Reference< XSingleServiceFactory > xFactory( createSingleFactory( - reinterpret_cast< XMultiServiceFactory * >( pServiceManager ), - OUString::createFromAscii( pImplName ), - CreateInstance, getSupportedServiceNames() ) ); - - if (xFactory.is()) - { - xFactory->acquire(); - pRet = xFactory.get(); - } - } - - return pRet; + return component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey , g_entries ); } } + diff --git a/remotebridges/source/bridge/remote_bridge.hxx b/remotebridges/source/bridge/remote_bridge.hxx index 06cf8d0ae0cf..b33b04831ec4 100644 --- a/remotebridges/source/bridge/remote_bridge.hxx +++ b/remotebridges/source/bridge/remote_bridge.hxx @@ -2,9 +2,9 @@ * * $RCSfile: remote_bridge.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: jbu $ $Date: 2001-05-02 14:13:35 $ + * last change: $Author: jbu $ $Date: 2001-06-22 16:39:16 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -81,6 +81,8 @@ namespace remotebridges_bridge { + extern rtl_StandardModuleCount g_moduleCount; + struct MyMutex { ::osl::Mutex m_mutex; diff --git a/remotebridges/source/bridge/remotebridge.map b/remotebridges/source/bridge/remotebridge.map new file mode 100644 index 000000000000..f76809fbd37b --- /dev/null +++ b/remotebridges/source/bridge/remotebridge.map @@ -0,0 +1,10 @@ +UDK_3_0_0 { + global: + component_getImplementationEnvironment; + component_writeInfo; + component_getFactory; + component_canUnload; + component_getDescriptionFunc; + local: + *; +}; diff --git a/remotebridges/source/factory/brdgfctr.map b/remotebridges/source/factory/brdgfctr.map new file mode 100644 index 000000000000..f76809fbd37b --- /dev/null +++ b/remotebridges/source/factory/brdgfctr.map @@ -0,0 +1,10 @@ +UDK_3_0_0 { + global: + component_getImplementationEnvironment; + component_writeInfo; + component_getFactory; + component_canUnload; + component_getDescriptionFunc; + local: + *; +}; diff --git a/remotebridges/source/factory/bridgefactory.cxx b/remotebridges/source/factory/bridgefactory.cxx index b38d56b7f942..f17f62bfc32d 100644 --- a/remotebridges/source/factory/bridgefactory.cxx +++ b/remotebridges/source/factory/bridgefactory.cxx @@ -2,9 +2,9 @@ * * $RCSfile: bridgefactory.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: tbe $ $Date: 2001-05-11 10:56:49 $ + * last change: $Author: jbu $ $Date: 2001-06-22 16:39:16 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -67,7 +67,7 @@ #include <bridges/remote/context.h> -#include <cppuhelper/factory.hxx> +#include <cppuhelper/implementationentry.hxx> #include <cppuhelper/component.hxx> #include <cppuhelper/typeprovider.hxx> @@ -99,6 +99,8 @@ using namespace ::com::sun::star::container; namespace remotebridges_factory { + rtl_StandardModuleCount g_moduleCount = MODULE_COUNT_INIT; + struct hashOUString { size_t operator()(const OUString & s) const @@ -137,7 +139,8 @@ namespace remotebridges_factory public XServiceInfo { public: - OBridgeFactory( const Reference < XMultiServiceFactory > &rSMgr ); + OBridgeFactory( const Reference < XComponentContext > &rCtx ); + ~OBridgeFactory(); public: // XInterface ::com::sun::star::uno::Any SAL_CALL @@ -169,29 +172,40 @@ namespace remotebridges_factory virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); - private: //XServiceInfo + public: //XServiceInfo 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); + public: + static OUString getImplementationNameStatic( ) SAL_THROW( () ); + static Sequence< OUString > getSupportedServiceNamesStatic() SAL_THROW( () ); + private: void init(); OUString getServiceNameForProtocol( const OUString &sProtocol ); private: - Reference < XMultiServiceFactory > m_rSMgr; + Reference < XMultiComponentFactory > m_rSMgr; + Reference < XComponentContext > m_rCtx; BridgeHashMap m_mapBridge; ServiceHashMap m_mapProtocolToService; sal_Bool m_bInitialized; ::osl::Mutex m_mutexInit; }; - OBridgeFactory::OBridgeFactory( const Reference < XMultiServiceFactory > &rSMgr ) : - OComponentHelper( m_mutex ), - m_rSMgr( rSMgr ), - m_bInitialized( sal_False ) + OBridgeFactory::OBridgeFactory( const Reference < XComponentContext > &rCtx ) + : OComponentHelper( m_mutex ) + , m_rCtx( rCtx ) + , m_rSMgr( rCtx->getServiceManager() ) + , m_bInitialized( sal_False ) { + g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt ); + } + OBridgeFactory::~OBridgeFactory() + { + g_moduleCount.modCnt.release( &g_moduleCount.modCnt ); } void OBridgeFactory::init() @@ -202,7 +216,8 @@ namespace remotebridges_factory Reference< XContentEnumerationAccess > rContent( m_rSMgr , UNO_QUERY ); if( rContent.is() ) { - OUString sMetaService = OUString::createFromAscii( "com.sun.star.bridge.Bridge" ); + OUString sMetaService = OUString( + RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.bridge.Bridge" ) ); Reference < XEnumeration > rEnum = rContent->createContentEnumeration( sMetaService ); while( rEnum->hasMoreElements() ) @@ -289,7 +304,8 @@ namespace remotebridges_factory { OUString sService = getServiceNameForProtocol( sProtocol ); - Reference < XInterface > rXInterface = m_rSMgr->createInstance ( sService ); + Reference < XInterface > rXInterface = + m_rSMgr->createInstanceWithContext(sService, m_rCtx ); Reference < XInitialization > rInit(rXInterface, UNO_QUERY ); Reference < XBridge > rBridge( rInit , UNO_QUERY ); @@ -412,7 +428,22 @@ namespace remotebridges_factory return (*pId).getImplementationId(); } - Sequence< OUString > getSupportedServiceNames() + OUString OBridgeFactory::getImplementationNameStatic() + { + static OUString *pName = 0; + if( ! pName ) + { + MutexGuard guard( Mutex::getGlobalMutex() ); + if( ! pName ) + { + static OUString name( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) ); + pName = &name; + } + } + return *pName; + } + + Sequence< OUString > OBridgeFactory::getSupportedServiceNamesStatic() { static Sequence < OUString > *pNames = 0; if( ! pNames ) @@ -430,12 +461,12 @@ namespace remotebridges_factory OUString OBridgeFactory::getImplementationName( ) throw(RuntimeException) { - return OUString::createFromAscii( IMPLEMENTATION_NAME ); + return getImplementationNameStatic(); } sal_Bool SAL_CALL OBridgeFactory::supportsService( const OUString& ServiceName ) throw(RuntimeException) { - Sequence< OUString > seq = remotebridges_factory::getSupportedServiceNames(); + Sequence< OUString > seq = getSupportedServiceNamesStatic(); sal_Bool bReturn = sal_False; for( sal_Int32 i = 0 ; i < seq.getLength() ; i ++ ) { @@ -450,20 +481,33 @@ namespace remotebridges_factory Sequence< OUString > SAL_CALL OBridgeFactory::getSupportedServiceNames( ) throw(RuntimeException) { - return remotebridges_factory::getSupportedServiceNames(); + return getSupportedServiceNamesStatic(); } - Reference< XInterface > SAL_CALL CreateInstance( const Reference< XMultiServiceFactory > &r) + + Reference< XInterface > SAL_CALL CreateInstance(Reference< XComponentContext > const & xContext) { - return Reference < XInterface > (( OWeakObject * ) new OBridgeFactory( r ) ); + return Reference < XInterface > ( *new OBridgeFactory( xContext ) ); } - } using namespace remotebridges_factory; +static ImplementationEntry g_entries[] = +{ + { CreateInstance, OBridgeFactory::getImplementationNameStatic, + OBridgeFactory::getSupportedServiceNamesStatic, createSingleComponentFactory , + &g_moduleCount.modCnt , 0 + }, + { 0, 0, 0, 0, 0, 0 } +}; extern "C" { +sal_Bool SAL_CALL component_canUnload( TimeValue *pTime ) +{ + return g_moduleCount.canUnload( &g_moduleCount , pTime ); +} + //================================================================================================== void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv ) @@ -474,48 +518,13 @@ void SAL_CALL component_getImplementationEnvironment( sal_Bool SAL_CALL component_writeInfo( void * pServiceManager, void * pRegistryKey ) { - if (pRegistryKey) - { - try - { - Reference< XRegistryKey > xNewKey( - reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( - OUString::createFromAscii("/" IMPLEMENTATION_NAME "/UNO/SERVICES" ) ) ); - - const Sequence< OUString > & rSNL = getSupportedServiceNames(); - 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 (pServiceManager && rtl_str_compare( pImplName, IMPLEMENTATION_NAME ) == 0) - { - Reference< XSingleServiceFactory > xFactory( createSingleFactory( - reinterpret_cast< XMultiServiceFactory * >( pServiceManager ), - OUString::createFromAscii( pImplName ), CreateInstance, getSupportedServiceNames() ) ); - - if (xFactory.is()) - { - xFactory->acquire(); - pRet = xFactory.get(); - } - } - - return pRet; + return component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey , g_entries ); } } diff --git a/remotebridges/source/factory/bridgeimpl.cxx b/remotebridges/source/factory/bridgeimpl.cxx index 3a535985ae7c..7f9c913b7bde 100644 --- a/remotebridges/source/factory/bridgeimpl.cxx +++ b/remotebridges/source/factory/bridgeimpl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: bridgeimpl.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: tbe $ $Date: 2001-05-11 10:57:01 $ + * last change: $Author: jbu $ $Date: 2001-06-22 16:39:16 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -75,6 +75,8 @@ namespace remotebridges_factory { OComponentHelper( m_mutex ), m_pContext( pContext ) { + g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt ); + remote_DisposingListener::acquire = thisAcquire; remote_DisposingListener::release = thisRelease; remote_DisposingListener::disposing = thisDisposing; @@ -89,6 +91,7 @@ namespace remotebridges_factory { { m_pContext->aBase.release( (uno_Context * ) m_pContext ); } + g_moduleCount.modCnt.release( &g_moduleCount.modCnt ); } ::com::sun::star::uno::Any OBridge::queryInterface( const ::com::sun::star::uno::Type & aType ) @@ -134,7 +137,6 @@ namespace remotebridges_factory { m_pContext->aBase.release( (uno_Context*)m_pContext ); m_pContext = 0; } - } @@ -300,9 +302,4 @@ namespace remotebridges_factory { OBridge *m = (OBridge * ) p; m->dispose(); } - - } - - - diff --git a/remotebridges/source/factory/bridgeimpl.hxx b/remotebridges/source/factory/bridgeimpl.hxx index 03a144a23358..51c99a36e2f1 100644 --- a/remotebridges/source/factory/bridgeimpl.hxx +++ b/remotebridges/source/factory/bridgeimpl.hxx @@ -2,9 +2,9 @@ * * $RCSfile: bridgeimpl.hxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-18 15:29:56 $ + * last change: $Author: jbu $ $Date: 2001-06-22 16:39:16 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -79,6 +79,7 @@ #include <com/sun/star/bridge/XInstanceProvider.hpp> namespace remotebridges_factory { + extern rtl_StandardModuleCount g_moduleCount; struct MyMutex { diff --git a/remotebridges/source/factory/makefile.mk b/remotebridges/source/factory/makefile.mk index 3b50592a77e7..66831c721303 100644 --- a/remotebridges/source/factory/makefile.mk +++ b/remotebridges/source/factory/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.7 $ +# $Revision: 1.8 $ # -# last change: $Author: obo $ $Date: 2001-05-07 13:59:20 $ +# last change: $Author: jbu $ $Date: 2001-06-22 16:39:16 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -82,6 +82,7 @@ SLOFILES= \ $(SLO)$/bridgeimpl.obj SHL1TARGET= $(TARGET) +SHL1VERSIONMAP= $(TARGET).map SHL1STDLIBS= \ $(SALLIB) \ @@ -95,7 +96,6 @@ SHL1LIBS= $(SLB)$/$(TARGET).lib SHL1DEF= $(MISC)$/$(SHL1TARGET).def DEF1NAME= $(SHL1TARGET) -DEF1EXPORTFILE= exports.dxp # --- Targets ------------------------------------------------------ diff --git a/remotebridges/source/unourl_resolver/makefile.mk b/remotebridges/source/unourl_resolver/makefile.mk index 8a6efcbe0e9d..81041aee9e95 100644 --- a/remotebridges/source/unourl_resolver/makefile.mk +++ b/remotebridges/source/unourl_resolver/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.5 $ +# $Revision: 1.6 $ # -# last change: $Author: pluby $ $Date: 2001-03-02 07:16:37 $ +# last change: $Author: jbu $ $Date: 2001-06-22 16:39:16 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -99,6 +99,7 @@ SLOFILES= \ $(SLO)$/unourl_resolver.obj SHL1TARGET= $(TARGET) +SHL1VERSIONMAP= $(TARGET).map SHL1STDLIBS= \ $(CPPULIB) \ @@ -111,7 +112,6 @@ SHL1LIBS= $(SLB)$/$(TARGET).lib SHL1DEF= $(MISC)$/$(SHL1TARGET).def DEF1NAME= $(SHL1TARGET) -DEF1EXPORTFILE= exports.dxp # --- Targets ------------------------------------------------------ diff --git a/remotebridges/source/unourl_resolver/unourl_resolver.cxx b/remotebridges/source/unourl_resolver/unourl_resolver.cxx index e4cfefefc141..39f2c295b38c 100644 --- a/remotebridges/source/unourl_resolver/unourl_resolver.cxx +++ b/remotebridges/source/unourl_resolver/unourl_resolver.cxx @@ -2,9 +2,9 @@ * * $RCSfile: unourl_resolver.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: tbe $ $Date: 2001-05-11 11:27:39 $ + * last change: $Author: jbu $ $Date: 2001-06-22 16:39:16 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -66,6 +66,7 @@ #include <osl/mutex.hxx> #include <cppuhelper/factory.hxx> #include <cppuhelper/implbase2.hxx> +#include <cppuhelper/implementationentry.hxx> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XComponent.hpp> @@ -88,21 +89,48 @@ using namespace com::sun::star::registry; namespace unourl_resolver { - + rtl_StandardModuleCount g_moduleCount = MODULE_COUNT_INIT; //-------------------------------------------------------------------------------------------------- -inline static Sequence< OUString > getSupportedServiceNames() +Sequence< OUString > resolver_getSupportedServiceNames() { - OUString aName( RTL_CONSTASCII_USTRINGPARAM(SERVICENAME) ); - return Sequence< OUString >( &aName, 1 ); + 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 resolver_getImplementationName() +{ + static OUString *pImplName = 0; + if( ! pImplName ) + { + MutexGuard guard( Mutex::getGlobalMutex() ); + if( ! pImplName ) + { + static OUString implName( + RTL_CONSTASCII_USTRINGPARAM( IMPLNAME ) ); + pImplName = &implName; + } + } + return *pImplName; } //================================================================================================== class ResolverImpl : public WeakImplHelper2< XServiceInfo, XUnoUrlResolver > { - Reference< XMultiServiceFactory > _xSMgr; + Reference< XMultiComponentFactory > _xSMgr; + Reference< XComponentContext > _xCtx; public: - ResolverImpl( const Reference< XMultiServiceFactory > & xSMgr ); + ResolverImpl( const Reference< XComponentContext > & xSMgr ); virtual ~ResolverImpl(); // XServiceInfo @@ -118,13 +146,16 @@ public: //################################################################################################## //__________________________________________________________________________________________________ -ResolverImpl::ResolverImpl( const Reference< XMultiServiceFactory > & xSMgr ) - : _xSMgr( xSMgr ) +ResolverImpl::ResolverImpl( const Reference< XComponentContext > & xCtx ) + : _xSMgr( xCtx->getServiceManager() ) + , _xCtx( xCtx ) { + g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt ); } //__________________________________________________________________________________________________ ResolverImpl::~ResolverImpl() { + g_moduleCount.modCnt.release( &g_moduleCount.modCnt ); } // XServiceInfo @@ -132,7 +163,7 @@ ResolverImpl::~ResolverImpl() OUString ResolverImpl::getImplementationName() throw(::com::sun::star::uno::RuntimeException) { - return OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME) ); + return resolver_getImplementationName(); } //__________________________________________________________________________________________________ sal_Bool ResolverImpl::supportsService( const OUString & rServiceName ) @@ -151,7 +182,7 @@ sal_Bool ResolverImpl::supportsService( const OUString & rServiceName ) Sequence< OUString > ResolverImpl::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException) { - return unourl_resolver::getSupportedServiceNames(); + return resolver_getSupportedServiceNames(); } // XUnoUrlResolver @@ -174,8 +205,12 @@ Reference< XInterface > ResolverImpl::resolve( const OUString & rUnoUrl ) throw ConnectionSetupException( OUString( RTL_CONSTASCII_USTRINGPARAM("illegal uno url given!" ) ), Reference< XInterface >() ); } - Reference< XConnector > xConnector( _xSMgr->createInstance( - OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.connection.Connector") ) ), UNO_QUERY ); + Reference< XConnector > xConnector( + _xSMgr->createInstanceWithContext( + OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.connection.Connector") ), + _xCtx ), + UNO_QUERY ); + if (! xConnector.is()) throw RuntimeException( OUString( RTL_CONSTASCII_USTRINGPARAM("no connector!" ) ), Reference< XInterface >() ); @@ -186,8 +221,13 @@ Reference< XInterface > ResolverImpl::resolve( const OUString & rUnoUrl ) Reference< XConnection > xConnection( xConnector->connect( aConnectDescr ) ); - Reference< XBridgeFactory > xBridgeFactory( _xSMgr->createInstance( - OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.BridgeFactory") ) ), UNO_QUERY ); + // As soon as singletons are ready, switch to singleton ! + Reference< XBridgeFactory > xBridgeFactory( + _xSMgr->createInstanceWithContext( + OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.BridgeFactory") ), + _xCtx ), + UNO_QUERY ); + if (! xBridgeFactory.is()) throw RuntimeException( OUString( RTL_CONSTASCII_USTRINGPARAM("no bridge factory!" ) ), Reference< XInterface >() ); @@ -199,32 +239,37 @@ Reference< XInterface > ResolverImpl::resolve( const OUString & rUnoUrl ) Reference< XInterface > xRet( xBridge->getInstance( aInstanceName ) ); -// if (! xRet.is()) // dispose bridge manually -// { -// Reference< XComponent > xComp( xBridge, UNO_QUERY ); -// if (xComp.is()) -// xComp->dispose(); -// } - return xRet; } //================================================================================================== -static Reference< XInterface > SAL_CALL ResolverImpl_create( const Reference< XMultiServiceFactory > & xSMgr ) +static Reference< XInterface > SAL_CALL ResolverImpl_create( const Reference< XComponentContext > & xCtx ) { - return Reference< XInterface >( *new ResolverImpl( xSMgr ) ); + return Reference< XInterface >( *new ResolverImpl( xCtx ) ); } + } +using namespace unourl_resolver; -//################################################################################################## -//################################################################################################## -//################################################################################################## - +static struct ImplementationEntry g_entries[] = +{ + { + ResolverImpl_create, resolver_getImplementationName, + resolver_getSupportedServiceNames, createSingleComponentFactory, + &g_moduleCount.modCnt , 0 + }, + { 0, 0, 0, 0, 0, 0 } +}; extern "C" { +sal_Bool SAL_CALL component_canUnload( TimeValue *pTime ) +{ + return g_moduleCount.canUnload( &g_moduleCount , pTime ); +} + //================================================================================================== void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv ) @@ -235,47 +280,12 @@ void SAL_CALL component_getImplementationEnvironment( sal_Bool SAL_CALL component_writeInfo( void * pServiceManager, void * pRegistryKey ) { - if (pRegistryKey) - { - try - { - Reference< XRegistryKey > xNewKey( - reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( - OUString( RTL_CONSTASCII_USTRINGPARAM("/" IMPLNAME "/UNO/SERVICES") ) ) ); - xNewKey->createKey( OUString( RTL_CONSTASCII_USTRINGPARAM(SERVICENAME) ) ); - - 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 (pServiceManager && rtl_str_compare( pImplName, IMPLNAME ) == 0) - { - Reference< XSingleServiceFactory > xFactory( createSingleFactory( - reinterpret_cast< XMultiServiceFactory * >( pServiceManager ), - OUString( RTL_CONSTASCII_USTRINGPARAM(IMPLNAME) ), - unourl_resolver::ResolverImpl_create, - unourl_resolver::getSupportedServiceNames() ) ); - - if (xFactory.is()) - { - xFactory->acquire(); - pRet = xFactory.get(); - } - } - - return pRet; + return component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey , g_entries ); } } - - diff --git a/remotebridges/source/unourl_resolver/uuresolver.map b/remotebridges/source/unourl_resolver/uuresolver.map new file mode 100644 index 000000000000..f76809fbd37b --- /dev/null +++ b/remotebridges/source/unourl_resolver/uuresolver.map @@ -0,0 +1,10 @@ +UDK_3_0_0 { + global: + component_getImplementationEnvironment; + component_writeInfo; + component_getFactory; + component_canUnload; + component_getDescriptionFunc; + local: + *; +}; |