// File: PortableInterceptor.idl
// CORBA 3.0, Chapter 21

#ifndef _PORTABLE_INTERCEPTOR_IDL_
#define _PORTABLE_INTERCEPTOR_IDL_

#ifdef _PRE_3_0_COMPILER_ 
#pragma prefix "omg.org"
#include <orb.idl>
#include <IOP.idl>
#include <Messaging.idl>
#include <Dynamic.idl>
#else
import ::CORBA;
import ::IOP;
import ::Messaging;
import ::Dynamic;
#endif // _PRE_3_0_COMPILER_

module PortableInterceptor {

#ifndef _PRE_3_0_COMPILER_ 
    typeprefix PortableInterceptor "omg.org";
#endif // _PRE_3_0_COMPILER_

    local interface Interceptor {
        readonly attribute string name;
    };

    exception ForwardRequest {
        Object forward;
    };

    typedef short ReplyStatus;

    // Valid reply_status values:
    const ReplyStatus SUCCESSFUL = 0;
    const ReplyStatus SYSTEM_EXCEPTION = 1;
    const ReplyStatus USER_EXCEPTION = 2;
    const ReplyStatus LOCATION_FORWARD = 3;
    const ReplyStatus TRANSPORT_RETRY = 4;
    const ReplyStatus UNKNOWN = 5;

    typedef unsigned long SlotId;

    exception InvalidSlot {};

    local interface Current : CORBA::Current {
        any get_slot (in SlotId id) raises (InvalidSlot);
        void set_slot (in SlotId id, in any data) raises (InvalidSlot);
    };

    local interface RequestInfo {

        readonly attribute unsigned long request_id;
        readonly attribute string operation;
        readonly attribute Dynamic::ParameterList arguments;
        readonly attribute Dynamic::ExceptionList exceptions;
        readonly attribute Dynamic::ContextList contexts;
        readonly attribute Dynamic::RequestContext operation_context;
        readonly attribute any result;
        readonly attribute boolean response_expected;
        readonly attribute Messaging::SyncScope sync_scope;
        readonly attribute ReplyStatus reply_status;
        readonly attribute Object forward_reference;

        any get_slot (in SlotId id) raises (InvalidSlot);
        IOP::ServiceContext get_request_service_context (
            in IOP::ServiceId id);
            IOP::ServiceContext get_reply_service_context (
            in IOP::ServiceId id);
    };

    local interface ClientRequestInfo : RequestInfo {

        readonly attribute Object target;
        readonly attribute Object effective_target;
        readonly attribute IOP::TaggedProfile effective_profile;
        readonly attribute any received_exception;
        readonly attribute CORBA::RepositoryId received_exception_id;

        IOP::TaggedComponent get_effective_component (
            in IOP::ComponentId id);
        IOP::TaggedComponentSeq get_effective_components (
            in IOP::ComponentId id);
        CORBA::Policy get_request_policy (in CORBA::PolicyType type);
        void add_request_service_context (
            in IOP::ServiceContext service_context,
            in boolean replace);
    };

    typedef string ServerId ;
    typedef string ORBId ;
    typedef CORBA::StringSeq AdapterName ;
    typedef CORBA::OctetSeq ObjectId ;

    local interface ServerRequestInfo : RequestInfo {
        readonly attribute any sending_exception;
	readonly attribute ServerId server_id;
	readonly attribute ORBId orb_id;
	readonly attribute AdapterName adapter_name;
        readonly attribute ObjectId object_id;
        readonly attribute CORBA::OctetSeq adapter_id;
        readonly attribute CORBA::RepositoryId target_most_derived_interface;

        CORBA::Policy get_server_policy (in CORBA::PolicyType type);
        void set_slot (in SlotId id, in any data) raises (InvalidSlot);
        boolean target_is_a (in CORBA::RepositoryId id);
        void add_reply_service_context (
            in IOP::ServiceContext service_context,
            in boolean replace);
    };

