summaryrefslogtreecommitdiff
path: root/flat/CIAO/ofccm/NodeApplication/NodeApplication_Impl.h
blob: 1802e649b0fd08f453b148807ca3c35b9328de2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
// -*- C++ -*-

//=============================================================================
/**
 *  @file    NodeApplication_Impl.h
 *
 *  $Id$
 *
 * @Brief  Implementation of Deployment::NodeApplication
 *
 * @author Erwin Gottlieb <eg@prismtech.com>
 */
//=============================================================================


#ifndef NODEAPPLICATION_IMPL_H_
#define NODEAPPLICATION_IMPL_H_

#include "ace/Map_Manager.h"

#include "ccm/CCM_KeylessCCMHomeC.h"
#include "ccm/ComponentsC.h"
#include "ofccm/Cdmw/CDMW_IDLC.h"
#include "ComponentServer/ComponentServerC.h"
#include "Deployment/Deployment_NodeApplicationS.h"
#include "Deployment/Deployment_DeploymentPlanC.h"
#include "Deployment/DeploymentC.h"

#include "NodeApplication_Export.h"
#include "ComponentInstallation_Impl.h"
#include "ServerActivator_Impl.h"
#include "RedirectionService/RedirectionService.h"
/*
 *     // required variables list:
    // PROCESS_DESTINATION
    // This destination is specified in .cad file in a <processcollocation><destination> tag.
    const char* DESTINATION_NAME = "Process_1@CCMApplication";
    // COMPONENT_KIND
    // The component kind is specified in .ccd file, in <componentkind> tag.
    const CdmwDeployment::ComponentKindValue kind = CdmwDeployment::SESSION;
    // UUID
    // The uuid parameter corresponds to the implementation id specified
    // in .csd file, in <implementation id=” ”> tag.
    const char* uuid = "DCE:700dc518-0110-11ce-ac8f-0800090b5d3e";
    // ENTRYPOINT
    // The entrypoint parameter correspond to the operation to be called for Home creation.
    // It is specified in .csd file, in <implementation><code><entrypoint> tag.
    const char* entrypoint = "create_HelloProviderHome";
    // SERVANT_LIFETIME
    // The servant lifetime is specified in .ccd file, in <componentkind>…<servant lifetime=” “> tag.
    CdmwDeployment::ServantLifetimeValue lifetime = CdmwDeployment::COMPONENT_LIFETIME;
    // THREADING_POLICY
    // The threading policy is specified in .ccd file, in <threading policy=” “> tag.
    const CdmwDeployment::ThreadingPolicyValue threading = CdmwDeployment::MULTITHREAD;
    // HOME_REPOSITORY_ID
    // The home’s RepositoryId is specified in .ccd file, in <homerepid repid=” “> tag.
    const char* repositoryID = "IDL:acme.com/Example/HelloProviderHome:1.0";
    // HOME_SERVANT_CLASSNAME
    // The home’s servant classname is specified in .ccd file,
    // in <homefeatures><extension class=”HOME_SERVANT_CLASSNAME“ origin=”Cdmw”> tag.
    const char* servantHomeClassName = "Cdmw.CCM.CIF.CdmwExample.SessionHelloProviderHome_impl";
    // VALUETYPE_FACTORY_DEPENDENCIES
    // The valuetype factories are specified in .csd file,
    // in <implementation><dependency><valuetypefactory> tag.
    CdmwDeployment::ValuetypeFactoryDescriptionSeq dependenciesValueFactory(1L);
    CdmwDeployment::ValuetypeFactoryDescription desc;
    desc.repid = "IDL:acme.com/Example/SaySomethingElse:1.0";
    desc.factory_entrypoint = "createSaySomethingElseFactory";
    dependenciesValueFactory[0]=desc;
    // FAULT_TOLERANCE_REPLICATION_STYLE
    // The FaultTolerance replication style is always set to WARM_PASSIVE at this time.
    const CdmwDeployment::FTReplicationStyleValue styleFaultTolerance = CdmwDeployment::WARM_PASSIVE;
    // COMPONENT_NAME
    // The component’s name is specified in .cad file, as id in <componentinstantiation id=” “> tag.
    const char* componentName = "HelloProvider";
    // USES_PORT_TIMEOUTS
    // The uses port timeouts are specified in .cad file,
    // in <componentinstantiation><extension class=”USES_PORT_TIMEOUT“ origin=”Cdmw”> tags.
    CdmwCcmCif::UsesPortTimeouts timeouts(1L);
    CdmwCcmCif::UsesPortTimeout timeout;
    timeout.uses_name = "";
    timeout.timeout = 0;
    // RECORDING
    // If incoming requests to a component are to be recorded, it is specified in .cad file,
    // in <componentinstantiation><extension class=”RECORDING“ origin=”Cdmw”>true</extension> tags.
    const bool recording = true;
    // FAULT_TOLERANCE_GROUP_REF
    // The object group reference is retrieved according to the fault tolerant group’s destination,
    // specified in .cad file, in <ftcomponentgroup><destination> tag.
    //FT::ObjectGroup_var = FT::ObjectGroup::_nil();//"HelloProviderGroupName";
    // FACET_NAME
    // If component provides some facets they specified
    // in .ccd file, in <ports><provides providesname="hello_facet"> tag
    const char* facet = "hello_facet";
  */

