Professional Documents
Culture Documents
TECHNOLOGIES
i
Anna University of Technology Trichy
Middleware Technologies
SYLLABUS
Client server – File server – Database server – Group server – Object server – Web server
– Middleware – General Middleware – Service specific middleware – Client / server
building blocks – RPC – Messaging – Peer-to-peer.
EJB session beans – EJB entity beans – EJB clients – EJB deployment – Building an
application with EJB.
UNIT IV CORBA 9
UNIT V COM 9
COM – Data types – Interfaces – Proxy and stub – Marshalling – Implementing server /
client – Interface pointers – Object creation – Invocation – Destruction – Comparison
COM and CORBA – Introduction to .NET – Overview of .NET architecture –
Marshalling – Remoting.
ii
LIST OF ABBREVIATION IN MIDDLEWARE TECHNOLOGY
iii
J2ME -Java 2 Micro Edition
SOAP -Simple Object Access Protocol
SOM -System Object model
JVM -Java Virtual Machine
JMS -Java Message Service
OMA -Object Management Architecture
OMG - Object Management Group
DLL -Dynamic Linked Library
OMG IDÌ -Object Management Group Interface Definition Language
SMTP - Simple Mail Transfer Protocol
CDMA -Code Division Multiple Access
WORA - Write Once Read Anywhere
JNDI - Java Naming Directory Interface
UTF - Universal Text Format
OWL - Web Ontology Language
JIT - Just In time
CLR - Common Language Runtime
MSIL - Microsoft Intermediate Language
WSDL - Web Service Description Language
SET - Service Endpoint Interface
JAX RPC - Java XML RPC
XML - Extended Markup Language
RPC - Remote Procedure Call
XSD - XML Schema Definition
SOAP - Simple Object Access Protocol
iv
RDF - Resource Description Framework
IIS - Internet Information Server
JMS - Java Message Service
JSP - Java Server Page
ASP - Active Serve page
VTBL - Virtual Table Pointer
COM - Component Object model
DCOM - Distributed Component Object Model
OLE - Object Linking & Embedding
v
UNIT I CLIENT / SERVER CONCEPTS 1.11 – 1.32
vi
1.7 RPC – MESSAGING – PEER-TO-PEER 1.25
1.7.1 Peer – to – Peer Communicat ions 1.26
1.7.2 Sockets 1.27
1.7.3 Datagrams Vs Sessio ns 1.39
vii
UNIT III EJB APPLICATIONS 3.1 – 3.34
viii
4.2.1 Socket Programming 4.2
4.2.2 Remote Procedure Call (RPC) 4.3
4.2.3 OSF Distributed Computing Environment (DCE) 4.3
4.2.4 Microsoft Distributed Component Object Model (DCOM) 4.3
4.2.5 Java Remote Method Invocation (RMI) 4.4
4.2.6 Introducing the Object Management Group (OMG) 4.4
ix
4.8.5 Use of the C Preprocessor 4.18
4.8.6 The Module 4.18
4.8.7. Primitive Types 4.19
4.8.8 Constructed Types 4.21
4.8.9 Other IDL Constructs 4.28
x
5.9 OVERVIEW OF .NET ARCHITECTURE 5.19
5.9.1 Common Language Infrastructure (CLI) 5.19
5.9.2 Assemblies 5.20
5.9.3 Security 5.21
5.9.4 Class library 5.21
5.9.5 Memory management 5.22
5.9.6 Standardization and licensing 5.23
5.9.7 Versions 5.24
5.9.8 Criticism 5.25
5.9.9 Alternative implementations 5.26
5.10 MARSHALLING 5.27
5.10.1 Usage 5.28
5.10.2 Comparison with serialization 5.28
5.11 .NET Framework Remoting Overview 5.28
5.11.1. Operations of Remoting in .Net Framework 5.29
5.11.2 References of Remoting in .Net Framework 5.30
5.11.3 Architecture of Remoting 5.32
5.11.4 Example 5.33
xi
xii
Client/Server Computing 1.1
UNIT I
CLIENT/SERVER COMPUTING
Client – Server – File Server, Data Base Server, Group Server, Object
Server, Web Server Middleware – General Middleware – Service Specific
Middleware Client
– Client Server Building blocks – RPC – Messaging – Peer-to-Peer
1.1 INTRODUCTION
Client/ server computing is an irresistible movement that is reshaping the
way computers are being used. Although the computing movement is relatively
young it is already in full and is not leaving any fact of the computer industry untouched.
In addition, the Internet is like tsunami; it is introducing a new form of client/server
computing- intergalactic client/server. It is revolution within the revolution.
Client-server is a co mputing architecture which separates a client from a server,
and is almost always implemented over a computer network. Each client or server
connected to a network can also be referred to as a node. The most basic type of client-
server architecture employs only two types of nodes: clients and servers. This type of
architecture is somet imes referred to as two-tier. It allows devices to share files and
resources.
Each instance of the client software can send data requests to one or more connected
servers. In turn, the servers can accept these requests, process them, and return the
requested information to the client. Although this concept can be applied for a variety of
reasons to many different kinds of applicat ions, the architecture remains fundamentally the
same.
These days, clients are most often web browsers, although that has not always
been the case. Servers typically include web servers, database servers and mail servers.
Online gaming is usually client-server too. In the specific case of MMORPG, the
servers are typically operated by the company selling the game; for other games one of the
players will act as the host by setting his game in server mode.
The interaction between client and server is often described using sequence
diagrams. Sequence diagrams are standardized in the Unified Modeling Language.
computerized systems. This model is based on distribution of functions between two types
of independent and autonomous processes: Server and Client. A Client is any process
that requests specific services from the server process. A Server is a process that
provides requested services for the Client. Client and Server processes can reside in same
computer or in different computers linked by a network.
When Client and Server processes reside on two or more independent computers on
a network, the Server can provide services for more than one Client. In addition, a client
can request services from several servers on the network without regard to the location
or the physical characteristics of the computer in which the Server process resides. The
network ties the server and client together, providing the medium through which the clients
and the server communicate. The Fig. 1.1 given below shows a basic Client/Server
computing model.
Functions such as email exchange, web access and database access, are built on
the client–server model. Users accessing banking services from their computer use a
web browser client to send a request to a web server at a bank. That program may in turn
forwar d the request to its own database client program that sends a request to a database
server at another bank computer to retrieve the account information. The balance is
returned to the bank database client, which in turn serves it back to the web browser
client displaying the results to the user. The client–server model has become one of the
central ideas of network comput ing. Many business applications being written today use
the client–server model. So do the Internet's main application protocols, such as HTTP,
SMTP, Telnet, and DNS.
Client/Server Computing 1.3
The interaction between client and server is often described using sequence
diagrams. Sequence diagrams are standardized in the Unified Modeling Language.
Specific types of clients include web browsers, email clients, and online chat clients.
Specific types of servers include web servers, ftp servers, applicat ion
servers, database servers, name servers, mail servers, file servers, print servers, and
terminal servers. Most web services are also types of servers.
The client–server paradigm lacks the robustness of a good P2P network. Under
client–server, should a critical server fail, clients‘ requests cannot be fulfilled. In
P2P networks, resources are usually distributed among many nodes. Even if one or more
nodes depart and abandon a downloading file, for example, the remaining nodes should
still have the data needed to complete the download.
In software engineering, multi-tier architecture (often referred to as n-tier
architecture) is a client –server architecture in which the presentation, the
application
1.4 Client/Server Computing
processing, and the data management are logically separate processes. For example,
an application that uses middleware to service data requests between a user and a
database employs multi-tier architecture.
Shared resources : A server can service many clients at the same time and
regulate their access to shared resources.
Transparency Of Location: The server is a process that can reside on the same
machine as the client or on a different machine across a network. Client/server software
usually masks the location of the server from the clients by redirecting service calls
when needed. This is referred as
Message – Based Exchanges: client and server are loosely coupled systems that
interact through a message passing mechanism. The message is the delivery mechanism
for the service requests and replies.
Integrity: The server code and server data is centrally managed, which results in
cheaper maintenance and guarding of shared data integrity. At the same time, the clients
remain personal and independent.
ACID (atomicity, consistency, isolation, durability) is a set of properties that guarantee that
database transact ions are processed reliably. In the context of databases, a single logical
operation on the data is called a transaction. For example, a transfer of funds from one
bank account to another, even though that might involve multiple changes (such as
debiting one account and crediting another), is a single transaction.
ATOMICITY
Atomicit y requires that each transaction is "all or nothing": if one part of the transaction
fails, the entire transaction fails, and the database state is left unchanged. An atomic
system must guarantee atomicity in each and every situation, including power failures,
errors, and crashes.
CONSISTENCY
The consistency property ensures that any transaction will bring the database from one
valid state to another. Any data written to the database must be valid according to all
defined rules, including but not limited to constraints, cascades, triggers, and any
combination thereof.
ISOLATION
Isolat ion refers to the requirement that no transaction should be able to interfere with
another transaction. One way of achieving this is to ensure that no transactions that affect
the same rows can run concurrently, since their sequence, and hence the outcome,
might be unpredictable. This property of ACID is often partly relaxed due to the huge
speed decrease this type of concurrency management entails.
DURABILITY
Durabilit y means that once a transaction has been committed, it will remain so, even in
the event of power loss, crashes, or errors. In a relational database, for instance, once a
group of SQL statements execute, the results need to be stored permanently. If the
database crashes
1.6 Client/Server Computing
immediately thereafter, it should be possible to restore the database to the state after the
last transaction committed.
EXAMPLES
The following examples are used to further explain the ACID properties. In these
examples, the database has two fields, A and B, in two records. An integrity constraint
requires that the value in A and the value in B must sum to 100. The following SQL code
creates a table as described above:
ATOMICITY FAILURE
The transaction subtracts 10 from A and adds 10 to B. This is a valid transaction, since
the data continue to satisfy the constraint after it has executed. However, assume that
after removing 10 from A, the transaction is unable to modify B. If the database retained
A's new value, atomicity and the constraint would both be violated. Atomicity requires that
both parts of this transaction, or neither, be complete.
CONSISTENCY FAILURE
Consistency is a very general term that demands the data meets all validation rules. In
the previous example, the validation is a requirement that A + B = 100. Also, it may be
implied that both A and B must be integers. A valid range for A and B may also be
implied. All validation rules must be checked to ensure consistency.
In reality, this goes much further than simply A and B, as it implies every single cascade
or trigger chain related to the events in the transaction, and thus every check on all of
the indirectly impacted values as well. If there had been other constraints, triggers or
cascades, every single change operation would have been checked in the same way as the
above before the transaction was committed.
Client/Server Computing 1.7
ISOLATION FAILURE
subtract 10 from A
add 10 to B.
subtract 10 from B
add 10 to A.
DURABILITY FAILURE
File server is a computer attached to a network that has the primary purpose of
providing a location for shared disk access that can be accessed by the workstations that
are attached to the computer network. The term server highlights the role of the machine
in the client–server scheme, where the clients are the workstations using the storage. A file
server is not intended to perform computational tasks, and does not run programs on
behalf of its clients. It is designed primarily to enable the storage and retrieval of
data while the computation is carried out by the workstations.
Database server is the term used to refer to the back-end system of a database
application using client/server architecture. The back-end, sometimes called a
database server, performs tasks such as data analysis, storage, data manipulation, archiving,
and other
Client/Server Computing 1.9
non-user specific tasks. A database server is a computer program that provides database
services to other computer programs or computers, as defined by the client–server model.
The term may also refer to a computer dedicated to running such a program. Database
management systems frequently provide database server functionality, and some DBMS
rely exclusively on the client–server model for database access.
It also performs tasks such as data analysis, storage, data manipulation, archiving,
and other tasks using client/server architecture. Such a server is accessed either through a
"front end" running on the user‘s computer which displays requested data or the "back
end" which runs on the server and handles tasks such as data analysis and storage. In a
master-slave model, database master servers are central and primary locations of data while
database slave servers are synchronized backups of the master acting as proxies.
Some examples of Database servers are Oracle, DB2, Informix, Ingres, SQL Server,
MySQL. Every server uses its own query logic and structure. The SQL query language is
more or less the same in all the database servers.
Groupware refers to programs that help people work together collectively while located
remotely from each other. Programs that enable real time collaboration are called
synchronous groupware. Groupware services can include the sharing of calendars,
collective writing, e-mail handling, shared database access, electronic meetings with each
person able to see and display information to others, and other activities. Sometimes called
collaborative software, groupware is an integral component of a field of study known
as Computer- Supported Cooperative Work or CSCW.
Groupware is often broken down into categories describing whether or not work group
members collaborate in real time (synchronous groupware and asynchronous groupware).
Some product examples of groupware include Lotus Notes and Microsoft Exchange, both
of which facilitate calendar sharing, e-mail handling, and the replication of files
across a distributed system so that all users can view the same information. Electronic
"face-to-face" meetings are facilitated by CU-SeeMe and Microsoft NetMeeting.
There are no limitations to the number of tiers an application may have. The 'three'
in three-tier represents the most common number of logical separations for an
application. These logical separations are broken down into Presentation, Application, and
Data services, as described further below.
Two-tier architecture
Two tier Client/Server provides a basic separation of tasks. The client, or first tier, is
primarily responsible for the presentation of data to the user and the 'server,' or second tier,
is primarily responsible for supplying data services to the client. So far, so good.
Presentation services
Presentation services' refers to the portion of the application which presents data
to the user. In addition, it also provides for the mechanisms in which the user will interact
with the data. More simply put, presentation logic defines and interacts with the user
interface. The presentation of the data should generally not contain any validation
rules. Delphi Client/Server Suite's Rapid Application Development (RAD) approach
to application development and component architecture allows the developer to
easily assemble the presentation layer and move quickly from prototype to production.
Business services/objects
Business services' are a category of application services. Business services
encapsulate or componentized an organizations business processes and requirements.
These rules are derived from the steps necessary to carry out day-today business in an
organization. These rules can be validation rules, used to be sure that the incoming
information is of a valid type and format, or they can be process rules, which ensure that
the proper business process is followed in order to complete an operation. Through
Delphi Client/Server Suite these services can be encapsulated in Delphi components
which can then be shares amongst development teams providing for easier maintenance
and component/code reuse.
Application services -Application services' provide other functions necessary for
the application.
Data services
Data services' provide access to data independent of their location. The data can
come from legacy mainframe systems, SQL RDBMS systems, or proprietary data access
systems. Once again, the data services provide a standard interface for accessing data.
Delphi Client/Server Suite includes connectivity to Informix, InterBase, Microsoft
SQL Server, Oracle, Sybase and any other data source which supports ODBC.
Where do application logic and business rules reside in two-tier Client/Server?
As Figure 1 depicts, both business rules and application logic can reside on either the
client or the server. The Client/Server divisio n doesn't apply to them. The resulting lack
of clarity raises several critical issues: reuse, scalability, and maintenance. Delphi
Client/Server offers a number of features which ameliorate these issues, and an n-tier
architecture provides further resolution.
Delphi for two-tier development
Delphi Client/Server Suite addresses the issues mentioned above, smoothing
the transition from existing two-tier to three-tier solutions.
Delphi Client/Server Suite outpaces the competition such as PowerBuilder, SQL
Windows and Visual Basic for two-tier application development. Delphi Client/Server
Suite employs a true object-oriented language, to support a component-based RAD model
offering greater re-use and scalability. Unlike competing products, Delphi allows
developers to create custom components (VCLs) in Delphi to extend the Delphi
development environment
1.16 Client/Server Computing
without having to resort to using another tool or language. Delphi Client/Server Suite's 32-
bit optimized native-code compiler delivers high performance native-code applications.
1.3.6.2 Two Tier Architecture Pros and Cons
Advantages Disadvantages
Three-tier architecture
In order to address the above-mentioned issues in an effective way,
software developers community came with an evolutionary but effective and efficient
solution referred to as "three-tier architecture". That is, an application can be separated
into three logical layers, each with a well-defined set of interfaces. The first tier is called
as the presentation layer and it normally consists of a graphical user interface. The
middle tier consists of the application logic and the third tier is the data layer. The three
logical layers can lie in the same machine also through smart software configuration.
Thus three-tier client/server applications employ an intermediary or middle-
tier application server, which operates between client applications and the back-end
databases. The middle tier composes business application logic code, which the user calls
upon through
Client/Server Computing 1.17
the front-end graphical user interface to retrieve the desired data. The presentation layer
on getting the data from the middle tier formats the data for displaying it to the user. This
kind of separations brings a number of unique advantages such as flexibility and
performance increment. Also multiple user interfaces can be built and deployed with out
bringing any change to the application logic.
There are a variety of ways of implementing this middle tier, such as
using transaction processing (TP) monitors, message servers, object request brokers
(ORBs) or application servers. The middle tier can perform queuing, application execution,
locating and connecting application objects and database staging. If the middle tier
provides queuing, the client can deliver its request to the middle layer and disengage
because the middle tier will access the data and return the answer to the client.
The third tier contains the data that is needed for the application.. The data can be
from any source of information such an enterprise database like Oracle, MS SQL Server,
a set of XML documents, a directory service like an LDAP server, or even any legacy
and proprietary systems.
This approach heavily improves those lacking points found in two-tier application.
There are two fundamental motivations for using a three-tier architecture over a two-tier
model:
Improved Scalability, availability, and performance
Improved flexibility, and extensibility of business systems
These features are being achieved through managing back-end resources in a
more effective and smart manner. There are some good resource management techniques
such as pooling and clustering middle-tier servers. Pooling makes three-tier systems more
effective by allowing more clients to share scarce resources like database connections,
which reduces the workload on back-end servers. Clustering makes three-tier systems
more available and scalable because multiple servers and resources can support fail-over
and balance the word loads of a growing client population.
Three-tier systems are more flexible and extensible than their two-tier systems as the
business logic and services such as security, persistence, transactions etc reside on
the middle-tier and transparent to the client applications. This tends to make t hese services
being applied automatically to client requests and any changes made in the business logic
code do not reflect on the clients in any way.
Still it has been found that three-tier methodology lacks some critical features such as
reusability of application logic code and scalability. That is, there may arise a situation
whereby a collection of application logic code results and they cannot be reused and also
they do not communicate with one another. Thus there came a need for a viable
architecture that mainly facilitates reusability of business logic as reusability phenomena
has been found to reduce the cost of software development and the time to market and its
quality is assured.
1.18 Client/Server Computing
Transaction Processing (TP) monitor technology - The most basic type of three-
tier architecture has a middle layer consisting of Transaction Processing (TP)
monitor technology. The TP monitor technology is a type of message queuing,
transaction scheduling, and prioritization service where the client connects to the TP
monitor in the middle layer instead of database server on the back-end. The transaction is
accepted by the monitor, which queues it and then takes responsibility for managing it to
completion, thus freeing up the client. A typical TP monitor technology provides the
ability to update multiple different DBMSs in a single transaction connectivity of data
sources including flat files, non
-relational DBMS‘s and even mainframe systems the ability to attach priority to
transactions and to give robust security For systems with thousands of users, TP monitor
technology has been one of the most effective solutions.
The main limitation of this technology is that the implementation code has to be
written in a low-level language such as COBOL and there is no visual toolsets to
interoperate with the middle tier.
Message Server - This is another viable technology to implement three-tier
architecture applications. Messages from clients are being prioritized and
processed asynchronously. A typical message consists of a header that
contains priority information, and the address and identification number. The
message server connects to the backend RDBMS and other data sources. The
main difference between TP monitor technology and message server paradigm
is that the message server architecture focuses on intelligent messages, whereas
the TP monitor environment has the intelligence in the monitor, and treats
transactions as dumb data packets. Click here for an overview of Java Message
Service (JMS).
Application Server - This helps the application logic code to be deployed in a
shared host machine rather than in the user system interface.
.
Figure 1.10. Three-tier Client/Server architecture
Client/Server Computing 1.19
Through standard tiered interfaces, services are made available to the application.
A single application can employ many different services which may reside on
dissimilar platforms or are developed and maintained with different tools. This
approach allows a developer to leverage investments in existing systems while creating
new application which can utilize existing resources.
Multi-tier architectures
Thus the notion of n-tier architecture. To turn three-tier architecture into an n-tier
system, the middle tier can be allowed to have multiple application objects rather than a
single application. Each of these application objects must have a well-defined
interface which allows them to contact and communication with one another. An interface
is actually brings an idea of contract. That is, each object states through its interface that it
will accept certain parameters and return a specific set of results. Application objects use
their interfaces to do business processing.
With n-tier architecture, one can have multiple applications using a common set
of business objects across an organization. This promotes the standardization of
business practices by creating a single set of business functions for the entire organization to
access. If a particular business rule changes, then changes have to be made to only the
business object and if need, to its interface also.
For example, in the diagram below the client application looks to Application Server
#1 to supply data from a mainframe based application. Application Server #1 has no
direct
access to the mainframe application but, it does know, through the development of
application services, that Application Server #2 provides a service to access the data from
the mainframe application which satisfies the client request. Application Server #1 then
invokes the appropriate service on Application Server #2 and receives the requested data
which is then passed on to the client.
Application servers can take many forms. An application server may be anything
from custom application services, Transaction Processing Monitors, Database
Middleware, Message Queue to a CORBA/COM based solution.
Application server vendors such as Open Environment Corporation (Entera),
BEA Systems (Tuxedo), IBM (CICS, MQSeries), IBM/Transarc (Encina), Iona
Technologies (ORBix), NCR (TopEnd) in combination with their partners offer
connectivity solutions for Delphi Client/Server Suite.
1.20 Client/Server Computing
2-Tier Vs 3-Tier
Instead of Fat clients and fat servers these terms can be used. It is all about how
We split the client/server applications into functional units. These functional units
can be assigned to either the client or to one or more servers. The most typical functional
units are:
User Interface
Business Logic and
the Shared Data
In 2-tier, the application logic is either buried inside the User Interface on the client
or within the database on the server (or both) 2-tier system examples: File Servers and
Database Servers with stored procedure. In 3-tier, the application logic (or) process lives in
the middle- tier, it is separated from the data and the user interface. 3-tier systems are
more scalable, robust and flexible. In addition, they can integrate data from multiple
sources.
Examples: TP Monitors, Distributed Objects and the Web.
Client/Server Computing 1.21
Table1.1
2-tier 3-tier
System Complex Less complex
administration (more logic on the client to (the application can be centrally,
manage) managed on the server-
application programs are made
visible to standard system
management tools)
Security Low( data level security) High (fine tuned at the service,
method, or object type level)
Encapsulation of Low( data tables are exposed) High(the client invokes service
data or method)
Performance Poor(many SQL statement sent Good(only service requests and
over the network, selected data responses are sent between the
must be down loaded for analysis client and server)
on the client)
Scale Poor(limited management of Excellent (concentrates incoming
client communications sessions; can distribute loads
links)
1.22 Client/Server Computing
across multiple)
Application reuse Poor(monolithic application Excellent (can reuse service and
on client) objects)
Ease of High Getting better(standard tools can
development be used to create the client and
server sides of the application)
Server to Server No Yes(via server –side middleware)
infrastructure
Legacy application No Yes(via gateways encapsulated
integration by service or objects)
Internet support Poor(internet bandwidth Excellent (thin clients are easier
limitations make it harder to to download as applets or beans;
download clients and exacerbate remote service invocations
the already noted limitations) distribute the application load to
the server)
Heterogeneous No Yes(3-tier application can use
database support multiple database within the
same business transaction)
No(only synchronous, connection Yes(supports RPC-like calls, but
oriented RPC like calls) can also support connectionless
messaging, queued delivery,
public and subscribe and broad
cast)
Architecture Limited(We have a client and a Excellent(all three tiers may
flexibility server) reside on different computers, or
the second and third tires may
both reside on the same computer
with component based
environment We can distribute
the second tier across mulitple
servers as well)
Logic Tier
This layer coordinates the application, processes
Get list of all sales Add all sales
commands, makes logical decisions and made last year together
evaluations
and performs calculations. It also moves and Sale1
processes data between the two surrounding layers. Query Sale2
Sale3
Sale4
Data Tier
Here information is stored and retrieved from
a database or file system. The information is Database
Storage
then
passed back to the logic tier for processing,
and then eventually back to the user.
Communication Stacks
At the lower layers, they interface to the hardware using MAC protocols defined
by IEEE. The LLC provides a common interface to the MACs and a reliable link service
for transmitting communication packets between two nodes. The transport layer provides
end-to- end delivery service.
1.7.2 Sockets
Sockets were introduced in 1981 as the UNIX BSD 4.2 generic interface that
would provide Unix-to-Unix communications over network. In 1985, SUN OS introduced
NFS and RPC over sockets. Sockets are supported on virtually every OS. The windows
socket API, known as WinSock, is a multivendor specification that standardizes the use of
TCP/IP under windows. In BSD UNIX System, sockets are part of the Kernel and
provide both a standalone and networked IPC service.
1.32 Client/Server Computing
information to the program. A command can be issued in either wait or no-wait mode. In
the wait mode, the requesting thread is blocked until the command completes. In the no
-wait mode , control is returned to the calling thread at the earliest time possible, usually
before the command completes. When the command complete, the NetBIOS DLL places a
return code in the client.
Named Pipes
Named pipes Provide highly reliable, two-way communications between clients and
a server. They provide a file-like programming API that abstracts a session-based two-
way exchange of data. Using named pipes, processes can exchange data as if they were
writing to, or reading from, a sequential file. These are suitable for implementing server
programs that require many-to-one pipelines.
Important benefit of named pipes are part of the base interprocess communications
service. Named pipes interface is identical, whether the processes are running on
an individual machine or distributed across the network. Named pipes run on
NetBIOS, IPX/SPX, and TCP/IP stacks. Named pipes are built-in networking features in
Windows NT, Windows for Workgroups, Windows 95 and Warp Server. Unix support for
Named Pipes is provided by LAN Manager/X.
CPI-C/APPC
Common Programming Interface for Communications (CPI-C) build on top of
APPC and marks its complexities and irregularities. Writing to the CPI-C API allows We to
port our programs to all SNA platforms.
The CPI-C API consists of about 40 calls; APPC consists of over 60 calls. Most
of these calls deals with configuration and services.
Advanced program-to-program communication is a protocol which computer
programs can use to communicate over a network. APPC was developed as a
component of IBM‘s Systems Network Architecture (SNA). APPC is linked with the
term LU6.2. LU6.2. (Logic Unit Version 6.2) is a device independent SNA Protocol.
It was developed to allow computers in IBM environments to setup their
own communications sessions, rather than rely on a hos computer to do so. Contrary to
TCP/IP, in which both communication partners always possess a clear role, the
communication partners in APPC are equal, i.e., everyone can be both servers and clients
equally. With the wide success of TCP/IP, APPC has declined.
1.34 Client/Server Computing
CPI-C on Top of APPC
Figure 1.22. CPI-C/APPC
computer in the network and not possible. Instead the system can broadcast the datagram
to the manager.
convert their data to a neutral canonical format using the External Data Representation
(XDR) APIs.
In contrast, DCE‘s Network Data Representation (NDR) service is multi
canonical, meaning that it supports multiple data format representations. The client chooses
one of these formats, tags the data with chosen format, and then leaves it up to the server to
transform the data into a format it understands. In other words, the server makes it right. It
lets the client to do translation, which makes the life easy for the server. With Sun, all
clients look the same to the server: The Client makes it right.
Figure 1.2.4 shows how the RPC mechanism all comes together. The scenario
shows a simple seat reservation application. The seating server first starts up, advertises its
location and service in the network directory, and begins its continuous cycle of
receiving and servicing requests. A ticket client keeps in its cache the location of the
server. When a customer is ready to buy a ticket for a madonna concert, an RPC is issued
to reserve a seat. Notice how the client and server stubs cooperate to make that happen.
the local OS to create their queues. Most messaging products allow the sender to specify
the name of the reply queue. The products also include some type of format field that
tells the recipient how to interpret the message data. MOM enabled programs do not talk to
each other directly, so either program can be busy, unavailable, or simply not running at
the same time. The target program can even be started several hours later.
UNIT II
ENTERPRISE JAVA BEAN
EJB – EJB Architecture – Overview of EJB Software Architecture – View of
EJB Conversation – Building and Deploying EJBs – Roles in EJB
Second, because the beans and not the clients it contain the application's business
logic, the client developer can focus on the presentation of the client. The client
developer does not have to code the routines that implement business rules or access
databases. As a result, the clients are thinner, a benefit that is particularly important for
clients that run on small devices also.
Third, because enterprise beans are portable components, the application assembler
can build new applications from existing beans. These applications can run on any
compliant J2EE server.
2. 2 EJB LOGICAL ARCHITECTURE
An EJB system is logically a three-tier system. The three tiers are as follows:
1. The Client
2. The EJB Server
2.2 Enterprise Java Bean
Figure 2.1 shows a typical physical architecture for an EJB system. Most commonly,
the client, the EJB server, and the database will reside on separate machines-though
not necessarily. For example, if We‘re using an application server that supports servlets, We
may put our servlet clients on the same physical box as our EJB objects.
At an abstract level, though, the relationship between the container and server is such
that the server will provide the container with low-level implementation of the services
required
2.4 Enterprise Java Bean
by the container. This layered architecture is used in many areas in the computer field. Figure
2.3 draws an analogy between EJB, and both the TCP/IP and an Operating system.
Figure 2.3 The layered division of services employed by EJB can also be found in
other areas of computing.
The container generally provides support for managing and monitoring EJBs as well as
for version management.
EJB container provides the beans with ACID properties. EJB supports transaction
by having the transaction manager for ‗begin‘ and ‗commit‘ operations. It also provides
another approach, called declarative transaction management. In declarative transaction
management, the author of the bean can specify what type of transaction support for that
bean requires for the server.
When the bean is deployed, the container reads the deployment descriptor
associated with that particular EJB Bean. Then it provides necessary transaction support
automatically. EJB provides six modes of transaction management.
TX_NOT_SUPPORTED
TX_BEAN_MANAGED
TX_REQUIRED
TX_SUPPORTS
TX_REQUIRES_NEW
TX_MANDATORY
Instance Passivation
Instance Pooling
Database connection pooling
Preached Instances
Optimized method invocation
Instance Pooling means that the container shares instances of EJB beans among
multiple clients. This task is typically undertaken for purposes of efficiency; to increase the
efficiency the container instantiate fewer copies of a given bean to service requests. This not
possible in all cases. The container must provide one session bean per client otherwise
conversational state can‘t be tracked by the containers.
Precached instances may be used when an EJB needs to load some state information from
a database when it is created. To speed up the loading process, it is possible to keep a cache
of EJB state information in some readily accessible place to a accelerate the initial
creation of EJB‘s
If two EJBs exist in the same container, using a full blown remote protocol for
communication adds needless overhead. Contain short circuit the remote protocol, when
both the beans live in the same container.
EJB container provides Support for persistent to beans. EJBs (Entity Beans) are
not mandatory in the 1.x version of the EJB specification, but it will become mandatory,
but it will become mandatory in the 2.0 version. Persistence means that the state of an
object is saved to some sort of persistent storage (typically a file or a database) allowing
the object to be read in and used at some later time, instead of being recreated each time.
The container will then take responsibility for saving and restoring these fields.
EJB security is the main mechanism and it can be provided through access control list
(ACL). An ACL is a list of persons or groups that are allowed to access particular
pieces of functionality. Only those users who are included in the ACL will be able to
access the ACL protected beans others are not allowed.
java.rmi.Remote
The home interface serves as the initial point of contact for a client. When the client uses
a naming service to lookup an EJB bean, the naming service returns a reference to an
object that implements the bean‘s home interface.
getEJBMetaData()
boolean isSession();
Builder tools can use the information in the EJBMetaData class to generate
wrapper classes to invoke methods on the bean.
remove(Handle handle)
remove(Object primaryKey)
This method removes an EJB object by its primary key. (Only an Entity bean can
have a primary key)
2.10 Enterprise Java Bean
The EJBHome interface does not provide any methods by which a client can
create new beans or look up existing ones. Instead, the EJB bean developer must write the
method signatures for these tasks in their own interfaces.
A client uses a naming service to look up an EJB, getting a reference to an object that
implements its home interface to get a reference to the bean‘s remote interface.
getEJBHome()
This method returns a reference to an object implementing the EJB object‘s home interface.
getHandle()
getPrimaryKey()
This method returns the primary key used by the EJB object. Although it exists on
the interfaces for both session and entity beans, it really makes sense to use this method
only on an entity bean; session beans do not expose a primary key to the outside world,
and indeed need not have a primary key at all.
Enterprise Java Bean 2.11
isIdentical()
This method provides a way to test whether two EJB object references refer to an
identical object. It is mainly useful for Entity Beans. Two Entity beans that are from the
same home interface and have the same primary key are considered identical.The two
references in this method do not necessarily point to the same object in memory, but all of
these instances are considered to have the same identity.
remove()
This method allows the caller to remove the remote EJB object.To create a remote
interface, simply create an interface that inherits from EJBObject and add the
method signatures of the methods. And there is no need to implement this remote
interface. Instead the container generates a proxy object that interacts with remote clients
and passes their method calls to the bean
java.io.Serializable
This merely serves as a common point of ancestry for the Session and Entity
beans, and requires that its subinterfaces be serializable. The transaction attribute
logically belong with the Enterprise Bean interface, even though they‘re not associated
directly with it. Either a Session or an Entity Bean can be assigned any of the six available
transaction attributes.2.3
ejbPassivate()
The Container calls this method to swap the EJB class out to ―semi-persistent‖
storage.The storage is ―semi-persistent‖ because Session EJBs do not carry the same sort
of guarantee of long life as Entity EJBs do. If the EJB container crashes or restarts, the
session beans that existed before the crash or restart are destroyed. Session bean also
have an associated timeout value; after the timeout expires, they are destroyed. If none of
these events happens the session bean can be sapped back in at some later time.
ejbActivate()
The ejbActivate() method is essentially the inverse of the ejbPassivate() call. The
container calls this method after a session bean‘s state has been restored from
―semi- persistent‖ storage, but before it becomes available to the outside world. A bean
can use the ejbActivate() call to restore any resources that is closed before being passivated.
ejbRemove()
This callback method in invoked by the container as a result of a client calling the
remove() method of a bean‘s home or remote interface. The client‘s invocation of
the remove() method notifies the container that this particular session bean instance
should be destroyed.
setSessionContext(SessionContext ctx)
This method is called at the very beginning of a session bean‘s life. The container
passes the session bean an object that implements the SessionContext interface. The
bean stores this object in an object variable, and can then use the SessionContext to
interact with container-provided services such as security and transaction management.
The SessionContext interface inherits from the EJBContext interface. The EJBContext
interface is the parent interface of both the SessionContext and EntityContext
interfaces.
Enterprise Java Bean 2.13
This method is used to get a java.security. Identity object that represents the
identity of the client.It can be used in concert with isCallerInRole() to allow the EJB
object to perform authorization checks before performing an operation.
getEJBHome()
This method is used to get a reference to its own home interface.This interface can
be used to create or find other instances of the bean class, or to do several other things.
getEnvironment()
This call returns the EJB‘s environment properties.These properties can be adjusted at
deployment time.
getRollbackOnly()
getUserTransaction()
isCallerInRole()
This boolean method can be used to test whether the caller has assumed a given
role. An EJB developer might specify several different roles that can be played by the users
of the class.
Enterprise Java Bean 2.15
setRollbackOnly()
This contains only one method namely getEJBObject(). This method returns
a reference to an EJBObject. This remote reference to an object implements the bean‘s
remo te interface, and can be used if the bean wants to pass a reference to itself to some
other entity. EJB Container is responsible for creating objects that implement the remote
interface; these objects act as proxies, forwarding the business method calls to the object.
The method must have a void return type. The container will pass the
remote interface back to the client.
The number and type of arguments to the ejbCreate() method must exactly match
the number and type of arguments in the corresponding create() method declared
in the home interface.
The following steps are involved in the creation of a new Session Bean:
A stateless session bean is one that doesn’t keep track of any information from
one method call to another. It is essentially, a bean with no instance variables.
(Ex: CalculateInterest Bean). Any two instances of a stateless bean are equivalent. A
container can easily handle a stateless Session bean, because instances of a stateless
bean can be created and destroyed at will, without worrying about their state at the
time of their destruction.
A stateful session bean, is a bean that changes state during a conversation – that is,
a bean that has instance variables. (Ex: Shopping Cart Bean). The life cycle of a stateful
bean is more complex for the container than the stateless bean. Because, the container
have to maintain the state of the stateful session bean during swap out and swap in
process. According to the EJB specification, EJB Objects are not allowed to have static
variables.
afterBegin()
beforeCompletion()
This method indicates that a transaction is nearly complete. If the bean wishes to
roll back the transaction for some reason, it can call the setRollbackOnly() method
of the SessionContext interface.
Enterprise Java Bean 2.17
afterCompletion()
The container calls this method after a transaction has been completed. Its
boolean argument will be set to true if the transaction was committed successfully, and
false if the transaction was rolled back. This interface must be implemented in the stateful
session bean because, the state of instance variables is not transactional. That is, if the
instance variables in a session bean are modified during the course of a transaction and
the transaction is then rolled back, the instance variables will not be automatically reset to
their original state prior to the transaction.
These methods analogous to the methods of the same name in the SessionBean
Interface. ejbPassivate() is called before an Entity object is swapped out and ejbActivate()
is called after the Entity Object is swapped in.
2.18 Enterprise Java Bean
These operations allow the Entity bean to synchronize its state with an
underlying database. Under bean managed persistence the developer has to write the
coding in these methods. Under container managed persistence no coding is needed for
these methods.
javax.ejb.EJBContext
{
public abstract EJBObject getEJBObject();
public abstract Object getPrimaryKey();
}
Because Entity EJBs can exist across many client invocations, the Entity
Bean interface includes an unsetEntityContext() method that allows the bean to discard its
previous context when it is destroyed.
ejbRemove()
The container invokes the ejbRemove() method when a client has called the
remove() method of the bean‘s home interface. The bean then has one last chance to put
affairs in order before being destroyed.
ejbFindByPrimaryKey()
Entity beans are classified based on how they maintain synchronization. Entity beans
are intrinsically tied to an underlying database representation. The internal state of an
active Entity EJB should always be synchronized with its underlying data after a
transaction concludes. The EJB specification permits two
approaches to maintaining this
synchronization:
Bean-Managed persistence
Container-Managed persistence
Entity EJBs are non reentrant defaultly. That is, if a call is being processed and
another call to the same object comes in with the same transaction context, the program
will throw a RemoteException and the call will not be allowed. It is possible to specify
in a deployment descriptor that an Entity EJB is reentrant that is, it will accept more than
one call in the same transaction context.
The developer might choose this approach so as to allow a remote object invoked by a
client to perform callbacks to the client. If possible, always avoid reentrant entity beans.
JNDI API provides a uniform interface to naming and directory services. A naming service
is a service that associates a Symbolic Name with an object. Domain Name Service is
a commonly used naming service that is used to transfer symbolic machine names into
numeric IP addresses. Previous model of DNS, needed to maintain a file containing a list of
symbolic host names along with the numeric IP addresses that they should resolve to.
This approach was problematic for several reasons:
Where does JNDI fit in? JNDI provides a uniform interface to naming services. JNDI
client uses the Server‘s SPI (Server Provider Interface) to access its
services.
A Java client can use JNDI to lookup an EJB component. The JNDI call returns a
reference to an object implementing the EJB component‘s ―home‖ interface, which can
then be used to gain access to the EJB object itself.
The other way to find an EJB component is to use CORBA‘s Common Object
Services (COS) naming service. COS refers to a group of Services, including naming, that
is provided as part of the CORBA services specification. In addition to suing COS
naming directly, can make use it via JNDI.
EJB client that uses RMI will use the JNDI API to locate the home interface of
the desired bean. The client will then invoke a find () or create () method contained in the
bean‘s home interfaces; this call results in a reference to the beans remote interface.
The INDI to locate a bean‘s home interface, however, We use CORBA‘s COS naming
service. The pattern is
followed:
Each EJB must provide with a deployment descriptor. The deployment descriptor
is serialized instance of a Java class that contains information about how to deploy the
bean. Two flavors of deployment descriptors:
Properties File may be generated, which contains environment properties that will
be activated during runtime.
Manifest File is needed to create the ejb-jar file, which is the medium used to distribute
EJBs.
Name : <filename>
Enterprise-Bean: True
At the time of deployment, the EJB container must read the ejb-jar file, create
implementations for the home and remote interfaces. Reads the deployment-descriptor
and ensures that the bean has what it wants and the bean‘s property settings to the
environment so that they‘re available to the bean at runtime.
The final step is to access the bean from a client. The client can use either RMI or
CORBA to connect to the EJB. The client looks up the EJB‘s home interface using a
naming service (JNDI or COS). Invokes a find() or create() method on the home interface
to get a reference to an EJB object. And then uses the EJB object as if it were an ordinary
object.
The Enterprise bean provider is the person or group that writes and packages EJBs.
It might be a third-party vendor of EJB components, or it might be an information
systems programmer who writes EJBs to implement their company‘s business logic.
Because the container must provide transaction and network communication support, the
enterprise bean provider does not need to be an expert at low-level system programming,
networking or transaction processing.
Deployer
The deployer takes an ejb-jar file and installs it into an EJB container. The
deployer‘s task begins with the receipt of an ejb-jar file, and ends with the installation of
the ejb-jar file in the container. In the management information system(MIS)world, this
task is typically handled by the System Administrator in MIS world.
Application Assembler
The role of the EJB server provider is similar to that of a database system vendor.
The server provider offers the container whatever services it needs to do it job. The
server provider will typically have a great deal of expertise in area such as concurrent
programming, transaction programming, and network communication.
Enterprise Java Bean 2.25
Figure 2.5 The relationship among the EJB server, container, and bean
An EJB container is the world in which an EJB bean lives. The container
services requests from the EJB, forwards requests from the client to the EJB, and
interacts with the EJB server. The container provider must provide transaction
support, security and persistence to beans. It is also responsible for running the beans
and for ensuring that the beans are protected from the outside world.
System Administrator
System Administrators are responsible for the day-to-day operation of the EJB
server. Their responsibilities include keeping security information up-to-date and
monitoring the performance of the server. The role of the system administrator will likely
be understand by a company‘s current system administration.