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.

激 活 器 界 面Java:这 个 代 码 示 例 示 范 激 活 器 界 面 , 该 界 面 提 供 BOA 可 调 用 来 激 活 和 去 激 活<strong>VisiBroker</strong> ORB 对 象 的 方 法 。package com.inprise.vbroker.extension;public interface Activator {public abstract org.omg.CORBA.Object activate(ImplementationDef impl);public abstract void deactivate(org.omg.CORBA.Object obj, ImplementationDefimpl);}以 下 的 代 码 示 例 示 范 您 如 何 为 AccountImpl Interface 创 建 Activator 。C++: class extension {. . .class AccountImplActivator :public extension::Activator {public:virtual CORBA::Object_ptr activate(CORBA::ImplementationDef_ptr impl);virtual void deactivate(CORBA::Object_ptr,CORBA::ImplementationDef_ptr impl);};CORBA::Object_ptr AccountImplActivator::activate(CORBA::ImplementationDef_ptr impl) {// 当 BOA 需 要 激 活 我 们 时 , 将 AccountImpl 对 象 实 例 化 。extension::ActivationImplDef* actImplDef =extension::ActivationImplDef::_downcast(impl);CORBA::Object_var obj = new AccountImpl(actImplDef->object_name());return CORBA::_duplicate(obj);}void AccountImplActivator::deactivate(CORBA::Object_ptr obj,CORBA::ImplementationDef_ptr impl) {// 当 BOA 去 激 活 我 们 时 , 释 放 Account 对 象 。obj->_release;}}Java:以 下 的 代 码 示 例 示 范 如 何 为 DBObjectImpl Interface 创 建 Activator 。// Server.javaimport com.inprise.vbroker.extension.*;. . .class DBActivator implements Activator {private static int _count;private com.inprise.vbroker.CORBA.BOA _boa;public DBActivator(com.inprise.vbroker.CORBA.BOA boa) {_boa = boa;}public org.omg.CORBA.Object activate(com.inprise.vbroker.extension.ImplementationDef impl) {System.out.println("Activator called " + ++_count + " times");byte[] ref_data = ((ActivationImplDef) impl).id();DBObjectImpl obj = new DBObjectImpl(new String(ref_data));_boa.obj_is_ready(obj);return obj;}public void deactivate(org.omg.CORBA.Object obj,31-2 <strong>VisiBroker</strong> 开 发 者 指 南

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

Saved successfully!

Ooh no, something went wrong!