The UNO Executable

From Apache OpenOffice Wiki
Jump to: navigation, search
  • The UNO Executable



In chapter C++ Language Binding, several methods to bootstrap a UNO application were introduced. In this section, the option UNO executable is discussed. With UNO executable, there is no need to write executables anymore, instead only components are developed. Code within executables is locked up, it can only run by starting the executable, and it can never be used in another context. Components offer the advantage that they can be used from anywhere. They can be executed from Java or from a remote process.

For these cases, the com.sun.star.lang.XMain interface was introduced. It has one method:

  /* module com.sun.star.lang.XMain */
  interface XMain: com::sun::star::uno::XInterface
  {
      long run( [in] sequence< string > aArguments ); 
  };

Instead of writing an executable, write a component and implement this interface. The component gets the fully initialized service manager during instantiation. The run() method then should do what a main() function would have done. The UNO executable offers one possible infrastructure for using such components.

Basically, the uno tool can do two different things:

  1. Instantiate a UNO component which supports the [IDL:com.sun.star.lang.XMain] interface and executes the run() method.
  // module com::sun::star::lang
  interface XMain: com::sun::star::uno::XInterface
  { 
      long run( [in] sequence< string > aArguments ); 
  };
  1. Export a UNO component to another process by accepting on a resource, such as a tcp/ip socket or named pipe, and instantiating it on demand.

In both cases, the uno executable creates a UNO component context which is handed to the instantiated component. The registries that should be used are given by command line arguments. The goal of this tool is to minimize the need to write executables and focus on writing components. The advantage for component implementations is that they do not care how the component context is bootstrapped. In the future there may be more ways to bootstrap the component context. While executables will have to be adapted to use the new features, a component supporting XMain can be reused.

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