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.

仅 适 用 于 C++:C++:使 用 非 型 别 对 象 封 装 器Closure closure) {System.out.println("Timing: " +((com.inprise.vbroker.CORBA.Object) target)._object_name() + "->"+ operation + "()");time = System.currentTimeMillis();}public void post_method(String operation,org.omg.CORBA.Object target,org.omg.CORBA.Environment env,Closure closure) {long diff = System.currentTimeMillis() - time;System.out.println("Timing:Time for call \t" +((com.inprise.vbroker.CORBA.Object)target)._object_name() + "->" + operation + "() = " + diff + " ms.");}}pre_method 和 post_method 参 数pre_method 和 post_method 都 会 收 到 下 表 所 示 参 数 。表 22.2参 数pre_method 和 post_method 方 法 的 普 通 变 量说 明operation 目 标 对 象 上 要 求 的 操 作 名 称 。target 目 标 对 象 。closure在 调 用 方 法 期 间 可 以 为 此 封 装 器 保 存 数 据 的 区域 。post_method 也 会 收 到 一 个 Environment 参 数 , 该 参 数 可 用 于 通 知 用 户 在 方 法 调 用的 上 一 步 骤 期 间 可 能 发 生 的 任 何 违 例 现 象 。创 建 和 注 册 非 型 别 对 象 封 装 器 工 厂无 论 何 时 使 用 接 受 定 位 的 基 类 构 建 器 创 建 非 型 别 对 象 封 装 器 工 厂 时 , 该 封 装 器 工 厂均 会 自 动 被 添 加 到 非 型 别 封 装 器 链 上 。在 客 户 端 , 只 有 在 对 象 被 限 制 之 前 创 建 和 注 册 非 型 别 对 象 封 装 器 , 才 会 封 装 对 象 。在 服 务 器 端 , 非 型 别 对 象 封 装 器 工 厂 是 在 对 象 实 现 被 调 用 之 前 创 建 和 注 册 的 。以 下 代 码 示 例 为 样 本 文 件 UntypedClient.C 的 一 部 分 , 其 中 示 范 了 为 某 客 户 端 创 建( 自 动 注 册 ) 两 个 非 型 别 对 象 封 装 器 工 厂 的 过 程 。 这 些 工 厂 是 在 <strong>VisiBroker</strong> ORB被 初 始 化 之 后 、 客 户 端 限 制 到 对 象 之 前 创 建 的 。C++: int main(int argc, char* const* argv) {try {// 初 始 化 ORB。CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);// 安 装 非 型 别 对 象 封 装 器TimingObjectWrapperFactory timingfact(VISObjectWrapper::Client,"timeclient");TraceObjectWrapperFactory tracingfact(VISObjectWrapper::Client,使 用 对 象 封 装 器 22-7

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

Saved successfully!

Ooh no, something went wrong!