This example shows how to use the Notification Service as a simple e-mail system.
The example uses a MailBox object, which is an instance of both a StructuredPushSupplier and StructuredPullConsumer. The mailbox class also holds two proxies that it connects to: a StructuredProxyPushConsumer and a StructuredProxyPullSupplier. Combined, the MailBox Object and its proxies provide a facility for a user's inbox and outbox. Both proxies are connected to the same channel, and the consumer-side proxy has a filter applied that only allows events destined to be received by the given consumer to be delivered.
The example consists of three components a user uses to create mailboxes and send and receive e-mail. The three components are MailServer, Admin, and MailTool.
MailServerImpl is the mail server that waits for incoming requests. The server accepts requests to create or delete a user mail account. If a request is received to create an account, the server creates a new MailBox object for the user and stores the IOR for this new mailbox into a file.
Admin is used to create and delete accounts. This is the program that accesses the mail server and uses the server to create accounts for the user.
MailTool allows the user to access his mailbox and send and receive mail. The MailTool is able to reference a user's mailbox using the IOR stored in the file and is used by the user to send or receive mail.
Below is a diagram showing how the MailBox object uses the NotificationService to provide an e-mail facility.
The following diagram shows how the example works and how the MailServer, Admin and MailTool components of the example interact:
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
INSLIB=$TAO_ROOT/lib; export INSLIB
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/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\examples.sln
. Double-click on the project file to load
it into
Microsoft Visual C++. For each of the projects lised below, change the project from debug
mode to release mode using the Build | Configuration Manager menu option.
UNIX: Ensure
that the environment variable LD_LIBRARY_PATH
includes the path to
where the
common files and the video files were compiled:
LD_LIBRARY_PATH=<TAO install dir>/examples/cc/Common:<TAO install dir>/examples/cc/Notification/mail:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH
Windows NT: Start a DOS window. Ensure that your path contains:
<TAO
install dir>\bin;<TAO install dir>\examples\cc\bin
Ensure that all commands are executed from the same directory otherwise there
may be a problem in finding the MailServer.ior
file.
Ensure that the Notification Service is running. In order to run the OpenFusion Notification 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.
./mailserver -ORBInitRef NotificationService=file://<OF_INSTALL_DIR>/domains/OpenFusion/localhost/NotificationService/NotificationSingleton/NotificationSingleton.ior
where OF_INSTALL_DIR
is the OpenFusion TCS - JacORB with OpenFusion
CORBA Services installation directory.
The MailServer should output "Waiting for
incoming requests
" on execution.
Leave the MailServer program running, since it is used by clients (the Admin
program) to deal with mailboxes for users.
./admin create <username> -ORBInitRef NotificationService=file://<OF_INSTALL_DIR>/domains/OpenFusion/localhost/NotificationService/NotificationSingleton/NotificationSingleton.ior
where OF_INSTALL_DIR
is the OpenFusion TCS - JacORB with OpenFusion
CORBA Services installation directory, and <username>
is the username you wish to create a mailbox for. You can also use this
program to delete users, by substituting create
with delete
.
./mailtool <username> -ORBInitRef NotificationService=file://<OF_INSTALL_DIR>/domains/OpenFusion/localhost/NotificationService/NotificationSingleton/NotificationSingleton.ior
where OF_INSTALL_DIR
is the OpenFusion TCS - JacORB with OpenFusion
CORBA Services installation directory, and <username>
is the name of the user who you want to use to send or receive mail. The
MailTool program provides a very simple text interface.