
module Components {
  typedef string FeatureName;
  typedef sequence<FeatureName> NameList;

  exception InvalidName {};

  /*
   * Facets
   */

  struct FacetDescription { // was valuetype
    string InterfaceID;
    FeatureName Name;
  };

  struct Facet { // was valuetype
    string InterfaceID;
    FeatureName Name;
    Object ref;
  };

  typedef sequence<Facet> Facets;
  typedef sequence<FacetDescription> FacetDescriptions;

  interface Navigation {
    Object provide_facet (in FeatureName name)
      raises (InvalidName);

    FacetDescriptions describe_facets ();

    Facets provide_all_facets ();

    Facets provide_named_facets (in NameList names)
      raises (InvalidName);

    boolean same_component (in Object ref);
  };

  /*
   * Receptacles
   */

  struct Cookie { // was valuetype
    sequence<octet> CookieValue;
  };

  struct ConnectionDescription { // was valuetype
    Cookie ck;
    Object objref;
  };

  exception AlreadyConnected {};
  exception InvalidConnection {};
  exception NoConnection {};
  exception ExceededConnectionLimit {};
  exception CookieRequired {};

  typedef sequence<ConnectionDescription> ConnectionDescriptions;

  interface Receptacles {
    Cookie connect (in FeatureName name, in Object connection)
      raises (InvalidName, InvalidConnection,
	      AlreadyConnected, ExceededConnectionLimit);

    void disconnect (in FeatureName name, in Cookie ck)
      raises (InvalidName, InvalidConnection,
	      CookieRequired, NoConnection);

    ConnectionDescriptions get_connections (in FeatureName name)
      raises (InvalidName);
  };

  /*
   * Events
   */

  interface Events {};

  /*
   * CCMObject
   */

  interface CCMHome;

  interface CCMObject : Navigation, Receptacles, Events {
    Object get_component_def ();
    CCMHome get_ccm_home ();
    /* PrimaryKeyBase get_primary_key (); */
    void configuration_complete ();
    void remove ();
  };

  /*
   * Homes
   */

  exception DuplicateKeyValue {};
  exception UnknownKeyValue {};
  exception InvalidKey {};

  interface CCMHome {
    Object get_component_def ();
    Object get_home_def ();
    void remove_component (in CCMObject comp);
  };

  interface KeylessCCMHome {
    CCMObject create_component ();
  };

  exception HomeNotFound {};

  interface HomeFinder {
    CCMHome find_home_by_component_type (in string comp_repid)
      raises (HomeNotFound);
    CCMHome find_home_by_home_type (in string home_repid)
      raises (HomeNotFound);
    CCMHome find_home_by_name (in string home_name);
  };

  /*
   * Context
   */

  /*
   * typedef SecurityLevel2::Credentials Principal;
   */

  exception IllegalState {};

  local interface CCMContext {
    /*
     * Principal get_caller_principal ();
     * boolean get_rollback_only ()
     * Transaction::UserTransaction get_user_transaction ();
     * boolean is_caller_in_role (string role);
     * void set_rollback_only ();
     */
    CCMHome get_CCM_home ();
  };

  local interface SessionContext : CCMContext {
    Object get_CCM_object () raises (IllegalState);
  };

  /*
   * Component base interfaces
   */

  local interface ComponentBase {
  };

  local interface EnterpriseComponent : ComponentBase {
  };

  enum CCMExceptionReason {
    SYSTEM_ERROR,
    CREATE_ERROR,
    REMOVE_ERROR,
    DUPLICATE_KEY,
    FIND_ERROR,
    OBJECT_NOT_FOUND,
    NO_SUCH_ENTITY
  };

  exception CCMException {
    CCMExceptionReason reason;
  };

  local interface SessionComponent : EnterpriseComponent {
    void set_session_context (in SessionContext ctx)
      raises (CCMException);
    void ccm_activate () raises (CCMException);
    void ccm_passivate () raises (CCMException);
    void ccm_remove () raises (CCMException);
  };

};
