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.

A New Framework for Build<strong>in</strong>g Secure Collaborative Systems 169Service Discovery – Pr<strong>in</strong>t<strong>in</strong>gAs an example of an M2MI-based system <strong>in</strong>volv<strong>in</strong>g stand-alone devices provid<strong>in</strong>gservices, consider pr<strong>in</strong>t<strong>in</strong>g. To pr<strong>in</strong>t a document from a mobile device, the user mustdiscover the near<strong>by</strong> pr<strong>in</strong>ters and pr<strong>in</strong>t the document on one selected pr<strong>in</strong>ter. Pr<strong>in</strong>terdiscovery is a two-step process: the user broadcasts a pr<strong>in</strong>ter discovery request via anomnihandle <strong>in</strong>vocation; then each pr<strong>in</strong>ter sends its own unihandle back to the user viaa unihandle <strong>in</strong>vocation on the user. To pr<strong>in</strong>t the document, the user does an <strong>in</strong>vocationon the selected pr<strong>in</strong>ter's unihandle.Specifically, each pr<strong>in</strong>ter has a pr<strong>in</strong>t service object that implements this <strong>in</strong>terface:public <strong>in</strong>terface Pr<strong>in</strong>tService {public void pr<strong>in</strong>t(Document doc);}The pr<strong>in</strong>ter exports its pr<strong>in</strong>t service object to the M2MI layer and obta<strong>in</strong>s a unihandleattached to the object. The pr<strong>in</strong>ter is now prepared to process document pr<strong>in</strong>t<strong>in</strong>grequests. To discover pr<strong>in</strong>ters, there are two pr<strong>in</strong>t discovery <strong>in</strong>terfaces:public <strong>in</strong>terface Pr<strong>in</strong>tDiscovery {public void request(Pr<strong>in</strong>tClient client);}public <strong>in</strong>terface Pr<strong>in</strong>tClient {public void report(Pr<strong>in</strong>tService pr<strong>in</strong>ter,Str<strong>in</strong>g name);}The client pr<strong>in</strong>t<strong>in</strong>g application exports a pr<strong>in</strong>t client object implement<strong>in</strong>g <strong>in</strong>terfacePr<strong>in</strong>tClient to the M2MI layer and obta<strong>in</strong>s a unihandle attached to the object.The application also obta<strong>in</strong>s from the M2MI layer an omnihandle for <strong>in</strong>terfacePr<strong>in</strong>tDiscovery. The application is now prepared to make pr<strong>in</strong>t discovery requestsand process pr<strong>in</strong>t discovery reports.Each pr<strong>in</strong>ter exports a pr<strong>in</strong>t discovery object implement<strong>in</strong>g <strong>in</strong>terface Pr<strong>in</strong>tDiscoveryto the M2MI layer. The pr<strong>in</strong>ter is now prepared to process pr<strong>in</strong>t discoveryrequests and generate pr<strong>in</strong>t discovery reportsThe application first callspr<strong>in</strong>tDiscovery.request(theClient);on an omnihandle for <strong>in</strong>terface Pr<strong>in</strong>tDiscovery, pass<strong>in</strong>g <strong>in</strong> the unihandle to itsown pr<strong>in</strong>t client object. S<strong>in</strong>ce it is <strong>in</strong>voked on an omnihandle, this call goes to all thepr<strong>in</strong>ters. The application now waits for pr<strong>in</strong>t discovery reports.Each pr<strong>in</strong>ter's request method callstheClient.report(thePr<strong>in</strong>ter,"Pr<strong>in</strong>ter Name");The method is <strong>in</strong>voked on the pr<strong>in</strong>t client unihandle passed <strong>in</strong> as an argument. Themethod call arguments are the unihandle to the pr<strong>in</strong>ter's pr<strong>in</strong>t service object and thename of the pr<strong>in</strong>ter. S<strong>in</strong>ce it is <strong>in</strong>voked on a unihandle, this call goes just to the re-

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

Saved successfully!

Ooh no, something went wrong!