Difference between revisions of "Zh/Documentation/DevGuide/ProUNO/Java/Mapping of Singletons"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (New page: {{Documentation/DevGuide/ProUNOTOC/Zh |ProUNO2c=block |ProUNO2cJava=block |ProUNO2cJavaTM=block |ShowPrevNext=block |PrevPage=Zh/Documentation/DevGuide/ProUNO/Java/Mapping of Services |Nex...)
 
m
 
Line 7: Line 7:
 
|NextPage=Zh/Documentation/DevGuide/ProUNO/Java/Inexact approximation of UNO Value Semantics
 
|NextPage=Zh/Documentation/DevGuide/ProUNO/Java/Inexact approximation of UNO Value Semantics
 
}}
 
}}
[[en:Documentation/DevGuide/ProUNO/Java/Mapping of Singletons]]
+
{{Documentation/DevGuideLanguages|Documentation/DevGuide/ProUNO/Java/{{SUBPAGENAME}}}}
 
{{DISPLAYTITLE:Singleton 的映射}}
 
{{DISPLAYTITLE:Singleton 的映射}}
  

Latest revision as of 02:46, 14 May 2009



以下形式的新式 singleton

 singleton Name: XIfc;

被映射成同名的公共 Java 类。该类有单一方法

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

在 Java 中,这种 singleton getter 方法的语义如下:

  • singleton getter 使用 com.sun.star.uno.XComponentContext:getValueByName 获取 singleton 实例(在 “/singletons/” 命名空间内)。
  • 如果未获取 singleton 实例,则 singleton getter 会抛出 com.sun.star.uno.DeploymentException 并以失败告终。实际结果是 singleton getter 或者返回所请求服务的 singleton 非空实例,或者抛出异常;singleton getter 决不会返回空实例。


没有将旧式 singleton 映射成 Java 语言绑定

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