else if (args[i].equalsIgnoreCase("-fillNames")) {
fillNames = (new Boolean(args[++i])).booleanValue();
}
}
NamingService namingService = null;
if (startNamingService) {
namingService = new NamingService();
namingService.start();
System.out.println("Started an ebedded naming service.");
}
Hashtable properties = new Hashtable();
if (factory != null) {
properties.put("java.naming.factory.initial", factory);
System.out.println("Forcing java.naming.factory.initial=" + factory);
}
else {
System.out.println("Using System.getProperty(java.naming.factory.initial)=" + System.getProperty("java.naming.factory.initial"));
}
InitialContext context = new InitialContext(properties);
if (fillNames) {
context.bind("first", new String("first"));
context.bind("second", new String("first"));
context.bind("third", new String("first"));
context.createSubcontext("dir1");
context.createSubcontext("dir2");
context.createSubcontext("dir3");
context.bind("dir1/first", new String("first"));
context.bind("dir1/second", new String("first"));
context.bind("dir1/third", new String("first"));
Context ctx = (Context)context.lookup("dir2");
ctx.bind("first", new String("first"));
ctx.bind("second", new String("first"));
ctx.bind("third", new String("first"));
}
System.out.println("================JNDI CONTENT START=============");
JndiDumper.scanContext(null, context, System.out);
System.out.println("================JNDI CONTENT END =============");
if (namingService != null) namingService.stop();
}
catch (Exception ex) {
ex.getMessage();
ex.printStackTrace();
}