This is a simple CORBA example that has a module Bank with two interfaces Account and AccountManager. The Account interface has operations for balance, deposit and withdraw. It has a read-only attribute for the Account Holder's name. It also has a user defined exception which is raised for withdrawing more money than the current balance. The AccountManager interface has methods to create and close Accounts. It also has a method to shutdown the server. The example demonstrates:
To keep this example simple, the server advertises its IOR in the following manner; the server program writes its server object's IOR to an ior_file. Later on, the client reads this IOR from the specified ior_file and uses the <string_to_object> method to obtain a reference to the server object.
For this mechanism to work, the file must be readable and writable. If it doesn't exist, a new file is created by the server. Moreover, the file path must be accessible to both the client and server.
If the client and server are on different machine, then there must be a shared directory accessible by both. On UNIX systems this is typically done via the NFS mount command. On Windows, the 'explorer' application provides an option to share drives.
In general if no such file sharing option is available, then using the the Naming Service mechanism is the only alternative, as described by the -n option below. There are other command line options available for the server and client which are also explained below.
server [-d] [-o IOR_file_name] [-n]
Options
When the server is started, you should see as the first line of output
something that looks like
iiop:1.0//danzon.cs.wustl.edu:10015/P35ad159600081a38/child_poa/server
(-ORBobjrefstyle url)
or
IOR:000000000000001649444c3a43756269745...(-ORBobjrefstyle ior)
Using -d turns on debugging messages. This option is additive, i.e., the more -d options provided, the more debugging you can get. At the moment, only 2 levels of debugging are implemented, and more than 2 -d options are ignored.
The file can be used by clients who wish to access the server directly using this ior file. This obviates the need for the client to use the naming service for getting the server ior. The client can use the -f option to specify the file which contains the ior of the server (the same file that was written by the server using the -o option).
client [-d] [-x] [-n] [-b initial_balance] [-o Name_of_account_holder] [-f IOR_file_name ] [-k IOR]
Options