Borland(R) Enterprise Server VisiBroker(R) デベロッパーズガイド

[目次][索引][前へ][次へ]

19.2.7 ポータブルインタセプタの作成

ポータブルインタセプタの一般的な作成手順を次に示します。

  1. インタセプタは次のインタセプタインタフェースの一つから継承されなければなりません。
    • ClientRequestInterceptor
    • ServerRequestInterceptor
    • IORInterceptor
  2. インタセプタは,インタセプタで使用できる一つ以上のインタセプトポイントをインプリメントします。
  3. インタセプタは名前付き,または名前なしでもかまいません。すべての名前は同じタイプのインタセプタすべての中では一意である必要がありますが,名前なしのインタセプタは幾つでもBorland Enterprise Server VisiBroker ORBに登録できます。

コードサンプル19-15 ポータブルインタセプタの作成例(C++)
 
#include "PortableInterceptor_c.hh"
 
class SampleClientRequestInterceptor:public 
   PortableInterceptor::ClientRequestInterceptor
{
   char *name(){
      return "SampleClientRequestInterceptor";
   }
 
   void send_request(ClientRequestInfo_ptr _ri){
     .......//actual interceptor code here
   }
 
   void send_poll(ClientRequestInfo_ptr _ri){
     .......//actual interceptor code here
   }
 
   void receive_reply(ClientRequestInfo_ptr _ri){
     .......//actual interceptor code here
   }
 
   void receive_exception(ClientRequestInfo_ptr _ri){
     .......//actual interceptor code here
   }
 
   void receive_other(ClientRequestInfo_ptr _ri){
     .......//actual interceptor code here
   }
};
 

コードサンプル19-16 ポータブルインタセプタの作成例(Java)
 
import org.omg.PortableInterceptor.*;
 
public class SampleClientRequestInterceptor extends 
   org.omg.CORBA.LocalObject
   implements ClientRequestInterceptor
{
   public java.lang.String name(){
      return "SampleClientRequestInterceptor";
   }
 
   public void send_request(ClientRequestInfo ri)
      throws ForwardRequest {
      .......//actual interceptor code here
   }
 
   public void send_poll(ClientRequestInfo ri)
      throws ForwardRequest {
      .......//actual interceptor code here
   }
 
   public void receive_reply(ClientRequestInfo ri){
      .......//actual interceptor code here
   }
 
   public void receive_exception(ClientRequestInfo ri)
      throws ForwardRequest {
      .......//actual interceptor code here
   }
 
   public void receive_other(ClientRequestInfo ri)
      throws ForwardRequest {
      .......//actual interceptor code here
   }
}