Preconfigured UCBs
A UCB is called preconfigured if it was given a UCB configuration at the time it was instantiated. A UCB configuration contains a set of UCP registration information.
To create a preconfigured UCB:
- Create an instance of the UNO service com.sun.star.ucb.UniversalContentBroker.
- Pass the configuration as a parameters to the creation function. The UCB instance returned offers all UCPs defined in the given configuration.
Preconfigured UCB:
import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.uno.Exception; import com.sun.star.uno.XInterface; boolean initUCB() { ///////////////////////////////////////////////////////////////////// // Obtain Process Service Manager. ///////////////////////////////////////////////////////////////////// XMultiServiceFactory xServiceFactory = ... ///////////////////////////////////////////////////////////////////// // Create UCB. This needs to be done only once per process. ///////////////////////////////////////////////////////////////////// XInterface xUCB; try { // Supply configuration to use for this UCB instance... String[] keys = new String[2]; keys[0] = "Local"; keys[1] = "Office"; xUCB = xServiceFactory.createInstanceWithArguments( "com.sun.star.ucb.UniversalContentBroker", keys); } catch (com.sun.star.uno.Exception e) { } if (xUCB == null) return false; return true; }
A UCB configuration used by a preconfigured UCB describes a set of UCPs available in a configuration. All UCPs contained in a configuration are registered at the UCB that is created using this configuration. A UCB configuration is identified by two keys that are strings. The keys allow some structuring in the configuration files, but they do not have a purpose. See the example file below. The standard configuration is "Local" and "Office", that allows access to all UCPs. The XML sample below shows how these keys are used to organize UCB configurations.
The predefined configurations for Apache OpenOffice are defined in the file <OfficePath>/share/config/data/org/openoffice/ucb/Configuration.xcd. This file must be adapted to add configurations or edit existing configurations. The XCD file is used during the Apache OpenOffice build process to generate the appropriate XML file. This XML file is part of a Apache OpenOffice installation and is located in <OfficePath>share/config/registry/instance/org/openoffice/ucb/Configuration.xml. The UCB tries to get configuration data from this XML file.
UCB Configuration (org/openoffice/ucb/Configuration.xcd):
<!DOCTYPE schema:package SYSTEM "../schema/schema.description.dtd"> <schema:package package-id="org.openoffice.ucb.Configuration" xml:lang="en-US" xmlns:schema="http://openoffice.org/2000/registry/schema/description" xmlns:default="http://openoffice.org/2000/registry/schema/default" xmlns:cfg="http://openoffice.org/2000/registry/instance"> <schema:templates template-id="org.openoffice.ucb.Configuration"> <!-- ContentProvider --> <schema:group cfg:name="ContentProviderData"> <schema:value cfg:name="ServiceName" cfg:type="string"> </schema:value> <schema:value cfg:name="URLTemplate" cfg:type="string"> </schema:value> <schema:value cfg:name="Arguments" cfg:type="string"> </schema:value> </schema:group> <!-- ContentProvidersDataSecondaryKeys --> <schema:group cfg:name="ContentProvidersDataSecondaryKeys"> <schema:set cfg:name="ProviderData" cfg:element-type="ContentProviderData"/> </schema:group> <!-- ContentProvidersDataPrimaryKeys --> <schema:group cfg:name="ContentProvidersDataPrimaryKeys"> <schema:set cfg:name="SecondaryKeys" cfg:element-type="ContentProvidersDataSecondaryKeys"/> </schema:group> </schema:templates> <schema:component cfg:writable="true" component-id="org.openoffice.ucb.Configuration" cfg:notified="true" cfg:localized="false"> <schema:set cfg:name="ContentProviders" cfg:element-type="ContentProvidersDataPrimaryKeys"> <default:group cfg:name="Local"> <default:set cfg:name="SecondaryKeys" cfg:element-type="ContentProvidersDataSecondaryKeys"> <default:group cfg:name="Office"> <default:set cfg:name="ProviderData" cfg:element-type="ContentProviderData"> <!-- Hierarchy UCP --> <default:group cfg:name="Provider1"> <default:value cfg:name="ServiceName" cfg:type="string"> <default:data>com.sun.star.ucb.HierarchyContentProvider</default:data> </default:value> <default:value cfg:name="URLTemplate" cfg:type="string"> <default:data>vnd.sun.star.hier</default:data> </default:value> <default:value cfg:name="Arguments" cfg:type="string"> <default:data/> </default:value> </default:group> <!-- File UCP --> <default:group cfg:name="Provider2"> <default:value cfg:name="ServiceName" cfg:type="string"> <default:data>com.sun.star.ucb.FileContentProvider</default:data> </default:value> <default:value cfg:name="URLTemplate" cfg:type="string"> <default:data>file</default:data> </default:value> <default:value cfg:name="Arguments" cfg:type="string"> <default:data/> </default:value> </default:group> <!-- Other UCPs go here --> </default:set> </default:group> </default:set> </default:group> </schema:set> </schema:component> </schema:package>
Content on this page is licensed under the Public Documentation License (PDL). |