25#include <com/sun/star/deployment/XPackageManagerFactory.hpp>
26#include <com/sun/star/lang/XServiceInfo.hpp>
27#include <unordered_map>
35typedef ::cppu::WeakComponentImplHelper<
49 typedef std::unordered_map<
50 OUString, WeakReference<deployment::XPackageManager> > t_string2weakref;
55 virtual void SAL_CALL disposing()
override;
58 explicit PackageManagerFactoryImpl(
59 Reference<XComponentContext>
const & xComponentContext );
67 virtual Reference<deployment::XPackageManager> SAL_CALL getPackageManager(
68 OUString
const & context )
override;
73PackageManagerFactoryImpl::PackageManagerFactoryImpl(
74 Reference<XComponentContext>
const & xComponentContext )
81OUString PackageManagerFactoryImpl::getImplementationName()
83 return "com.sun.star.comp.deployment.PackageManagerFactory";
86sal_Bool PackageManagerFactoryImpl::supportsService(
const OUString& ServiceName )
91css::uno::Sequence< OUString > PackageManagerFactoryImpl::getSupportedServiceNames()
94 return {
"com.sun.star.comp.deployment.PackageManagerFactory" };
97inline void PackageManagerFactoryImpl::check()
99 ::osl::MutexGuard guard( m_aMutex );
100 if (rBHelper.bInDispose || rBHelper.bDisposed)
102 throw lang::DisposedException(
103 "PackageManagerFactory instance has already been disposed!",
104 static_cast<OWeakObject *
>(
this) );
109void PackageManagerFactoryImpl::disposing()
112 ::osl::MutexGuard guard( m_aMutex );
126Reference<deployment::XPackageManager>
127PackageManagerFactoryImpl::getPackageManager( OUString
const & context )
129 Reference< deployment::XPackageManager > xRet;
130 ::osl::ResettableMutexGuard guard( m_aMutex );
132 t_string2weakref::const_iterator
const iFind(
m_managers.find( context ) );
134 xRet = iFind->second;
142 std::pair< t_string2weakref::iterator, bool > insertion(
144 if (insertion.second)
146 OSL_ASSERT( insertion.first->second.get() == xRet );
148 if ( context ==
"user" )
150 else if ( context ==
"shared" )
152 else if ( context ==
"bundled" )
154 else if ( context ==
"tmp" )
156 else if ( context ==
"bak" )
161 Reference< deployment::XPackageManager > xAlreadyIn(
162 insertion.first->second );
171 insertion.first->second = xRet;
179extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
181 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const& )
183 return cppu::acquire(
new dp_manager::factory::PackageManagerFactoryImpl(context));
Reference< deployment::XPackageManager > m_xBakMgr
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_deployment_PackageManagerFactory_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Reference< deployment::XPackageManager > m_xUserMgr
Reference< deployment::XPackageManager > m_xBundledMgr
Reference< deployment::XPackageManager > m_xTmpMgr
t_string2weakref m_managers
Reference< deployment::XPackageManager > m_xSharedMgr
Reference< XComponentContext > m_xComponentContext
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
::cppu::WeakComponentImplHelper< deployment::XPackageManagerFactory, lang::XServiceInfo > t_pmfac_helper
void try_dispose(css::uno::Reference< css::uno::XInterface > const &x)
css::uno::Reference< css::deployment::XPackageRegistry > create(css::uno::Reference< css::deployment::XPackageRegistry > const &xRootRegistry, OUString const &context, OUString const &cachePath, css::uno::Reference< css::uno::XComponentContext > const &xComponentContext)