Professional Documents
Culture Documents
TECHNOLOGIES
(ITec4121)
CHAPTER TWO:
FUNDAMENTALS OF CLIENT-SERVER
ARCHITECTURE
Distributed system concepts
2
Distributed system concepts…
System types:
Personal systems that are not distributed and that are designed to
run on a personal computer or workstation.
Embedded systems that run on a single processor or on an
integrated group of processors.
Distributed systems where the system software runs on a loosely
integrated group of cooperating processors linked by a network.
Examples of distributed systems:
Local Area Network and Intranet
Database Management System
Automatic Teller Machine Network
Internet/World-Wide Web
Mobile Computing
3
Distributed system concepts…
4
Distributed system concepts…
6
Distributed Systems Architectures…
Client-server Architectures
– The application is modeled as a set of services that are
provided by servers and a set of clients that use these services.
– Clients know of servers but servers need not know of clients.
– Clients and servers are logical(consistent) processes
– The mapping of processors to processes is not necessarily 1:1.
– Clients and servers can be distributed across different
machines
– Servers provide services related to a shared resources
7
Distributed Systems Architectures…
8
Distributed Systems Architectures…
9
Distributed Systems Architectures…
o1 o2 o3 o4
o5 o6
S (o5) S (o6)
10
Distributed Systems Architectures…
11
Distributed Systems Architectures…
12
Message and queuing services
14
JMS Administration
15
JMS Models (Message exchange Models)
Publish-Subscribe Messaging
Point- To-Point Messaging
Request-Reply Messaging
16
Publish-Subscribe Messaging
17
Point- To-Point Messaging
18
Request-Reply Messaging
19
JMS API Programming Model
20
The Messages
Message Components:
Header
Properties
Body
21
Message Header
22
Message Properties
Application-specific properties
Messaging system provider-specific properties
Optional fields
Properties are Name/Value pairs
Values can be int, string, byte etc
23
Message Body
24
Message Body Interfaces(Message types)
25
Example: Creating a Text Message
26
Building a JMS Client
Steps:
1. Create a Connection to the provider
2. Create Sessions to send/receive messages
3. Create MessageProducers
4. Create MessageConsumers
Step 1: Creating a Connection
Connection provides access to messaging system
Performs resource allocation and management
ConnectionFactory used to create connection and it is located
through JNDI.
27
Building a JMS Client…
28
Building a JMS Client…
29
Building a JMS Client…
31
Building a JMS Client…
Point-to-Point Programming:
Queue Browsing:
session.createBrowser (Queue queue);
session.createBrowser (QueueSession session, Queue queue,
String messageSelector) ;
32
Object broker design pattern
33
Types of Design Patterns
1 Creational Patterns
These design patterns provide a way to create objects while hiding the creation logic,
rather than instantiating objects directly using new opreator. This gives program more
flexibility in deciding which objects need to be created for a given use case.
2 Structural Patterns
These design patterns concern class and object composition. Concept of inheritance is
used to compose interfaces and define ways to compose objects to obtain new
functionalities.
3 Behavioral Patterns
These design patterns are specifically concerned with communication between objects.
4 J2EE Patterns
These design patterns are specifically concerned with the presentation tier. These
patterns are identified by Sun Java Center.
34
Proxy Design Pattern
35
Proxy Design Pattern…
@Override
public void display() {
System.out.println("Displaying " + fileName);
}
private void loadFromDisk(String fileName){
System.out.println("Loading " + fileName);
}
}
//ProxyImage.java
public class ProxyImage implements Image{
private RealImage realImage;
private String fileName;
public ProxyImage(String fileName){
this.fileName = fileName;
}
37
Proxy Design Pattern…
@Override
public void display() {
if(realImage == null){
realImage = new RealImage(fileName);
}
realImage.display();
}
}
38
Proxy Design Pattern…
39
Proxy Design Pattern…
40
Facade Design Pattern…
Hides the complexities of the system and provides an interface to the client
using which the client can access the system.
Comes under structural pattern.
Involves a single class which provides simplified methods required by client
and delegates calls to methods of existing system classes.
Implementation:
41
Facade Design Pattern…
42
Facade Design Pattern…
//Square.java
public class Square implements Shape {
@Override
public void draw() {
System.out.println("Square::draw()");
}
}
Circle.java
public class Circle implements Shape {
@Override
public void draw() {
System.out.println("Circle::draw()");
}
}
43
Facade Design Pattern…
44
Facade Design Pattern…
45
Facade Design Pattern…