13.07.2015 Views

Page 2 Lecture Notes in Computer Science 2865 Edited by G. Goos ...

Page 2 Lecture Notes in Computer Science 2865 Edited by G. Goos ...

Page 2 Lecture Notes in Computer Science 2865 Edited by G. Goos ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

168 H.-P. Bischof, A. Kam<strong>in</strong>sky, and J. B<strong>in</strong>derreturn a unihandle for that object. Unlike an omnihandle, a unihandle is bound to oneparticular object at the time the unihandle is created. A unihandle is created <strong>by</strong> codelike this:Foo b_Foo = M2MI.getUnihandle(b,Foo.class);Once a unihandle is created, call<strong>in</strong>g method Y on the unihandle means, “The particularobject out there associated with this unihandle, perform method Y.” When thestatement b_Foo.y(); is executed, only object B performs the method. As with anomnihandle, the target object for a unihandle <strong>in</strong>vocation need not reside <strong>in</strong> the sameprocess or device as the call<strong>in</strong>g object.A unihandle can be detached from its object, after which the object can no longerbe <strong>in</strong>voked via the unihandle:b_Foo.detach();MultihandlesA multihandle for an <strong>in</strong>terface stands for “one particular set of objects out there thatimplement this <strong>in</strong>terface.” Unlike a unihandle which only refers to one object, a multihandlecan refer to zero or more objects. But unlike an omnihandle which automaticallyrefers to all objects that implement a certa<strong>in</strong> target <strong>in</strong>terface, a multihandle onlyrefers to those objects that have been explicitly attached to the multihandle.The multihandle is named someFoos, and it is attached to two objects, A and D.The multihandle is created and attached to the objects <strong>by</strong> code like this:Foo someFoos = M2MI.getMultihandle(Foo.class);someFoos.attach(a); someFoos.attach(d);Once a multihandle is created, call<strong>in</strong>g method Y on the multihandle means, “Theparticular object or objects out there associated with this multihandle, perform methodY.” When the statement someFoos.y(); is executed, objects A and D perform themethod, but not objects B or C. As with an omnihandle or unihandle, the target objectsfor a multihandle <strong>in</strong>vocation need not reside <strong>in</strong> the same process or device as thecall<strong>in</strong>g object or each other.A multihandle can be created <strong>in</strong> one process and sent toanother process, and the dest<strong>in</strong>ation process can then attach its own objects to themultihandle.An object can also be detached from a multihandle:someFoos.detach(a);M2MI-Based SystemsThis section gives one examples show<strong>in</strong>g how M2MI can be used to design a chatapplication and a pr<strong>in</strong>t service discovery system. These examples show the eleganceof ad hoc collaborative systems based on M2MI. Further examples can be found at[4].

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!