Principles of Object-Oriented Software Development Component Technology Component Technology Introduction Objects versus components Standards for interoperability The Java Platform A simple workgroup application Crush -- extending hush with CORBA Summary Q/A Literature Component Technology • • • • • objects versus components -- definitions interoperability requirements for distribution a simple workgroup application extending hush with CORBA Additional keywords and phrases: (D)COM, Java, CORBA, OLE, persistent objects, ODMG, workgroup Objects versus components Subsections: Definitions The technology matrix Component myths Definitions Component substitutability unit of independent deployment unit of third party composition no persistent state Object unit of instantiation (persistent) state encapsulation of state and behavior identity A software component is a unit of composition with contractually specified interfaces and explicit context dependencies only. A software component can be deployed independently and is subject to composition by third parties. Szyperski The technology matrix distribution mobility language platform reflection COM * +/DCOM + * +/+/CORBA + * * +/Java/Beans classes Java * + Java/RMI + classes Java * + Voyager + objects Java * + Components: Myths and Reality component-ware allows for combining components if semantical issues can be resolved component-ware simplifies software distribution and maintenance development becomes more complex component-ware support mega applications it affects performance significantly component-ware is a revolution wrong, it is an evolution from OO and C/S unknown source Component Questions • How to describe the interaction between components? • How to manage variety and flexibility? • How to guarantee critical system-wide properties? Standards for interoperability Subsections: Microsoft COM OMG CORBA ODMG persistency Object linking and embedding COM Object-enabling technology OLE • document centered -- text, graphics, reports • component software -- standard programmatic interface • distributed object systems -- component object model (D)COM Features Alternatives linking, embedding, storage IBM SOM/DSOM, Apple OpenDoc Object Request Brokers CORBA Standardization -- system integration OMG information sharing -- technology, policy Object Management Architecture -- interface standards Object Services Object Request Broker IDL CORBA Common Facilities -- file manipulation, print queuing, email Application Objects -- spreadsheets, word processor The OMG standardization effort Object Services • • • • life cycle -- creation and deletion persistence -- management of object storage naming -- mapping names to references event notification -- registration of events Future transactions, concurrency, relationships,...,time Persistent objects ODMG Persistent objects database extension -- unified type system ODMG Object Definition Language standard types -- objects and literals references -- Ref< T > collections -- List< T > , Bag< T >, Set< T > ODL Object Manipulation Language create, delete, modify, reference OML Object Query Language oql(type& value, const char* query,...) OQL The ODMG-93 standardization efforts Design principles object model the programmer feels that there is one language Language binding C++ODL/OML objects and literals -- embedded objects are literals relationships -- not directly supported by C++ extents -- must be maintained by programmer keys -- simulated by C++ data members Language binding -- C++ ODL/OML C++ODL/OML binding -- future no distinction between persistent and transient objects better integration of the query sublanguage Modifications to C++ overloading dot (access operator), r/l values, ... Standardization efforts -- de facto market share PDES/STEP, ODA, PCTE, OSI/NMF, ISO ODP, ANSI X3 Future standardization efforts The Java Platform technology innovation Perspectives • • • • Internet Applications -- the dial-tone of the Internet Software Engineering -- long-term maintenance Language Design -- semantic compromises System Development -- light weight clients, heavy weight servers • Computer Science -- towards declarative, verifiable technology • IT (in) Business -- standards for business objects and processes • Global Village -- virtual world technology An Internet-based Workgroup Applications Object Model Crush extending hush with CORBA Extending a framework with CORBA • the legacy problem -- granularity of wrappers • object creation and access -- factories and tables • client-side adaptors -- to fit within native type system • events versus objects -- natural interfaces Interfaces The hush module interface handler { handler event dispatch( in event data ); }; interface event : handler { attribute long type; attribute long x; attribute long y; }; event interface kit : handler { void source(in string file); void eval(in string command); string result(); widget root(); }; kit interface widget : handler { widget string path(); void eval( in string cmd ); void configure( in string options ); void pack( in string options ); }; interface item : handler { void move( in long x, in long y ); }; item interface iterator { iterator Object next(); }; interface container { long length(); Object first(); Object next(); Object current(); iterator walk(); }; container interface factory { factory hush::kit kit(in string name); hush::event event(in long type); }; interface dot { hush::kit kit(in string name); hush::container container(in string name); hush::iterator iterator(in string name); hush::factory hush(in string name); }; dot The widgets module module widgets { interface canvas : hush::widget { canvas canvas create( in hush::widget anc, in string path ); hush::item circle( in long x, in long y, in long radius, in string options ); // other items ... }; interface message : hush::widget { message create( in hush::widget anc, in string path ); void text(in string txt); }; message interface factory : hush::factory { factory widgets::canvas canvas(in string name, in string options); widgets::message message(in string name, in string options); }; interface dot : hush::dot { widgets::canvas canvas(in string name); widgets::message message(in string name); widgets::factory widgets(in string name); }; }; dot Examples A remote interpreter kit client hush::dot* hush; // (distributed) object tables widgets::dot* widgets; // widgets contains hush hush::kit* tk; // remote kit object widgets::message* banner; try { hush = widgets = widgets::dot::_bind (SERVER, argv[1]); tk = hush->kit("tk"); banner = widgets->message("hello"); // must exist } catch (...) { cerr << "Unexpected exception ..." << endl; return -1; } while (1) { char text = readtext(); // from stdin banner->text( text ); // display text tk->eval(text); } client (ctnd) class application : public session { server public: application(int argc, char* argv[]) : session(argc,argv,"hello") { } void corba(); int main(); }; int application::main() { tk->trace(); kit::declare("tk",tk); message* m = new hello(".hello"); m->pack(); message::declare("hello",m); corba(); // make yourself available as a server return OK; } void application::corba() { widgets::dot* dw = new widgets_dot_srv(); // create dot for widgets try { CORBA::Orbix.registerIOCallback(it_orbix_fd_open, FD_OPEN_CALLBACK); CORBA::Orbix.registerIOCallback(it_orbix_fd_close, FD_CLOSE_CALLBACK); CORBA::Orbix.impl_is_ready(SERVER,0); CORBA::Orbix.processEvents(0); } catch (...) { cout << "apparently something went wrong" << endl; } } Evaluating logical queries try { tk = hush->kit("bp"); // A kit for BinProlog tk->eval("consult(facts)"); } catch(...) { cout << "An exception ... " << endl; } while (1) { char* text = readtext(); tk->eval(text); char* q = 0; while ( (q = tk->result()) ) cout << "Result: " << q << endl; } client A remote canvas class draw_clt : public canvas { public: void plug(widgets::canvas* x) { draw = x; } int operator()() { hush::event* e = hush->event(_event->type()); cerr << "Getting event " << e->type() << endl; e->x(_event->x()+10); e->y(_event->y()+10); hush::event::_duplicate(e); // CORBA 2.0 hush::event* res = draw->dispatch(e); return canvas::operator()(); } draw_clt draw_clt(const widget* w, char* path ) : canvas(w,path) { configure("-background white"); geometry(200,100); self()->bind(this); dragging = 0; } draw_clt(char* path ) : canvas(path) { configure("-background white"); geometry(200,100); self()->bind(this); dragging = 0; } void press( event& ) { dragging = 1; } void motion( event& e) { if (dragging) { self()->circle(e.x(),e.y(),2,"-fill black"); draw->circle(e.x(),e.y(),3,"-fill yellow"); } } void release( event& ) { dragging = 0; } protected: int dragging; widgets::canvas* draw; }; class draw_srv : public canvas { draw_srv public: draw_srv( const widget* w, char* path ) : canvas(w,path) { geometry(200,100); self()->bind(this); dragging = 0; } void press( event& ) { dragging = 1; } void motion( event& e) { if (dragging) circle(e.x(),e.y(),10,"-fill black"); } void release( event& ) { dragging = 0; } protected: int dragging; }; Moving items server list<hush::item>* rlist = new list<hush::item>; item* it = draw->circle(40,40,10,"-fill yellow"); hush::item* rit = new item_srv(it); rlist->insert(rit); it = draw->circle(30,30,10,"-fill red"); rit = new item_srv(it); rlist->insert(rit); hush::container* rx = new list_srv<hush::item>(rlist); list<hush::item>::declare("items",rx); // store server iter<hush::item>* riter = rlist->walk(); iter<hush::item>::declare("riter",riter); Summary 1 Objects versus components • definitions -- components • the technology matrix • component myths -- (r)evolution 2 Standards for interoperability • Microsoft COM • OMG CORBA • ODMG persistency 3 The Java Platform • a matter of perspectives 4 An Internet-based workgroup application • agent, workgroup, agenda, appointment • CORBA server, Java applets 5 Crush -- extending hush with CORBA • factories -- (distributed) object tables • server wrappers -- remote objects • client-side adaptors -- transparant typing Questions 1. Give a definition of the notion of components. How is this related to a definition of objects? Explain the difference between these definitions. 2. What actual component technologies can you think of? How would you compare them? 3. Describe Microsoft (D)COM, OMG CORBA, ODMG Persistent Objects. Is there any relation between these standards? 4. Discuss the Java platform. What perspectives can you think of? Discuss pros and cons! 5. Describe the architecture of an Internet-based workgroup application. What technology would you use? 6. What issues may arise in extending a given library or framework with CORBA? Can you think of any solutions? Further reading I recommend [Szyperski97], both as an introduction to component-technology, and as a reference for more advanced readers. For an introduction to CORBA, you may read [Siegel96]. A readable account of the ODMG standard is given in [Cattell94]. For more information on Java, again, visit http://www.javasoft.com . For information on (D)COM, look at http://www.microsoft.com/com . Learning how to program CORBA applications is probably best learned from the manuals that come with your CORBA distribution.