This lab consist of several examples and simple programming problems. There are no deliverables for the lab besides Milestone 2. However, you need to understand all examples and make sure you know how to solve all programming problems below.
Here is an example (another HelloWorld of course) where the client uses server's IORs (and not the Smart Agent - osagent as in lab 4) to locate the server.
The server obtains its IOR (using object_to_string method and writes it to a file. The client reads the file and and uses the IOR and the string_to_object method to find the server.
To start your server and the client use the vbj utility. To look at the info contained
into the IOR use the printIOR command.
Modify your Calculator server (from previous lab) to raise a user defined exception DivisionBy0. You will have to add an exception definition to your IDL, to specify that the method(s) that implements the calculator server can throw DivisionBy0exception and to raise and catch the exception where appropriate.
Pages 177-179 of "Java Programming with CORBA" tell you more about
user defined exception. And here is an example: http://www.classes.cs.uchicago.edu/current/51024-1/labs/lab5/UserException/
The factory (more on the factory method design pattern) will pass its IOR to the client using a file as previously. The client will use the IOR to locate the factory, call a method createCalculator (or createHelloWorld if you decide a to make a factory of HelloWorld objects) to get an object reference to a Calculator (or HelloWorld) object.
You will have to create a factory object that has a method createCalculator which starts a new calculator server and
returns a calculator reference object. The client will use this object
reference to call the calculator method(s) and compute what it needs. At the
end the client will ask the factory to destroy the calculator object created
for him. Examples from Chapter 10 of "Java Programming with
CORBA" might be useful in implementing the the Factory.
Server 2: a simple table counter: this server has one
method, called perhaps count. The method receives three arguments: a
database name, a password and a table name and will return the number of
rows in that table. Of course here is room for providing appropriate
exception handling . (The point here is to write Corba objects that
make JDBC calls)
We located services so far in two ways: in Lab. 5 we used Smart Agents (osagent), and here we used IORs. Let's try a third way for service location, namely Naming Service.
Naming Service allows you to "name" objects and then refer to them by their name. In order to use the Naming Service, you have to start it and/or locate it. You name a service using the method bind(name, object) and locate it using the method resolve(name).
This example illustrates how to connect to a remote object without using any proprietary extensions. It has a simple AccountManager interface to open an Account and to query the balance in that account. The server publishes its IOR into the root context of the Naming Server, which is then retrieved by the client.
Steps: