CORBAリクエスト・レベルのインターセプタの使用

     前  次    新規ウィンドウで目次を開く  新規ウィンドウで索引を開く  PDFとして表示 - 新規ウィンドウ  Adobe Readerを取得 - 新規ウィンドウ
コンテンツはここから始まります

リクエスト・レベルのインターセプタのスタータ・ファイル

この付録では、インターセプタの実装を開始する際に使用できる次のコードを示します。

このコードを使用する場合は、YourInterceptorを実装しているインターセプタの名前に置き換えてください。

 


スタータ実装コード

#if defined(WIN32)
#include <windows.h>
#endif

#include <ctype.h>


#include "YourInterceptor.h"

// Cleanup class -- suggested
class Cleanup
{
    public:
    Cleanup() {}
    ~Cleanup()
    {
        // <<<Fill in your code here>>>

    }
};
static Cleanup CleanupOnImageExit;

#define SECURITY_BUFFSIZE   100

#if defined(WIN32)
// suggestion for standard DLL processing

BOOL WINAPI DllMain( HANDLE hDLL,
             DWORD dwReason,
             LPVOID lpReserved )
{
    switch( dwReason )
    {
    case DLL_PROCESS_ATTACH:
            break;
    case DLL_PROCESS_DETACH:
            break;
    case DLL_THREAD_ATTACH:
            break;
    case DLL_THREAD_DETACH:
            break;
    }

    // Return that the operation was successful
    return( TRUE );
    }
#endif /* WIN32 */

/*************************************************************

   FUNCTION NAME:       YourInterceptorInit

   FUNCTIONAL DESCRIPTION:

        Initialization routine called by the ORB during initialization.
        This routine will create and return instances of the
        RequestLevelInterceptor classes that it supports.

        NOTE: An interceptor library can support more than one set of
        interceptors by supplying multiple initialization entry points
        (each initialization entry must be separately registered with the
        ORB) Also, it is legal for only one kind of interceptor to be
        supplied (i.e. only a client or only a target.)

***************************************************************/
#ifdef WIN32
extern "C" __declspec(dllexport) void __cdecl
#else
extern "C" void
#endif
YourInterceptorInit(
    CORBA::ORB_ptr                                       TheORB,
    RequestLevelInterceptor::ClientRequestInterceptor ** ClientPtr,
    RequestLevelInterceptor::TargetRequestInterceptor ** TargetPtr,
    CORBA::Boolean *                                     RetStatus)
{
    // <<<Fill in your code here>>>

}

/*************************************************************

   FUNCTION NAME:       YourInterceptorClient constructor

   FUNCTIONAL DESCRIPTION:

***************************************************************/
YourInterceptorClient::YourInterceptorClient(CORBA::ORB_ptr TheOrb)
{
    // This next line is useful, but not absolutely necessary.

    m_orb = TheOrb;

    // <<<Fill in your code here>>>
}

/*************************************************************

   FUNCTION NAME:        YourInterceptorClient::shutdown

   FUNCTIONAL DESCRIPTION:

        The shutdown operation is used by the ORB to notify an
        implementation of an interceptor that the interceptor
        is being shutdown. The ORB will destroy the instance
        of the interceptor once control is returned from the
        operation back to the ORB.

***************************************************************/

Interceptors::ShutdownReturnStatus YourInterceptorClient::shutdown(
    Interceptors::ShutdownReason    reason,
    CORBA::Exception_ptr &          excep_val)
{
    // The following lines are a suggestion only. Replace them if you wish.

    Interceptors::ShutdownReturnStatus ret_status = Interceptors::SHUTDOWN_NO_EXCEPTION;
    switch (reason)
    {
    case Interceptors::ORB_SHUTDOWN:
        // <<<Fill in your code here>>>
        break;
    case Interceptors::CONNECTION_ABORTED:
        // <<<Fill in your code here>>>

        break;
    case Interceptors::RESOURCES_EXCEEDED:
        // <<<Fill in your code here>>>

        break;
    }
    return ret_status;
}

/*************************************************************

   FUNCTION NAME:        YourInterceptorClient::id

   FUNCTIONAL DESCRIPTION:
        The id accessor operation is used by the ORB to obtain
        the vendor assigned identity of the interceptor as a string
        value. This attribute is used primarily for debugging and
        tracing of operations on the interceptors called by the ORB.

***************************************************************/
CORBA::String YourInterceptorClient::id()
{
    // <<<Fill in your code here>>>

    // The next line is a possible implementation that is useful
    return CORBA::string_dup("YourInterceptorClient");
}

/*************************************************************

   FUNCTION NAME:        YourInterceptorClient::exception_occurred

   FUNCTIONAL DESCRIPTION:

        The exception_occurred operation is called on a request-level
        interceptor implementation when an exception occurs.
        It is called instead of the <xxx>_response
        method of that interceptor. The ORB calls this operation to
        allow the interceptor implementation to clean-up any state
        that it might have been managing that is specific to a request.

***************************************************************/
void YourInterceptorClient::exception_occurred (
        const RequestLevelInterceptor::ReplyContext &   reply_context,
        CORBA::Exception_ptr                            excep_val)
{
    // <<<Fill in your code here>>>
}

