Developing Distributed Object - Vanderbilt University

Transcription

Developing Distributed ObjectComputing Applications with CORBACORBA TutorialDouglas C. Schmidt & Bala NatarajanMotivation: the Distributed Software CrisisSymptomsDouglas C. tl.edu/ schmidt/ Hardware gets smaller, faster, cheaperDepartment of EECSVanderbilt University(615) 343-8197 Software gets larger, slower, moreexpensiveCulprits Inherent and accidental complexitySolution ApproachSponsorsNSF, DARPA, ATD, BAE Systems, BBN, Boeing, Cisco, Comverse, GDIS, Experian,Global MT, Hughes, Kodak, Krones, Lockheed, Lucent, Microsoft, Mitre, Motorola,NASA, Nokia, Nortel, OCI, Oresis, OTI, Qualcomm, Raytheon, SAIC, SAVVIS,Siemens SCR, Siemens MED, Siemens ZT, Sprint, Telcordia, USENIX Components, Frameworks, Patterns,& ArchitectureVanderbilt UniversityCORBA TutorialDouglas C. Schmidt & Bala NatarajanCORBA TutorialTechniques for Improving VENTLOOPNETWORKCLASSESCODEIPCCLASSES(A) CLASSLIBRARY PMATHCLASSESDATABASE(B) FRAMEWORKVanderbilt UniversityEVENT1Douglas C. Schmidt & Bala NatarajanOverview of CORBA Middleware ArchitectureProven solutions !IDLIDLINTERFACEINTERFACEREPOSITORYREPOSITORY Components– Self-contained, “pluggable”ADTs Frameworks– Reusable, “semi-complete”applications Patterns– Problem/solution/context Architecture– Families of related patternsand POSITORYCOMPILERCOMPILERin argsCLIENTOBJREFOBJECT(SERVANT)operation()out args return valueIDLDIIIDLORBSTUBSINTERFACEORB ANDARD INTERFACESTANDARD LANGUAGE MAPPINGORB-SPECIFICSTANDARD PROTOCOLINTERFACEwww.cs.wustl.edu/ schmidt/corba.htmlARCHITECTURE2Vanderbilt UniversityGoals of CORBA Simplifydistribution byautomating– Object location &activation– Parametermarshaling– Demultiplexing– Error handling Providefoundation forhigher-levelservices3

CORBA TutorialDouglas C. Schmidt & Bala NatarajanApplying CORBA to Medical ImagingATMLANDIAGNOSTIC STATIONSATMLANMODALITIES(CT, MR, CR)Vanderbilt UniversityAirFrame– Large volume of “Blob” data e.g., 10 to 40 Mbps– “Lossy compression” isn’tviable– Prioritization of requestsCLUSTERBLOBSTORECENTRALBLOB STOREVanderbilt UniversityActivate server (ifnecessary)Activate object’s servant(if necessary)Process requestReturn result orexceptionORB CORE2c3cIDLSTUBS1cServer processing stepsOBJECTADAPTERIDLSKELETONOBJECT(SERVANT)out args return value3sin argsHUDEVENTCHANNELWTSNav4: PULL(DATA)3:PUSH (EVENTS)3:PUSH (EVENTS)REPLICATIONSERVICE2: SENSOR PROXIES DEMARSHAL DATA& PASS TO EVENT CHANNEL URLsATMMANDouglas C. Schmidt & Bala NatarajanApplying CORBA to Real-time Avionics Domain ChallengesDXBLOBSTORE4s 2s1sCORBA Tutorial1c Locate target object1s2c Sent request message toserver2s3c Wait for request tocomplete3s4c Return control to client 4s4Client processing stepsVanderbilt University4c Stub: A proxy that converts method ORB Core:calls into messagesMessage-passing Skeleton: An adapter that convertsinfrastructuremessages back into method callsoperation() POA: A container forobjects/servants in a serverCORBA Tutorial– Client and server are “roles” - aprogram can play both rolesOBJREF Server: Computational context(e.g., process) for objects/servants Servant: A programminglanguage entity thatimplements requests on oneor more objectsCLIENT Client: Makes requests on anobject via one of its references Object: A CORBAprogramming entity with anidentity, an interface, and TORYREPOSITORY Object reference: A strongly-typedopaque handle that identifies anobject’s locationDouglas C. SchmidtDouglas C. Schmidt & Bala NatarajanKey CORBA ConceptsCORBA Twoway Processing StepsCORBA Tutorial– schmidt/PDF/COOTS96.pdf– schmidt/PDF/av chapter.pdf– schmidt/NMVC.html6GPSIFFFLIROBJECT REQUEST BROKER1: SENSORSGENERATEDATAVanderbilt University Domain Challenges– Real-time periodicprocessing– Complexdependencies– Very low latency URLs– schmidt/PDF/JSAC98.pdf– schmidt/TAOboeing.html7

