1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: servicemanager.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_stoc.hxx"
33 #include <osl/mutex.hxx>
34 #include <osl/diagnose.h>
35 #include <rtl/ustrbuf.hxx>
40 #include <uno/mapping.hxx>
41 #include <uno/dispatcher.h>
42 #include <cppuhelper/queryinterface.hxx>
43 #include <cppuhelper/weakref.hxx>
44 #include <cppuhelper/component.hxx>
45 #include <cppuhelper/factory.hxx>
46 #ifndef _CPPUHELPER_IMPLBASE1_HXX
47 #include <cppuhelper/implbase1.hxx>
49 #include <cppuhelper/typeprovider.hxx>
50 #ifndef _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_
51 #include <cppuhelper/implementationentry.hxx>
53 #include <rtl/unload.h>
54 #include <cppuhelper/component_context.hxx>
55 #include <cppuhelper/bootstrap.hxx>
56 #include <cppuhelper/compbase8.hxx>
59 #include <com/sun/star/lang/XUnoTunnel.hpp>
60 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
61 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
62 #include <com/sun/star/lang/XServiceInfo.hpp>
63 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
64 #include <com/sun/star/lang/XInitialization.hpp>
65 #include <com/sun/star/lang/XEventListener.hpp>
66 #include <com/sun/star/lang/DisposedException.hpp>
67 #include <com/sun/star/beans/XPropertySet.hpp>
68 #include <com/sun/star/beans/PropertyAttribute.hpp>
69 #include <com/sun/star/registry/XRegistryKey.hpp>
70 #include <com/sun/star/registry/XSimpleRegistry.hpp>
71 #include <com/sun/star/container/XSet.hpp>
72 #include <com/sun/star/container/XElementAccess.hpp>
73 #include <com/sun/star/container/XEnumeration.hpp>
74 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
75 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
76 #include <com/sun/star/uno/XUnloadingPreference.hpp>
78 #include <bootstrapservices.hxx>
80 #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
83 using namespace com::sun::star
;
84 using namespace com::sun::star::uno
;
85 using namespace com::sun::star::beans
;
86 using namespace com::sun::star::registry
;
87 using namespace com::sun::star::lang
;
88 using namespace com::sun::star::container
;
94 rtl_StandardModuleCount g_moduleCount
= MODULE_COUNT_INIT
;
96 namespace stoc_bootstrap
98 Sequence
< OUString
> smgr_wrapper_getSupportedServiceNames()
100 static Sequence
< OUString
> *pNames
= 0;
103 MutexGuard
guard( Mutex::getGlobalMutex() );
106 static Sequence
< OUString
> seqNames(1);
107 seqNames
.getArray()[0] = OUString(
108 RTL_CONSTASCII_USTRINGPARAM("com.sun.star.lang.MultiServiceFactory") );
115 OUString
smgr_wrapper_getImplementationName()
117 static OUString
*pImplName
= 0;
120 MutexGuard
guard( Mutex::getGlobalMutex() );
123 static OUString
implName(
124 RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.stoc.OServiceManagerWrapper" ) );
125 pImplName
= &implName
;
131 Sequence
< OUString
> smgr_getSupportedServiceNames()
133 static Sequence
< OUString
> *pNames
= 0;
136 MutexGuard
guard( Mutex::getGlobalMutex() );
139 static Sequence
< OUString
> seqNames(2);
140 seqNames
.getArray()[0] = OUString(
141 RTL_CONSTASCII_USTRINGPARAM("com.sun.star.lang.MultiServiceFactory") );
142 seqNames
.getArray()[1] = OUString(
143 RTL_CONSTASCII_USTRINGPARAM("com.sun.star.lang.ServiceManager") );
150 OUString
smgr_getImplementationName()
152 static OUString
*pImplName
= 0;
155 MutexGuard
guard( Mutex::getGlobalMutex() );
158 static OUString
implName(
159 RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.stoc.OServiceManager" ) );
160 pImplName
= &implName
;
166 Sequence
< OUString
> regsmgr_getSupportedServiceNames()
168 static Sequence
< OUString
> *pNames
= 0;
171 MutexGuard
guard( Mutex::getGlobalMutex() );
174 static Sequence
< OUString
> seqNames(2);
175 seqNames
.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.lang.MultiServiceFactory"));
176 seqNames
.getArray()[1] = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.lang.RegistryServiceManager"));
183 OUString
regsmgr_getImplementationName()
185 static OUString
*pImplName
= 0;
188 MutexGuard
guard( Mutex::getGlobalMutex() );
191 static OUString
implName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.stoc.ORegistryServiceManager" ) );
192 pImplName
= &implName
;
201 static Sequence
< sal_Int8
> smgr_getImplementationId()
203 static OImplementationId
* s_pId
= 0;
206 MutexGuard
aGuard( Mutex::getGlobalMutex() );
209 static OImplementationId s_aId
;
213 return s_pId
->getImplementationId();
217 static Sequence
< OUString
> retrieveAsciiValueList(
218 const Reference
< XSimpleRegistry
> &xReg
, const OUString
&keyName
)
220 Reference
< XEnumerationAccess
> xAccess( xReg
, UNO_QUERY
);
221 Sequence
< OUString
> seq
;
224 Reference
< XEnumeration
> xEnum
= xAccess
->createEnumeration();
225 while( xEnum
.is() && xEnum
->hasMoreElements() )
227 Reference
< XSimpleRegistry
> xTempReg
;
228 xEnum
->nextElement() >>= xTempReg
;
231 Sequence
< OUString
> seq2
= retrieveAsciiValueList( xTempReg
, keyName
);
233 if( seq2
.getLength() )
235 sal_Int32 n1Len
= seq
.getLength();
236 sal_Int32 n2Len
= seq2
.getLength();
238 seq
.realloc( n1Len
+ n2Len
);
239 const OUString
*pSource
= seq2
.getConstArray();
240 OUString
*pTarget
= seq
.getArray();
241 for( int i
= 0 ; i
< n2Len
; i
++ )
243 pTarget
[i
+n1Len
] = pSource
[i
];
249 else if( xReg
.is () )
253 Reference
< XRegistryKey
> rRootKey
= xReg
->getRootKey();
256 Reference
<XRegistryKey
> xKey
= rRootKey
->openKey(keyName
);
259 seq
= xKey
->getAsciiListValue();
263 catch( InvalidRegistryException
& )
266 catch (InvalidValueException
&)
273 /*****************************************************************************
274 Enumeration by ServiceName
275 *****************************************************************************/
278 size_t operator()(const Reference
<XInterface
> & rName
) const
280 // query to XInterface. The cast to XInterface* must be the same for the same object
281 Reference
<XInterface
> x( Reference
<XInterface
>::query( rName
) );
282 return (size_t)x
.get();
286 struct equaltoRef_Impl
288 size_t operator()(const Reference
<XInterface
> & rName1
, const Reference
<XInterface
> & rName2
) const
289 { return rName1
== rName2
; }
294 Reference
<XInterface
>,
300 class ServiceEnumeration_Impl
: public WeakImplHelper1
< XEnumeration
>
303 ServiceEnumeration_Impl( const Sequence
< Reference
<XInterface
> > & rFactories
)
304 : aFactories( rFactories
)
306 { g_moduleCount
.modCnt
.acquire( &g_moduleCount
.modCnt
); }
307 virtual ~ServiceEnumeration_Impl()
308 { g_moduleCount
.modCnt
.release( &g_moduleCount
.modCnt
); }
311 sal_Bool SAL_CALL
hasMoreElements()
312 throw(::com::sun::star::uno::RuntimeException
);
313 Any SAL_CALL
nextElement()
314 throw(::com::sun::star::container::NoSuchElementException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
317 Sequence
< Reference
<XInterface
> > aFactories
;
322 sal_Bool
ServiceEnumeration_Impl::hasMoreElements() throw(::com::sun::star::uno::RuntimeException
)
324 MutexGuard
aGuard( aMutex
);
325 return nIt
!= aFactories
.getLength();
329 Any
ServiceEnumeration_Impl::nextElement()
330 throw(::com::sun::star::container::NoSuchElementException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
)
332 MutexGuard
aGuard( aMutex
);
333 if( nIt
== aFactories
.getLength() )
334 throw NoSuchElementException();
336 return Any( &aFactories
.getConstArray()[nIt
++], ::getCppuType( (const Reference
<XInterface
> *)0 ) );
339 //==================================================================================================
340 class PropertySetInfo_Impl
: public WeakImplHelper1
< beans::XPropertySetInfo
>
342 Sequence
< beans::Property
> m_properties
;
345 inline PropertySetInfo_Impl( Sequence
< beans::Property
> const & properties
) SAL_THROW( () )
346 : m_properties( properties
)
349 // XPropertySetInfo impl
350 virtual Sequence
< beans::Property
> SAL_CALL
getProperties()
351 throw (RuntimeException
);
352 virtual beans::Property SAL_CALL
getPropertyByName( OUString
const & name
)
353 throw (beans::UnknownPropertyException
, RuntimeException
);
354 virtual sal_Bool SAL_CALL
hasPropertyByName( OUString
const & name
)
355 throw (RuntimeException
);
357 //__________________________________________________________________________________________________
358 Sequence
< beans::Property
> PropertySetInfo_Impl::getProperties()
359 throw (RuntimeException
)
363 //__________________________________________________________________________________________________
364 beans::Property
PropertySetInfo_Impl::getPropertyByName( OUString
const & name
)
365 throw (beans::UnknownPropertyException
, RuntimeException
)
367 beans::Property
const * p
= m_properties
.getConstArray();
368 for ( sal_Int32 nPos
= m_properties
.getLength(); nPos
--; )
370 if (p
[ nPos
].Name
.equals( name
))
373 throw beans::UnknownPropertyException(
374 OUSTR("unknown property: ") + name
, Reference
< XInterface
>() );
376 //__________________________________________________________________________________________________
377 sal_Bool
PropertySetInfo_Impl::hasPropertyByName( OUString
const & name
)
378 throw (RuntimeException
)
380 beans::Property
const * p
= m_properties
.getConstArray();
381 for ( sal_Int32 nPos
= m_properties
.getLength(); nPos
--; )
383 if (p
[ nPos
].Name
.equals( name
))
390 /*****************************************************************************
391 Enumeration by implementation
392 *****************************************************************************/
393 class ImplementationEnumeration_Impl
: public WeakImplHelper1
< XEnumeration
>
396 ImplementationEnumeration_Impl( const HashSet_Ref
& rImplementationMap
)
397 : aImplementationMap( rImplementationMap
)
398 , aIt( aImplementationMap
.begin() )
400 g_moduleCount
.modCnt
.acquire( &g_moduleCount
.modCnt
);
402 virtual ~ImplementationEnumeration_Impl();
405 virtual sal_Bool SAL_CALL
hasMoreElements()
406 throw(::com::sun::star::uno::RuntimeException
);
407 virtual Any SAL_CALL
nextElement()
408 throw(::com::sun::star::container::NoSuchElementException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
412 HashSet_Ref aImplementationMap
;
413 HashSet_Ref::iterator aIt
;
415 Reference
<XInterface
> xNext
;
418 ImplementationEnumeration_Impl::~ImplementationEnumeration_Impl()
420 g_moduleCount
.modCnt
.release( &g_moduleCount
.modCnt
);
424 sal_Bool
ImplementationEnumeration_Impl::hasMoreElements()
425 throw(::com::sun::star::uno::RuntimeException
)
427 MutexGuard
aGuard( aMutex
);
428 return aIt
!= aImplementationMap
.end();
432 Any
ImplementationEnumeration_Impl::nextElement()
433 throw(::com::sun::star::container::NoSuchElementException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
)
435 MutexGuard
aGuard( aMutex
);
436 if( aIt
== aImplementationMap
.end() )
437 throw NoSuchElementException();
439 Any
ret( &(*aIt
), ::getCppuType( (const Reference
<XInterface
> *)0 ) );
444 /*****************************************************************************
446 *****************************************************************************/
447 struct equalOWString_Impl
449 sal_Bool
operator()(const OUString
& s1
, const OUString
& s2
) const
453 struct hashOWString_Impl
455 size_t operator()(const OUString
& rName
) const
456 { return rName
.hashCode(); }
466 typedef hash_multimap
469 Reference
<XInterface
>,
472 > HashMultimap_OWString_Interface
;
477 Reference
<XInterface
>,
480 > HashMap_OWString_Interface
;
482 /*****************************************************************************
483 class OServiceManager_Listener
484 *****************************************************************************/
485 class OServiceManager_Listener
: public WeakImplHelper1
< XEventListener
>
488 WeakReference
<XSet
> xSMgr
;
491 OServiceManager_Listener( const Reference
<XSet
> & rSMgr
)
496 virtual void SAL_CALL
disposing(const EventObject
& rEvt
) throw(::com::sun::star::uno::RuntimeException
);
499 void OServiceManager_Listener::disposing(const EventObject
& rEvt
)
500 throw(::com::sun::star::uno::RuntimeException
)
502 Reference
<XSet
> x( xSMgr
);
507 x
->remove( Any( &rEvt
.Source
, ::getCppuType( (const Reference
<XInterface
> *)0 ) ) );
509 catch( const IllegalArgumentException
& )
511 OSL_ENSURE( sal_False
, "IllegalArgumentException catched" );
513 catch( const NoSuchElementException
& )
515 OSL_ENSURE( sal_False
, "NoSuchElementException catched" );
521 /*****************************************************************************
522 class OServiceManager
523 *****************************************************************************/
524 struct OServiceManagerMutex
529 extern "C" void SAL_CALL
smgrUnloadingListener(void* id
);
531 typedef WeakComponentImplHelper8
<
532 lang::XMultiServiceFactory
, lang::XMultiComponentFactory
, lang::XServiceInfo
,
533 lang::XInitialization
, lang::XUnoTunnel
,
534 container::XSet
, container::XContentEnumerationAccess
,
535 beans::XPropertySet
> t_OServiceManager_impl
;
537 class OServiceManager
538 : public OServiceManagerMutex
539 , public t_OServiceManager_impl
542 friend void SAL_CALL
smgrUnloadingListener(void* id
);
544 OServiceManager( Reference
< XComponentContext
> const & xContext
);
545 virtual ~OServiceManager();
548 sal_Int64 SAL_CALL
getSomething( Sequence
< sal_Int8
> const & id
)
549 throw (RuntimeException
);
552 void SAL_CALL
initialize( Sequence
< Any
> const & args
)
556 virtual OUString SAL_CALL
getImplementationName() throw(::com::sun::star::uno::RuntimeException
);
557 static OUString
getImplementationName_Static() throw(::com::sun::star::uno::RuntimeException
)
558 { return stoc_bootstrap::smgr_getImplementationName(); }
559 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) throw(::com::sun::star::uno::RuntimeException
);
560 virtual Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException
);
562 // XMultiComponentFactory
563 virtual Reference
< XInterface
> SAL_CALL
createInstanceWithContext(
564 OUString
const & rServiceSpecifier
, Reference
< XComponentContext
> const & xContext
)
565 throw (Exception
, RuntimeException
);
566 virtual Reference
< XInterface
> SAL_CALL
createInstanceWithArgumentsAndContext(
567 OUString
const & rServiceSpecifier
,
568 Sequence
< Any
> const & rArguments
,
569 Reference
< XComponentContext
> const & xContext
)
570 throw (Exception
, RuntimeException
);
571 // virtual Sequence< OUString > SAL_CALL getAvailableServiceNames()
572 // throw (RuntimeException);
574 // XMultiServiceFactory
575 virtual Sequence
< OUString
> SAL_CALL
getAvailableServiceNames() throw(::com::sun::star::uno::RuntimeException
);
576 virtual Reference
<XInterface
> SAL_CALL
createInstance(const OUString
&) throw(::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
);
577 virtual Reference
<XInterface
> SAL_CALL
createInstanceWithArguments(const OUString
&, const Sequence
<Any
>& Arguments
) throw(::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
);
579 // The same as the getAvailableServiceNames, but only uique names
580 Sequence
< OUString
> getUniqueAvailableServiceNames(
581 HashSet_OWString
& aNameSet
);
584 virtual Type SAL_CALL
getElementType() throw(::com::sun::star::uno::RuntimeException
);
585 virtual sal_Bool SAL_CALL
hasElements() throw(::com::sun::star::uno::RuntimeException
);
587 // XEnumerationAccess
588 virtual Reference
<XEnumeration
> SAL_CALL
createEnumeration() throw(::com::sun::star::uno::RuntimeException
);
591 virtual sal_Bool SAL_CALL
has( const Any
& Element
) throw(::com::sun::star::uno::RuntimeException
);
592 virtual void SAL_CALL
insert( const Any
& Element
) throw(::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::container::ElementExistException
, ::com::sun::star::uno::RuntimeException
);
593 virtual void SAL_CALL
remove( const Any
& Element
) throw(::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::container::NoSuchElementException
, ::com::sun::star::uno::RuntimeException
);
595 // XContentEnumerationAccess
596 //Sequence< OUString > getAvailableServiceNames() throw( (Exception) );
597 virtual Reference
<XEnumeration
> SAL_CALL
createContentEnumeration(const OUString
& aServiceName
) throw(::com::sun::star::uno::RuntimeException
);
598 virtual Reference
<XEnumeration
> SAL_CALL
createContentEnumeration(
599 const OUString
& aServiceName
, Reference
< XComponentContext
> const & xContext
)
600 throw(::com::sun::star::uno::RuntimeException
);
603 virtual void SAL_CALL
dispose() throw(::com::sun::star::uno::RuntimeException
);
606 Reference
<XPropertySetInfo
> SAL_CALL
getPropertySetInfo()
607 throw(::com::sun::star::uno::RuntimeException
);
608 void SAL_CALL
setPropertyValue(const OUString
& PropertyName
, const Any
& aValue
)
609 throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::beans::PropertyVetoException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
610 Any SAL_CALL
getPropertyValue(const OUString
& PropertyName
)
611 throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
612 void SAL_CALL
addPropertyChangeListener(const OUString
& PropertyName
, const Reference
<XPropertyChangeListener
>& aListener
)
613 throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
614 void SAL_CALL
removePropertyChangeListener(const OUString
& PropertyName
, const Reference
<XPropertyChangeListener
>& aListener
)
615 throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
616 void SAL_CALL
addVetoableChangeListener(const OUString
& PropertyName
, const Reference
<XVetoableChangeListener
>& aListener
)
617 throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
618 void SAL_CALL
removeVetoableChangeListener(const OUString
& PropertyName
, const Reference
<XVetoableChangeListener
>& aListener
)
619 throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
622 inline bool is_disposed() const SAL_THROW( (lang::DisposedException
) );
623 inline void check_undisposed() const SAL_THROW( (lang::DisposedException
) );
624 virtual void SAL_CALL
disposing();
626 sal_Bool
haveFactoryWithThisImplementation(const OUString
& aImplName
);
628 virtual Sequence
< Reference
< XInterface
> > queryServiceFactories(
629 const OUString
& aServiceName
, Reference
< XComponentContext
> const & xContext
);
631 Reference
< XComponentContext
> m_xContext
;
633 Reference
< beans::XPropertySetInfo
> m_xPropertyInfo
;
635 sal_Int32 m_nUnloadingListenerId
;
637 // Does clean up when the unloading mechanism has been set off. It is called from
638 // the listener function smgrUnloadingListener.
639 void onUnloadingNotify();
640 // factories which have been loaded and not inserted( by XSet::insert)
641 // are remembered by this set. Those factories
642 // are not released on a call to onUnloadingNotify
643 HashSet_Ref m_SetLoadedFactories
;
646 Reference
<XEventListener
> getFactoryListener();
649 HashMultimap_OWString_Interface m_ServiceMap
;
650 HashSet_Ref m_ImplementationMap
;
651 HashMap_OWString_Interface m_ImplementationNameMap
;
652 Reference
<XEventListener
> xFactoryListener
;
657 //______________________________________________________________________________
658 inline bool OServiceManager::is_disposed() const
659 SAL_THROW( (lang::DisposedException
) )
661 // ought to be guarded by m_mutex:
662 return (m_bInDisposing
|| rBHelper
.bDisposed
);
665 //______________________________________________________________________________
666 inline void OServiceManager::check_undisposed() const
667 SAL_THROW( (lang::DisposedException
) )
671 throw lang::DisposedException(
672 OUSTR("service manager instance has already been disposed!"),
673 (OWeakObject
*)this );
677 //##################################################################################################
678 //##################################################################################################
679 //##################################################################################################
681 class OServiceManagerWrapper
: public OServiceManagerMutex
, public t_OServiceManager_impl
683 Reference
< XComponentContext
> m_xContext
;
684 OServiceManager
* m_root
;
685 inline OServiceManager
* getRoot() SAL_THROW( (RuntimeException
) )
689 throw lang::DisposedException(
690 OUSTR("service manager instance has already been disposed!"),
691 Reference
< XInterface
>() );
697 virtual void SAL_CALL
disposing();
700 OServiceManagerWrapper(
701 Reference
< XComponentContext
> const & xContext
)
702 SAL_THROW( (RuntimeException
) );
703 virtual ~OServiceManagerWrapper() SAL_THROW( () );
706 sal_Int64 SAL_CALL
getSomething( Sequence
< sal_Int8
> const & id
) throw (RuntimeException
)
707 { return getRoot()->getSomething( id
); }
710 void SAL_CALL
initialize( Sequence
< Any
> const & args
) throw (Exception
)
711 { getRoot()->initialize( args
); }
714 virtual OUString SAL_CALL
getImplementationName() throw (RuntimeException
)
715 { return getRoot()->getImplementationName(); }
716 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) throw (RuntimeException
)
717 { return getRoot()->supportsService( ServiceName
); }
718 virtual Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() throw (RuntimeException
)
719 { return getRoot()->getSupportedServiceNames(); }
721 // XMultiComponentFactory
722 virtual Reference
< XInterface
> SAL_CALL
createInstanceWithContext(
723 OUString
const & rServiceSpecifier
, Reference
< XComponentContext
> const & xContext
)
724 throw (Exception
, RuntimeException
)
725 { return getRoot()->createInstanceWithContext( rServiceSpecifier
, xContext
); }
726 virtual Reference
< XInterface
> SAL_CALL
createInstanceWithArgumentsAndContext(
727 OUString
const & rServiceSpecifier
,
728 Sequence
< Any
> const & rArguments
,
729 Reference
< XComponentContext
> const & xContext
)
730 throw (Exception
, RuntimeException
)
731 { return getRoot()->createInstanceWithArgumentsAndContext( rServiceSpecifier
, rArguments
, xContext
); }
732 // virtual Sequence< OUString > SAL_CALL getAvailableServiceNames()
733 // throw (RuntimeException);
735 // XMultiServiceFactory
736 virtual Sequence
< OUString
> SAL_CALL
getAvailableServiceNames() throw (RuntimeException
)
737 { return getRoot()->getAvailableServiceNames(); }
738 virtual Reference
<XInterface
> SAL_CALL
createInstance(const OUString
& name
) throw (Exception
)
739 { return getRoot()->createInstanceWithContext( name
, m_xContext
); }
740 virtual Reference
<XInterface
> SAL_CALL
createInstanceWithArguments(const OUString
& name
, const Sequence
<Any
>& Arguments
) throw (Exception
)
741 { return getRoot()->createInstanceWithArgumentsAndContext( name
, Arguments
, m_xContext
); }
744 virtual Type SAL_CALL
getElementType() throw (RuntimeException
)
745 { return getRoot()->getElementType(); }
746 virtual sal_Bool SAL_CALL
hasElements() throw (RuntimeException
)
747 { return getRoot()->hasElements(); }
749 // XEnumerationAccess
750 virtual Reference
<XEnumeration
> SAL_CALL
createEnumeration() throw (RuntimeException
)
751 { return getRoot()->createEnumeration(); }
754 virtual sal_Bool SAL_CALL
has( const Any
& Element
) throw (RuntimeException
)
755 { return getRoot()->has( Element
); }
756 virtual void SAL_CALL
insert( const Any
& Element
) throw (lang::IllegalArgumentException
, container::ElementExistException
, RuntimeException
)
757 { getRoot()->insert( Element
); }
758 virtual void SAL_CALL
remove( const Any
& Element
) throw (lang::IllegalArgumentException
, container::NoSuchElementException
, RuntimeException
)
759 { getRoot()->remove( Element
); }
761 // XContentEnumerationAccess
762 //Sequence< OUString > getAvailableServiceNames() throw( (Exception) );
763 virtual Reference
<XEnumeration
> SAL_CALL
createContentEnumeration(const OUString
& aServiceName
) throw (RuntimeException
)
764 { return getRoot()->createContentEnumeration( aServiceName
, m_xContext
); }
767 Reference
<XPropertySetInfo
> SAL_CALL
getPropertySetInfo() throw (RuntimeException
)
768 { return getRoot()->getPropertySetInfo(); }
770 void SAL_CALL
setPropertyValue(const OUString
& PropertyName
, const Any
& aValue
)
771 throw (beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, RuntimeException
);
772 Any SAL_CALL
getPropertyValue(const OUString
& PropertyName
)
773 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, RuntimeException
);
775 void SAL_CALL
addPropertyChangeListener(const OUString
& PropertyName
, const Reference
<XPropertyChangeListener
>& aListener
)
776 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, RuntimeException
)
777 { getRoot()->addPropertyChangeListener( PropertyName
, aListener
); }
778 void SAL_CALL
removePropertyChangeListener(const OUString
& PropertyName
, const Reference
<XPropertyChangeListener
>& aListener
)
779 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, RuntimeException
)
780 { getRoot()->removePropertyChangeListener( PropertyName
, aListener
); }
781 void SAL_CALL
addVetoableChangeListener(const OUString
& PropertyName
, const Reference
<XVetoableChangeListener
>& aListener
)
782 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, RuntimeException
)
783 { getRoot()->addVetoableChangeListener( PropertyName
, aListener
); }
784 void SAL_CALL
removeVetoableChangeListener(const OUString
& PropertyName
, const Reference
<XVetoableChangeListener
>& aListener
)
785 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, RuntimeException
)
786 { getRoot()->removeVetoableChangeListener( PropertyName
, aListener
); }
788 //__________________________________________________________________________________________________
789 void SAL_CALL
OServiceManagerWrapper::setPropertyValue(
790 const OUString
& PropertyName
, const Any
& aValue
)
791 throw (beans::UnknownPropertyException
, beans::PropertyVetoException
,
792 lang::IllegalArgumentException
, lang::WrappedTargetException
, RuntimeException
)
794 if (PropertyName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("DefaultContext") ))
796 Reference
< XComponentContext
> xContext
;
797 if (aValue
>>= xContext
)
799 MutexGuard
aGuard( m_mutex
);
800 m_xContext
= xContext
;
804 throw IllegalArgumentException(
805 OUString( RTL_CONSTASCII_USTRINGPARAM("no XComponentContext given!") ),
806 (OWeakObject
*)this, 1 );
811 getRoot()->setPropertyValue( PropertyName
, aValue
);
814 //__________________________________________________________________________________________________
815 Any SAL_CALL
OServiceManagerWrapper::getPropertyValue(
816 const OUString
& PropertyName
)
817 throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, RuntimeException
)
819 if (PropertyName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("DefaultContext") ))
821 MutexGuard
aGuard( m_mutex
);
822 if( m_xContext
.is() )
823 return makeAny( m_xContext
);
829 return getRoot()->getPropertyValue( PropertyName
);
832 //__________________________________________________________________________________________________
833 void OServiceManagerWrapper::disposing()
839 // no m_root->dispose(), because every context disposes its service manager...
844 //__________________________________________________________________________________________________
845 OServiceManagerWrapper::~OServiceManagerWrapper() SAL_THROW( () )
853 g_moduleCount
.modCnt
.release( &g_moduleCount
.modCnt
);
855 //__________________________________________________________________________________________________
856 OServiceManagerWrapper::OServiceManagerWrapper(
857 Reference
< XComponentContext
> const & xContext
)
858 SAL_THROW( (RuntimeException
) )
859 : t_OServiceManager_impl( m_mutex
)
860 , m_xContext( xContext
)
863 g_moduleCount
.modCnt
.acquire( &g_moduleCount
.modCnt
);
865 Reference
< XUnoTunnel
> xTunnel( m_xContext
->getServiceManager(), UNO_QUERY
);
866 OSL_ASSERT( xTunnel
.is() );
869 m_root
= reinterpret_cast< OServiceManager
* >(
870 xTunnel
->getSomething( smgr_getImplementationId() ) );
871 OSL_ASSERT( m_root
);
880 throw RuntimeException(
881 OUString( RTL_CONSTASCII_USTRINGPARAM("can only wrap OServiceManager instances!") ),
882 Reference
< XInterface
>() );
886 //##################################################################################################
887 //##################################################################################################
888 //##################################################################################################
891 sal_Int64
OServiceManager::getSomething( Sequence
< sal_Int8
> const & id
)
892 throw (RuntimeException
)
895 if (id
== smgr_getImplementationId())
896 return reinterpret_cast< sal_Int64
>(this);
902 * Create a ServiceManager
904 OServiceManager::OServiceManager( Reference
< XComponentContext
> const & xContext
)
905 : t_OServiceManager_impl( m_mutex
)
906 , m_xContext( xContext
)
907 , m_bInDisposing( false )
909 g_moduleCount
.modCnt
.acquire( &g_moduleCount
.modCnt
);
910 m_nUnloadingListenerId
= rtl_addUnloadingListener( smgrUnloadingListener
, this);
914 * Destroy the ServiceManager
916 OServiceManager::~OServiceManager()
918 if( m_nUnloadingListenerId
!= 0)
919 rtl_removeUnloadingListener( m_nUnloadingListenerId
);
921 g_moduleCount
.modCnt
.release( &g_moduleCount
.modCnt
);
924 // Removes entries in m_ServiceMap, m_ImplementationNameMap and m_ImplementationNameMap
925 // if those entries have not been inserted through XSet::insert. Therefore the entries
926 // are compared with the entries in m_SetLoadedFactories.
927 void OServiceManager::onUnloadingNotify()
929 MutexGuard
aGuard( m_mutex
);
931 typedef HashSet_Ref::const_iterator CIT_S
;
932 typedef HashMultimap_OWString_Interface::iterator IT_MM
;
934 CIT_S it_SetEnd
= m_SetLoadedFactories
.end();
935 IT_MM it_end1
= m_ServiceMap
.end();
936 list
<IT_MM
> listDeleteServiceMap
;
937 typedef list
<IT_MM
>::const_iterator CIT_DMM
;
938 // find occurences in m_ServiceMap
939 for(IT_MM it_i1
= m_ServiceMap
.begin(); it_i1
!= it_end1
; it_i1
++)
941 if( m_SetLoadedFactories
.find( it_i1
->second
) != it_SetEnd
)
943 Reference
<XUnloadingPreference
> xunl( it_i1
->second
, UNO_QUERY
);
946 if( xunl
->releaseOnNotification())
947 listDeleteServiceMap
.push_front( it_i1
);
950 listDeleteServiceMap
.push_front( it_i1
);
953 // delete elements from m_ServiceMap
954 CIT_DMM it_end2
= listDeleteServiceMap
.end();
955 for( CIT_DMM it_i2
= listDeleteServiceMap
.begin(); it_i2
!= it_end2
; it_i2
++)
956 m_ServiceMap
.erase( *it_i2
);
958 // find elements in m_ImplementationNameMap
959 typedef HashMap_OWString_Interface::iterator IT_M
;
960 IT_M it_end3
= m_ImplementationNameMap
.end();
961 list
<IT_M
> listDeleteImplementationNameMap
;
962 typedef list
<IT_M
>::const_iterator CIT_DM
;
963 for( IT_M it_i3
= m_ImplementationNameMap
.begin(); it_i3
!= it_end3
; it_i3
++)
965 if( m_SetLoadedFactories
.find( it_i3
->second
) != it_SetEnd
)
967 Reference
<XUnloadingPreference
> xunl( it_i3
->second
, UNO_QUERY
);
970 if( xunl
->releaseOnNotification())
971 listDeleteImplementationNameMap
.push_front( it_i3
);
974 listDeleteImplementationNameMap
.push_front( it_i3
);
977 // delete elements from m_ImplementationNameMap
978 CIT_DM it_end4
= listDeleteImplementationNameMap
.end();
979 for( CIT_DM it_i4
= listDeleteImplementationNameMap
.begin(); it_i4
!= it_end4
; it_i4
++)
980 m_ImplementationNameMap
.erase( *it_i4
);
982 // find elements in m_ImplementationMap
983 typedef HashSet_Ref::iterator IT_S
;
984 IT_S it_end5
= m_ImplementationMap
.end();
985 list
<IT_S
> listDeleteImplementationMap
;
986 typedef list
<IT_S
>::const_iterator CIT_DS
;
987 for( IT_S it_i5
= m_ImplementationMap
.begin(); it_i5
!= it_end5
; it_i5
++)
989 if( m_SetLoadedFactories
.find( *it_i5
) != it_SetEnd
)
991 Reference
<XUnloadingPreference
> xunl( *it_i5
, UNO_QUERY
);
994 if( xunl
->releaseOnNotification())
995 listDeleteImplementationMap
.push_front( it_i5
);
998 listDeleteImplementationMap
.push_front( it_i5
);
1001 // delete elements from m_ImplementationMap
1002 CIT_DS it_end6
= listDeleteImplementationMap
.end();
1003 for( CIT_DS it_i6
= listDeleteImplementationMap
.begin(); it_i6
!= it_end6
; it_i6
++)
1004 m_ImplementationMap
.erase( *it_i6
);
1006 // remove Event listener before the factories are released.
1007 IT_S it_end7
= m_SetLoadedFactories
.end();
1009 Reference
<XEventListener
> xlistener
= getFactoryListener();
1010 for( IT_S it_i7
= m_SetLoadedFactories
.begin(); it_i7
!= it_end7
; it_i7
++)
1012 Reference
<XComponent
> xcomp( *it_i7
, UNO_QUERY
);
1014 xcomp
->removeEventListener( xlistener
);
1016 // release the factories in m_SetLoadedFactories
1017 m_SetLoadedFactories
.clear();
1021 void OServiceManager::dispose()
1022 throw(::com::sun::star::uno::RuntimeException
)
1024 if (rBHelper
.bDisposed
|| rBHelper
.bInDispose
)
1026 t_OServiceManager_impl::dispose();
1029 void OServiceManager::disposing()
1031 // dispose all factories
1034 MutexGuard
aGuard( m_mutex
);
1035 m_bInDisposing
= true;
1036 aImpls
= m_ImplementationMap
;
1038 HashSet_Ref::iterator aIt
= aImpls
.begin();
1039 while( aIt
!= aImpls
.end() )
1043 Reference
<XComponent
> xComp( Reference
<XComponent
>::query( *aIt
++ ) );
1047 catch (RuntimeException
& exc
)
1049 #if OSL_DEBUG_LEVEL > 1
1050 OString
str( OUStringToOString( exc
.Message
, RTL_TEXTENCODING_ASCII_US
) );
1051 OSL_TRACE( "### RuntimeException occured upon disposing factory: %s", str
.getStr() );
1053 (void) exc
; // unused
1059 HashSet_Ref aImplMap
;
1061 MutexGuard
aGuard( m_mutex
);
1062 // erase all members
1063 m_ServiceMap
= HashMultimap_OWString_Interface();
1064 aImplMap
= m_ImplementationMap
;
1065 m_ImplementationMap
= HashSet_Ref();
1066 m_ImplementationNameMap
= HashMap_OWString_Interface();
1067 m_SetLoadedFactories
= HashSet_Ref();
1072 // not only the Event should hold the object
1073 OSL_ASSERT( m_refCount
!= 1 );
1075 // Revoke this service manager as unloading listener
1076 rtl_removeUnloadingListener( m_nUnloadingListenerId
);
1077 m_nUnloadingListenerId
=0;
1081 Reference
<XPropertySetInfo
> OServiceManager::getPropertySetInfo()
1082 throw(::com::sun::star::uno::RuntimeException
)
1085 if (! m_xPropertyInfo
.is())
1087 Sequence
< beans::Property
> seq( 1 );
1088 seq
[ 0 ] = beans::Property(
1089 OUSTR("DefaultContext"), -1, ::getCppuType( &m_xContext
), 0 );
1090 Reference
< beans::XPropertySetInfo
> xInfo( new PropertySetInfo_Impl( seq
) );
1092 MutexGuard
aGuard( m_mutex
);
1093 if (! m_xPropertyInfo
.is())
1095 m_xPropertyInfo
= xInfo
;
1098 return m_xPropertyInfo
;
1101 void OServiceManager::setPropertyValue(
1102 const OUString
& PropertyName
, const Any
& aValue
)
1103 throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::beans::PropertyVetoException
, ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
)
1106 if (PropertyName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("DefaultContext") ))
1108 Reference
< XComponentContext
> xContext
;
1109 if (aValue
>>= xContext
)
1111 MutexGuard
aGuard( m_mutex
);
1112 m_xContext
= xContext
;
1116 throw IllegalArgumentException(
1117 OUString( RTL_CONSTASCII_USTRINGPARAM("no XComponentContext given!") ),
1118 (OWeakObject
*)this, 1 );
1123 throw UnknownPropertyException(
1124 OUString( RTL_CONSTASCII_USTRINGPARAM("unknown property ") ) + PropertyName
,
1125 (OWeakObject
*)this );
1129 Any
OServiceManager::getPropertyValue(const OUString
& PropertyName
)
1130 throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
)
1133 if (PropertyName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("DefaultContext") ))
1135 MutexGuard
aGuard( m_mutex
);
1136 if( m_xContext
.is() )
1137 return makeAny( m_xContext
);
1143 UnknownPropertyException except
;
1144 except
.Message
= OUString( RTL_CONSTASCII_USTRINGPARAM( "ServiceManager : unknown property " ) );
1145 except
.Message
+= PropertyName
;
1150 void OServiceManager::addPropertyChangeListener(
1151 const OUString
&, const Reference
<XPropertyChangeListener
>&)
1152 throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
)
1155 throw UnknownPropertyException();
1158 void OServiceManager::removePropertyChangeListener(
1159 const OUString
&, const Reference
<XPropertyChangeListener
>&)
1160 throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
)
1163 throw UnknownPropertyException();
1166 void OServiceManager::addVetoableChangeListener(
1167 const OUString
&, const Reference
<XVetoableChangeListener
>&)
1168 throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
)
1171 throw UnknownPropertyException();
1174 void OServiceManager::removeVetoableChangeListener(
1175 const OUString
&, const Reference
<XVetoableChangeListener
>&)
1176 throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
)
1179 throw UnknownPropertyException();
1183 Reference
<XEventListener
> OServiceManager::getFactoryListener()
1186 MutexGuard
aGuard( m_mutex
);
1187 if( !xFactoryListener
.is() )
1188 xFactoryListener
= new OServiceManager_Listener( this );
1189 return xFactoryListener
;
1192 // XMultiServiceFactory, XContentEnumeration
1193 Sequence
< OUString
> OServiceManager::getUniqueAvailableServiceNames(
1194 HashSet_OWString
& aNameSet
)
1197 MutexGuard
aGuard( m_mutex
);
1198 HashMultimap_OWString_Interface::iterator aSIt
= m_ServiceMap
.begin();
1199 while( aSIt
!= m_ServiceMap
.end() )
1200 aNameSet
.insert( (*aSIt
++).first
);
1202 /* do not return the implementation names
1203 HashMap_OWString_Interface m_ImplementationNameMap;
1204 HashMap_OWString_Interface::iterator aIt = m_ImplementationNameMap.begin();
1205 while( aIt != m_ImplementationNameMap.end() )
1206 aNameSet.insert( (*aIt++).first );
1209 Sequence
< OUString
> aNames( aNameSet
.size() );
1210 OUString
* pArray
= aNames
.getArray();
1212 HashSet_OWString::iterator next
= aNameSet
.begin();
1213 while( next
!= aNameSet
.end() )
1214 pArray
[i
++] = (*next
++);
1219 // XMultiComponentFactory
1220 Reference
< XInterface
> OServiceManager::createInstanceWithContext(
1221 OUString
const & rServiceSpecifier
,
1222 Reference
< XComponentContext
> const & xContext
)
1223 throw (Exception
, RuntimeException
)
1226 #if OSL_DEBUG_LEVEL > 0
1227 Reference
< beans::XPropertySet
> xProps( xContext
->getServiceManager(), UNO_QUERY
);
1228 OSL_ASSERT( xProps
.is() );
1231 Reference
< XComponentContext
> xDefContext
;
1232 xProps
->getPropertyValue(
1233 OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ) >>= xDefContext
;
1235 xContext
== xDefContext
,
1236 "### default context of service manager singleton differs from context holding it!" );
1240 Sequence
< Reference
< XInterface
> > factories(
1241 queryServiceFactories( rServiceSpecifier
, xContext
) );
1242 Reference
< XInterface
> const * p
= factories
.getConstArray();
1243 for ( sal_Int32 nPos
= 0; nPos
< factories
.getLength(); ++nPos
)
1247 Reference
< XInterface
> const & xFactory
= p
[ nPos
];
1250 Reference
< XSingleComponentFactory
> xFac( xFactory
, UNO_QUERY
);
1253 return xFac
->createInstanceWithContext( xContext
);
1257 Reference
< XSingleServiceFactory
> xFac2( xFactory
, UNO_QUERY
);
1260 #if OSL_DEBUG_LEVEL > 1
1261 OString
aStr( OUStringToOString( rServiceSpecifier
, RTL_TEXTENCODING_ASCII_US
) );
1262 OSL_TRACE( "### ignoring given context raising service %s !!!\n", aStr
.getStr() );
1264 return xFac2
->createInstance();
1269 catch (lang::DisposedException
& exc
)
1271 #if OSL_DEBUG_LEVEL > 1
1272 OString
str( OUStringToOString( exc
.Message
, RTL_TEXTENCODING_ASCII_US
) );
1273 OSL_TRACE( "### DisposedException occured: %s", str
.getStr() );
1275 (void) exc
; // unused
1280 return Reference
< XInterface
>();
1282 // XMultiComponentFactory
1283 Reference
< XInterface
> OServiceManager::createInstanceWithArgumentsAndContext(
1284 OUString
const & rServiceSpecifier
,
1285 Sequence
< Any
> const & rArguments
,
1286 Reference
< XComponentContext
> const & xContext
)
1287 throw (Exception
, RuntimeException
)
1290 #if OSL_DEBUG_LEVEL > 0
1291 Reference
< beans::XPropertySet
> xProps( xContext
->getServiceManager(), UNO_QUERY
);
1292 OSL_ASSERT( xProps
.is() );
1295 Reference
< XComponentContext
> xDefContext
;
1296 xProps
->getPropertyValue(
1297 OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ) >>= xDefContext
;
1299 xContext
== xDefContext
,
1300 "### default context of service manager singleton differs from context holding it!" );
1304 Sequence
< Reference
< XInterface
> > factories(
1305 queryServiceFactories( rServiceSpecifier
, xContext
) );
1306 Reference
< XInterface
> const * p
= factories
.getConstArray();
1307 for ( sal_Int32 nPos
= 0; nPos
< factories
.getLength(); ++nPos
)
1311 Reference
< XInterface
> const & xFactory
= p
[ nPos
];
1314 Reference
< XSingleComponentFactory
> xFac( xFactory
, UNO_QUERY
);
1317 return xFac
->createInstanceWithArgumentsAndContext( rArguments
, xContext
);
1321 Reference
< XSingleServiceFactory
> xFac2( xFactory
, UNO_QUERY
);
1324 #if OSL_DEBUG_LEVEL > 1
1325 OString
aStr( OUStringToOString( rServiceSpecifier
, RTL_TEXTENCODING_ASCII_US
) );
1326 OSL_TRACE( "### ignoring given context raising service %s !!!\n", aStr
.getStr() );
1328 return xFac2
->createInstanceWithArguments( rArguments
);
1333 catch (lang::DisposedException
& exc
)
1335 #if OSL_DEBUG_LEVEL > 1
1336 OString
str( OUStringToOString( exc
.Message
, RTL_TEXTENCODING_ASCII_US
) );
1337 OSL_TRACE( "### DisposedException occured: %s", str
.getStr() );
1339 (void) exc
; // unused
1344 return Reference
< XInterface
>();
1347 // XMultiServiceFactory, XMultiComponentFactory, XContentEnumeration
1348 Sequence
< OUString
> OServiceManager::getAvailableServiceNames()
1349 throw(::com::sun::star::uno::RuntimeException
)
1353 HashSet_OWString aNameSet
;
1354 return getUniqueAvailableServiceNames( aNameSet
);
1357 // XMultibleServiceFactory
1358 Reference
<XInterface
> OServiceManager::createInstance(
1359 const OUString
& rServiceSpecifier
)
1360 throw(::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
)
1362 return createInstanceWithContext(
1363 rServiceSpecifier
, m_xContext
);
1366 // XMultibleServiceFactory
1367 Reference
<XInterface
> OServiceManager::createInstanceWithArguments(
1368 const OUString
& rServiceSpecifier
,
1369 const Sequence
<Any
>& rArguments
)
1370 throw(::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
)
1372 return createInstanceWithArgumentsAndContext(
1373 rServiceSpecifier
, rArguments
, m_xContext
);
1377 void OServiceManager::initialize( Sequence
< Any
> const & )
1381 OSL_ENSURE( 0, "not impl!" );
1385 OUString
OServiceManager::getImplementationName()
1386 throw(::com::sun::star::uno::RuntimeException
)
1389 return getImplementationName_Static();
1393 sal_Bool
OServiceManager::supportsService(const OUString
& ServiceName
)
1394 throw(::com::sun::star::uno::RuntimeException
)
1397 Sequence
< OUString
> aSNL
= getSupportedServiceNames();
1398 const OUString
* pArray
= aSNL
.getConstArray();
1399 for( sal_Int32 i
= 0; i
< aSNL
.getLength(); i
++ )
1400 if( pArray
[i
] == ServiceName
)
1406 Sequence
< OUString
> OServiceManager::getSupportedServiceNames()
1407 throw(::com::sun::star::uno::RuntimeException
)
1410 return stoc_bootstrap::smgr_getSupportedServiceNames();
1414 Sequence
< Reference
< XInterface
> > OServiceManager::queryServiceFactories(
1415 const OUString
& aServiceName
, Reference
< XComponentContext
> const & )
1417 Sequence
< Reference
< XInterface
> > ret
;
1419 MutexGuard
aGuard( m_mutex
);
1421 HashMultimap_OWString_Interface::iterator
,
1422 HashMultimap_OWString_Interface::iterator
> p(
1423 m_ServiceMap
.equal_range( aServiceName
) );
1425 if (p
.first
== p
.second
) // no factories
1427 // no service found, look for an implementation
1428 HashMap_OWString_Interface::iterator aIt
= m_ImplementationNameMap
.find( aServiceName
);
1429 if( aIt
!= m_ImplementationNameMap
.end() )
1431 Reference
< XInterface
> const & x
= aIt
->second
;
1432 // an implementation found
1433 ret
= Sequence
< Reference
< XInterface
> >( &x
, 1 );
1438 ::std::vector
< Reference
< XInterface
> > vec
;
1440 while (p
.first
!= p
.second
)
1442 vec
.push_back( p
.first
->second
);
1445 ret
= Sequence
< Reference
< XInterface
> >(
1446 vec
.empty() ? 0 : &vec
[ 0 ], vec
.size() );
1452 // XContentEnumerationAccess
1453 Reference
<XEnumeration
> OServiceManager::createContentEnumeration(
1454 const OUString
& aServiceName
, Reference
< XComponentContext
> const & xContext
)
1455 throw(::com::sun::star::uno::RuntimeException
)
1458 Sequence
< Reference
< XInterface
> > factories(
1459 OServiceManager::queryServiceFactories( aServiceName
, xContext
) );
1460 if (factories
.getLength())
1461 return new ServiceEnumeration_Impl( factories
);
1463 return Reference
< XEnumeration
>();
1465 Reference
<XEnumeration
> OServiceManager::createContentEnumeration(
1466 const OUString
& aServiceName
)
1467 throw(::com::sun::star::uno::RuntimeException
)
1469 return createContentEnumeration( aServiceName
, m_xContext
);
1473 Reference
<XEnumeration
> OServiceManager::createEnumeration() throw(::com::sun::star::uno::RuntimeException
)
1476 MutexGuard
aGuard( m_mutex
);
1477 return new ImplementationEnumeration_Impl( m_ImplementationMap
);
1481 Type
OServiceManager::getElementType()
1482 throw(::com::sun::star::uno::RuntimeException
)
1485 return ::getCppuType( (const Reference
< XInterface
> *)0 );
1489 sal_Bool
OServiceManager::hasElements()
1490 throw(::com::sun::star::uno::RuntimeException
)
1493 MutexGuard
aGuard( m_mutex
);
1494 return !m_ImplementationMap
.empty();
1498 sal_Bool
OServiceManager::has( const Any
& Element
)
1499 throw(::com::sun::star::uno::RuntimeException
)
1502 if( Element
.getValueTypeClass() == TypeClass_INTERFACE
)
1504 Reference
<XInterface
> xEle( Element
, UNO_QUERY_THROW
);
1505 MutexGuard
aGuard( m_mutex
);
1506 return m_ImplementationMap
.find( xEle
) !=
1507 m_ImplementationMap
.end();
1509 else if (Element
.getValueTypeClass() == TypeClass_STRING
)
1511 OUString
const & implName
=
1512 *reinterpret_cast< OUString
const * >(Element
.getValue());
1513 MutexGuard
aGuard( m_mutex
);
1514 return m_ImplementationNameMap
.find( implName
) !=
1515 m_ImplementationNameMap
.end();
1521 void OServiceManager::insert( const Any
& Element
)
1522 throw(::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::container::ElementExistException
, ::com::sun::star::uno::RuntimeException
)
1525 if( Element
.getValueTypeClass() != TypeClass_INTERFACE
)
1527 throw IllegalArgumentException(
1528 OUString( RTL_CONSTASCII_USTRINGPARAM("no interface given!") ),
1529 Reference
< XInterface
>(), 0 );
1531 Reference
<XInterface
> xEle( Element
, UNO_QUERY_THROW
);
1534 MutexGuard
aGuard( m_mutex
);
1535 HashSet_Ref::iterator aIt
= m_ImplementationMap
.find( xEle
);
1536 if( aIt
!= m_ImplementationMap
.end() )
1538 throw ElementExistException(
1539 OUString( RTL_CONSTASCII_USTRINGPARAM("element already exists!") ),
1540 Reference
< XInterface
>() );
1543 // put into the implementation hashmap
1544 m_ImplementationMap
.insert( xEle
);
1546 // put into the implementation name hashmap
1547 Reference
<XServiceInfo
> xInfo( Reference
<XServiceInfo
>::query( xEle
) );
1550 OUString aImplName
= xInfo
->getImplementationName();
1551 if( aImplName
.getLength() )
1552 m_ImplementationNameMap
[ aImplName
] = xEle
;
1554 //put into the service map
1555 Sequence
< OUString
> aServiceNames
= xInfo
->getSupportedServiceNames();
1556 const OUString
* pArray
= aServiceNames
.getConstArray();
1557 for( sal_Int32 i
= 0; i
< aServiceNames
.getLength(); i
++ )
1559 m_ServiceMap
.insert( HashMultimap_OWString_Interface::value_type(
1560 pArray
[i
], *(Reference
<XInterface
> *)Element
.getValue() ) );
1564 // add the disposing listener to the factory
1565 Reference
<XComponent
> xComp( Reference
<XComponent
>::query( xEle
) );
1567 xComp
->addEventListener( getFactoryListener() );
1571 sal_Bool
OServiceManager::haveFactoryWithThisImplementation(const OUString
& aImplName
)
1573 return ( m_ImplementationNameMap
.find(aImplName
) != m_ImplementationNameMap
.end());
1577 void OServiceManager::remove( const Any
& Element
)
1578 throw(::com::sun::star::lang::IllegalArgumentException
,
1579 ::com::sun::star::container::NoSuchElementException
,
1580 ::com::sun::star::uno::RuntimeException
)
1585 Reference
<XInterface
> xEle
;
1586 if (Element
.getValueTypeClass() == TypeClass_INTERFACE
)
1588 xEle
.set( Element
, UNO_QUERY_THROW
);
1590 else if (Element
.getValueTypeClass() == TypeClass_STRING
)
1592 OUString
const & implName
=
1593 *reinterpret_cast< OUString
const * >(Element
.getValue());
1594 MutexGuard
aGuard( m_mutex
);
1595 HashMap_OWString_Interface::const_iterator
const iFind(
1596 m_ImplementationNameMap
.find( implName
) );
1597 if (iFind
== m_ImplementationNameMap
.end())
1599 throw NoSuchElementException(
1600 OUString( RTL_CONSTASCII_USTRINGPARAM("element is not in: ") )
1601 + implName
, static_cast< OWeakObject
* >(this) );
1603 xEle
= iFind
->second
;
1607 throw IllegalArgumentException(
1608 OUString( RTL_CONSTASCII_USTRINGPARAM(
1609 "neither interface nor string given!") ),
1610 Reference
< XInterface
>(), 0 );
1613 // remove the disposing listener from the factory
1614 Reference
<XComponent
> xComp( Reference
<XComponent
>::query( xEle
) );
1616 xComp
->removeEventListener( getFactoryListener() );
1618 MutexGuard
aGuard( m_mutex
);
1619 HashSet_Ref::iterator aIt
= m_ImplementationMap
.find( xEle
);
1620 if( aIt
== m_ImplementationMap
.end() )
1622 throw NoSuchElementException(
1623 OUString( RTL_CONSTASCII_USTRINGPARAM("element is not in!") ),
1624 static_cast< OWeakObject
* >(this) );
1626 //First remove all factories which have been loaded by ORegistryServiceManager.
1627 m_SetLoadedFactories
.erase( *aIt
);
1628 //Remove from the implementation map. It contains all factories of m_SetLoadedFactories
1629 //which have been added directly through XSet, that is not via ORegistryServiceManager
1630 m_ImplementationMap
.erase( aIt
);
1632 // remove from the implementation name hashmap
1633 Reference
<XServiceInfo
> xInfo( Reference
<XServiceInfo
>::query( xEle
) );
1636 OUString aImplName
= xInfo
->getImplementationName();
1637 if( aImplName
.getLength() )
1638 m_ImplementationNameMap
.erase( aImplName
);
1641 //remove from the service map
1642 Reference
<XServiceInfo
> xSF( Reference
<XServiceInfo
>::query( xEle
) );
1645 Sequence
< OUString
> aServiceNames
= xSF
->getSupportedServiceNames();
1646 const OUString
* pArray
= aServiceNames
.getConstArray();
1647 for( sal_Int32 i
= 0; i
< aServiceNames
.getLength(); i
++ )
1649 pair
<HashMultimap_OWString_Interface::iterator
, HashMultimap_OWString_Interface::iterator
> p
=
1650 m_ServiceMap
.equal_range( pArray
[i
] );
1652 while( p
.first
!= p
.second
)
1654 if( xEle
== (*p
.first
).second
)
1656 m_ServiceMap
.erase( p
.first
);
1665 /*****************************************************************************
1666 class ORegistryServiceManager
1667 *****************************************************************************/
1668 class ORegistryServiceManager
: public OServiceManager
1671 ORegistryServiceManager( Reference
< XComponentContext
> const & xContext
);
1672 virtual ~ORegistryServiceManager();
1675 void SAL_CALL
initialize(const Sequence
< Any
>& Arguments
)
1676 throw(::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
);
1679 OUString SAL_CALL
getImplementationName() throw(::com::sun::star::uno::RuntimeException
)
1680 { return stoc_bootstrap::regsmgr_getImplementationName(); }
1682 Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException
);
1684 // XMultiServiceFactory
1685 Sequence
< OUString
> SAL_CALL
getAvailableServiceNames() throw(::com::sun::star::uno::RuntimeException
);
1687 // XContentEnumerationAccess
1688 //Sequence< OUString > getAvailableServiceNames() throw( (Exception) );
1689 Reference
<XEnumeration
> SAL_CALL
createContentEnumeration(const OUString
& aServiceName
) throw(::com::sun::star::uno::RuntimeException
);
1690 virtual Reference
<XEnumeration
> SAL_CALL
createContentEnumeration(
1691 const OUString
& aServiceName
, Reference
< XComponentContext
> const & xContext
)
1692 throw(::com::sun::star::uno::RuntimeException
);
1695 void SAL_CALL
dispose() throw(::com::sun::star::uno::RuntimeException
);
1698 Reference
<XPropertySetInfo
> SAL_CALL
getPropertySetInfo()
1699 throw(::com::sun::star::uno::RuntimeException
);
1700 Any SAL_CALL
getPropertyValue(const OUString
& PropertyName
)
1701 throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
1705 Sequence
< Reference
< XInterface
> > queryServiceFactories(
1706 const OUString
& aServiceName
, Reference
< XComponentContext
> const & xContext
);
1708 Reference
<XRegistryKey
> getRootKey();
1709 Reference
<XInterface
> loadWithImplementationName(
1710 const OUString
& rImplName
, Reference
< XComponentContext
> const & xContext
);
1711 Sequence
<OUString
> getFromServiceName(const OUString
& serviceName
);
1712 Reference
<XInterface
> loadWithServiceName(
1713 const OUString
& rImplName
, Reference
< XComponentContext
> const & xContext
);
1714 void fillAllNamesFromRegistry( HashSet_OWString
& );
1716 sal_Bool m_searchedRegistry
;
1717 Reference
<XSimpleRegistry
> m_xRegistry
; // readonly property Registry
1718 Reference
<XRegistryKey
> m_xRootKey
;
1720 #if OSL_DEBUG_LEVEL > 0
1726 * Create a ServiceManager
1728 ORegistryServiceManager::ORegistryServiceManager( Reference
< XComponentContext
> const & xContext
)
1729 : OServiceManager( xContext
)
1730 , m_searchedRegistry(sal_False
)
1731 #if OSL_DEBUG_LEVEL > 0
1738 * Destroy the ServiceManager
1740 ORegistryServiceManager::~ORegistryServiceManager()
1745 void ORegistryServiceManager::dispose()
1746 throw(::com::sun::star::uno::RuntimeException
)
1748 if (rBHelper
.bDisposed
|| rBHelper
.bInDispose
)
1750 OServiceManager::dispose();
1752 MutexGuard
aGuard( m_mutex
);
1753 // erase all members
1754 m_xRegistry
= Reference
<XSimpleRegistry
>();
1755 m_xRootKey
= Reference
<XRegistryKey
>();
1759 * Return the root key of the registry. The Default registry service is ordered
1760 * if no registry is set.
1762 //Reference<XServiceProvider > create_DefaultRegistry_ServiceProvider();
1764 Reference
<XRegistryKey
> ORegistryServiceManager::getRootKey()
1766 if( !m_xRootKey
.is() )
1768 MutexGuard
aGuard( m_mutex
);
1769 // DefaultRegistry suchen !!!!
1770 if( !m_xRegistry
.is() && !m_searchedRegistry
)
1772 // merken, es wird nur einmal gesucht
1773 m_searchedRegistry
= sal_True
;
1776 createInstanceWithContext(
1777 OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.registry.DefaultRegistry") ),
1781 if( m_xRegistry
.is() && !m_xRootKey
.is() )
1782 m_xRootKey
= m_xRegistry
->getRootKey();
1789 * Create a service provider from the registry with an implementation name
1791 Reference
<XInterface
> ORegistryServiceManager::loadWithImplementationName(
1792 const OUString
& name
, Reference
< XComponentContext
> const & xContext
)
1794 Reference
<XInterface
> ret
;
1796 Reference
<XRegistryKey
> xRootKey
= getRootKey();
1797 if( !xRootKey
.is() )
1802 OUString implementationName
= OUString( RTL_CONSTASCII_USTRINGPARAM("/IMPLEMENTATIONS/") ) + name
;
1803 Reference
<XRegistryKey
> xImpKey
= m_xRootKey
->openKey(implementationName
);
1807 Reference
< lang::XMultiServiceFactory
> xMgr
;
1809 xMgr
.set( xContext
->getServiceManager(), UNO_QUERY_THROW
);
1812 ret
= createSingleRegistryFactory( xMgr
, name
, xImpKey
);
1813 insert( makeAny( ret
) );
1814 // Remember this factory as loaded in contrast to inserted ( XSet::insert)
1815 // factories. Those loaded factories in this set are candidates for being
1816 // released on an unloading notification.
1817 m_SetLoadedFactories
.insert( ret
);
1820 catch (InvalidRegistryException
&)
1828 * Return all implementation out of the registry.
1830 Sequence
<OUString
> ORegistryServiceManager::getFromServiceName(
1831 const OUString
& serviceName
)
1834 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM( "/SERVICES/" ) );
1835 buf
.append( serviceName
);
1836 return retrieveAsciiValueList( m_xRegistry
, buf
.makeStringAndClear() );
1840 * Create a service provider from the registry
1842 Reference
<XInterface
> ORegistryServiceManager::loadWithServiceName(
1843 const OUString
& serviceName
, Reference
< XComponentContext
> const & xContext
)
1845 Sequence
<OUString
> implEntries
= getFromServiceName( serviceName
);
1846 for (sal_Int32 i
= 0; i
< implEntries
.getLength(); i
++)
1848 Reference
< XInterface
> x(
1849 loadWithImplementationName( implEntries
.getConstArray()[i
], xContext
) );
1854 return Reference
<XInterface
>();
1858 * Return a sequence of all service names from the registry.
1860 void ORegistryServiceManager::fillAllNamesFromRegistry( HashSet_OWString
& rSet
)
1862 Reference
<XRegistryKey
> xRootKey
= getRootKey();
1863 if( !xRootKey
.is() )
1868 Reference
<XRegistryKey
> xServicesKey
= xRootKey
->openKey(
1869 OUString( RTL_CONSTASCII_USTRINGPARAM("SERVICES") ) );
1870 // root + /Services + /
1871 if( xServicesKey
.is() )
1873 sal_Int32 nPrefix
= xServicesKey
->getKeyName().getLength() +1;
1874 Sequence
<Reference
<XRegistryKey
> > aKeys
= xServicesKey
->openKeys();
1875 for( sal_Int32 i
= 0; i
< aKeys
.getLength(); i
++ )
1876 rSet
.insert( aKeys
.getConstArray()[i
]->getKeyName().copy( nPrefix
) );
1879 catch (InvalidRegistryException
&)
1885 void ORegistryServiceManager::initialize(const Sequence
< Any
>& Arguments
)
1886 throw(::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
)
1889 MutexGuard
aGuard( m_mutex
);
1890 if (Arguments
.getLength() > 0)
1893 Arguments
[ 0 ] >>= m_xRegistry
;
1895 #if OSL_DEBUG_LEVEL > 0
1896 // to find all bootstrapping processes to be fixed...
1897 OSL_ENSURE( !m_init
, "### second init of service manager instance!" );
1902 // XMultiServiceFactory, XContentEnumeration
1903 Sequence
< OUString
> ORegistryServiceManager::getAvailableServiceNames()
1904 throw(::com::sun::star::uno::RuntimeException
)
1907 MutexGuard
aGuard( m_mutex
);
1909 HashSet_OWString aNameSet
;
1911 // all names from the registry
1912 fillAllNamesFromRegistry( aNameSet
);
1914 return OServiceManager::getUniqueAvailableServiceNames( aNameSet
);
1918 Sequence
< OUString
> ORegistryServiceManager::getSupportedServiceNames()
1919 throw(::com::sun::star::uno::RuntimeException
)
1922 return stoc_bootstrap::regsmgr_getSupportedServiceNames();
1927 Sequence
< Reference
< XInterface
> > ORegistryServiceManager::queryServiceFactories(
1928 const OUString
& aServiceName
, Reference
< XComponentContext
> const & xContext
)
1930 Sequence
< Reference
< XInterface
> > ret(
1931 OServiceManager::queryServiceFactories( aServiceName
, xContext
) );
1932 if (ret
.getLength())
1938 MutexGuard
aGuard( m_mutex
);
1939 Reference
< XInterface
> x( loadWithServiceName( aServiceName
, xContext
) );
1941 x
= loadWithImplementationName( aServiceName
, xContext
);
1942 return Sequence
< Reference
< XInterface
> >( &x
, 1 );
1946 // XContentEnumerationAccess
1947 Reference
<XEnumeration
> ORegistryServiceManager::createContentEnumeration(
1948 const OUString
& aServiceName
, Reference
< XComponentContext
> const & xContext
)
1949 throw(::com::sun::star::uno::RuntimeException
)
1952 MutexGuard
aGuard( ((ORegistryServiceManager
*)this)->m_mutex
);
1953 // get all implementation names registered under this service name from the registry
1954 Sequence
<OUString
> aImpls
= ((ORegistryServiceManager
*)this)->getFromServiceName( aServiceName
);
1955 // load and insert all factories specified by the registry
1958 for( i
= 0; i
< aImpls
.getLength(); i
++ )
1960 aImplName
= aImpls
.getConstArray()[i
];
1961 if ( !haveFactoryWithThisImplementation(aImplName
) )
1963 loadWithImplementationName( aImplName
, xContext
);
1966 // call the superclass to enumerate all contents
1967 return OServiceManager::createContentEnumeration( aServiceName
, xContext
);
1969 Reference
<XEnumeration
> ORegistryServiceManager::createContentEnumeration(
1970 const OUString
& aServiceName
)
1971 throw(::com::sun::star::uno::RuntimeException
)
1973 return createContentEnumeration( aServiceName
, m_xContext
);
1977 Reference
<XPropertySetInfo
> ORegistryServiceManager::getPropertySetInfo()
1978 throw(::com::sun::star::uno::RuntimeException
)
1981 if (! m_xPropertyInfo
.is())
1983 Sequence
< beans::Property
> seq( 2 );
1984 seq
[ 0 ] = beans::Property(
1985 OUSTR("DefaultContext"), -1, ::getCppuType( &m_xContext
), 0 );
1986 seq
[ 1 ] = beans::Property(
1987 OUSTR("Registry"), -1, ::getCppuType( &m_xRegistry
),
1988 beans::PropertyAttribute::READONLY
);
1989 Reference
< beans::XPropertySetInfo
> xInfo( new PropertySetInfo_Impl( seq
) );
1991 MutexGuard
aGuard( m_mutex
);
1992 if (! m_xPropertyInfo
.is())
1994 m_xPropertyInfo
= xInfo
;
1997 return m_xPropertyInfo
;
2000 Any
ORegistryServiceManager::getPropertyValue(const OUString
& PropertyName
)
2001 throw(::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
)
2004 if (PropertyName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Registry") ))
2006 MutexGuard
aGuard( m_mutex
);
2007 if( m_xRegistry
.is() )
2008 return makeAny( m_xRegistry
);
2012 return OServiceManager::getPropertyValue( PropertyName
);
2015 /* This is the listener function used by the service manager in order
2016 to implement the unloading mechanism, id is the this pointer of the
2017 service manager instances. On notification, that is the function is being called
2018 by rtl_unloadUnusedModules, the cached factroies are being removed from the
2019 service manager ( except manually inserted factories).
2021 extern "C" void SAL_CALL
smgrUnloadingListener(void* id
)
2023 stoc_smgr::OServiceManager
* pMgr
= reinterpret_cast<stoc_smgr::OServiceManager
*>( id
);
2024 pMgr
->onUnloadingNotify();
2029 namespace stoc_bootstrap
2032 * Create the ServiceManager
2034 Reference
<XInterface
> SAL_CALL
OServiceManager_CreateInstance(
2035 const Reference
< XComponentContext
> & xContext
)
2037 return Reference
<XInterface
>(
2039 XInterface
*, SAL_STATIC_CAST(
2040 OWeakObject
*, new stoc_smgr::OServiceManager( xContext
) ) ) );
2044 * Create the ServiceManager
2046 Reference
<XInterface
> SAL_CALL
ORegistryServiceManager_CreateInstance(
2047 const Reference
< XComponentContext
> & xContext
)
2048 throw(::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
)
2050 return Reference
<XInterface
>(
2052 XInterface
*, SAL_STATIC_CAST(
2053 OWeakObject
*, new stoc_smgr::ORegistryServiceManager( xContext
) ) ) );
2056 Reference
<XInterface
> SAL_CALL
OServiceManagerWrapper_CreateInstance(
2057 const Reference
< XComponentContext
> & xContext
)
2060 return (OWeakObject
*)new stoc_smgr::OServiceManagerWrapper( xContext
);