module CORBA {
  typedef sequence<unsigned long> ULongSeq;
  typedef sequence<string> StringSeq;
};

module Deployment {

  enum SatisfierPropertyKind {
    Quantity,
    Capacity,
    Minimum,
    Maximum,
    _Attribute,
    Selection
  };

  struct SatisfierProperty {
    string name;
    SatisfierPropertyKind kind;
    any value;
  };

  typedef sequence < SatisfierProperty > SatisfierProperties;

  struct SharedResource {
    string name;
    ::CORBA::StringSeq resourceType;
    ::CORBA::ULongSeq nodeRef;
    SatisfierProperties property;
  };

  typedef sequence < SharedResource > SharedResources;

  struct Resource {
    string name;
    ::CORBA::StringSeq resourceType;
    SatisfierProperties property;
  };

  typedef sequence < Resource > Resources;

  struct Node {
    string name;
    string label;
    ::CORBA::ULongSeq sharedResourceRef;
    ::CORBA::ULongSeq connectionRef;
    Resources resource;
  };

  typedef sequence < Node > Nodes;

  struct Interconnect {
    string name;
    string label;
    ::CORBA::ULongSeq connectionRef;
    ::CORBA::ULongSeq connectRef;
    Resources resource;
  };

  typedef sequence < Interconnect > Interconnects;

  struct Bridge {
    string name;
    string label;
    ::CORBA::ULongSeq connectRef;
    Resources resource;
  };

  typedef sequence < Bridge > Bridges;

  struct Property {
    string name;
    any value;
  };

  typedef sequence < Property > Properties;

  struct Domain {
    string UUID;
    string label;
    SharedResources sharedResource;
    Nodes node;
    Interconnects interconnect;
    Bridges bridge;
    Properties infoProperty;
  };

  enum CCMComponentPortKind {
    Facet,
    SimplexReceptacle,
    MultiplexReceptacle,
    EventEmitter,
    EventPublisher,
    EventConsumer
  };

  struct ComponentPortDescription {
    string name;
    string specificType;
    ::CORBA::StringSeq supportedType;
    boolean provider;
    boolean exclusiveProvider;
    boolean exclusiveUser;
    boolean optional;
    CCMComponentPortKind kind;
  };

  typedef sequence < ComponentPortDescription > ComponentPortDescriptions;

  struct ComponentPropertyDescription {
    string name;
    CORBA::TypeCode type;
  };

  typedef sequence < ComponentPropertyDescription > ComponentPropertyDescriptions;

  struct ComponentInterfaceDescription {
    string label;
    string UUID;
    string specificType;
    ::CORBA::StringSeq supportedType;
    ::CORBA::StringSeq idlFile;
    Properties configProperty;
    ComponentPortDescriptions port;
    ComponentPropertyDescriptions property;
    Properties infoProperty;
  };

  struct Requirement {
    string resourceType;
    string name;
    Properties property;
  };

  typedef sequence < Requirement > Requirements;

  struct MonolithicDeploymentDescription {
    string name;
    ::CORBA::StringSeq source;
    ::CORBA::ULongSeq artifactRef;
    Properties execParameter;
    Requirements deployRequirement;
  };

  typedef sequence < MonolithicDeploymentDescription > MonolithicDeploymentDescriptions;

  enum ResourceUsageKind {
    None,
    InstanceUsesResource,
    ResourceUsesInstance,
    PortUsesResource,
    ResourceUsesPort
  };

  struct InstanceResourceDeploymentDescription {
    ResourceUsageKind resourceUsage;
    string requirementName;
    string resourceName;
    any resourceValue;
  };

  typedef sequence < InstanceResourceDeploymentDescription > InstanceResourceDeploymentDescriptions;

  struct InstanceDeploymentDescription {
    string name;
    string node;
    ::CORBA::StringSeq source;
    unsigned long implementationRef;
    Properties configProperty;
    InstanceResourceDeploymentDescriptions deployedResource;
    InstanceResourceDeploymentDescriptions deployedSharedResource;
  };

  typedef sequence < InstanceDeploymentDescription > InstanceDeploymentDescriptions;

  struct ComponentExternalPortEndpoint {
    string portName;
  };

  typedef sequence < ComponentExternalPortEndpoint > ComponentExternalPortEndpoints;

  struct PlanSubcomponentPortEndpoint {
    string portName;
    boolean provider;
    CCMComponentPortKind kind;
    unsigned long instanceRef;
  };

  typedef sequence < PlanSubcomponentPortEndpoint > PlanSubcomponentPortEndpoints;

  struct ExternalReferenceEndpoint {
    string location;
  };

  typedef sequence < ExternalReferenceEndpoint > ExternalReferenceEndpoints;

  struct ConnectionResourceDeploymentDescription {
    string targetName;
    string requirementName;
    string resourceName;
    any resourceValue;
  };

  typedef sequence < ConnectionResourceDeploymentDescription > ConnectionResourceDeploymentDescriptions;