/*************************************************************

   FUNCTION NAME:       YourInterceptorClient::client_invoke

   FUNCTIONAL DESCRIPTION:

        This operation is called by the ORB anytime that an
        invocation is being sent to a target object, regardless
        of whether the target object is in a different address
        space or the same address space as the target object.

***************************************************************/
Interceptors::InvokeReturnStatus YourInterceptorClient::client_invoke (
        const RequestLevelInterceptor::RequestContext &   request_context,
        RequestLevelInterceptor::ServiceContextList_ptr   service_context,
        CORBA::DataInputStream_ptr                        request_arg_stream,
        CORBA::DataOutputStream_ptr                       reply_arg_stream,
        CORBA::Exception_ptr &                            excep_val)
{
    // The next line is a suggestion that works in conjunction with the last line below

    Interceptors::InvokeReturnStatus ret_status = Interceptors::INVOKE_NO_EXCEPTION;
    

    // <<<Fill in your code here>>>
    

    return ret_status;
}

/*************************************************************

   FUNCTION NAME:        YourInterceptorClient::client_response

   FUNCTIONAL DESCRIPTION:

        The operation is called by the ORB anytime that a reply
        to an invocation is being received by the initiator of
        the request, regardless of whether the initiator is in
        a different address space or the same address space as
        the target object.
  
***************************************************************/
Interceptors::ResponseReturnStatus YourInterceptorClient::client_response (
        const RequestLevelInterceptor::ReplyContext &     reply_context,
        RequestLevelInterceptor::ServiceContextList_ptr   service_context,
        CORBA::DataInputStream_ptr                        arg_stream,
        CORBA::Exception_ptr &                            excep_val)
{
    // The next line is a suggestion that works in conjunction with the last line below

    // See the examples for other suggestions of general use

    Interceptors::ResponseReturnStatus ret_status = Interceptors::RESPONSE_NO_EXCEPTION;

    

    // <<<Fill in your code here>>>

    

    return ret_status;

}

/*************************************************************

    FUNCTION NAME:       YourInterceptorTarget constructor

    FUNCTIONAL DESCRIPTION:

        This function constructs the target interceptor instance.
        This example provides data members that could be used to
        implement a security interceptor.
  
***************************************************************/
YourInterceptorTarget::YourInterceptorTarget(CORBA::ORB_ptr TheOrb) :
    m_orb(TheOrb),          // suggestion
    m_security_current(0), // suggestion for security interceptors
    m_attributes_to_get(0) // suggestion for security interceptors
{
    // <<<Fill in your code here>>>

}


/*************************************************************

   FUNCTION NAME:       YourInterceptorTarget::shutdown

   FUNCTIONAL DESCRIPTION:

        The shutdown operation is used by the ORB to notify an
        implementation of an interceptor that the interceptor
        is being shutdown. The ORB will destroy the instance
        of the interceptor once control is returned from the
        operation back to the ORB.

***************************************************************/
Interceptors::ShutdownReturnStatus YourInterceptorTarget::shutdown(
        Interceptors::ShutdownReason    reason,
        CORBA::Exception_ptr &          excep_val)
{
    // <<<Fill in your code here>>>



    // The following lines are a suggestion only. Replace them if you wish.

    Interceptors::ShutdownReturnStatus ret_status = Interceptors::SHUTDOWN_NO_EXCEPTION;
    switch (reason)
    {
    case Interceptors::ORB_SHUTDOWN:
        // <<<Fill in your code here>>>
        break;
    case Interceptors::CONNECTION_ABORTED:
        // <<<Fill in your code here>>>
        break;
    case Interceptors::RESOURCES_EXCEEDED:
        // <<<Fill in your code here>>>
        break;
    }
    return ret_status;
}

/*************************************************************

   FUNCTION NAME:       YourInterceptorTarget::id

   FUNCTIONAL DESCRIPTION:

        The id accessor operation is used by the ORB to obtain
        the vendor assigned identity of the interceptor as a string
        value. This attribute is used primarily for debugging and
        tracing of operations on the interceptors called by the ORB.

***************************************************************/
CORBA::String YourInterceptorTarget::id()
{
    // <<<Fill in your code here>>>

    // The next line is a possible implementation that is useful

    return CORBA::string_dup("YourInterceptorTarget");
}

/*************************************************************

   FUNCTION NAME:       YourInterceptorTarget::exception_occurred

   FUNCTIONAL DESCRIPTION:

        The exception_occurred operation is called on a request-level
        interceptor implementation when an exception occurs.
        It is called instead of the <xxx>_response
        method of that interceptor. The ORB calls this operation to
        allow the interceptor implementation to clean-up any state
        that it might have been managing that is specific to a request.

***************************************************************/
void YourInterceptorTarget::exception_occurred (
        const RequestLevelInterceptor::ReplyContext &   reply_context,
        CORBA::Exception_ptr                            excep_val)
{
    // <<<Fill in your code here>>>

}

