12.07.2015 Views

VisiBroker Edition

VisiBroker Edition

VisiBroker Edition

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

实 现 工 厂return new PointImpl();}};Point_init 包 含 公 共 方 法 create_for_unmarshal, 在 Map_c.hh 中 此 方 法 是 作 为 纯虚 拟 方 法 的 输 出 。 您 必 须 从 Point_init 中 派 生 类 , 并 执 行 create_for_unmarshal方 法 以 产 生 工 厂 类 。 在 编 译 IDL 文 件 时 , 它 不 会 为 此 创 建 框 架 类 。Java: public class PointDefaultFactory implements PointValueFactory {public java.io.Serializable read_value (org.omg.CORBA.portable.InputStream is){java.io.Serializable val = new PointImpl(); // Called the implementationclass// 创 建 并 初 始 化 值val = ((org.omg.CORBA_2_3.portable.InputStream)is).read_value(val);return val;}// 现 在 该 由 用 户 以 他 们 所 需 的 任 何 方 式 来 实 现 valuetype:public Point create (int x,int y,java.lang.String z) {// 实 现 :return null;}}调 用 PointImpl() 以 创 建 新 valuetype,read_value 会 从 InputStream 中 读 取 该 新valuetype。Java: 您 必 须 调 用 read_value, 否 则 工 厂 不 起 作 用 , 并 且 您 无 法 调 用 任 何 其 它 方 法 。向 <strong>VisiBroker</strong> ORB 注 册 工 厂C++:Java:调 用 ORB::register_value_factory 以 向 <strong>VisiBroker</strong> ORB 注 册 工 厂 。 有 关 注 册 工厂 的 详 情 , 请 参 阅 “ 第 26-7 页 " 注 册 valuetypes"。调 用 ORB.register_value_factory 以 向 <strong>VisiBroker</strong> ORB 注 册 工 厂 。 仅 在 未 对 工厂 valuetypenameDefaultFactory 命 名 时 执 行 此 操 作 。 有 关 注 册 工 厂 的 详 情 , 请 参阅 第 26-7 页 " 注 册 valuetypes"。实 现 工 厂在 <strong>VisiBroker</strong> ORB 接 收 valuetype 时 , 首 先 必 须 对 其 解 包 , 然 后 必 须 查 找 该 类型 的 相 应 工 厂 , 以 便 创 建 该 类 型 的 新 实 例 。 在 创 建 实 例 后 , 将 值 数 据 解 包 成 实 例 。类 型 是 通 过 作 为 调 用 的 一 部 分 来 传 递 的 RepositoryID 来 识 别 的 。 类 型 和 工 厂 之 间的 映 射 是 特 写 于 语 言 的 映 射 。以 下 代 码 示 例 包 含 使 用 JDK 1.2 实 现 “ 点 ” valuetype 工 厂 的 示 例 。使 用 valuetypes 26-5

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!