  struct PlanConnectionDescription {
    string name;
    ::CORBA::StringSeq source;
    Requirements deployRequirement;
    ComponentExternalPortEndpoints externalEndpoint;
    PlanSubcomponentPortEndpoints internalEndpoint;
    ExternalReferenceEndpoints externalReference;
    ConnectionResourceDeploymentDescriptions deployedResource;
  };

  typedef sequence < PlanConnectionDescription > PlanConnectionDescriptions;

  struct PlanSubcomponentPropertyReference {
    string propertyName;
    unsigned long instanceRef;
  };

  typedef sequence < PlanSubcomponentPropertyReference > PlanSubcomponentPropertyReferences;

  struct PlanPropertyMapping {
    string name;
    ::CORBA::StringSeq source;
    string externalName;
    PlanSubcomponentPropertyReferences delegatesTo;
  };

  typedef sequence < PlanPropertyMapping > PlanPropertyMappings;

  struct ImplementationDependency {
    string requiredType;
  };

  typedef sequence < ImplementationDependency > ImplementationDependencies;

  struct ResourceDeploymentDescription {
    string requirementName;
    string resourceName;
    any resourceValue;
  };

  typedef sequence < ResourceDeploymentDescription > ResourceDeploymentDescriptions;

  struct ArtifactDeploymentDescription {
    string name;
    ::CORBA::StringSeq location;
    string node;
    ::CORBA::StringSeq source;
    Properties execParameter;
    Requirements deployRequirement;
    ResourceDeploymentDescriptions deployedResource;
  };

  typedef sequence < ArtifactDeploymentDescription > ArtifactDeploymentDescriptions;

  struct DeploymentPlan {
    string label;
    ComponentInterfaceDescription realizes;
    MonolithicDeploymentDescriptions implementation;
    InstanceDeploymentDescriptions instance;
    PlanConnectionDescriptions connection;
    PlanPropertyMappings externalProperty;
    ImplementationDependencies dependsOn;
    ArtifactDeploymentDescriptions artifact;
    Properties infoProperty;
  };

  exception ResourceNotAvailable {
    string name;
    string resourceType;
    string propertyName;
    string elementName;
    string resourceName;
  };

  exception PlanError {
    string name;
    string reason;
  };

  enum DomainUpdateKind {
    Add,
    Delete,
    UpdateAll,
    UpdateAvailable
  };

  interface TargetManager {
    Domain getAllResources ();
    Domain getAvailableResources ();
    void commitResources (in DeploymentPlan plan)
      raises (ResourceNotAvailable, PlanError);
    void releaseResources (in DeploymentPlan argname);
    void updateDomain (in ::CORBA::StringSeq elements, in Domain domainSubset, in DomainUpdateKind updateKind);
  };

  typedef sequence < Object > Endpoints;

  struct Connection {
    string name;
    Endpoints endpoint;
  };

  typedef sequence < Connection > Connections;

  exception StartError {
    string name;
    string reason;
  };

  exception InvalidConnection {
    string name;
    string reason;
  };

  interface Application {
    void finishLaunch (in Connections providedReference, in boolean start)
      raises (StartError, InvalidConnection);
    void start ()
      raises (StartError);
  };

  exception InvalidProperty {
    string name;
    string reason;
  };

  exception StopError {
    string name;
    string reason;
  };

  interface ApplicationManager {
    Application startLaunch (in Properties configProperty, out Connections providedReference, in boolean start)
      raises (ResourceNotAvailable, StartError, InvalidProperty);
    void destroyApplication (in Application app)
      raises (StopError);
  };

  typedef sequence < Application > Applications;

  interface DomainApplicationManager :
      ApplicationManager
  {
    Applications getApplications ();
    DeploymentPlan getPlan ();
  };

  typedef sequence < DomainApplicationManager > DomainApplicationManagers;

  interface ExecutionManager {
    DomainApplicationManager preparePlan (in DeploymentPlan plan, in boolean commitResources)
      raises (ResourceNotAvailable, PlanError, StartError);
    DomainApplicationManagers getManagers ();
    void destroyManager (in DomainApplicationManager manager)
      raises (StopError);
  };

  interface Logger {
  };

  interface NodeApplicationManager :
      ApplicationManager
  {
  };

  interface NodeManager {
    void joinDomain (in Domain domain, in TargetManager manager, in Logger log);
    void leaveDomain ();
    NodeApplicationManager preparePlan (in DeploymentPlan plan)
      raises (StartError, PlanError);
    void destroyManager (in NodeApplicationManager appManager)
      raises (StopError);
  };

  interface NodeApplication :
      Application
  {
  };

  interface DomainApplication :
      Application
  {
  };

  exception NameExists {
  };

  exception PackageError {
    string source;
    string reason;
  };

  exception NoSuchName {
  };

  exception LastConfiguration {
  };

  exception InvalidReference {
  };

  struct PackageConfiguration;

  typedef sequence < PackageConfiguration > PackageConfigurations;

