This JNDI solution describes how to create the functionality of a GUI-based browser that accepts commands from an input stream and executes these commands. A demo NSIBrowser utility, with accompanying source code, is provided to show the functionality of this browser solution.
The GUI Browser implementation consists of two major components (NSIBrowser class and NSIBrowserFrame class) with other supporting interfaces and classes.
The NSIBrowser class contains the main method for the NSI Browser (GUI) application. Sample source code is provided by the NSIBrowser.java file. The primary purpose of the NSIBrowser class is to construct and start up the browser frame. The specific tasks included in this class are as follows:
The NSIBrowserFrame class provides for displaying, processing, and updating the program's one or more browser window(s) and its components. Sample source code is provided by the NSIBrowserFrame.java file. The components of the main window include the following:
The NSIBrowser constructor creates the browser’s main window (frame) and all of its components. In addition to the main window components listed above, the constructor does the following:
The following methods are provided for processing and updating the program's browser windows.
The actionPerformed(ActionEvent) method is the action handler for the main window (frame). It handles any menu item selections, including closing the window and terminating the application, and it handles event buttons and events in the listbox.
The following WindowListener methods are implemented:
The setProperties(Properties) method set the properties for the browser frame based on the Properties parameter input.
The updateList method updates the name list component using the initial context and the current name using the initCtx and currName variables.
The resetInitCtx method updates the initial context variable (initCtx) using the new initial context as specified in the system properties.
The showAttributes method displays the attributes (if any) for the currently selected item.
The lookupContext method looks up a context and begins a new browser frame for that context.
The startNewContextFrame(String, Context) method starts a new browser frame for a given context based on the input parameters (title name and starting context).
The callSpecialHandler method handles ’special’ button requests. A ’special’ request indicates that the user wants to interact with the ’real’ object. Since this can happen in so many different ways, a list of property entries is used to find a special handler for the object selected, based on its class name. This allows anyone interested to extend this browser to do just about anything.
The NSIBrowser class and the NSIBrowserFrame class use the following additional interfaces and classes:
NSIBrowser is a GUI-based browser that allows you to explore JNDI providers. It is designed for users who have a basic knowledge of the JNDI Context and DirContext interfaces. Basic JNDI Context and DirContext methods can be called. Some possible uses for NSIBrowser are
To run the NSIBrowser demo utility, follow the procedures below.
javac *.java
java NSIBrowser
jnos.browser.handler.<classname>=<handler>
where <classname> is the full class name of the class you want to handle and <handler> is the full class name of your custom handler to which you want to bind the class. For example, the FileSpecialHandler looks like this (although it is hard coded into the sample):
jnos.browser.handler.com.novell.service.file.nw.naming.fileDirContext=FileSpecial Handler
Edit the shell.ini file to change the initial environment. To use the JNDI providers other than those supplied by Novell, set the environment key 'java.naming.factory.initial' to the class name of the desired initial context factory.
These samples demonstrate how to create the functionality of a GUI-based browser that accepts commands from an input stream and executes these commands.