Difference between revisions of "Documentation/DevGuide/Config/Using a Data Source"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (FINAL VERSION FOR L10N)
(adapted to configmgr re-write)
Line 29: Line 29:
 
(or "<code>*</code>")  
 
(or "<code>*</code>")  
 
|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.  
 
|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.  
|-
 
|<code>EnableAsync</code>
 
|<code>boolean</code>
 
|<code>true</code>
 
|This parameter was called "<code>lazywrite</code>" in a former version. The old name is still supported for compatibility.
 
|-
 
|<code>depth</code>
 
|<code>integer</code>
 
|(unlimited)
 
|This parameter causes the view to be truncated to a specified nesting depth. 
 
|-
 
|<code>nocache</code>
 
|<code>boolean</code>
 
|<code>false</code>
 
|This parameter is deprecated. 
 
 
|}
 
|}
  
 
{{Documentation/Note|If the special value "<tt>*</tt>" is used for the <tt>locale</tt> 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.
 
{{Documentation/Note|If the special value "<tt>*</tt>" is used for the <tt>locale</tt> 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 <idl>com.sun.star.configuration.AdministrationProvider</idl>.
+
It can be used if you want to assign values for different locales in a targeted manner.}}
 
+
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 <idl>com.sun.star.configuration.ConfigurationAccess</idl> is requested:
 
To create a read-only view on the data, the service <idl>com.sun.star.configuration.ConfigurationAccess</idl> is requested:
Line 76: Line 59:
 
   }
 
   }
 
  </source>
 
  </source>
To obtain updatable access, the service <idl>com.sun.star.configuration.ConfigurationUpdateAccess</idl> is requested. In this case, there are additional parameters available that control the caching behavior of the configuration management component:
+
To obtain updatable access, the service <idl>com.sun.star.configuration.ConfigurationUpdateAccess</idl> is requested.
<source lang="java">
+
  // 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;
+
  }
+
</source>
+
A <idl>com.sun.star.configuration.AdministrationProvider</idl> 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 <idl>com.sun.star.configuration.AdministrationProvider</idl> :
+
 
+
{|border="1" cellpadding=4 style="border-collapse:collapse;"
+
|-bgcolor=#EDEDED
+
!Parameter Name
+
!Type
+
!Default
+
!Comments
+
|-
+
|<code>Entity</code>
+
|<code>string</code>
+
| -
+
|Identifies an entity that the backend can map to a sequence of layers to merge and a target layer for updates.
+
|}
+
 
+
If no <code>Entity</code> is provided, the <idl>com.sun.star.configuration.AdministrationProvider</idl> uses the entity the backend provides through <idlml>com.sun.star.configuration.backend.XBackendEntities:getAdminEntity</idlml>(). 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 <idl>com.sun.star.configuration.AdministrationProvider</idl>, the default value for the locale parameter is "<code>*</code>".
+
  
 
{{PDL1}}
 
{{PDL1}}
  
 
[[Category:Documentation/Developer's Guide/Configuration Management]]
 
[[Category:Documentation/Developer's Guide/Configuration Management]]

Revision as of 15:00, 22 June 2010



After a configuration provider is obtained, call <idlml>com.sun.star.lang.XMultiServiceFactory:createInstanceWithArguments</idlml>() 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.

Template:Documentation/Note

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.

Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages