Difference between revisions of "Documentation/DevGuide/ProUNO/Java/Mapping of Services"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (Robot: Changing Category:Professional UNO)
m (Robot: Changing Category:Documentation/Developers Guide/Professional UNO)
Line 40: Line 40:
 
{{PDL1}}
 
{{PDL1}}
  
[[Category:Documentation/Developers Guide/Professional UNO]]
+
[[Category:Documentation/Developer's Guide/Professional UNO]]

Revision as of 10:05, 5 June 2008



A new-style services is mapped to a public Java class with the same name. The class has one or more public static methods that correspond to the explicit or implicit constructors of the service.

For a new-style service with a given interface type XIfc, an explicit constructor of the form

 name([in] Type1 arg1, [in] Type2 arg2) raises (Exception1, ..., ExceptionN);

is represented by the Java method

 public   static XIfc name(com.sun.star.uno.XComponentContext context, 
 Type1 arg1, Type2 arg2) 
    throws Exception1, ..., ExceptionN { ... }

A UNO rest parameter (any...) is mapped to a Java rest parameter (java.lang.Object...) in Java 1.5, and to java.lang.Object[] in older versions of Java.

If a new-style service has an implicit constructor, the corresponding Java method is of the form

 public static XIfc create(com.sun.star.uno.XComponentContext context) { ... }

The semantics of both explicit and implicit service constructors in Java are as follows:

  • The first argument to a service constructor is always a com.sun.star.uno.XComponentContext, which must be non-null. Any further arguments are used to initialize the created service (see below).
  • If any of the above steps fails with an exception that the service constructor may throw (according to its exception specification), the service constructor also fails by throwing that exception. Otherwise, if any of the above steps fails with an exception that the service constructor may not throw, the service constructor instead fails by throwing a com.sun.star.uno.DeploymentException. Finally, if no service instance could be created (because either the given component context has no service manager, or the service manager does not support the requested service), the service constructor fails by throwing a com.sun.star.uno.DeploymentException. The net effect is that a service constructor either returns a non-null instance of the requested service, or throws an exception; a service constructor will never return a null instance.

Old-style services are not mapped into the Java language binding.

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