12.07.2015 Views

VisiBroker Edition

VisiBroker Edition

VisiBroker Edition

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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

接 收 器 实 例表 21.2接 收 器 实 例 执 行 结 果客 户 端============> SampleClientInterceptor idMyClientInterceptor postinvoke============>SampleBindInterceptor bind============>SampleBindInterceptor bind_succeeded============>SampleClientInterceptor id MyClientInterceptorpreinvoke_premarshal => balance ============>SampleClientInterceptor id MyClientInterceptorpreinvoke_postmarshal============> SampleClientInterceptor idMyClientInterceptor postinvokeThe balance in john'saccount is $245.64服 务 器============> SampleServerInterceptor idMyServerInterceptor postinvoke_premarshal============>SampleServerInterceptor id MyServerInterceptorpostinvoke_postmarshal由 于 OAD 未 运 行 , bind 调 用 失 败 , 服 务 器 继 续 执 行 。 客 户 端 限 制 到 帐 户 对 象 , 然 后 调 用balance 方 法 。 服 务 器 收 到 此 请 求 并 处 理 , 然 后 结 果 返 回 给 客 户 端 。 客 户 端 打 印 结 果 。如 实 例 代 码 和 结 果 所 示 , 在 相 应 进 程 开 始 时 同 时 安 装 客 户 端 和 服 务 器 的 接 收 器 。 有关 注 册 接 收 器 的 信 息 在 第 21-5 页 " 向 <strong>VisiBroker</strong> <strong>Edition</strong> ORB 注 册 接 收 器 " 中有 介 绍 。ServiceResolverInterceptor 实 例Java: 下 列 代 码 为 如 何 实 现 ServiceLoader 接 口 的 实 例 :import com.inprise.vbroker.properties.*;import com.inprise.vbroker.interceptor.*;import com.inprise.vbroker.InterceptorExt.*;public final class UtilityServiceLoader implements ServiceLoader,ServiceResolverInterceptor {private com.inprise.vbroker.orb.ORB _orb = null;private String[] _serviceNames = { "TimeService", "WeatherService"};public void init(org.omg.CORBA.ORB orb) {// 以 防 resolve() 需 要_orb = (com.inprise.vbroker.orb.ORB) orb;PropertyManager pm = _orb.getPropertyManager();// 使 用 PropertyManager 查 询 属 性 设 置// ( 如 有 必 要 , 此 实 例 中 未 使 用 )/**** 安 装 初 始 引 用 *****/InterceptorManagerControl control = _orb.interceptorManager();ServiceResolverInterceptorManager manager =(ServiceResolverInterceptorManager)control.get_manager("ServiceResolver");for (int i = 0; i < _serviceNames.length; i++) {manager.add(_serviceNames[i], this);}21-8 <strong>VisiBroker</strong> 开 发 者 指 南

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

Saved successfully!

Ooh no, something went wrong!