|
[Help |
API Docs |
Short Course|
Magercises]
Unlike a client/server system, the objects in CORBA application are
peers: none is intrinsically more important than any other. You may
decide to design your program using various kinds of Client/Server
metaphors, but that decision is yours to make. The ORB just sees
objects communicating with each other over a network.
In this Magercise there is a pair of peer objects, PingObject
and PongObject, for which Java implementations have already
been written: PingObjectImpl and PongObjectImpl.
Their behavior is such that when the PingObject is pinged, it
pongs the given PongObject. When PongObject is
ponged, it returns the favor by pinging the given PingObject.
To keep things from getting out of hand, the PingObject keeps
track of the number of times it has been pinged, and stops after a
maximum number of pings.
Your task is to create two Java classes, PingServer and
PongServer whose main methods will instantiate
either a PingObject or a PongObject respectively,
and call the appropriate methods to start the pings and pongs going.
Prerequisites
Skeleton Code
Tasks
1. First take a look at the IDL file, pingpong.idl,
and generate it.
2. Examine the two implementation classes, PingObjectImpl and PongObjectImpl to see how they work and how to use them.
3. Using the skeleton code file as a starting point, modify the class PingServer to add all the code necessary to start up the ORB and BOA, create a PingObject instance, set the maximum number of pings, etc. There are comments to guide your way. Be sure to pick a unique name for your PingObject instance.
4. Now fill out the PongServer class. The code needed here will be very similar to that for PingServer, but you will also initiate the ping-pong exchange.
5. Compile your program and run it to see what happens.
Where help exists, the task numbers above are linked to the
step-by-step help page.
The timing information printed out when the solution is run
gives you some idea of the latency involved when calling
methods on a distributed object. For extra credit, you can
modify the implementation classes to print out the time
difference between pings and pongs.
Solution Source
Demonstration
The PongServer part of your program should output something like:
PongObjectImpl[Server,oid=TransientId[repId=IDL:
PPModule/PongObject:1.0,serverId=1,creationTime=
-1557647756]] is ready.
pong:917565354109
pong:917565354219
pong:917565354429
pong:917565354619
pong:917565354820
|
The PingServer part of your program should output a
similar set of messages.
Copyright © 1998-1999
MageLang Institute.
All Rights Reserved.
|