Return to Overview

## Working with the Master Index (Repository) API

The Master Index (Repository) methods are fully accessible to external Java classes. In order to incorporate these methods into your custom Java classes, you must set up the environment and specify the correct information in each custom class. Follow these procedures to use the Master Index (Repository) API in custom classes.

- Create a Java Class
- Copy the .jar Files
- Set up the Environment

### Create a Java Class

Each custom Java class you create must include information related to the Master Index (Repository) implementation. You can view a sample Java class that provides all the necessary information by clicking here. Each class must import the appropriate classes from both Java and Master Index (Repository) . For example:

       import javax.ejb.*;
       import javax.ejb.*;
       import javax.naming.*;
       import java.util.*;
       import javax.rmi.PortableRemoteObject;

       // Master Index imports
       import com.stc.eindex.objects.*;
       import com.stc.eindex.ejb.master.*;
       import com.stc.eindex.master.*;

In addition, you need to define information about the application server, MasterController, and factory classes. Remember that the JNDI Name for the MasterController is always <AppName>MasterController (where <AppName> is the name of the Master Index application). The port number for the server ORBport can be found in the `domain.xml` file for the domain. Following is a sample of server, factory, and MasterController information.

       // server connection parameters
            String ORBhost = "localhost";
            String ORBport = "3100";
       ...

       // connect to server and get handle MasterController
                Hashtable env = new Hashtable();
                env.put("org.omg.CORBA.ORBInitialHost", ORBhost);
                env.put("org.omg.CORBA.ORBInitialPort", ORBport);
                Context jndiContext = new InitialContext(env);
                Object obj = jndiContext.lookup("ejb/PersonMasterController");
                MasterControllerHome home = (MasterControllerHome)
                PortableRemoteObject.narrow(obj, MasterControllerHome.class);
                MasterController mc = home.create();

Return to top

### Copy the .jar Files

The .jar files created for the Master Index (Repository) project must be accessible to the Java classes you create. Certain .jar files from the application server must be accessible as well. Perform the following steps to access the .jar files.

1. In the NetBeans Projects window, expand the Master Index project whose Java API you want to access.
2. Right-click the <AppName>_ejb.jar file, and select Export (where <AppName> is the name of the Master Index application).
3. In the Save In field, select your working directory, and then click Save.
4. Repeat the above steps for the following files:
   - <AppName>_ejb_service.jar
   - <AppName>_stc_eindex_client.jar
   - <AppName>_stc_eindex_util.jar
5. In Microsoft Explorer or at the command prompt, navigate to the GlassFish home directory and then to \lib. Copy the following files to the same working directory you exported the Master Index files to: `j2ee.jar`, `appserv-rt.jar`, and `appserv-ext.jar`.

Return to top

### Set up the Environment

You must modify the CLASSPATH and PATH variables to implement the Master Index Java API (if you are working in UNIX, modify the variable corresponding to PATH, such as SHLIB_PATH for HP UNIX, LD_LIBRARY_PATH for Sparc Solaris, and LIBPATH for AIX). You can either create a batch file to set these variables (in which case you can use the relative path), or you can set them in your computer's environment variables (in which case you would use the absolute path). To set up the environment:

1. Add all of the .jar files you copied in the previous step to the CLASSPATH.
2. Add the path to your Java installation's \jdk\bin folder to the PATH variable.

Return to Overview

Return to top