CORBA TutorialDouglas C. Schmidt & Bala NatarajanCORBA TutorialDouglas C. Schmidt & Bala NatarajanApplying CORBA to Global PCSTRACKINGSTATIONPEERSSATELLITESSTATUS INFOTutorial Outline Domain Challenges Motivation– Long latency satellite links– High reliability– Prioritization Example CORBA Applications URLWIDE AREANETWORKCOMMANDSGATEWAYBULK DATATRANSFER Using CORBA to Cope with Changing Requirements– schmidt/PDF/TAPOS00.pdf Detailed Overview of CORBA Architecture and Features Evaluations and RecommendationsLOCAL AREA NETWORKGROUNDSTATIONPEERSVanderbilt University8CORBA TutorialDouglas C. Schmidt & Bala NatarajanMotivation for COTS MiddlewareVanderbilt University9CORBA TutorialDouglas C. Schmidt & Bala NatarajanSources of Complexity for Distributed Applications Inherent complexityPRINTER It is hard to develop distributed applications whose componentscollaborate efficiently, reliably, transparently, and scalablyCOMPUTERCD ROM To help address this challenge, the Object Management Group(OMG) is specifying the Common Object Request BrokerArchitecture (CORBA)FILESYSTEM(1) STAND-ALONE APPLICATION ARCHITECTURETIMESERVICENAMESERVICE OMG is a consortium of 800 companiesCYCLESERVICEDISPLAYSERVICE– Sun, HP, DEC, IBM, IONA, Borland, Cisco, Motorola, Boeing, etc. The latest version of the CORBA spec is available onlineNETWORKFI LESERVICEPRINTSERVICECD ROM– E SYSTEM(2) DISTRIBUTED APPLICATION ARCHITECTUREVanderbilt University10Vanderbilt oningOrderingSecurity Accidental Complexity– Low-level APIs– Poor debugging tools– Algorithmicdecomposition– Continuous re-invention11

CORBA TutorialDouglas C. Schmidt & Bala NatarajanCORBA TutorialSources of Inherent ComplexityDouglas C. Schmidt & Bala NatarajanSources of Accidental Complexity Inherent complexity results from fundamental challenges in thedistributed application domain Accidental complexity results from limitations with tools andtechniques used to develop distributed applications Key challenges of distributed computing include In practice, key limitations of distributed computing include– Addressing the impact of latency– Detecting and recovering from partial failures of networks andhosts– Load balancing and service partitioning– Consistent ordering of distributed eventsVanderbilt University– Lack of type-safe, portable, re-entrant, and extensible system callinterfaces and component libraries– Inadequate debugging support– Widespread use of algorithmic decomposition– Continuous rediscovery and reinvention of core concepts andcomponents12CORBA TutorialDouglas C. Schmidt & Bala NatarajanVanderbilt UniversityCORBA TutorialMotivation for CORBADouglas C. Schmidt & Bala NatarajanCORBA Quoter Example Simplifies application interworking– Higher level integration than untyped TCP bytestreams Supports heterogeneity– e.g., middleware enables applications to be independent oftransports, OS, hardware, language, location, and implementationdetailsint main (void) {// Use a factory to bind// to a Quoter.Quoter var quoter resolve quoter service (); const char *name "ACME ORB Inc."; Benefits for distributed programming similar to OO languagesIdeally, a distributedservice should look justlike a non-distributedserviceUnfortunately, life isharder when errorsoccur.CORBA::Long value quoter- get quote (name);cout name " " value endl;– e.g., encapsulation, interface inheritance, polymorphism, andexception handling Provides a foundation for higher-level distributed object collaboration}– e.g., CCM, J2EE, and CORBAServicesVanderbilt University1314Vanderbilt University15

Douglas C. Schmidt & Bala NatarajanCORBA TutorialDouglas C. Schmidt & Bala NatarajanCORBA Quoter Interface– Used by bothclients andservers}; Only CORBA objects defined with interfaces can be accessedremotelyUsing OMG IDL promotes language/platform independence, locationtransparency, modularity, and UN-TIMELIBRARIESSERVER DEVELOPERC COMPILERCLIENT DEVELOPERVanderbilt University18 Different IDL compilers generate different filesand provide different optionsVanderbilt UniversityC COMPILER Due to limitations with certain programming language mappings,operations cannot be overloaded in IDL interfacesCORBA Tutorial– A raises clause, which indicates the exceptions(s) the operationcan throw– A oneway qualifier, which indicates the caller doesn’t expect anyresults– A context clause, which is deprecated and RCE CODECODE An operation can optionally DE– A name– A return type (can be void)– Zero or more parametersSERVERSKELETONBODY Each operation in an OMG interface must haveSERVERSKELETONHEADEROverview of OMG OperationsIDL COMPILERDouglas C. Schmidt & Bala Natarajan17CLIENTSTUBHEADERCORBA TutorialVanderbilt Universityinterface Quoter{long get quote (in string name);};16IDL FILEVanderbilt University– However, locality constrained CORBA objects can’t be accessedremotelyDouglas C. Schmidtlong get quote(in string stock name)raises (Invalid Stock); OMG interfaces are similar to There are several differences,C abstract classes or Javahowever, since theyinterfaces– Cannot define data– They define object typesmembers– Can be passed as (reference)– Cannot have private orparametersprotected access control– Can raise exceptions andsections– Can be forward declared– Must designate theirparameter directions We write an OMGIDL interface forour QuoterUsing an OMG IDL Compiler for C // IDL interface is like a C // class or Java interface.interface Quoter{exception Invalid Stock {};Overview of OMG InterfacesCLIENTSTUBBODYCORBA Tutorial

