예제 #1
0
 public void unregisterObject(String name) {
   BusObject o = objects.get(name);
   if (o != null) {
     bus.unregisterBusObject(o);
     enabled.put(name, false);
     aboutObj.announce((short) 42, aboutData);
   }
 }
예제 #2
0
 public void registerObject(String name) {
   BusObject o = objects.get(name);
   if (o != null) {
     bus.registerBusObject(o, makePath(name));
     enabled.put(name, true);
     aboutObj.announce((short) 42, aboutData);
   }
 }
예제 #3
0
 public void stop() {
   for (String name : objects.keySet()) {
     if (enabled.get(name)) {
       bus.unregisterBusObject(objects.get(name));
     }
   }
   objects.clear();
   if (aboutObj != null) {
     aboutObj.unannounce();
     aboutObj = null;
   }
 }
예제 #4
0
    public Participant(String _name) {
      participants.add(this);
      try {
        name = _name;
        objects = new HashMap<String, BusObject>();
        enabled = new HashMap<String, Boolean>();

        bus = new BusAttachment(getClass().getName() + name);
        Status status = bus.connect();
        assertEquals(Status.OK, status);

        SessionOpts sessionOpts = new SessionOpts();
        Mutable.ShortValue sessionPort = new Mutable.ShortValue((short) 42);
        accepter = new SessionAccepter(true);
        assertEquals(Status.OK, bus.bindSessionPort(sessionPort, sessionOpts, accepter));

        aboutObj = new AboutObj(bus);
        aboutData = new MyAboutData();
        aboutObj.announce((short) 42, aboutData);
      } catch (Exception e) {
        fail("creation of participant failed: " + e);
      }
    }