Package org.groovymud.engine.event.observer

Examples of org.groovymud.engine.event.observer.Observable


  private ObjectLocation shutDownInformer;

  private static final Logger logger = Logger.getLogger(ShutdownBehaviour.class);

  protected void initialise() {
    Observable informer = null;
    if (getInformer() == null) {
      try {
        MudObject obj = getAttendant().load(getShutDownInformer());
        if (obj instanceof Observable) {
          informer = (Observable) obj;
          informer.addObserver(attendant.getObjectRegistry());
          setInformer(informer);
        } else {
          logger.info("could not use shutdowninformer, was not observable");
        }
      } catch (Exception e) {
View Full Code Here


  private ObjectLocation shutDownInformer;

  private static final Logger logger = Logger.getLogger(ShutdownBehaviour.class);

  protected void initialise() {
    Observable o = null;
    if (getInformer() == null) {
      try {
        getAttendant().load(getShutDownInformer());
        MudObject obj = getAttendant().cloneObject(getShutDownInformer().getHandle());
        if (obj instanceof Observable) {
          o = (Observable) obj;
          o.addObserver(attendant.getObjectRegistry());
          setInformer(o);
        } else {
          logger.info("could not use shutdowninformer, was not observable");
        }
      } catch (Exception e) {
View Full Code Here

   */
  public void testAddRoom() {
    MockControl mockCtrl = MockControl.createNiceControl(Room.class);
    final Room mockRoom = (Room) mockCtrl.getMock();
    MockControl obsCtrl = MockClassControl.createControl(Observable.class);
    final Observable obs = (Observable) obsCtrl.getMock();

    MockControl invCtrl = MockClassControl.createControl(InventoryHandler.class);
    final InventoryHandler inv = (InventoryHandler) invCtrl.getMock();

    Registry reg = new Registry(null) {

      @Override
      public void addMudObject(MudObject object) {
        // TODO Auto-generated method stub
        assertSame(mockRoom, object);
      }

      @Override
      public InventoryHandler getInventoryHandler() {
        // TODO Auto-generated method stub
        return inv;
      }

    };
    mockRoom.getContainerLocation();
    ObjectLocation loc = new ObjectLocation();
    loc.setDefinition("tomb/tomb1.groovy");
    loc.setBeanId("id");
    mockCtrl.setDefaultReturnValue(loc);
    mockRoom.setCurrentContainer(reg);
    mockCtrl.setDefaultVoidCallable();
    mockCtrl.replay();
    inv.addMudObject("id", mockRoom);
    invCtrl.setDefaultVoidCallable();
    invCtrl.replay();

    obs.addObserver(reg);
    obsCtrl.setDefaultVoidCallable();
    obsCtrl.replay();

    reg.addMudObject(loc.getBeanId(), mockRoom);

View Full Code Here

TOP

Related Classes of org.groovymud.engine.event.observer.Observable

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.