This lab consist of several examples and simple programming problems. There are no deliverables for the labbesides Milestone 2. However, you need to understand all examples and make sure you know how to solve all programming problems below.
Copy the directory /stage/classes/current/51024-1/pub/CORBA/IOR . This is an example (another HelloWorld of course) where the client uses server's IORs (and not the Smart Agent - osagent as in lab 5) 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.
Start your server and the client using vbj. To look at the info contained
into the IOR use the printIOR command.
Modify your Calculator server (from the previous lab) to raise a user-defined exception DivisionBy0. You will have to:
An example of user defined exceptions can be found at /stage/classes/current/51024-1/pub/CORBA/UserException.
Pages 177-179 of "Java Programming with CORBA" tell you more about
user defined exceptions.
The factory (more on the factory method design pattern) will pass its IOR to the client using a file as before. The client will use the IOR to locate the factory, and call a method createCalculator (or createHelloWorld if you decide 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 factory.
Server1: a tokenizer -- it receives a text as a String, breaks the string apart into words and returns those words as an IDL sequence.
Server 2: a simple table counter: this server has one method (which may be named "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).
The examples at ${VBROKER_HOME}/examples/vbroker/basic/bank_naming/ and ${VBROKER_HOME}/examples/vbroker/interop/ illustrate how to connect to a remote object without using any proprietary extensions. Both examples show 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: