Design Patterns for
Distributed Programming:
Sharing Objects with Java

A thesis submitted in fulfilment of the
requirements for the award of the degree

Master of Science (Hons)

at the

UNIVERITY OF WOLLONGONG

by

Robert Ott

Department of Computer Science

June 1996


Contents


Abstract

This thesis presents results from studies on the design of distributed applications. After studying implementations of schemes for object sharing, and broker based systems, two new design patterns have been abstracted. The first pattern, Simple Shared Object, describes a client/server based system for sharing objects across address spaces. The pattern is implemented in C++ using an experimental class library for distributed programming. The second pattern, Deputy, is a contribution to multi-threaded programming techniques. The pattern describes a general way for delegating commands from one object to another by using multi- threading. The implementation of the pattern is shown using the Java programming language.

The main part of this thesis shows a broker based system for sharing objects across address spaces. The system is an advanced version of the Simple Shared Object pattern and is fully implemented in the Java programming language. The system is called Simple Shared Object Request Broker (abbreviated to SSORB). A sample application using the SSORB system shows how a distributed application can be implemented. Then, a short evaluation of the system touches aspects such as portability, performance and reusability of the SSORB system. The SSORB system fulfils the lack of classes for the facilitation of object sharing across address spaces in the Java development kit.


Dedication

I dedicate this thesis to my parents,
who have been adoring my life from birth
with affection and love.

Ich widme diese Dissertation meinen Eltern,
die mein Leben seit meiner Geburt mit Zuneigung
und Liebe schmücken.


Acknowledgments

An important key point of every research is to have someone to talk about problems throughout the research, in short, to have a smart guardian angel as a supervisor. I was lucky to have Associate Professor Neil A. B. Gray as my supervisor and would like to express my sincere thanks to him. I learned him not only as a smart and correct expert in object-oriented technology, I also experienced Neil as a helpful and concerned friend.

What is a research student doing when he comes home from the University? I was pleased to have my two housemates Hakan Yilmaz and Murat Polat to share most of the time here in Wollongong. I experienced these two guys as very close friends and remember endless nights discussing about our research. I will never forget the joyful time we spent together here in Australia.

A research in Computer Science is also a collaboration between experts all around the world. I would like to thank all the individuals who helped me by e-mail. I especially would like to express my thanks to Grady Booch (Rational Software Corporation), Gerard Meszaros (Bell Northern Research, Ltd), Douglas C. Schmidt (Washington University) and Bob Hathaway (SIGS Publications) for their contribution to this research.

A special thank-you is due to my friend Roman Selm in Switzerland, who has set the course of my career dominantly at those days as he was my boss in Grossenbacher Elektronik AG. I also would like to thank him for his critical comments to my paper "Simple Shared Object".

I believe that every person on earth has a soulmate, a special and close friend. I call Edgar Sattler as my soulmate and want to thank him for his encouragement and the psychological support he gave via phone, fax, e-mail, c-mail, letters and postcards. ;-)

Finally and most importantly I wish to thank my parents, my sister and my brother for their encouragement and help during my stay here in Australia.


Table of Contents

