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.

接 收 器 实 例orb.resolve_initial_references("<strong>VisiBroker</strong>InterceptorControl"));// 安 装 一 个 POA 接 收 器POALifeCycleInterceptorManager poa_manager =(POALifeCycleInterceptorManager)control.get_manager("POALifeCycle");poa_manager.add(new SamplePOALifeCycleInterceptor());} catch(Exception e) {e.printStackTrace();throw new org.omg.CORBA.INITIALIZE(e.toString());}System.out.println("============>SampleServerLoader:Interceptors loaded");}public void init_complete(org.omg.CORBA.ORB orb) {}public void shutdown(org.omg.CORBA.ORB orb) {}}Java:每 次 创 建 或 销 毁 POA 时 会 调 用 SamplePOALifeCycleInterceptor 对 象 。 由 于 在client_server 实 例 中 有 两 个 POA, 因 此 此 接 收 器 被 调 用 两 次 , 一 次 是 在 rootPOA创 建 期 间 , 另 一 次 是 在 创 建 myPOA 时 。 我 们 只 在 创 建 myPOA 时 安 装SampleServerInterceptor。import com.inprise.vbroker.interceptor.*;import com.inprise.vbroker.PortableServerExt.*;import com.inprise.vbroker.IOP.*;public class SamplePOALifeCycleInterceptor implements POALifeCycleInterceptor {public void create(org.omg.PortableServer.POA poa,org.omg.CORBA.PolicyListHolder policies_holder,IORValueHolder iorTemplate,InterceptorManagerControl control) {if(poa.the_name().equals("bank_agent_poa")) {// 添 加 请 求 级 接 收 器SampleServerInterceptor interceptor =new SampleServerInterceptor("MyServerInterceptor");// 取 得 IORCreation 接 收 器 管 理 器ServerRequestInterceptorManager manager =(ServerRequestInterceptorManager)control.get_manager("ServerRequest");// 添 加 接 收 器manager.add(interceptor);System.out.println("============>In POA " + poa.the_name() +", 1 ServerRequest interceptor installed");} elseSystem.out.println("============>In POA " + poa.the_name() + ".Nothing todo.");}public void destroy(org.omg.PortableServer.POA poa) {// 作 为 一 跟 踪 手 段 !S ystem.out.println("============> SamplePOALifeCycleInterceptor destroy");}}每 次 服 务 器 收 到 请 求 或 作 出 应 答 时 会 调 用 SampleServerInterceptor 对 象 。21-10 <strong>VisiBroker</strong> 开 发 者 指 南

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

Saved successfully!

Ooh no, something went wrong!