summaryrefslogtreecommitdiff
path: root/remotebridges/source/unourl_resolver
diff options
context:
space:
mode:
authorJörg Budischewski <jbu@openoffice.org>2001-06-22 15:39:16 +0000
committerJörg Budischewski <jbu@openoffice.org>2001-06-22 15:39:16 +0000
commite03c41fe2e1b4c564e83128499020343e9f1047c (patch)
treec7210bedf386848c6fcedc8280c8ba786e696990 /remotebridges/source/unourl_resolver
parent4409e1cfb5d33e57c1eba238bd5ab9d153cbbacd (diff)
#67468# Added unloading and context support
Diffstat (limited to 'remotebridges/source/unourl_resolver')
-rw-r--r--remotebridges/source/unourl_resolver/makefile.mk6
-rw-r--r--remotebridges/source/unourl_resolver/unourl_resolver.cxx142
-rw-r--r--remotebridges/source/unourl_resolver/uuresolver.map10
3 files changed, 89 insertions, 69 deletions
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:
+ *;
+};