Download presentation
Presentation is loading. Please wait.
Published byShanon Leonard Modified over 9 years ago
1
A Quick CCM Example
2
Tutorial on CCM Introduction A Simple Sender&Receiver Scenario Sender sends out the click-out event to inform the Receiver. Receiver reads the message from Sender. Multiple instances of the Receiver could be deployed. $CIAO_ROOT/examples/Hello $CIAO_ROOT/examples/Hello/ste p-by-step.html
3
Tutorial on CCM Steps To Develop A CIAO Based Application 1.Define your IDL types. 2.Define your Component types. 3.Implement your components. 4.Assemble your components. 5.Deploy and run your application.
4
A Quick CCM Example Define IDL/Component Types
5
Tutorial on CCM Common IDL module Hello { interface message { string get_message(); }; eventtype timeout { }; }; Common IDL definition. Used by both Sender and Receiver. $CIAO_ROO/examples/Hello/Hello_Base/Hello_Base.idl This file could be skipped if not necessary.
6
Tutorial on CCM Component Definition (IDL) – Receiver 1/3 //Receiver.idl component Receiver { uses message read_message; consumes timeout click_in; }; home ReceiverHome manages Receiver{}; Define the event receptacle.
7
Tutorial on CCM Component Definition (IDL) – Receiver 2/3 //Receiver.idl component Receiver { uses message read_message; consumes timeout click_in; }; home ReceiverHome manages Receiver{}; Define the interface receptacle.
8
Tutorial on CCM Component Definition (IDL) – Receiver 3/3 //Receiver.idl component Receiver { uses message read_message; consumes timeout click_in; }; home ReceiverHome manages Receiver{}; Define the component home
9
Tutorial on CCM Component Definition (IDL) – Sender 1/5 //Sender.idl interface trigger { void start (); }; component Sender supports trigger { provides message push_message; publishes timeout click_out; attribute string local_message;}; home SenderHome manages Sender {}; Define the event source.
10
Tutorial on CCM Define the interface facet. The interface facet is plugged into the component in the way of composition. //Sender.idl interface trigger { void start (); }; component Sender supports trigger { provides message push_message; publishes timeout click_out; attribute string local_message;}; home SenderHome manages Sender {}; Component Definition (IDL) – Sender 2/5
11
Tutorial on CCM Define the attribute. //Sender.idl interface trigger { void start (); }; component Sender supports trigger { provides message push_message; publishes timeout click_out; attribute string local_message;}; home SenderHome manages Sender {}; Component Definition (IDL) – Sender 3/5
12
Tutorial on CCM Sender specific interface. //Sender.idl interface trigger { void start (); }; component Sender supports trigger { provides message push_message; publishes timeout click_out; attribute string local_message;}; home SenderHome manages Sender {}; Component Definition (IDL) – Sender 4/5 Supported interface which is part of the component (inheritance).
13
Tutorial on CCM Define the component home. //Sender.idl interface trigger { void start (); }; component Sender supports trigger { provides message push_message; publishes timeout click_out; attribute string local_message;}; home SenderHome manages Sender {}; Component Definition (IDL) – Sender 5/5
14
A Quick CCM Example Component Implementations
15
Tutorial on CCM What does CIDL do? 1/2 CIDL is part of CCM strategy for managing complex applications Helps separation of concerns Helps coordination of tools Increases the ratio of generated to hand-written code Server code is now generated, startup automated by other CCM tools uses
16
Tutorial on CCM A CIDL file is Passed to CIDL compiler Triggers code generation for –Component Home ( SenderHome ) –managed component ( Senderer ) CIDL compiler generates –SenderHome servant –Senderer servant attribute operations port operations supported interface operations container callback operations navigation operation overrides –IDL executor mapping –XML descriptor with meta-data What does CIDL do? 2/2
17
Tutorial on CCM Sender.cidl SenderHome servant Sender servant SenderHome_Exec Sender_Exec Manages // Sender.cidl composition session Sender_Impl { home executor SenderHome_Exec { implements SenderHome; manages Sender_Exec; } }; An executor is where a component/home is implemented –The component/home’s servant will forward a client’s business logic request on the component to its corresponding executor User should write the implementations (specified in the exacutor mapping IDL file) of: –SenderHome_Exec –Sender_Exec Which are (In the example): –class SenderHome_exec_i –class Sender_exec_i
18
Tutorial on CCM Executor Mapping 1/2 CIDL compiler generates the Executor Mapping An IDL file consists of local interface definitions. IDL compiler will generate the stubs for these local interfaces. uses Home servant Component servant Home_Exec Component_Exec Manages Defines
19
Tutorial on CCM Executor Mapping 2/2 //Sender.cidl –snipped-- composition session Sender_Impl { home executor SenderHome_Exec { implements Hello::SenderHome; manages Sender_Exec; }; }; //SenderE.idl --snipped— Module Sender_Impl { local interface Sender_Exec: … Local interface SenderHome_Exec: … }; CIDL Compiler //SenderEC.h --snipped— namespace Sender_Impl { class Sender_Exec: … class SenderHome_Exec: … }; IDL Compiler Inheritance //Sender_exec.h --snipped— namespace Sender_Impl { class Sender_Exec_i: public virtual Sender_Exec … class SenderHome_Exec_i: public virtual SenderHome_Exec … }; User writes Auto- generated
20
A Quick CCM Example Implementation in Detail
21
Tutorial on CCM Implementation in Detail - Overview Component Specific context Interface connection –Facet –Receptacle Event connection –Event source –Event receptacle Attribute Component Entry point Handles all connections/subscriptions
22
Tutorial on CCM Initializing Component-specific Context Component-specific context manages connections & subscriptions Container passes component its context via either –set_session_context() –set_entity_context() class Sender_exec_i : public virtual Sender_Exec, public virtual CORBA::LocalObject { protected: Sender_Exec_Context_var context_; public: … void set_session_context (Components::SessionContext_ptr c) { this->context_ = Sender_Exec_Context::narrow (c); } … }; //SenderE.idl –snipped-- local interface Sender_Exec : Hello::CCM_Sender, Components::SessionComponent { };
23
Tutorial on CCM Implement the Provided Interface Facet 1/2 //Sender.idl –snipped-- component Sender supports trigger { provides message push_message; …}; //SenderE.idl --snipped— Module Hello { local interface CCM_message:message … local interface CCM_Sender : … { Hello::CCM_message get_push_message(); } }; //Hello_Base.idl –snipped-- Module Hello { interface message { …}; … } //Sender_exec.h --snipped— namespace Sender_Impl { class Sender_Exec_i: public virtual Sender_Exec … { public : … get_push_message () {return (new Message_Impl(…)); } }; class Message_Impl : public virtual CCM_message … { //All operations in interface //message }; We use Message_Impl to implement interface message. In this example, we intend to plug the facet into the component. In C++ terminology, we use composition but not inheritance.
24
Tutorial on CCM Implement the Provided Interface Facet 2/2 //Sender.idl –snipped-- component Sender supports trigger push_message { provides message push_message; …}; //SenderE.idl --snipped— Module Hello { local interface CCM_message:message … local interface CCM_Sender : … { push_message Hello::CCM_message get_push_message(); } }; //Hello_Base.idl –snipped-- Module Hello { interface message { …}; … } //Sender_exec.h --snipped— namespace Sender_Impl { class Sender_Exec_i: public virtual Sender_Exec … { public : push_message … get_push_message () {return (new Message_Impl(…)); } }; class Message_Impl : public virtual CCM_message … { //All operations in interface //message }; }; We plug the interface facet into the component and implement the get_ method, which will be called by D&C tools or client to get the object reference of the interface servant implementation. User is responsible for managing the lifecycle of the facet object.
25
Tutorial on CCM Invocation on Interface Receptacle //Receiver.idl –snipped-- component Receiver { read_message uses message read_message; … }; //Hello_Base.idl –snipped-- Module Hello { interface message { String get_message (); }; … }; //Receiver_exec.h/cpp --snipped— namespace Receiver_Impl { class Receiver_Exec_i: public virtual Receiver_Exec … { public : void push_click_in () { read_message Hello::message_var rev = this->context_- >get_connection_read_message(); CORBA::String_var str = rev->get_message(); } };}; Component specific context manages the receptacle connections. Component executor implementation acquires the connected reference by calling: get_connection_. Then you can invoke opertaions supported by the interface on the OBJ reference. Get the Obj-Ref Operation invocation
26
Tutorial on CCM Send out an Event //Sender.idl –snipped-- Component Sender.idl click_out { publishes timeout click_out; … }; //Hello_Base.idl –snipped-- Module Hello { eventtype timeout { …}; … } //Sender_exec.h/cpp --snipped— namespace Sender_Impl { class Sender_Exec_i: public virtual Sender_Exec … { public : void start () { this->context_-> click_out push_click_out(); } };}; Component specific context manages the event source. push_ sends out a event. //SenderE.idl --snipped— module Hello { local interface CCM_Sender_Contex : …{ click_out void push_click_out(); } }; module Sender_Impl { typedef Hello::CCM_Sender_Contex Sender_Exec_Contex; };
27
Tutorial on CCM Upon Receiving an Event //Receiver.idl –snipped-- component Receiver { click_in consuems timeout click_in; … }; //Hello_Base.idl –snipped-- Module Hello { eventtype timeout {}; … }; //Receiver_exec.h --snipped— namespace Receiver_Impl { class Receiver_Exec_i: public virtual Receiver_Exec … { public : void push_click_in (); }; CIDL generates event consumer servants Executor mapping defines push operations directly push_ will be called upon receiving an event. //ReceiverE.idl --snipped— module Hello { local interface CCM_Receiver : …{ click_in void push_click_in(); } }; module Sender_Impl { Hello::CCM_Receiver_Exec : CCM_Receiver {}; };
28
Tutorial on CCM Attribute Implementation //Sender.idl –snipped-- component Sender { local_message attribute string local_message; … }; //Sender_exec.h --snipped— namespace Sender_Impl { class Sender_Exec_i: public virtual Sender_Exec … { public : void local_message (const char* ); char * local_message (); }; }; Intended for component configuration User need to implement the Accessor and Mutator methods. //SenderE.idl --snipped— module Hello { local interface CCM_Sender : …{ attribute string local_message; } }; module Sender_Impl { Hello::CCM_Receiver_Exec : CCM_Receiver {}; };
29
Tutorial on CCM Component Entry Point extern "C" { Components::HomeExecutorBase_ptr creatSenderHome_Impl (void) { return new Sender_Impl::SenderHome_exec_i(); } } The signature is defined by the CCM spec Container calls this method to create a home executor extern “C” required to prevent C++ name mangling, so function name can be resolved in DLL XML tag reserved for entry point name Assembly ServerActivator ComponentServer Container CCMHome «instantiates»... createSenderHome_Impl ()
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.