/*************************************************************

   FUNCTION NAME:       YourInterceptorTarget::target_invoke

   FUNCTIONAL DESCRIPTION:

        The operation is called by the ORB anytime that an
        invocation is being received by a target object,
        regardless of whether the target object is in a
        different address space or the same address space
        as the target object.

***************************************************************/
Interceptors::InvokeReturnStatus YourInterceptorTarget::target_invoke (
        const RequestLevelInterceptor::RequestContext &     request_context,
        RequestLevelInterceptor::ServiceContextList_ptr     service_context,
      CORBA::DataInputStream_ptr                           request_arg_stream,
        CORBA::DataOutputStream_ptr                         reply_arg_stream,
        CORBA::Exception_ptr &                              excep_val)
{
   // The next line is a suggestion that works in conjunction with the last line below

    Interceptors::InvokeReturnStatus ret_status = Interceptors::INVOKE_NO_EXCEPTION;

    

    // <<<Fill in your code here>>>

    

    return ret_status;

}

/*************************************************************

   FUNCTION NAME:       YourInterceptorTarget::target_response

   FUNCTIONAL DESCRIPTION:

        The operation is called by the ORB anytime that a reply
        to an invocation is being sent to the initiator of the
        request, regardless of whether the initiator is in a
        different address space or the same address space as
        the target object.

***************************************************************/
Interceptors::ResponseReturnStatus YourInterceptorTarget::target_response (
        const RequestLevelInterceptor::ReplyContext &       reply_context,
        RequestLevelInterceptor::ServiceContextList_ptr     service_context,
        CORBA::DataInputStream_ptr                          arg_stream,
        CORBA::Exception_ptr &                              excep_val)
{
   // The next line is a suggestion that works in conjunction with the last line below

    Interceptors::ResponseReturnStatus ret_status = Interceptors::RESPONSE_NO_EXCEPTION;



    // <<<Fill in your code here>>>

    

    return ret_status;

}

/*************************************************************

   FUNCTION NAME:       YourInterceptorTarget destructor

   FUNCTIONAL DESCRIPTION:

***************************************************************/
YourInterceptorTarget::~YourInterceptorTarget()
{
    // <<<Fill in your code here>>>

}

 


スタータ・ヘッダー・ファイル・コード

#include <CORBA.h>
#include <RequestLevelInterceptor.h>
#include <security_c.h>      //used with security

class YourInterceptorClient : public virtual RequestLevelInterceptor::ClientRequestInterceptor
{
private:
    YourInterceptorClient() {}
    CORBA::ORB_ptr m_orb;
public:
    YourInterceptorClient(CORBA::ORB_ptr TheOrb);
    ~YourInterceptorClient() {}
    Interceptors::ShutdownReturnStatus shutdown(
        Interceptors::ShutdownReason reason,
        CORBA::Exception_ptr & excep_val);
    CORBA::String id();
    void exception_occurred (
        const RequestLevelInterceptor::ReplyContext & reply_context,
        CORBA::Exception_ptr excep_val);
    Interceptors::InvokeReturnStatus client_invoke (
        const RequestLevelInterceptor::RequestContext & request_context,
        RequestLevelInterceptor::ServiceContextList_ptr service_context,
        CORBA::DataInputStream_ptr request_arg_stream,
        CORBA::DataOutputStream_ptr reply_arg_stream,
        CORBA::Exception_ptr & excep_val);
    Interceptors::ResponseReturnStatus client_response (
        const RequestLevelInterceptor::ReplyContext & reply_context,
        RequestLevelInterceptor::ServiceContextList_ptr service_context,
        CORBA::DataInputStream_ptr arg_stream,
        CORBA::Exception_ptr & excep_val);
    
};

class YourInterceptorTarget : public virtual RequestLevelInterceptor::TargetRequestInterceptor
{
private:
    YourInterceptorTarget() {}
    CORBA::ORB_ptr m_orb;
    SecurityLevel1::Current_ptr m_security_current;       //used with security
    Security::AttributeTypeList * m_attributes_to_get;    //used with security
public:
    YourInterceptorTarget(CORBA::ORB_ptr TheOrb);
    ~YourInterceptorTarget();
    Interceptors::ShutdownReturnStatus shutdown(
        Interceptors::ShutdownReason reason,
        CORBA::Exception_ptr & excep_val);
    CORBA::String id();
    void exception_occurred (
        const RequestLevelInterceptor::ReplyContext & reply_context,
        CORBA::Exception_ptr excep_val);
    Interceptors::InvokeReturnStatus target_invoke (
        const RequestLevelInterceptor::RequestContext & request_context,
        RequestLevelInterceptor::ServiceContextList_ptr service_context,
        CORBA::DataInputStream_ptr request_arg_stream,
        CORBA::DataOutputStream_ptr reply_arg_stream,
        CORBA::Exception_ptr & excep_val);
    Interceptors::ResponseReturnStatus target_response (
        const RequestLevelInterceptor::ReplyContext & reply_context,
        RequestLevelInterceptor::ServiceContextList_ptr service_context,
        CORBA::DataInputStream_ptr arg_stream,
        CORBA::Exception_ptr & excep_val);
    
};

  先頭に戻る       前  次