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.
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();
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.
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: