Difference between revisions of "Documentation/DevGuide/Config/Connecting to a Data Source"
m (fix idls ref for backend.Backend) |
|||
(3 intermediate revisions by 3 users not shown) | |||
Line 5: | Line 5: | ||
|NextPage=Documentation/DevGuide/Config/Using a Data Source | |NextPage=Documentation/DevGuide/Config/Using a Data Source | ||
}} | }} | ||
− | {{DISPLAYTITLE:Connecting to a Data Source}} | + | {{Documentation/DevGuideLanguages|Documentation/DevGuide/Config/{{SUBPAGENAME}}}} |
+ | {{DISPLAYTITLE:Connecting to a Data Source}} | ||
<!--<idltopic>com.sun.star.configuration.ConfigurationProvider;com.sun.star.configuration.AdministrationProvider</idltopic>--> | <!--<idltopic>com.sun.star.configuration.ConfigurationProvider;com.sun.star.configuration.AdministrationProvider</idltopic>--> | ||
The first step to access the configuration database is to connect to a configuration data source. | The first step to access the configuration database is to connect to a configuration data source. | ||
Line 11: | Line 12: | ||
To obtain a provider instance ask the global <idl>com.sun.star.lang.ServiceManager</idl> for a <idl>com.sun.star.configuration.ConfigurationProvider</idl>. Typically the first lines of code to get access to configuration data look similar to the following: | To obtain a provider instance ask the global <idl>com.sun.star.lang.ServiceManager</idl> for a <idl>com.sun.star.configuration.ConfigurationProvider</idl>. Typically the first lines of code to get access to configuration data look similar to the following: | ||
<!--[SOURCE:Config/ConfigExamples.java]--> | <!--[SOURCE:Config/ConfigExamples.java]--> | ||
− | + | <syntaxhighlight lang="java"> | |
// get my global service manager | // get my global service manager | ||
XMultiServiceFactory xServiceManager = (XMultiServiceFactory)UnoRuntime.queryInterface( | XMultiServiceFactory xServiceManager = (XMultiServiceFactory)UnoRuntime.queryInterface( | ||
Line 23: | Line 24: | ||
UnoRuntime.queryInterface(XMultiServiceFactory.class, | UnoRuntime.queryInterface(XMultiServiceFactory.class, | ||
xServiceManager.createInstance(sProviderService)); | xServiceManager.createInstance(sProviderService)); | ||
− | + | </syntaxhighlight> | |
This code creates a default <idl>com.sun.star.configuration.ConfigurationProvider</idl>. The most important interface a <idl>com.sun.star.configuration.ConfigurationProvider</idl> implements is <idl>com.sun.star.lang.XMultiServiceFactory</idl> that is used to create further configuration objects. | This code creates a default <idl>com.sun.star.configuration.ConfigurationProvider</idl>. The most important interface a <idl>com.sun.star.configuration.ConfigurationProvider</idl> implements is <idl>com.sun.star.lang.XMultiServiceFactory</idl> that is used to create further configuration objects. | ||
The <idl>com.sun.star.configuration.ConfigurationProvider</idl> always operates in the user mode, accessing data on behalf of the current user and directing updates to the user's personal layer. | The <idl>com.sun.star.configuration.ConfigurationProvider</idl> always operates in the user mode, accessing data on behalf of the current user and directing updates to the user's personal layer. | ||
− | + | The backend data store has several shared layers. One of these layers is used to store shared default data. The files for this layer are located in the share directory of the {{AOo}} installation. Additionally, there are special layers that are used by the Extension Manager for deploying configuration data associated with extensions. For details, see [[Documentation/DevGuide/Extensions/Extensions|Extensions]]. | |
− | + | Arguments can be provided that determine the default behavior of views created through this <idl>com.sun.star.configuration.ConfigurationProvider</idl>. The following parameter may be used for this purpose: | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | Arguments can be provided that determine the default behavior of views created through this <idl>com.sun.star.configuration.ConfigurationProvider</idl>. The following | + | |
{|border="1" cellpadding=4 style="border-collapse:collapse;" | {|border="1" cellpadding=4 style="border-collapse:collapse;" | ||
Line 164: | Line 44: | ||
|The user's locale. | |The user's locale. | ||
|This parameter was called "<code>locale</code>" in a former version. The old name is still supported for compatibility. | |This parameter was called "<code>locale</code>" in a former version. The old name is still supported for compatibility. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
|} | |} | ||
− | {{ | + | {{Warn|The default configuration provider obtained when no arguments are given will always be the same object. Be careful not to call <idlm>com.sun.star.lang.XComponent:dispose</idlm>() on this shared <idl>com.sun.star.configuration.ConfigurationProvider</idl>. |
− | If you provide any arguments, then a new instance is created. You must then call < | + | If you provide any arguments, then a new instance is created. You must then call <idlm>com.sun.star.lang.XComponent:dispose</idlm>() on this <idl>com.sun.star.configuration.ConfigurationProvider</idl>.}} |
{{PDL1}} | {{PDL1}} | ||
[[Category:Documentation/Developer's Guide/Configuration Management]] | [[Category:Documentation/Developer's Guide/Configuration Management]] |
Latest revision as of 16:53, 21 December 2020
The first step to access the configuration database is to connect to a configuration data source.
To obtain a provider instance ask the global com.sun.star.lang.ServiceManager for a com.sun.star.configuration.ConfigurationProvider. Typically the first lines of code to get access to configuration data look similar to the following:
// get my global service manager XMultiServiceFactory xServiceManager = (XMultiServiceFactory)UnoRuntime.queryInterface( XMultiServiceFactory.class, this.getRemoteServiceManager( "uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager")); final String sProviderService = "com.sun.star.configuration.ConfigurationProvider"; // create the provider and remember it as a XMultiServiceFactory XMultiServiceFactory xProvider = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xServiceManager.createInstance(sProviderService));
This code creates a default com.sun.star.configuration.ConfigurationProvider. The most important interface a com.sun.star.configuration.ConfigurationProvider implements is com.sun.star.lang.XMultiServiceFactory that is used to create further configuration objects.
The com.sun.star.configuration.ConfigurationProvider always operates in the user mode, accessing data on behalf of the current user and directing updates to the user's personal layer.
The backend data store has several shared layers. One of these layers is used to store shared default data. The files for this layer are located in the share directory of the Apache OpenOffice installation. Additionally, there are special layers that are used by the Extension Manager for deploying configuration data associated with extensions. For details, see Extensions.
Arguments can be provided that determine the default behavior of views created through this com.sun.star.configuration.ConfigurationProvider. The following parameter may be used for this purpose:
Parameter Name | Type | Default | Comments |
---|---|---|---|
Locale
|
string
|
The user's locale. | This parameter was called "locale " in a former version. The old name is still supported for compatibility.
|
The default configuration provider obtained when no arguments are given will always be the same object. Be careful not to call dispose() on this shared com.sun.star.configuration.ConfigurationProvider.
If you provide any arguments, then a new instance is created. You must then call dispose() on this com.sun.star.configuration.ConfigurationProvider. |
Content on this page is licensed under the Public Documentation License (PDL). |