1 / 29

A Quick CCM Example

A Quick CCM Example. 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

mandek
Télécharger la présentation

A Quick CCM Example

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. A Quick CCM Example

  2. 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/step-by-step.html

  3. Steps To Develop A CIAO Based Application • Define your IDL types. • Define your Component types. • Implement your components. • Assemble your components. • Deploy and run your application.

  4. A Quick CCM Example Define IDL/Component Types

  5. 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. Component Definition (IDL) – Receiver 1/3 • Define the event receptacle. //Receiver.idl component Receiver{ uses message read_message; consumes timeout click_in; }; home ReceiverHome managesReceiver{};

  7. Component Definition (IDL) – Receiver 2/3 • Define the interface receptacle. //Receiver.idl component Receiver{ uses message read_message; consumes timeout click_in; }; home ReceiverHome managesReceiver{};

  8. Component Definition (IDL) – Receiver 3/3 //Receiver.idl component Receiver{ uses message read_message; consumes timeout click_in; }; home ReceiverHome managesReceiver{}; • Define the component home

  9. Component Definition (IDL) – Sender 1/5 • Define the event source. //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{};

  10. Component Definition (IDL) – Sender 2/5 • 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{};

  11. Component Definition (IDL) – Sender 3/5 • 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{};

  12. Component Definition (IDL) – Sender 4/5 • 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{}; • Supported interface which is part of the component (inheritance).

  13. Component Definition (IDL) – Sender 5/5 • 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{};

  14. A Quick CCM Example Component Implementations

  15. 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. What does CIDL do? 2/2 • 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

  17. Sender.cidl // 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 SenderHome servant SenderHome_Exec Manages Sender servant Sender_Exec

  18. 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. Home servant uses Home_Exec Manages Defines Component servant Component_Exec

  19. 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 IDL Compiler User writes Auto-generated //Sender_exec.h --snipped— namespace Sender_Impl { class Sender_Exec_i: public virtual Sender_Exec … class SenderHome_Exec_i: public virtual SenderHome_Exec … }; //SenderEC.h --snipped— namespace Sender_Impl { class Sender_Exec: … class SenderHome_Exec: … }; Inheritance

  20. A Quick CCM Example Implementation in Detail

  21. 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. 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. Implement the Provided Interface Facet 1/2 //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 }; }; //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(); } }; 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. Implement the Provided Interface Facet 2/2 //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 }; }; //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(); } }; We plug the interface facet into the component and implement the get_<facet-name> 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. Invocation on Interface Receptacle //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 () { Hello::message_var rev = this->context_->get_connection_read_message(); CORBA::String_var str = rev->get_message(); } };}; //Receiver.idl –snipped-- component Receiver { uses message read_message; … }; Get the Obj-Ref Operation invocation • Component specific context manages the receptacle connections. • Component executor implementation acquires the connected reference by calling: • get_connection_<receptacle-name>. Then you can invoke opertaions supported by the interface on the OBJ reference.

  26. Send out an Event //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_-> push_click_out(); } };}; //Sender.idl –snipped-- Component Sender.idl {publishes timeoutclick_out; … }; //SenderE.idl --snipped— module Hello{ local interface CCM_Sender_Contex : …{ void push_click_out(); } }; module Sender_Impl { typedef Hello::CCM_Sender_Contex Sender_Exec_Contex; }; • Component specific context manages the event source. • push_<eventsource-name> sends out a event.

  27. Upon Receiving an Event //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 (); }; }; //Receiver.idl –snipped-- component Receiver { consuems timeout click_in; … }; //ReceiverE.idl --snipped— module Hello{ local interface CCM_Receiver : …{ void push_click_in(); } }; module Sender_Impl { Hello::CCM_Receiver_Exec : CCM_Receiver {}; }; • CIDL generates event consumer servants • Executor mapping defines push operations directly • push_<eventsink-name> will be called upon receiving an event.

  28. Attribute Implementation //Sender.idl –snipped-- component Sender { attribute string local_message; … }; //Sender_exec.h --snipped— namespace Sender_Impl { class Sender_Exec_i: public virtual Sender_Exec … { public : voidlocal_message(const char* ); char *local_message(); }; }; //SenderE.idl --snipped— module Hello{ local interface CCM_Sender : …{ attribute string local_message; } }; module Sender_Impl { Hello::CCM_Receiver_Exec : CCM_Receiver {}; }; • Intended for component configuration • User need to implement the Accessor and Mutator methods.

  29. Component Entry Point Assembly extern "C" { Components::HomeExecutorBase_ptrcreatSenderHome_Impl (void) { return new Sender_Impl::SenderHome_exec_i();} } ServerActivator «instantiates» ComponentServer «instantiates» Container • 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 «instantiates» CCMHome ... createSenderHome_Impl ()

More Related