CORBA TutorialDouglas C. Schmidt & Bala NatarajanCORBA TutorialOMG IDL-to-C Mapping Rules (1/2)Douglas C. Schmidt & Bala NatarajanOMG IDL-to-C Mapping Rules (2/2) There are mappings from OMG IDL to various programminglanguages standardized by CORBA Sample mapping OMG IDL to C – Each module is mapped to a namespace (or class)– Each interface is mapped to a class– Each operation is mapped to a C method with appropriateparameters– Each read/write attribute is mapped to a pair of get/set methods– An Environment is defined to carry exceptions in languagesthat lack this feature Mapping OMG IDL to C can be classified into– Basic C mapping for basic and structured types– Client-side mapping of IDL interfaces into C to support clientapplications– Server-side C mapping of IDL interfaces into C to supportserver developers– Pseudo-object C mapping of certain CORBA types, e.g.,Object, ORB, and PortableServer::POA We’ll discuss the various mapping issues as we go along See Henning and Vinoski for all details of IDL-to-C mapping Memory management in C mapping can be trickyVanderbilt University21CORBA TutorialDouglas C. Schmidt & Bala NatarajanSoftware Bus: PRINTER: STOCK: :STOCKSTOCKQUOTERQUOTERQUOTER: NETWORKTIME: LOCATIONBROKERSOFTWARE BUS: HEARTBEATMONITORVanderbilt UN-TIMELIBRARIESCLIENT DEVELOPER CORBA makes it straightforward to exchangedata between different programming languagesin different address spacesJAVACOMPILERSERVER DEVELOPERC COMPILERSERVERSERVERSOURCESERVERSOURCECODESOURCE ELETONBODY20CLIENTSTUBBODYIDL-TO-C COMPILERIDL-TO-JAVA COMPILERIDL FILEinterface Quoter{long get quote (in string name);};Douglas C. SchmidtCORBA TutorialUsing an IDL Compiler for C & JavaVanderbilt University: TRADINGRULES: STOCK: AUTHEN-TRADERTICATOR CORBA provides a communication infrastructure for aheterogeneous, distributed collection of collaborating objects Analogous to “hardware bus”Vanderbilt University23

