Difference between revisions of "Documentation/DevGuide/WritingUNO/The UNO Executable"

From Apache OpenOffice Wiki
Jump to: navigation, search
m
 
Line 11: Line 11:
  
 
For these cases, the <idl>com.sun.star.lang.XMain</idl> interface was introduced. It has one method:
 
For these cases, the <idl>com.sun.star.lang.XMain</idl> interface was introduced. It has one method:
<source lang="idl">
+
<syntaxhighlight lang="idl">
 
   /* module com.sun.star.lang.XMain */
 
   /* module com.sun.star.lang.XMain */
 
   interface XMain: com::sun::star::uno::XInterface
 
   interface XMain: com::sun::star::uno::XInterface
Line 17: Line 17:
 
       long run( [in] sequence< string > aArguments );  
 
       long run( [in] sequence< string > aArguments );  
 
   };
 
   };
</source>
+
</syntaxhighlight>
 
Instead of writing an executable, write a component and implement this interface. The component gets the fully initialized service manager during instantiation. The <code>run()</code> method then should do what a <code>main()</code> function would have done. The UNO executable offers one possible infrastructure for using such components.  
 
Instead of writing an executable, write a component and implement this interface. The component gets the fully initialized service manager during instantiation. The <code>run()</code> method then should do what a <code>main()</code> function would have done. The UNO executable offers one possible infrastructure for using such components.  
  
Line 23: Line 23:
  
 
# Instantiate a UNO component which supports the [IDL:com.sun.star.lang.XMain] interface and executes the <code>run()</code> method.
 
# Instantiate a UNO component which supports the [IDL:com.sun.star.lang.XMain] interface and executes the <code>run()</code> method.
<source lang="idl">
+
<syntaxhighlight lang="idl">
 
   // module com::sun::star::lang
 
   // module com::sun::star::lang
 
   interface XMain: com::sun::star::uno::XInterface
 
   interface XMain: com::sun::star::uno::XInterface
Line 29: Line 29:
 
       long run( [in] sequence< string > aArguments );  
 
       long run( [in] sequence< string > aArguments );  
 
   };
 
   };
</source>
+
</syntaxhighlight>
  
 
<ol start=2>
 
<ol start=2>

Latest revision as of 15:55, 24 December 2020

  • 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