Difference between revisions of "Documentation/DevGuide/WritingUNO/The UNO Executable"
(Initial author Sun Microsystems, Inc.) |
|||
(9 intermediate revisions by 5 users not shown) | |||
Line 5: | Line 5: | ||
|NextPage=Documentation/DevGuide/WritingUNO/Standalone Use Case | |NextPage=Documentation/DevGuide/WritingUNO/Standalone Use Case | ||
}} | }} | ||
+ | {{Documentation/DevGuideLanguages|Documentation/DevGuide/WritingUNO/{{SUBPAGENAME}}}} | ||
{{DISPLAYTITLE:The UNO Executable}} | {{DISPLAYTITLE:The UNO Executable}} | ||
<!--<idltopic>com.sun.star.lang.XMain</idltopic>--> | <!--<idltopic>com.sun.star.lang.XMain</idltopic>--> | ||
Line 10: | 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: | ||
− | + | <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 16: | Line 17: | ||
long run( [in] sequence< string > aArguments ); | long run( [in] sequence< string > aArguments ); | ||
}; | }; | ||
− | + | </syntaxhighlight> | |
− | 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 <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. |
Basically, the ''uno'' tool can do two different things: | Basically, the ''uno'' tool can do two different things: | ||
# 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. | ||
− | + | <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 28: | Line 29: | ||
long run( [in] sequence< string > aArguments ); | long run( [in] sequence< string > aArguments ); | ||
}; | }; | ||
− | + | </syntaxhighlight> | |
<ol start=2> | <ol start=2> | ||
Line 37: | Line 38: | ||
{{PDL1}} | {{PDL1}} | ||
− | [[Category: Writing UNO Components]] | + | |
+ | [[Category:Documentation/Developer's Guide/Writing UNO Components]] |
Latest revision as of 15:55, 24 December 2020
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:
- 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 );
};
- 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). |