Real Time Information Director User Documentation
RTID Message Format and Programmatic Interfaces
Hewlett-Packard Company 15 529618 - 002
import com.hp.rtid.beans.DispatchBean;
import com.hp.rtid.beans.DispatchBeanHome;
2. Get the initial context by retrieving the ContextFactory, the URL, and the JNDI
name for the class from the properties file, which is called zli.properties by
default. For example, use the following code:
Context ctx = getInitialContext();
To invoke the following method:
public static Context getInitialContext()
throws NamingException
{
String jndiFactory, url;
Properties properties = new Properties();
try{
properties.load(new FileInputStream(‘PropertyFileName’));
// read properties from property file
// if not defined, use default values
catch(IOException e)
{
System.out.println(“Cannot open property file " +
PropertyFileName. Using default properties.");
}
jndiFactory=properties.getProperty("ContextFactory","weblogic.jnd
i.WLInitialContextFactory");
url=properties.getProperty("url","t3://localhost:7001");
ejbJndiName
=properties.getProperty("ejbJndiName","DispatchBeanEJB");
// make a new Hashtable with context factory & url
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
jndiFactory);
env.put(Context.PROVIDER_URL, url);
// make a new InitialContext with new Hashtable
return new InitialContext(env);
}
3. Look up the JNDI name of the Dispatch EJB Home. For example:
DispatchBeanHome home = (DispatchBeanHome)
ctx.lookup(ejbJndiName);
4. Create the EJB. For example:
DispatchBean dispatchEjb = home.create();