The Location Service Example

This example illustrates VisiBroker for Java's location service. It enables developer code to discover, or be notified of, object instances that have particular attributes, such as satisfying an interface. The location service can be used for any function that requires knowledge of what objects are presently accessible and where they are. This information could be used for load balancing or debugging. This example subdirectory also contains a program illustrating triggers which are a part of the Location Service. Triggers are an asynchronous alternative to polling the OSAgent to learn when an instance becomes available or becomes unavailable. Note that usage of the LocationService (the OSAgent interface) with VisiBroker for Java currently requires the execution of the standalone server locserv which is provided with the VisiBroker for Java release. The program is shipped as part of the archive of platform-specific executables and scripts which should have been installed in the directory bin. Assuming the installation's bin directory has been added to your path, this executable can be run with the command:


From this example, you will learn how to:

Directory Contents

Building this example

Typing make(vbmake on Windows) in the locate subdirectory will build the following classes:

Compilation Warnings

You will see the following compilation warnings when you type make(vbmake on Windows) in the locate subdirectory or when you explicitly compile AccountTrigger.java and Find.java using: These warnings occur because the example uses a Java API that has been deprecated since JDK1.1. The calls to the deprecated Java API have not been changed for the sake of JDK1.0.2 users.

Running this example

To run the examples, first make sure that the VisiBroker Smart Agent (osagent executable) is running on your network. You should also have the Location Service (locserv executable) running on your network.

The AccountFinder program:
Then start the Bank Server from the Bank example using the command:

Note that the Location Service detects the Bank Server. Next start the AccountFinder: Kill the bank server and again run the AccountFinder program as indicated above. Notice the change in output.

The Find program:
The Find program provides a command line user interface which allows the user to obtain information about specific objects using the repository id. To test the Find program, start one or more Bank servers. Then start the Find program:

To obtain a list of the options the Find program provides, type at the Find program's command prompt.

The AccountTrigger program:
The AccountTrigger program will notify the user when a provider comes up or goes down. To test the AccountTrigger program, first start the Bank server:

Then start AccountTrigger: Try killing the Bank server. AccountTrigger should notify the user of this change. When you kill the server it may take up to 5 minutes for osagent to cleanup its tables. Hence AccountTrigger notification will be delayed. Running the following command after killing the server will make osagent clean up its tables immediately.



Return to the top-level examples page.