Abstract
Dedication
Acknowledgments
Table of Contents
Table of Figures
1. Introduction
1.1 Motivation
1.2 Objectives
1.3 Outline
2. Problem Context
2.1 Overview
2.2 Object-Oriented Technology - from Rhetoric to Reality
2.3 Design Patterns
2.3.1 Definition of Design Patterns
2.3.2 The Idea of Design Patterns
2.3.3 An Example of a Pattern
2.3.4 Antipatterns
2.3.5 Design Patterns - A Way to tame C++
2.4 Application Frameworks
2.4.1 Smalltalk Framework (MVC-Triad)
2.4.2 The MacApp Framework
2.4.3 Object-Studio - A Framework with Database Access and CASE
2.5 Distributed Programming
2.5.1 Reasons for Distributed Programming
2.5.2 Common Object Request Broker Architecture (CORBA)
2.5.3 The Java language and the World Wide Web
2.6 Summary
3. A Pattern for Sharing Objects - "Simple Shared Object"
3.1 Overview
3.2 An Experimental Class Library - Distributed Object Communication
3.2.1 The I/O-Dispatcher Object
3.2.2 Channel Objects
3.2.3 Coms Objects
3.2.4 The System (Collaborations)
3.2.5 A Typical Object Composition in an Example
3.3 Extension for Sharing Objects
3.4 "Simple Shared Object" - An Architectural Pattern for Simple Object Sharing
3.4.1 Intent
3.4.2 Motivation
3.4.2.1 Needs for Shared Objects
3.4.2.2 Behaviour of Shared Objects
3.4.3 Applicability
3.4.4 Structure
3.4.5 Participants
3.4.6 Collaborations
3.4.6.1 Shared Object Creation
3.4.6.2 Shared Object Modification
3.4.6.3 Shared Object Deletion
3.4.7 Consequences
3.4.8 Implementation
3.4.9 Sample Code
3.4.10 Variations
3.4.11 Known Uses
3.4.12 Related Patterns
3.5 Summary
4. Simple Shared Object Request Broker (SSORB) - A Tailored System for Java
4.1 Overview
4.2 Broker Systems for Collaborative Applications
4.2.1 On what systems (architectures) could CSCW applications base in the future?
4.2.2 Could another programming language than C++ be more appropriate?
4.2.3 Could an already existing model be specialised for simple object sharing?
4.3 The Basic Model of the SSORB
4.4 Message Objects within the SSORB System
4.5 The Broker
4.6 Object Servers
4.6.1 Referencing of Shared Objects across Address Spaces
4.6.2 "Well-known" Proxy Lists
4.7 Client Applications
4.8 "Deputy" - A Behavioural Pattern for Delegating Commands to a Multi-Threaded Deputy Object
4.8.1 Intent
4.8.2 Motivation
4.8.2.1 Requirements of Deputy Objects
4.8.2.2 Behaviours of Deputy Objects
4.8.3 Applicability
4.8.4 Structure
4.8.5 Participants
4.8.6 Collaborations
4.8.7 Consequences
4.8.8 Implementation
4.8.8.1 The "DPYCommand" Class
4.8.8.2 The "DPYSmartCommand" Class
4.8.8.3 The "DPYDumbCommand" Class
4.8.8.4 The "DPYReply" Class
4.8.8.5 The "DPYDelegator" Interface
4.8.8.6 The "DPYDeputy" Class
4.8.9 Sample Code
4.8.10 Variations
4.8.11 Known Uses
4.8.12 Related Patterns
4.9 Summary
5. Implementation of the SSORB System
5.1 Overview
5.2 The Implementation in General
5.2.1 Name Conventions
5.2.2 Pseudo Code
5.2.3 Complete Class Diagram of the SSORB System
5.2.4 Inter-Component Communication with Message Objects
5.2.5 Exception Handling within the SSORB System
5.2.5.1 The "SSOException" Class
5.2.5.2 The "SSOReplyException" Class
5.3 The Broker Implementation
5.3.1 The Java Code for the Broker Classes
5.3.1.1 The "SSORBCustomerHandler" Class
5.3.1.2 The "SSORBReceptionist" Class
5.3.1.3 The "SSORBAdministrator" Class
5.3.1.4 The "SSORB" Class
5.4 The Customer Implementation - Object Servers and Client Applications
5.4.1 The Java Code for the Application Independent Object Server and Client Application Classes
5.4.1.1 The "SSOMainInterface" Interface
5.4.1.2 The "SSOReceptionist" Class
5.4.1.3 The "SSORegistration" Class
5.4.1.4 The "SSOProxyHandler" Class
5.4.1.5 The "SSOProxy" Class
5.4.1.6 The "SSOProxyRef" Class
5.4.1.7 The "SSOProxyList" Class
5.5 Summary
6. A Sample Application and Evaluation
6.1 Overview
6.2 "Application Joiner" - A Sample Application using the SSORB System
6.2.1 Analysis
6.2.2 Design
6.2.2.1 Identification of the Sharable Classes
6.2.2.2 Specialisation of the User Interface Classes
6.2.3 Evolution
6.2.3.1 Implementation of a Specialised Sharable Proxy Class
6.2.3.2 The Application Joiner Program - A Posed Example
6.2.4 Modification
6.3 Evaluation
6.3.1 Portablility
6.3.2 Performance
6.3.3 Reusability
6.4 Summary
7. Conclusions and Future Research
7.1 Conclusions
7.1.1 Contributions
7.1.1.1 Contributions to Design Patterns
7.1.1.2 Contributions to Distributed Programming
7.1.1.3 Contributions to Applications Using Java
7.1.2 Reflections
7.1.2.1 Keeping a Catalogue of Design Patterns
7.1.2.2 Java: An Alternative to C++
7.1.2.3 Distributed Software Systems
7.1.2.4 The World Wide Web: An Important Means for Research
7.2 Future Research
Appendices
Appendix A: Abbreviations
Appendix B: Trademarks and Terms
Appendix C: Java Code Listings
Bibliography