  struct ComponentPackageDescription;

  typedef sequence < ComponentPackageDescription > ComponentPackageDescriptions;

  struct ComponentPackageReference {
    string requiredUUID;
    string requiredName;
    string requiredType;
  };

  typedef sequence < ComponentPackageReference > ComponentPackageReferences;

  struct SubcomponentInstantiationDescription {
    string name;
    ComponentPackageDescriptions package;
    Properties configProperty;
    Requirements selectRequirement;
    ComponentPackageReferences reference;
  };

  typedef sequence < SubcomponentInstantiationDescription > SubcomponentInstantiationDescriptions;

  struct SubcomponentPortEndpoint {
    string portName;
    unsigned long instanceRef;
  };

  typedef sequence < SubcomponentPortEndpoint > SubcomponentPortEndpoints;

  struct AssemblyConnectionDescription {
    string name;
    Requirements deployRequirement;
    ComponentExternalPortEndpoints externalEndpoint;
    SubcomponentPortEndpoints internalEndpoint;
    ExternalReferenceEndpoints externalReference;
  };

  typedef sequence < AssemblyConnectionDescription > AssemblyConnectionDescriptions;

  struct SubcomponentPropertyReference {
    string propertyName;
    unsigned long instanceRef;
  };

  typedef sequence < SubcomponentPropertyReference > SubcomponentPropertyReferences;

  struct AssemblyPropertyMapping {
    string name;
    string externalName;
    SubcomponentPropertyReferences delegatesTo;
  };

  typedef sequence < AssemblyPropertyMapping > AssemblyPropertyMappings;

  struct ComponentAssemblyDescription {
    SubcomponentInstantiationDescriptions instance;
    AssemblyConnectionDescriptions connection;
    AssemblyPropertyMappings externalProperty;
  };

  typedef sequence < ComponentAssemblyDescription > ComponentAssemblyDescriptions;

  struct NamedImplementationArtifact;

  typedef sequence < NamedImplementationArtifact > NamedImplementationArtifacts;

  struct ImplementationArtifactDescription {
    string label;
    string UUID;
    ::CORBA::StringSeq location;
    Properties execParameter;
    Requirements deployRequirement;
    NamedImplementationArtifacts dependsOn;
    Properties infoProperty;
  };

  struct NamedImplementationArtifact {
    string name;
    ImplementationArtifactDescription referencedArtifact;
  };

  typedef sequence < ResourceUsageKind > ResourceUsageKinds;

  struct ImplementationRequirement {
    ResourceUsageKinds resourceUsage;
    string resourcePort;
    string componentPort;
    string resourceType;
    string name;
    Properties property;
  };

  typedef sequence < ImplementationRequirement > ImplementationRequirements;

  struct MonolithicImplementationDescription {
    Properties execParameter;
    NamedImplementationArtifacts primaryArtifact;
    ImplementationRequirements deployRequirement;
  };

  typedef sequence < MonolithicImplementationDescription > MonolithicImplementationDescriptions;

  struct Capability {
    string name;
    ::CORBA::StringSeq resourceType;
    SatisfierProperties property;
  };

  typedef sequence < Capability > Capabilities;

  struct ComponentImplementationDescription {
    string label;
    string UUID;
    ComponentInterfaceDescription implements;
    ComponentAssemblyDescriptions assemblyImpl;
    MonolithicImplementationDescriptions monolithicImpl;
    Properties configProperty;
    Capabilities capability;
    ImplementationDependencies dependsOn;
    Properties infoProperty;
  };

  struct PackagedComponentImplementation {
    string name;
    ComponentImplementationDescription referencedImplementation;
  };

  typedef sequence < PackagedComponentImplementation > PackagedComponentImplementations;

  struct ComponentPackageDescription {
    string label;
    string UUID;
    ComponentInterfaceDescription realizes;
    Properties configProperty;
    PackagedComponentImplementations implementation;
    Properties infoProperty;
  };

  struct PackageConfiguration {
    string label;
    string UUID;
    PackageConfigurations specializedConfig;
    ComponentPackageDescriptions basePackage;
    ComponentPackageReferences reference;
    Requirements selectRequirement;
    Properties configProperty;
  };

  interface RepositoryManager {
    void installPackage (in string installationName, in string location)
      raises (NameExists, PackageError);
    void createPackage (in string installationName, in PackageConfiguration package, in string baseLocation, in boolean replace)
      raises (NameExists, PackageError);
    PackageConfiguration findPackageByName (in string name)
      raises (NoSuchName);
    PackageConfiguration findPackageByUUID (in string UUID)
      raises (NoSuchName);
    ::CORBA::StringSeq findNamesByType (in string type);
    ::CORBA::StringSeq getAllNames ();
    ::CORBA::StringSeq getAllTypes ();
    void deletePackage (in string installationName)
      raises (NoSuchName);
  };

  struct RequirementSatisfier {
    string name;
    ::CORBA::StringSeq resourceType;
    SatisfierProperties property;
  };
};
