import java.util.*;
import javax.swing.*;
import javax.naming.*;
import javax.naming.directory.*;
import com.novell.utility.naming.Environment;
public class NJCLApplet
extends JApplet
implements InterfaceCompare
{
ContextFrame rootFrame;
static PopupHandler popupHandlers[];
static String pluginParamStr = "plugins";
static String[][] paramInfo =
{
{Environment.INITIAL_CONTEXT_FACTORY,"String","class name (with package) for initial context factory"},
{Environment.PROVIDER_URL,"String (URL)","provider URL for initial context"},
{Environment.AUTHORITATIVE,"Boolean","if true specifies most authoritative source is to be used"},
{Environment.BATCHSIZE,"Unknown","specifies the preferred batch size to use when returning data"},
{Environment.REFERRAL,"String","'follow', 'ignore' or 'throw'"},
{Environment.SECURITY_AUTHENTICATION,"String","'none', 'simple', or 'strong'"},
{Environment.SECURITY_PRINCIPAL,"String","user name"},
{Environment.SECURITY_CREDENTIALS,"String","user tokens (password)"},
{"java.naming.ldap.derefAliases","String","'never', 'searching', 'finding', 'always'"},
{pluginParamStr,"String","semi-colon delimited list of plugin classes"}
};
public void init ()
{
int i;
getRootPane ().putClientProperty (
"defeatSystemEventQueueCheck",
Boolean.TRUE);
Properties props = Util.getPropertiesFromParams (this, paramInfo);
props = Util.mergeProperties (
props,
getDefaultProperties (),
true);
Object[] temp = Util.loadExtensions (this, props, pluginParamStr);
if (null == temp)
{
try
{
temp = Util.loadExtensions (this, "plugins");
}
catch (Throwable e)
{
System.out.println (
"Unable to load extensions from file system:\n" +
Util.getExceptionTrace (e));
}
}
if (null != temp)
popupHandlers = new PopupHandler [temp.length];
else
popupHandlers = new PopupHandler [0];
for (i = 0; i < popupHandlers.length; i++)
{
popupHandlers[i] = (PopupHandler) temp[i];
}
try
{
AboutFrame.getAboutFrame (getCodeBase ());
ContextTreeNode treeNode = new ContextTreeNode (
(ContextFrame) null,
"Root");
Hashtable hash = Util.getHashtableFromProperties (props);
Context ctx = new InitialContext (hash);
ctx = (Context) ctx.lookup ("");
treeNode.setThisContext (ctx);
rootFrame = new ContextFrame (treeNode);
rootFrame.setStatusLabel (
"Initial Context: " +
props.getProperty (Context.INITIAL_CONTEXT_FACTORY));
rootFrame.setRootFlag (true);
rootFrame.show ();
} catch (NamingException e)
{
(new MessageBox (
"Error",
"Unable to initialize JNDI:\n" +
Util.getExceptionTrace (e))).show ();
}
}
public String[][] getParameterInfo ()
{
return (paramInfo);
}
public String getAppletInfo ()
{
return ("NJCLApplet demo, v1.0. Written by Novell Inc.\n" +
"Copyright 1999. All Rights Reserved.");
}
public boolean implementsInterface (
Object obj)
{
return (obj instanceof PopupHandler);
}
static Properties getDefaultProperties ()
{
Properties props = new Properties ();
props.put (
Context.INITIAL_CONTEXT_FACTORY,
Environment.NW_INITIAL_CONTEXT_FACTORY);
props.put ("plugins", "DataPopupHandler");
return (props);
}
public static void main (
String args[])
{
NJCLApplet app = new NJCLApplet ();
app.init ();
}
}