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.

推 型 提 供 者 和 接 收 者 的 实 例}PullSupply model = null; ProxyPullConsumer pullConsumer = null;channel =EventChannelHelper.narrow(orb.resolve_initial_references("EventService"));System.out.println("Located event channel:" + channel);pullConsumer = channel.for_suppliers().obtain_pull_consumer();System.out.println("Obtained pull consumer:" + pullConsumer);model = new PullSupply(pullConsumer, myPOA);myPOA.activate_object_with_id("PullSupply".getBytes(), model);myPOA.the_POAManager().activate();System.out.println("Created model:" + model);System.out.println("Connecting ...");pullConsumer.connect_pull_supplier(model._this());} catch(Exception e) {e.printStackTrace();}}PullConsumePullConsume 类 是 从 PullConsumerPOA 类 派 生 的 , 它 为 从 PullSupply 类 拉 出 数 据 提供 命 令 行 界 面 。 以 下 的 代 码 示 例 说 明 应 用 如 何 连 接 到 任 何 可 用 的 EventChannel,取 得 ProxyPullSupplier, 连 接 到 通 道 , 并 显 示 命 令 提 示 符 。 下 表 总 结 出 了 可 以输 入 的 命 令 。表 15.3描 述PullConsume 命 令使 用 try_pull 方 法 , 从 事 件 通 道 异 步 拉 出 数据 。 如 果 当 前 没 有 可 用 的 数 据 , 则 该 命 令 返 回一 个 “ 无 数 据 ” 消 息 。使 用 pull 方 法 , 从 事 件 通 道 同 步 拉 出 数 据 。如 果 当 前 没 有 可 用 的 数 据 , 则 该 命 令 保 持 阻 塞直 到 数 据 可 用 。从 通 道 断 开 并 退 出 工 具 。命 令asq执 行 PullConsume在 编 译 PullConsume.java 和 启 动 事 件 服 务 之 后 ( 参 见 第 15-22 页 " 进 程 内 事 件通 道 (Java) ", 您 可 以 用 以 下 命 令 来 执 行 接 收 者 :vbj -DORBInitRef = = file: PullConsume// PullConsume.javaimport org.omg.CosEventComm.*;import org.omg.CosEventChannelAdmin.*;import org.omg.PortableServer.*;import java.io.*;public class PullConsume extends PullConsumerPOA {public void disconnect_pull_consumer() {System.out.println("View.disconnect_pull_consumer");}public static void main(String[] args) {使 用 事 件 服 务 15-19

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

Saved successfully!

Ooh no, something went wrong!