Douglas C. SchmidtCORBA TutorialDouglas C. Schmidt & Bala NatarajanCommunication Features of CORBA CORBA supports reliable,uni-cast communication– i.e., oneway, twoway, deferredsynchronous, andasynchronous CORBA objects can alsocollaborate in a client/server,peer-to-peer, orpublish/subscribe mannerVanderbilt University For this to work transparently the ORB shouldsupport nested upcalls and collocationoptimizations– i.e., distributed or collocated Collaborating objects can be either remote orlocal: AUTHEN-TICATIONTIME3: timestamp(): NETWORK: QUOTESERVICE2: authenticate (broker)4: get quote ("ACME ORB, Inc."): NAMESERVICE1: resolve ("Quoter"): BROKERCORBA Object CollaborationCORBA TutorialCORBA TutorialDouglas C. Schmidt & Bala Natarajan– e.g., COS Event & NotificationServices define a publish &subscribe GETOBJECT4TARGETOBJECT4operation(args)response2: pollerPOLLINGCLIENT4: get1: requestoperation(args)POLLERCALLBACKCLIENT3: response1: requestoperation(callback, args)3: upcall2: responseVanderbilt University25CORBA TutorialFundamental CORBA Design PrinciplesDouglas C. Schmidt & Bala NatarajanRelated Work (1/4) Separation of interface and implementation Traditional Client/Server RPC (e.g., DCE)– Clients depend on interfaces, not implementations– Servers offer a service and wait for clients to invoke remoteprocedure calls (RPCs)– When a client invokes an RPC the server performs the requestedprocedure and returns a result Location transparency– Service use is orthogonal to service location Access transparency Problems with Client/Server RPC– Invoke operations on objects– Only supports “procedural” integration of application services– Doesn’t provide object abstractions, e.g., polymorphism,inheritance of interfaces, etc.– Doesn’t support async message passing, or dynamic invocation Typed interfaces– Object references are typed by interfaces Support of multiple inheritance of interfaces– Inheritance extends, evolves, and specializes behaviorVanderbilt University26Vanderbilt University27

CORBA TutorialDouglas C. Schmidt & Bala NatarajanCORBA TutorialRelated Work (2/4)Douglas C. Schmidt & Bala NatarajanRelated Work (3/4) Windows COM/DCOM/COM SOAP– A component model for Windows that support binary-levelintegration and reuse of components– A simple XML-based protocol that allows applications toexchange structured and typed information on the Web usingHTTP and MIME– Widely implemented Problems with Windows COM/DCOM/COM – Largely limited to desktop applications– Does not address heterogeneous distributed computing Problems with SOAP– Considerable time/space overheadVanderbilt UniversityCORBA Tutorial28Douglas C. Schmidt & Bala NatarajanRelated Work (4/4)Vanderbilt University29CORBA TutorialDouglas C. Schmidt & Bala NatarajanCORBA Stock Quoter Application Example The quote server(s)maintains thecurrent stock prices Java RMI– Limited to Java only Can be extended into other languages, such as C or C , byusing a bridge across the Java Native Interface (JNI)– Well-suited for all-Java applications because of its tight integrationwith the Java virtual machine e.g., can pass both object data and code by value– However, many challenging issues remain unresolved e.g., security, robustness, and versioningFDDIQUOTESERVERSWIDE AREABROKERSNETWORKMVS - IBMSunOS - SPARCETHERNETOS/2 - PowerPCWindows NT - Alpha– Higher-level distributed component frameworks– Widely used in business/enterprise domainsWindows- Pentium30Vanderbilt University Brokers access thequote server(s) viaCORBA Note all theheterogeneity!Gateway/RouterHP/UX - HPPA J2EE and .NETVanderbilt UniversityATMLANBROKERS We use this exampleto explore manyfeatures of CORBA31

