Difference between revisions of "Documentation/DevGuide/WritingUNO/XInitialization"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (1 revision(s))
m
Line 10: Line 10:
  
 
The specification for <code>XInitialization</code> looks like this:
 
The specification for <code>XInitialization</code> looks like this:
 
+
<source lang="idl">
 
   // module com::sun::star::lang
 
   // module com::sun::star::lang
 
    
 
    
Line 17: Line 17:
 
       void initialize(sequence< any > aArguments) raises (com::sun::star::uno::Exception);  
 
       void initialize(sequence< any > aArguments) raises (com::sun::star::uno::Exception);  
 
   };
 
   };
 
+
</source>
 
An old-style UNOIDL service specification will typically specify which arguments and in which order are expected within the any sequence.
 
An old-style UNOIDL service specification will typically specify which arguments and in which order are expected within the any sequence.
  

Revision as of 20:13, 21 March 2008



The interface com.sun.star.lang.XInitialization is usually implemented manually, because only the programmer knows how to initialize the object with arguments received from the service manager through createInstanceWithArguments() or createInstanceWithArgumentsAndContext(). In Java, XInitialization is used as well, but know that the Java factory helper provides a shortcut that uses arguments without implementing XInitialization directly. The Java factory helper can pass arguments to the class constructor under certain conditions. Refer to the section Create Instance with Arguments for more information.

The specification for XInitialization looks like this:

  // module com::sun::star::lang
 
  interface XInitialization : com::sun::star::uno::XInterface 
  {
      void initialize(sequence< any > aArguments) raises (com::sun::star::uno::Exception); 
  };

An old-style UNOIDL service specification will typically specify which arguments and in which order are expected within the any sequence.

With the advent of new-style service specifications with explicit constructors, you can now declare explicitly what arguments can be passed to an object when creating it. The arguments listed in a constructor are exactly the arguments passed to XInitialization.initialize (the various language bindings currently use XInitialization internally to implement service constructors; that may change in the future, however).

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