Table of Figures

Figure 2.1: Class diagram of the Singleton pattern
Figure 2.2: The components of the Model-View-Controller triad
Figure 2.3: Traditional programming and MacApp programming
Figure 2.4: Some of the popular classes within the MacApp class library
Figure 2.5: An Object Request Broker (ORB) and its environment
Figure 2.6: From Java language source code to the Java interpreter
Figure 3.1: A particular application using the experimental class library
Figure 3.2: A typical object composition using the experimental class library
Figure 3.3: A distributed application with shared objects
Figure 3.4: Class diagram of the Simple Shared Object pattern
Figure 3.5: Illustration of the Simple Shared Object pattern by an object diagram
Figure 3.6: Collaboration between participants in the creation process
Figure 3.7: Collaboration between participants in the modification process
Figure 3.8: Collaboration between participants in the deletion process
Figure 4.1: Traditional and broker based Client/Server systems
Figure 4.2: The components of the SSORB system and their responsibilities
Figure 4.3: The components of the Simple Shared Object Request Broker
Figure 4.4: A typical object constellation within a SSORB object server
Figure 4.5: The proxy reference class within the SSORB system
Figure 4.6: A typical object constellation within a SSORB client application
Figure 4.7: A deputy executing delegated commands
Figure 4.8: Class diagram of the Deputy pattern
Figure 4.9: Object diagram of the Deputy pattern
Figure 4.10: Collaborations between participants of the Deputy pattern
Figure 5.1: The classes within the SSORB system and their major relationships
Figure 5.2: Interaction table for message exchanges within the SSORB system
Figure 5.3: The structure of the SSORBCustomerHandler class
Figure 5.4: The structure of the SSORBReceptionist class
Figure 5.5: The structure of the SSORBAdministrator class
Figure 5.6: The structure of the SSORB class
Figure 5.7: The structure of the interface SSOMainInterface
Figure 5.8: The structure of the SSOReceptionist class
Figure 5.9: The structure of the SSORegistration class
Figure 5.10: The structure of the SSOProxyHandler class
Figure 5.11: The structure of the SSOProxy class
Figure 5.12: The structure of the SSOProxyRef class
Figure 5.13: The structure of the SSOProxyList class
Figure 6.1: A virtual collaboration house "Application Joiner"
Figure 6.2: Scenario of a user entering the virtual collaboration house
Figure 6.3: The sharable classes of the Application Joiner program
Figure 6.4: A sketch of the Application Joiner user interface
Figure 6.5: The GUI classes of the Application Joiner program
Figure 6.6: The structures of the classes User and UserProxy
Figure 6.7: A screen dump from the sample SSORB application (on Windows 95)
Figure 6.8: A screen dump from the sample SSORB application (on Unix)
Figure 6.9: Number of messages exchanged, classified by message tasks
Figure 6.10: Direct connection between an object server and a client application


Back to Thesis Home Page.