Registering Services

In general, every application has a registry. In OpenOffice.org, there are two registries, applicat.rdb and user.rdb. Both files applicat.rdb and user.rdb are interface and type description databases (type libraries), whereas the extension rdb is an abbreviation of reflection database. The Reflection Databases contain the definition of all types used in the OpenOffice.org application and information how to instantiate a service or component. This information is written into the reflection database by the component itself using the method Car.__writeRegistryServiceInfo().

The applicat.rdb contains services, interfaces, exceptions, enumerations, and structures, that are available to all users and are part of the installation files of the OpenOffice.org application suite. In contrast, the user.rdb file contains objects that are unique for each user. Applicat.rdb and user.rdb files are binary files. In order to view the registry entries, you have to use the tool regview, that is provided by the Office Development Kit. Regview is a small tool to show the content of a registry file. The tool dumps the hierarchical structure and the values of the nodes to standard output in a human readable form.

The service com.sun.star.registry.ImplementationRegistration can be used to register a shared library. The service exports the interface com.sun.star.registry.XImplementationRegistration, which offers the method registerImplementation. The library name, the service name of the loader (in general com.sun.star.loader.SharedLibrary), and a reference to a XRegistryKey interface (where the data shall be written to) must all be passed to the method. If an empty reference is passed, the service uses the registry of the servicemanager.

For example, a service implementation can be registered via StarBasic creating the service ImplementationRegistration and calling the method registerImplementation(). The method registerImplementation() requires three parameters: the implementation loader, the file location, and the registry. For registering a Java component, you must use the implementation loader string "com.sun.star.loader.Java2"; for registering a C++ component, you must use the implementation loader string "com.sun.star.loader.SharedLibrary". The second parameter must be a UNO file Uniform Resource Locator. Finally, you can select a specified registry, to which the service implementation should be registered. If an empty reference is passed, the method uses the default registry for the current user.

  regImpl = createUnoService("com.sun.star.registry.ImplementationRegistration")
  regImpl.registerImplementation("com.sun.star.loader.Java2", "file:///home/testComponent.jar",    null)
  regImpl.revokeImplementation(" file:///home/testComponent.jar", null)

The last StarBasic command revokes the service implementation from the default registry.

In the Office Development Kit, there is another way to register a service implementation: the command line tool for registration (regcomp). Just call the tool without parameters to see its usage. For example, you can write

  regcomp -register -r applicat.rdb -c file:///home/testComponent.jar

to your command shell, where the last argument has to be replaced with the name of your shared library. After the registration, the service is accessible directly through the servicemanager. Now you should be able to start the office program and have your implementation available. If you would like to revoke the shared library later, type

  regcomp -revoke -r applicat.rdb -c file:///home/testComponent.jar

at the prompt.


Legal Notices