Operation parameters in OMG IDL must be designated to have oneof the following directions:Vanderbilt University– in, which means that the parameter is passed from the client tothe server– out, which means that the parameter is returned from the serverto the client– inout, which means that the parameter is passed from the clientto the server and then returned from the server to the client,overwriting the original valueDouglas C. Schmidt & Bala NatarajanOverview of IDL Parameter Passing (2/2) Parameter passing modes are used in CORBA to optimize the dataexchanged between client and serverVanderbilt UniversityCORBA Tutorial33Douglas C. Schmidt & Bala NatarajanOverview of Object References (1/3) The C mapping for parameter passing depend on both the typeand the direction An object reference is a strongly-typed opaque handle to oneinstance of an interface that identifies the object’s location– Built-in in params (e.g., char and long) passed by value– User defined in params (e.g., structs) passed by constreference– Strings are passed as pointers (e.g., const char *)– inout params are passed by reference– Fixed-size out params are passed by reference– Variable-size out params are allocated dynamically– Fixed-size return values are passed by value– Variable-size return values are allocated dynamically– Object reference out params and return values are duplicated An object reference is an ORB-specific entity that can contain– A repository ID, which identifies its interface type– Transport address information, e.g., a server’s TCP/IP host/portaddress(es)– An object key that identifies which object in the server the requestis destined for As usual, applications can be shielded from most of these details byusing var typesVanderbilt UniversityDouglas C. Schmidt & Bala NatarajanOverview of IDL Parameter Passing (1/2)Note the use of the Factory Method pattern// A factory that creates Quoter objects.interface Quoter Factory{// Factory Method that returns a new Quoter// selected by name e.g., "Dow Jones,"// "Reuters,", etc.Quoter create quoter (in string quoter service)raises (Invalid Factory);};};// Interface is similar to a C class.interface Quoter{long get quote (in string stock name)raises (Invalid Stock);};module Stock {// Exceptions are similar to structs.exception Invalid Stock {};exception Invalid Factory {};Douglas C. SchmidtSimple OMG IDL Quoter DefinitionCORBA TutorialCORBA TutorialCORBA Tutorial34 An object reference similar to a C “pointer on steriods” that’s beenenhanced to identify objects in remote address spaces– e.g., it can be NULL and it can reference non-existent objectsVanderbilt University35

CORBA TutorialDouglas C. Schmidt & Bala NatarajanCORBA TutorialOverview of Object References (2/3)Douglas C. Schmidt & Bala NatarajanOverview of Object References (3/3) The following is a transient object reference Object references can be passed among processes on separatehosts– The timestamp helps ensure uniqueness across process lifetimes– The underlying CORBA ORB will correctly convert objectreferences into a form that can be transmitted over the network– The object stays where it is, however, and its reference is passedby valueProtocol IdCommunicationEndpoint– e.g., they support peer-to-peer interactions and distributedcallbacksCORBA Tutorial– There’s also a requirement to keep port numbers and IPaddresses consistent.36Douglas C. Schmidt & Bala NatarajanVanderbilt UniversityCORBA TutorialOverview of OMG Modules37Douglas C. Schmidt & Bala NatarajanOverview of OMG Exceptions OMG modules are similar to C namespaces or Java packages Two types of exceptions in OMG IDL inherit fromCORBA::Exception:– i.e., they define scopes and can be nested OMG modules can be reopened to enable incremental definitions,e.g.:module Stock {interface Quoter { /* . */ };};// .module Stock {interface Quoter Factory { /* . */ };};– System exceptions (e.g., CORBA::OBJECT NOT EXIST), whichare predefined by the CORBA spec and must not appear in araises clause– User exceptions (e.g., Stock::Invalid Stock), which canbe defined by user applications and can appear in a raisesclause There are various restrictions on exceptions in CORBA– e.g., they can’t be nested or inherited and can’t be members ofother data types Reopening of modules is particular useful for mutually dependentinterfaces that require forward definitionsVanderbilt UniversityObjectAdapter Id Persistent object references omit the timestamp to help ensureconsistency across process lifetimes Object references are a powerful feature of CORBAVanderbilt UniversityObject POA/myservant The ORB provides the receiver with a pointer to a proxy in its ownaddress space– This proxy refers to the remote object implementationTime Stamp38Vanderbilt University39

