Dynamic Bank
The Dynamic Bank example has a simple Bank interface to open a bank account and to query the balance in a bank account. It illustrates the use of the Dynamic Invocation Interface (DII) and the Dynamic Skeleton Interface (DSI). DII allows a client to dynamically formulate a request for an object interface. DSI allows a server to be implemented dynamically.
From this example, you will learn how to:
-
Implement a simple interface
-
Implement a server using the inheritance mechanism
-
Implement a server using DSI
-
Implement a client using DII
Directory Contents
-
Bank.idl
IDL interface for the Bank object.
-
Server.java
Bank server. Creates an instance of the Bank and calls
org.omg.CORBA.BOA.impl_is_ready()
to make this object available to client programs. The Bank Server
implementation implements two methods: open, which opens a bank
account, and balance, which returns the balance in a person's
account whose name is provided as input (by generating a random number).
Note that this server uses DSI to construct the ServerRequest object dynamically.
-
Client.java
This is the Bank client. It binds to a AccountManager object, invokesopen() to open a bank account and invokes balance() on the account object reference obtained. Note that this client uses DII to construct the Request object dynamically.
-
Makefile (vbmake.bat on Windows): Used to build all the test targets.
Building this example
Note: This example will not run under JDK1.0.2. The solution to this problem is to upgrade to JDK1.1.0 or higher.
Typing make (vbmake on Windows) in the dynamic_bank subdirectory will cause the Bank.idl
to be run through the idl2java compiler. It will also build the following
classes for the examples described above:
-
Server.class
-
Client.class
Running this example
To run the examples, first make sure that the VisiBroker Smart Agent (osagent
executable) is running on your network. Then start the Bank server using
the command:
prompt> vbj Server &
(start vbj Server on Windows
// make the server run in the background)
Next, open a user's bank account and query the balance in the account using the command
prompt> vbj Client BankManager john
Return to the top-level examples page.