Notification Service Example: Mail

Description

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.

Design

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 Mail Example

The following diagram shows how the example works and how the MailServer, Admin and MailTool components of the example interact:

Component interactions

How to Build This Example

UNIX

These instructions are based on the Solaris gcc3.2 compiler makefiles.

  1. Ensure that the following environment variables are set:
  2. Ensure that your environment is set up for your compiler and linker. For example, for gcc3.2:

    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

  3. Change to the <TAO install dir>/examples/cc directory.
  4. If you have not done so already, enter the make command to run the makefile. This will compile all of the OpenFusion examples.

Windows NT

  1. Set the environmental property TAO_ROOT=<TAO install dir>, where <TAO install dir> is the location into which you have installed TAO.
  2. A global example Microsoft Visual C++ project has been provided. This is called <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.
  3. Build the OFCommon files.
  4. Build the OFNotificationMailExample files.
  5. Build the admin files.
  6. Build the mailserver files.
  7. Build the mailtool files.

How to Run This Example

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.

  1. 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.

  2. Start the MailServer by typing the following at the command prompt:
    ./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.

  3. In a new window, run the Admin program to create as many users as you want. To run the Admin program, type the following at the command prompt:
    ./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.

  4. Now, run the MailTool program. You can only run the MailTool program for one user at a time. If you want to administer more than one user's mail at a time, you must run multiple instances of MailTool each within its own window. To run the MailTool program, type:
    ./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.

top
[top]


© PrismTech Limited 2002