42valueget quote(): DowJonesQuotername: DowJonesQuoterProxyQuoternamecreate object(): ReutersQuoterremove()valueget quote(): QuoterQUOTE SERVERname: QuoterFactoryVanderbilt UniversityVanderbilt University: QuoterFactoryProxy Again, use var types to simplify programming: ReutersQuoterProxy Variable-size types require the sender to dynamically allocateinstances and the receiver to deallocate instancesQUOTECLIENT Type any: QuoterProxy Object references structs, unions, and arraysare variable-size if they containany variable-size fields(recursively)CORBA Tutorialsequences: QuoterProxy Bounded or unbounded strings structs, unions, and arrays(as shown in theare fixed-size if they contain onlyStock::Quoter example)fixed-size fields (recursively) Bounded or unboundedQUOTE CLIENTOther types can be variable- orfixed-size:41QUOTESERVERVanderbilt UniversityDouglas C. SchmidtDouglas C. Schmidt & Bala Natarajaninterface Object {// Reference counting methodsObject duplicate ();void release ();// Checks for existence and reference identity & relationshipsboolean is nil ();boolean non existent ();boolean is equivalent (in Object another object);boolean is a (in string repository id);// .RPC- vs. Object-style DesignsVanderbilt University// Manage the lifecycle of a Quoter object.interface Quoter Factory :CosLifeCycle::GenericFactory{// Returns a new Quoter selected by name// e.g., "Dow Jones," "Reuters,", etc.// Inherits:// Object create object (in Key k,//in Criteria criteria)// raises (NoFactory, e Quoter : CosLifeCycle::LifeCycleObject{long get quote (in string stock name)raises (Invalid Stock);// Inherits:// void remove () raises (NotRemovable);};module Stock {exception Invalid Stock {};Apply the CORBA Lifecycle ServiceDouglas C. SchmidtRevised OMG IDL Quoter Definition Since all objects implicitly inherit from CORBA::Object, all objectreferences support the following operations:RPC-STYLECORBA Tutorial The CosLifeCycle::GenericFactory::create object()factory method returns an object reference to an instance that’sderived from the CORBA::Object interfaceOverview of Fixed- and Variable-size TypesCertain types are variable-size:Douglas C. Schmidt & Bala NatarajanOverview of OMG ObjectOBJECT-STYLECORBA TutorialCORBA Tutorial

CORBA TutorialDouglas C. Schmidt & Bala NatarajanOMG Object and POA IDL :ObjectServantA BaseACosLifeCycle::GenericFactoryPOA CosLifeCycle::GenericFactorycreate object() 0Acreate object() 0AStock::QuoterFactorycreate object() 0AStock::QuoterFactory varcreate object()Vanderbilt UniversityPOA Stock::Quoter Factorycreate object() 0AMyQuoterFactoryCORBA TutorialVanderbilt University44Note that you never instantiate a stub class directly,but always via a factoryVanderbilt Universityclass Quoter Factory: public virtual CosLifeCycle::GenericFactory {public:// Factory method for creation that inherits:// CORBA::Object ptr create object//(const CosLifeCycle::Key &factory key,//const CosLifeCycle::Criteria &criteria)// Note C mapping of Key and Criteria structs.// .};}; Each (twoway) stub is a proxy that Each skeleton is an adapterthat1. Ensures a connection to the1. Demarshals the requestserver is established2. Marshals the requestparameters2. Performs an upcall on theparameters3. Sends the requestdesignated servant4. Waits to get the replymethod5. Demarshals the reply3. Marshals the replyparametersparameters6. Returns to the client caller4. Sends the reply back tothe clientCORBA TutorialRunning the Stock module through the IDL compiler generates stubsand skeletons// Note C mapping of IDL module typenamespace Stock {// Note C mapping of IDL interface typeclass Quoter // Quoter also IS-A CORBA::Object.: public virtual CosLifeCycle::LifeCycleObject {public:// Note C mapping of IDL long and string typesCORBA::Long get quote (const char *stock name);// .};Douglas C. SchmidtDouglas C. Schmidt & Bala NatarajanResults of Compiling the Stock.idl FileOverview of Generated Client StubsCORBA TutorialDouglas C. Schmidt & Bala NatarajanOverview of Generated Server Skeletons The OMG client mapping inherits allproxy interfaces from the Objectinterface Skeleton classes provide the server counterpart to the client stubclass proxies– Moreover, proxy classes mirrorthe IDL inheritance hierarchy, soreferences to derived interfacesare compatible with references tobase interfaces via widening andpolymorphism– There’s a C virtual method in the skeleton class for eachoperation defined in the IDL interface CORBA associates a user-defined servant class to a generated IDLskeleton class using either1. The Class form of the Adapter pattern (inheritance)POA Stock::Quoter2. The Object form of the Adapter pattern (object composition, i.e.,TIE)template class Impl class POA Stock::Quoter tie The IDL server C mappinginherits all Servants fromServantBasecreate object()46Vanderbilt University47

CORBA TutorialDouglas C. SchmidtPortableServer::ServantBaseCORBA TutorialDouglas C. SchmidtThe Class Form of the Adapter Pattern PortableServer::ServantBaseimplements reference counting for servantclasses via two methods:clientServantA Base1: create object()– add ref() increments reference count(initial count is 1)– remove ref() decrements referencecount by 1 and deletes servant when value is0CosLifeCycleGenericFactorycreate object() 0AMyQuoterFactory Servant classes implicitly inherit fromPortableServer::ServantBase Developers should create the servant usingoperator newcreate object()QuoterFactorycreate object() 0A When ever any method is called that returns aservant object (e.g., id to servant(),reference to servant(), this()),add ref() is called automatically toincrement the ref count by 1Vanderbilt UniversityVanderbilt UniversityQuoterFactorycreate object() 0AQuoterFactory tiecreate object()create object()49Vanderbilt University2: create object()MyQuoterFactoryDouglas C. Schmidt & Bala NatarajanMy QuoterFactoryDefining a Servant Using Inheritancecreate object() 0ACORBA TutorialCosLifeCycleGenericFactory Servant classes can inherit from their skeleton directly:Aclass My Quoter Factory : public virtual POA Stock::Quoter Factory {public:My Quoter Factory (const char *factory "my quoter factory");virtual CORBA::Object ptr // Factory method for creation.create object (const CosLifeCycle::Key &factory key,const CosLifeCycle::Criteria &the criteria)throw (CORBA::SystemException, QuoterFactory::NoFactory);private:std::map std::string, CORBA::Object var objref list ;};ServantBase1: create quoter () However, this approach can create a “brittle” hierarchy and make ithard to integrate with legacy code (e.g., when distributing astand-alone application)client Moreover, virtual inheritance is sometimes implemented poorly byC compilersDouglas C. SchmidtThe Object Form of the Adapter PatternVanderbilt UniversityCORBA Tutorial

Douglas C. Schmidt & Bala NatarajanCORBA TutorialDouglas C. Schmidt & Bala NatarajanDefining a Servant Using TIE53namespace POA Stock {template class Impl class Quoter Factory tie : public Quoter Factory { /* . */ };// .We generate a typedef and a servant that places an implementationpointer object within the TIE class:typedef POA Stock::Quoter Factory tie My Quoter Factory MY QUOTER FACTORY;// operator () defined in CORBA::Object var// duplicates references.objref list .bind (factory key.id,objref);return objref. retn ();};MY QUOTER FACTORY *factory new MY QUOTER FACTORY (new My Quoter Factory);CORBA::Object ptrMy Quoter Factory::create object(/* args omitted */){CORBA::Object var objref;if (objref list .find (factory key.id,objref) 0)return objref. retn ();// Declarations.// Factory method selects quoter.if (strcmp (factory key.id,"my quoter") 0) {xfer quoter new My Quoter;}// Create a Stock::Quoter ptr, register// the servant with the default POA, and// return the new Object Reference.objref quoter- this ();All operation calls via the TIE class are then delegated to theimplementation objectPreventing multiple servant activations for thesame keyVanderbilt UniversityDouglas C. SchmidtAnother create object()ImplementationVanderbilt UniversityA TIE-based Implementation52Vanderbilt UniversityCORBA TutorialCORBA Tutorial// Create a Stock::Quoter ptr, register// the servant with the default POA, and// return the new Object Reference.return quoter- this ();};class My Quoter Factory {public:My Quoter Factory (const char *name "my quoter factory");// Factory method for creation.CORBA::Object ptr create object(const CosLifeCycle::Key &factory key,const CosLifeCycle::Criteria &the criteria)throw (CORBA::SystemException, QuoterFactory::NoFactory);private: // .};// Factory method selects quoter.if (strcmp (factory key.id,"my quoter") 0) {xfer quoter new My Quoter;}else if (strcmp (factory key.id,"dow jones") 0) {xfer quoter new Dow Jones Quoter;} else // Raise an exception.throw Quoter Factory::NoFactory ();TIE allows classes to become distributed even if they weren’tdeveloped with prior knowledge of CORBACORBA::Object ptrMy Quoter Factory::create object(const CosLifeCycle::Key &factory key,const CosLifeCycle::Cri

ADT CLASSES GUI CLASSES APPLICATION-SPECIFIC FUNCTIONALITY EVENT LOOP GLUE CODE LOCAL INVOCATIONS ADT CLASSES MATH . CENTRAL BLOB STORE CLUSTER BLOB STORE DX BLOB STORE Domain Challenges - Large volume of "Blob" data 3: . To help address this challenge, the Object Management Group (OMG) is specifying the Common Object Request Broker .