    local interface ClientRequestInterceptor : Interceptor {

        void send_request (in ClientRequestInfo ri)
            raises (ForwardRequest);
        void send_poll (in ClientRequestInfo ri);
        void receive_reply (in ClientRequestInfo ri);
        void receive_exception (in ClientRequestInfo ri)
            raises (ForwardRequest);
        void receive_other (in ClientRequestInfo ri)
            raises (ForwardRequest);
    };

    local interface ServerRequestInterceptor : Interceptor {

        void receive_request_service_contexts (in ServerRequestInfo ri)
            raises (ForwardRequest);
        void receive_request (in ServerRequestInfo ri)
            raises (ForwardRequest);
        void send_reply (in ServerRequestInfo ri);
        void send_exception (in ServerRequestInfo ri)
            raises (ForwardRequest);
        void send_other (in ServerRequestInfo ri)
            raises (ForwardRequest);
    };

//PolyORB:NI:    abstract valuetype ObjectReferenceFactory {
//PolyORB:NI:	Object make_object( in string repository_id, 
//PolyORB:NI:            in ObjectId id ) ;
//PolyORB:NI:    };
//PolyORB:NI:
//PolyORB:NI:    abstract valuetype ObjectReferenceTemplate :
//PolyORB:NI:	ObjectReferenceFactory {
//PolyORB:NI:	readonly attribute ServerId server_id ;
//PolyORB:NI:	readonly attribute ORBId orb_id ;
//PolyORB:NI:        readonly attribute AdapterName adapter_name ;
//PolyORB:NI:    } ;
//PolyORB:NI:
//PolyORB:NI:    typedef sequence<ObjectReferenceTemplate> ObjectReferenceTemplateSeq;
    typedef string AdapterManagerId;
    typedef short AdapterState ;

    const AdapterState  HOLDING      = 0 ;
    const AdapterState  ACTIVE       = 1 ;
    const AdapterState  DISCARDING   = 2 ;
    const AdapterState  INACTIVE     = 3 ;
    const AdapterState  NON_EXISTENT = 4 ;

    local interface IORInfo {
        CORBA::Policy get_effective_policy (in CORBA::PolicyType type);
        void add_ior_component (
            in IOP::TaggedComponent a_component);
        void add_ior_component_to_profile (
            in IOP::TaggedComponent a_component,
            in IOP::ProfileId profile_id);
    };

    local interface IORInterceptor : Interceptor {
        void establish_components (in IORInfo info);
    };

    local interface IORInterceptor_3_0 : IORInterceptor {
	void components_established( in IORInfo info );
	void adapter_manager_state_changed(
	    in AdapterManagerId id, 
            in AdapterState state );
//PolyORB:NI:	void adapter_state_changed( 
//PolyORB:NI:	    in ObjectReferenceTemplateSeq templates,
//PolyORB:NI:	    in AdapterState state);
    };

    local interface PolicyFactory {
        CORBA::Policy create_policy (
            in CORBA::PolicyType type,
            in any value)
            raises (CORBA::PolicyError);
    };

    local interface ORBInitInfo {

        typedef string ObjectId;

        exception DuplicateName {
            string name;
        };

        exception InvalidName {};

        readonly attribute CORBA::StringSeq arguments;
        readonly attribute string orb_id;
        readonly attribute IOP::CodecFactory codec_factory;
        void register_initial_reference (in ObjectId id, in Object obj)
            raises (InvalidName);
        Object resolve_initial_references(
	    in ObjectId id) raises (InvalidName);
        void add_client_request_interceptor (
            in ClientRequestInterceptor interceptor)
            raises (DuplicateName);
        void add_server_request_interceptor (
            in ServerRequestInterceptor interceptor)
            raises (DuplicateName);
        void add_ior_interceptor (in IORInterceptor interceptor)
            raises (DuplicateName);
        SlotId allocate_slot_id ();
        void register_policy_factory (
            in CORBA::PolicyType type,
            in PolicyFactory policy_factory);
    };

    local interface ORBInitializer {
        void pre_init (in ORBInitInfo info);
        void post_init (in ORBInitInfo info);
    };

}; // module PortableInterceptor
#endif // _PORTABLE_INTERCEPTOR_IDL_
