Package com.peterhi.working

Examples of com.peterhi.working.Registry


import com.peterhi.working.Registry;

public class Responder {

  public static void main(String[] args) throws Exception {
    Registry registry = new Registry(22222);
    registry.run();
    AboutMe aboutMe = new AboutMeImpl(registry);
    registry.publish("aboutMe", AboutMe.class, aboutMe);
    Thread.sleep(5000);
    aboutMe.fireCallback("HUGO is the best!");
    Thread.sleep(5000);
    aboutMe.fireCallback("HUGO is the best 2!");
  }
View Full Code Here


import com.peterhi.working.Registry;

public class Requester {

  public static void main(String[] args) throws Exception {
    final Registry registry = new Registry(0);
    registry.run();
    SocketAddress address = new InetSocketAddress(InetAddress.getLocalHost(), 22222);
    final AboutMe aboutMe = registry.subscribe(address, "aboutMe", AboutMe.class, 0);
    System.out.println("Returned! " + aboutMe.getClass());
    System.out.println("NAME = " + aboutMe.getName());
    Hobbies h = aboutMe.getHobbies();
    int c = h.getCount();
    System.out.println(c);
   
    for (int i = 0; i < c; i++) {
      System.out.println(h.getHobby(i));
    }
   
    AboutMeListener listener = new AboutMeListener() {
      @Override
      public void callback(String message) {
        final AboutMeListener me = this;
        System.out.println("Callback! " + message);
       
        /*new Thread() {

          @Override
          public void run() {
            aboutMe.removeAboutMeListener(me);
            registry.unregister(me);
          }
         
        }.run();*/
      }
    };
   
    registry.register(AboutMeListener.class, listener);
    aboutMe.addAboutMeListener(listener);
  }
View Full Code Here

TOP

Related Classes of com.peterhi.working.Registry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.