Using a Data Source
From OpenOffice.org Wiki
After a configuration provider is obtained, call com.sun.star.lang.XMultiServiceFactory:createInstanceWithArguments() to create a view on the configuration data.
The following arguments can be specified when creating a view:
| Parameter Name | Type | Default | Comments |
|---|---|---|---|
nodepath
| string
| - | This parameter is required. It contains an absolute path to the root node of the view. |
Locale
| string
| The user's locale
(or " | Using this parameter, specify the locale to be used for selecting locale-dependent values. Use the ISO code for a locale, for example, en-US for U.S. English. |
EnableAsync
| boolean
| true
| This parameter was called "lazywrite" in a former version. The old name is still supported for compatibility.
|
depth
| integer
| (unlimited) | This parameter causes the view to be truncated to a specified nesting depth. |
nocache
| boolean
| false
| This parameter is deprecated. |
| If the special value "*" is used for the locale parameter, values for all locales are retrieved. In this case, a locale-dependent property appears as a set item. The items of the set are the values for the different locales. They will have the ISO identifiers of the locales as names.
This mode is the default if you are using an com.sun.star.configuration.AdministrationProvider. It can be used if you want to assign values for different locales in a targeted manner. Usually this is logical in an administration or installation context only. |
To create a read-only view on the data, the service com.sun.star.configuration.ConfigurationAccess is requested:
// Create a specified read-only configuration view public Object createConfigurationView(String sPath) throws com.sun.star.uno.Exception { // get the provider to use XMultiServiceFactory xProvider = getProvider(); // The service name: Need only read access: final String sReadOnlyView = "com.sun.star.configuration.ConfigurationAccess"; // creation arguments: nodepath com.sun.star.beans.PropertyValue aPathArgument = new com.sun.star.beans.PropertyValue(); aPathArgument.Name = "nodepath"; aPathArgument.Value = sPath; Object[] aArguments = new Object[1]; aArguments[0] = aPathArgument; // create the view Object xViewRoot = xProvider.createInstanceWithArguments(sReadOnlyView, aArguments); return xViewRoot; }
To obtain updatable access, the service com.sun.star.configuration.ConfigurationUpdateAccess is requested. In this case, there are additional parameters available that control the caching behavior of the configuration management component:
// Create a specified updatable configuration view Object createUpdatableView(String sPath, boolean bAsync) throws com.sun.star.uno.Exception { // get the provider to use XMultiServiceFactory xProvider = getProvider(); // The service name: Need update access: final String cUpdatableView = "com.sun.star.configuration.ConfigurationUpdateAccess"; // creation arguments: nodepath com.sun.star.beans.PropertyValue aPathArgument = new com.sun.star.beans.PropertyValue(); aPathArgument.Name = "nodepath"; aPathArgument.Value = sPath; // creation arguments: commit mode - write-through or write-back com.sun.star.beans.PropertyValue aModeArgument = new com.sun.star.beans.PropertyValue(); aModeArgument.Name = "EnableAsync"; aModeArgument.Value = new Boolean(bAsync); Object[] aArguments = new Object[2]; aArguments[0] = aPathArgument; aArguments[1] = aModeArgument; // create the view Object xViewRoot = xProvider.createInstanceWithArguments(cUpdatableView, aArguments); return xViewRoot; }
A com.sun.star.configuration.AdministrationProvider supports the same service specifiers, but creates views on shared layers of configuration data. It supports additional parameters to select the exact layer to work on or to specify authorization credentials. Independent of the backend, the following parameter is supported by the com.sun.star.configuration.AdministrationProvider :
| Parameter Name | Type | Default | Comments |
|---|---|---|---|
Entity
| string
| - | Identifies an entity that the backend can map to a sequence of layers to merge and a target layer for updates. |
If no Entity is provided, the com.sun.star.configuration.AdministrationProvider uses the entity the backend provides through com.sun.star.configuration.backend.XBackendEntities:getAdminEntity(). The supported entities and their meaning depend on the backend. For the default file-based backend an entity is a file URL that points to the base directory of a layer.
For a com.sun.star.configuration.AdministrationProvider, the default value for the locale parameter is "*".
| Content on this page is licensed under the Public Documentation License (PDL). |

