summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configmgr/source/misc/providerfactory.cxx145
-rw-r--r--configmgr/source/misc/providerfactory.hxx55
2 files changed, 146 insertions, 54 deletions
diff --git a/configmgr/source/misc/providerfactory.cxx b/configmgr/source/misc/providerfactory.cxx
index cced93f01784..3b047aac2e52 100644
--- a/configmgr/source/misc/providerfactory.cxx
+++ b/configmgr/source/misc/providerfactory.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: providerfactory.cxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: jb $ $Date: 2001-04-03 16:33:58 $
+ * last change: $Author: jb $ $Date: 2001-05-18 16:16:52 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -158,14 +158,21 @@ namespace configmgr
}
//---------------------------------------------------------------------------------------
- void OProviderFactory::ensureSettings()
+ void OProviderFactory::ensureBootstrapSettings()
{
if (!m_pPureSettings)
- m_pPureSettings = new ConnectionSettings;
+ m_pPureSettings = new BootstrapSettings();
}
//---------------------------------------------------------------------------------------
- Reference< XInterface > OProviderFactory::implGetProvider(const ConnectionSettings& _rSettings, sal_Bool _bCreateWithPassword)
+ static bool checkForOptions(const ConnectionSettings& _rSettings)
+ {
+ return _rSettings.hasLocale() ||
+ _rSettings.hasAsyncSetting();
+ }
+
+ //---------------------------------------------------------------------------------------
+ Reference< XInterface > OProviderFactory::implGetProvider(const ConnectionSettings& _rSettings, sal_Bool _bCanReuse)
{
// the providers for the given session type
UserSpecificProviders& rProviders = m_aProviders[_rSettings.getSessionType()];
@@ -175,12 +182,18 @@ namespace configmgr
if (_rSettings.hasUser())
sUser = _rSettings.getUser();
+ if (checkForOptions(_rSettings))
+ _bCanReuse = false;
+
Reference< XInterface > xReturn;
- if (!_bCreateWithPassword)
+ if (_bCanReuse)
{
UserSpecificProvidersIterator aExistentProvider = rProviders.find(sUser);
if (rProviders.end() != aExistentProvider)
+ {
+ // should check for differing parameters here
xReturn = aExistentProvider->second;
+ }
}
// #78409
@@ -191,8 +204,18 @@ namespace configmgr
{
// create and connect the provider (may still throw exceptions)
xReturn = (*m_pObjectCreator)(m_xORB, _rSettings);
+
+ // check for success
+ if (!xReturn.is())
+ {
+ OSL_ENSURE(false, "Object creator could not create provider, but returned NULL instead of throwing an exception");
+ sal_Char const sCannotCreate[] = "Cannot create ConfigurationProvider. Unknown backend or factory error.";
+ // should become CannotLoadConfigurationException
+ throw uno::Exception( OUString::createFromAscii(sCannotCreate), *this );
+ }
+
// remember it for later usage
- if (!_bCreateWithPassword)
+ if (_bCanReuse)
rProviders[sUser] = xReturn;
}
@@ -200,14 +223,38 @@ namespace configmgr
}
//---------------------------------------------------------------------------------------
+ Reference< XInterface > OProviderFactory::implCreateProviderWithSettings(const ConnectionSettings& _rSettings, bool _bRequiresBootstrap, bool _bCanReuse)
+ {
+ try
+ {
+ return implGetProvider(_rSettings, _bCanReuse);
+ }
+ catch(uno::Exception& e)
+ {
+ if (_bRequiresBootstrap)
+ {
+ OSL_ASSERT(m_pPureSettings);
+ raiseBootstrapException(*m_pPureSettings, *this);
+
+ OSL_ASSERT(m_pPureSettings->status == BOOTSTRAP_DATA_OK);
+ }
+
+ sal_Char const sConnectionFailure[] = "Cannot open Configuration: ";
+ OUString const sFailure = OUString::createFromAscii(sConnectionFailure);
+ e.Message = sFailure.concat(e.Message);
+ throw;
+ }
+ }
+
+ //---------------------------------------------------------------------------------------
void OProviderFactory::ensureDefaultProvider()
{
- MutexGuard aGuard(m_aMutex);
if (m_xDefaultProvider.is())
return;
- ensureSettings();
- m_xDefaultProvider = createProviderWithArguments(Sequence< Any >());
+ ensureBootstrapSettings();
+
+ m_xDefaultProvider = implCreateProviderWithSettings(m_pPureSettings->settings,true,true);
// register disposing listener
Reference<com::sun::star::lang::XComponent> xComponent(m_xDefaultProvider, UNO_QUERY);
@@ -228,15 +275,38 @@ namespace configmgr
//---------------------------------------------------------------------------------------
Reference< XInterface > OProviderFactory::createProviderWithArguments(const Sequence< Any >& _rArguments)
{
+ ConnectionSettings aSettings(_rArguments);
+ return createProviderWithSettings( aSettings );
+ }
+
+ //---------------------------------------------------------------------------------------
+ Reference< XInterface > OProviderFactory::createProviderWithSettings(const ConnectionSettings& _rSettings)
+ {
MutexGuard aGuard(m_aMutex);
- ensureSettings();
- ConnectionSettings aThisRoundSettings = m_pPureSettings->createMergedSettings(_rArguments);
+ ConnectionSettings aThisRoundSettings(_rSettings);
+
+ // use bootstrap data if necessary
+ bool bUseBootstrapData = !aThisRoundSettings.isComplete();
- ::rtl::OUString sSessionType = aThisRoundSettings.getSessionType();
- sal_Bool bIsPluginSession = (0 == sSessionType.compareToAscii(PLUGIN_SESSION_IDENTIFIER));
+ // detect a plugin session. Can be specified only as argument
+ sal_Bool bIsPluginSession = aThisRoundSettings.isPlugin();
- Reference< XInterface > xProvider;
+ if (bIsPluginSession)
+ {
+ OSL_ENSURE(!aThisRoundSettings.isSourcePathValid(),"Invalid Argument: No explicit source path should be specified for plugin session");
+ bUseBootstrapData = true;
+ }
+
+ // use bootstrap data if necessary
+ if (bUseBootstrapData)
+ {
+ ensureBootstrapSettings();
+
+ ConnectionSettings aMergedSettings = m_pPureSettings->settings;
+ aMergedSettings.mergeOverrides(aThisRoundSettings);
+ aMergedSettings.swap(aThisRoundSettings);
+ }
// if we have a plugin session, translate the session type into the one appliable.
if (bIsPluginSession)
@@ -246,36 +316,46 @@ namespace configmgr
// For a plugin-local session, we need a valid update directory.
// (We can't just rely on the session to fail if it is created with a valid source directory and an
// invalid update directory. In such a scenario it will succeed to open, but not to update.)
- if (aThisRoundSettings.hasRegistry() && aThisRoundSettings.isValidUpdatePath())
+ if (!m_pPureSettings->settings.isLocalSession())
{
- const ::rtl::OUString sLocalSessionIdentifier = ::rtl::OUString::createFromAscii(LOCAL_SESSION_IDENTIFIER);
- aThisRoundSettings.setSessionType(sLocalSessionIdentifier);
+ const OUString sLocalSessionIdentifier = OUString::createFromAscii(LOCAL_SESSION_IDENTIFIER);
+ // (We can't just rely on the session to fail if it is created with a valid source directory and an
+ // invalid update directory. In such a scenario it will succeed to open, but not to update.)
+ if (aThisRoundSettings.isComplete(sLocalSessionIdentifier) &&
+ aThisRoundSettings.isUpdatePathValid())
try
{
- xProvider = implGetProvider(
- aThisRoundSettings,
- sal_False // no password for local sessions
- );
+ aThisRoundSettings.setSessionType(sLocalSessionIdentifier, Settings::SO_ADJUSTMENT);
+ return implGetProvider(aThisRoundSettings,true);
}
catch(Exception&)
{
// allowed. The creation of the local provider may fail.
}
}
+ // did not create the local session
- if (!xProvider.is())
- { // failed to create the local session
- // -> create a portal one
- const ::rtl::OUString sPortalSessionIdentifier = ::rtl::OUString::createFromAscii(PORTAL_SESSION_IDENTIFIER);
- aThisRoundSettings.setSessionType(sPortalSessionIdentifier);
- // the real creation is below ...
- sSessionType = sPortalSessionIdentifier;
+ // -> create the original one
+ if (m_pPureSettings->settings.isSessionTypeKnown())
+ {
+ OUString sOriginalType = m_pPureSettings->settings.getSessionType();
+ aThisRoundSettings.setSessionType(sOriginalType, Settings::SO_ADJUSTMENT);
+ }
+ else
+ {
+ OUString const sPortalSessionIdentifier = OUString::createFromAscii(PORTAL_SESSION_IDENTIFIER);
+ aThisRoundSettings.setSessionType(sPortalSessionIdentifier, Settings::SO_ADJUSTMENT);
}
}
- if (!xProvider.is())
- xProvider = implGetProvider(aThisRoundSettings, aThisRoundSettings.hasPassword());
+ aThisRoundSettings.validate();
+ OSL_ENSURE(aThisRoundSettings.isComplete(), "Incomplete Data for creating a ConfigurationProvider");
+
+ Reference< XInterface > xProvider =
+ implCreateProviderWithSettings( aThisRoundSettings,bUseBootstrapData,
+ !aThisRoundSettings.hasPassword() );
+
return xProvider;
}
@@ -331,6 +411,9 @@ namespace configmgr
/*************************************************************************
* history:
* $Log: not supported by cvs2svn $
+ * Revision 1.8 2001/04/03 16:33:58 jb
+ * Local AdministrationProvider now mapped to Setup-session
+ *
* Revision 1.7 2001/03/21 12:15:40 jl
* OSL_ENSHURE replaced by OSL_ENSURE
*
diff --git a/configmgr/source/misc/providerfactory.hxx b/configmgr/source/misc/providerfactory.hxx
index a8b181e1e073..9b907d34c79d 100644
--- a/configmgr/source/misc/providerfactory.hxx
+++ b/configmgr/source/misc/providerfactory.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: providerfactory.hxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: jb $ $Date: 2001-04-03 16:33:58 $
+ * last change: $Author: jb $ $Date: 2001-05-18 16:16:52 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -88,21 +88,26 @@
namespace configmgr
{
//........................................................................
+ namespace uno = ::com::sun::star::uno;
+ namespace lang = ::com::sun::star::lang;
+ using ::rtl::OUString;
+//........................................................................
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL
+ uno::Reference< lang::XSingleServiceFactory > SAL_CALL
createProviderFactory(
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rServiceManager,
- const ::rtl::OUString& _rComponentName,
+ const uno::Reference< lang::XMultiServiceFactory >& _rServiceManager,
+ const OUString& _rComponentName,
::configmgr::ProviderInstantiation _pCreateFunction,
- const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rServiceNames
+ const uno::Sequence< OUString >& _rServiceNames
);
class ConnectionSettings;
+ class BootstrapSettings;
//====================================================================
//= OProviderFactory
//====================================================================
- typedef ::cppu::WeakImplHelper1< ::com::sun::star::lang::XSingleServiceFactory > OProviderFactory_Base;
+ typedef ::cppu::WeakImplHelper1< lang::XSingleServiceFactory > OProviderFactory_Base;
/** a special factory for the configuration provider, which implements some kind of
"shared multiple instances" factory.
*/
@@ -113,43 +118,44 @@ namespace configmgr
protected:
::osl::Mutex m_aMutex;
ProviderInstantiation m_pObjectCreator;
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > m_xEventListener; // must be the first uno::object
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
- m_xORB;
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
- m_xDefaultProvider;
- ConnectionSettings* m_pPureSettings;
- // the pure settings, not overwritten by any runtime arguments
+ uno::Reference< lang::XEventListener > m_xEventListener; // must be the first uno::object
+ uno::Reference< lang::XMultiServiceFactory > m_xORB;
+ uno::Reference< uno::XInterface > m_xDefaultProvider;
+
+ // the pure settings, not overwritten by any runtime arguments
+ BootstrapSettings const* m_pPureSettings;
- typedef ::com::sun::star::uno::WeakReference< ::com::sun::star::uno::XInterface > ProviderReference;
+ typedef uno::WeakReference< uno::XInterface > ProviderReference;
DECLARE_STL_USTRINGACCESS_MAP(ProviderReference, UserSpecificProviders);
DECLARE_STL_USTRINGACCESS_MAP(UserSpecificProviders, SessionSpecificProviders);
SessionSpecificProviders m_aProviders;
public:
OProviderFactory(
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ const uno::Reference< lang::XMultiServiceFactory >& _rxORB,
ProviderInstantiation _pObjectCreator);
~OProviderFactory();
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance( ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ virtual uno::Reference< uno::XInterface > SAL_CALL createInstance( ) throw(uno::Exception, uno::RuntimeException);
+ virtual uno::Reference< uno::XInterface > SAL_CALL createInstanceWithArguments( const uno::Sequence< uno::Any >& aArguments ) throw(uno::Exception, uno::RuntimeException);
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createProvider();
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createProviderWithArguments(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& _rArguments);
+ uno::Reference< uno::XInterface > createProvider();
+ uno::Reference< uno::XInterface > createProviderWithArguments(const uno::Sequence< uno::Any >& _rArguments);
+ uno::Reference< uno::XInterface > createProviderWithSettings(const ConnectionSettings& _rSettings);
protected:
void ensureDefaultProvider();
+ void ensureBootstrapSettings();
+ uno::Reference< uno::XInterface > implCreateProviderWithSettings(const ConnectionSettings& _rSettings, bool bRequiresBootstrap, bool _bReusable);
// from the given map, extract a provider for the given user. (if necessary, create one and insert it into the map)
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > implGetProvider(
+ uno::Reference< uno::XInterface > implGetProvider(
const ConnectionSettings& _rSettings,
- sal_Bool _bCreateWithPassword
+ sal_Bool _bReusable
);
// to be called with m:aMutex locked
- void ensureSettings();
void disposing(com::sun::star::lang::EventObject const& rEvt) throw();
};
@@ -162,6 +168,9 @@ namespace configmgr
/*************************************************************************
* history:
* $Log: not supported by cvs2svn $
+ * Revision 1.4 2001/04/03 16:33:58 jb
+ * Local AdministrationProvider now mapped to Setup-session
+ *
* Revision 1.3 2001/01/29 08:51:11 dg
* #82336# invalid syntax for template
*