Back to Naming Service Examples Page
This example includes a server process that, on initialization, builds a Name Graph that will be used to bind the various server objects. The Name Graph is made of a context with two subcontexts.
The context is called ACME_Bank and is bound to the root context of the OpenFusion Naming Service.
The two subcontexts are AccountManager and Accounts and they are bound to the ACME_Bank context.
Once the graph is built, it will bind an AccountManager object into the AccountManager subcontext with the name AccountManagerServer.
The client process gets a reference to an AccountManager object from the Naming Service and creates 10 account objects. Each of the account objects is bound under the Accounts subcontext of the ACME_Bank context with the name that the account object was created with. The client will then try to get references to a couple of the Account objects and perform operations on them, such as depositing money, withdrawing money, and displaying account information.
This example includes the following source files:
Header files: Account.hh, AccountManager.hh, BankManager.hh, and BankClient.hh.
Code files: Account.cpp, AccountManager.cpp, BankManager.cpp, and BankClient.cpp.
Utilities: Util.hh and Util.cpp.
IDL Source files: Bank.idl and Util.cpp.
These instructions are based on the Solaris gcc3.2 compiler makefiles.
ACE_ROOT=<TAO install dir>; export ACE_ROOT
TAO_ROOT=<TAO install dir>; export TAO_ROOT
SHLIB_PATH=$TAO_ROOT/lib; export SHLIB_PATH
LD_LIBRARY_PATH=$TAO_ROOT/lib:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH
PATH=$PATH:$TAO_ROOT/bin; export PATH
PATH=/usr/local/gcc-3.2/bin:/usr/ccs/bin:$PATH; export PATH
LD_LIBRARY_PATH=/usr/local/gcc-3.2/lib:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH
<TAO install dir>/examples
directory.
<Local Copy>/cc
directory.
make
command to run the makefile. This will compile all of the OpenFusion examples.
TAO_ROOT=<TAO install dir>
, where
<TAO install dir>
is the location into which you have installed TAO.
<TAO install dir>\examples
directory.
<Local Copy>\cc\Common
directory.
<Local Copy>\cc\cc.dsw
. When loaded, change the Common
project from debug mode to release mode.This is found in Build/SetActive
Configuration.
UNIX: Ensure that the environment variable LD_LIBRARY_PATH
includes the path
to where the common files and the bank files were compiled:
LD_LIBRARY_PATH=<Local
Copy>/cc/Common:<Local Copy>/cc/Naming/Bank:$LD_LIBRARY_PATH;
export LD_LIBRARY_PATH
Change to <Local Copy>/cc/Naming/Bank/server directory.
Windows NT: Start a Command window. Ensure that your path contains:
<TAO
install dir>\lib;<Local
Copy>\cc\bin
Ensure that the OpenFusion Naming Service is running. In order to run the OpenFusion Naming Service you must first install the OpenFusion TCS - JacORB with OpenFusion CORBA Services distribution. This can be obtained from the downloads page by following the OpenFusion CORBA Products software link.
Start the server:
namingbankserver -ORBInitRef NameService=file://<OF_INSTALL_DIR>/domains/OpenFusion/localhost/NameService/NameSingleton/NameSingleton.ior
where OF_INSTALL_DIR
is the OpenFusion TCS - JacORB with OpenFusion
CORBA
Services installation directory.
The server will
respond with the prompt "Ready..."
when it is ready to receive remote function calls.
On UNIX, change to
<local copy example source code directory>/cc/Naming/Bank/client
directory.
In a new window, ensure that all environment variables are set up as above. Start the client:
namingbankclient -ORBInitRef NameService=file://<OF_INSTALL_DIR>/domains/OpenFusion/localhost/NameService/NameSingleton/NameSingleton.ior
This will resolve the Name Service and, from a context, the service provider reference and an arbitrary bank-supply company reference. The client will then make a remote function call to discover what bank titles are on offer by that company.