Singleton 的映射
From Apache OpenOffice Wiki
< Zh | Documentation
以下形式的新式 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). |