1 22 import java.rmi.*; 23 import java.awt.*; 24 import java.util.*; 25 import javax.ejb.*; 26 import javax.naming.*; 27 import java.awt.event.*; 28 import java.util.*; 29 import java.lang.*; 30 import java.io.*; 31 32 public class jnditester 33 { 34 public static void main(String [] args) 35 { 36 try 37 { 38 Properties p = new Properties(); 39 40 p.put(Context.INITIAL_CONTEXT_FACTORY, 41 "org.jnp.interfaces.NamingContextFactory"); 42 p.put(Context.PROVIDER_URL, "10.10.10.13:1100,10.10.10.14:1100"); 43 p.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); 45 InitialContext ctx = new InitialContext(p); 46 String hello = "hello world"; 47 48 try 49 { 50 String found = (String )ctx.lookup("testit"); 51 } 52 catch (NameNotFoundException nfe) 53 { 54 System.out.println("creating testit!!!"); 55 ctx.bind("testit", hello); 56 } 57 58 while (true) 59 { 60 String found = null; 61 try 62 { 63 found = (String )ctx.lookup("testit"); 64 System.out.println("found: " + found); 65 } 66 catch (NameNotFoundException nfe) 67 { 68 System.err.println("could not find testit"); 69 } 70 Thread.sleep(2000); 71 } 72 } 73 catch (Exception ex) 74 { 75 ex.printStackTrace(); 76 } 77 } 78 } 79 | Popular Tags |