namespace DAnCE
  {

  class NodeManager_Impl;

  class NodeApplication_Export NodeApplication_Impl : public virtual POA_Deployment::NodeApplication
    {
    public:
      NodeApplication_Impl (CORBA::ORB_ptr orb
                            , PortableServer::POA_ptr poa
                            , const Deployment::DeploymentPlan& plan
                            , RedirectionService & redirection
                            , const ACE_CString& node_name);

      virtual ~NodeApplication_Impl();

      //TODO Add throw specification
      void init();

      virtual void finishLaunch (
        const Deployment::Connections & providedReference,
        ::CORBA::Boolean start);

      virtual void start (void);

      Deployment::Connections * getAllConnections()
      ;

      //TODO Exception specification should be customized
      void initComponents();
    private:
      enum ERequestType
      {
        eCreateComponentServer,
        eCreateContainer,
        eInstallHome,
        eCreateComponentWithConfigValues
      };

      enum EInstanceType
      {
        eHome,
        eComponent
      };

      EInstanceType getInstanceType (const Deployment::Properties& prop) const;

      void createConfigValues (const Deployment::Properties& prop,
                               const ERequestType request,
                               Components::ConfigValues& cfg) const;

      void createConfigValues(const Deployment::Properties& prop,
      Components::ConfigValues& cfg) const;

      void createContainer (unsigned int index);

      void createHome (unsigned int index);

      void createComponent (unsigned int index);

      Components::Cookie* connectReceptacle (Components::CCMObject_ptr inst,
                                             const ACE_CString& port_name,
                                             CORBA::Object_ptr facet);

      Components::Cookie* connectReceptacleExt (Components::CCMObject_ptr inst,
                                                const ACE_CString& port_name,
                                                CORBA::Object_ptr facet);

      void connectEmitter (Components::CCMObject_ptr inst,
                           const ACE_CString& port_name,
                           CORBA::Object_ptr consumer);

      void connectEmitterExt (Components::CCMObject_ptr inst,
                              const ACE_CString& port_name,
                              CORBA::Object_ptr consumer);

      Components::Cookie* connectPublisher (Components::CCMObject_ptr inst,
                                            const ACE_CString& port_name,
                                            CORBA::Object_ptr consumer);

      CORBA::ORB_var orb_;
      PortableServer::POA_var poa_;
      const Deployment::DeploymentPlan& plan_;

      ComponentInstallation_Impl* installation_;
      ServerActivator_Impl* activator_;

      typedef ACE_Map_Manager<ACE_CString, ::Components::Deployment::Container_var, ACE_Null_Mutex> TContainers;
      TContainers containers_;

      typedef ACE_Map_Manager<ACE_CString, Components::KeylessCCMHome_var, ACE_Null_Mutex> THomes;
      THomes    homes_;

      typedef ACE_Map_Manager<ACE_CString, Components::CCMObject_var,  ACE_Null_Mutex> TComponents;
      TComponents components_;

      RedirectionService & redirection_;

      ACE_CString node_name_;
    };
};
#endif /*NODEAPPLICATION_IMPL_H_*/