1 package org.sapia.ubik.rmi.examples; 2 3 import org.sapia.ubik.rmi.Consts; 4 import org.sapia.ubik.rmi.naming.remote.RemoteInitialContextFactory; 5 import org.sapia.ubik.rmi.server.Hub; 6 import org.sapia.ubik.rmi.server.Log; 7 8 import java.util.Properties ; 9 10 import javax.naming.InitialContext ; 11 12 13 21 public class CallbackClient { 22 25 public CallbackClient() { 26 super(); 27 } 28 29 public static void main(String [] args) { 30 try { 31 Log.setWarning(); 32 33 Properties props = new Properties (); 34 35 System.setProperty(Consts.CALLBACK_ENABLED, "true"); 37 38 System.setProperty(Consts.MARSHALLING, "true"); 40 41 props.setProperty(InitialContext.PROVIDER_URL, "ubik://localhost:1100"); 42 props.setProperty(InitialContext.INITIAL_CONTEXT_FACTORY, 43 RemoteInitialContextFactory.class.getName()); 44 45 InitialContext ctx = new InitialContext (props); 46 Foo f = (Foo) ctx.lookup("Foo"); 47 48 for (int i = 0; i < 10; i++) { 49 System.out.println(f.getBar().getMsg()); 50 Thread.sleep(2000); 51 } 52 53 Hub.shutdown(30000); 54 } catch (Exception e) { 55 e.printStackTrace(); 56 } 57 } 58 } 59 | Popular Tags |