Package org.groovymud.object

Examples of org.groovymud.object.MudObject


  protected void resetRooms() {
    logger.info("Resetting rooms");
    Iterator<MudObject> i = getObjectRegistry().getMudObjects().iterator();
    while (i.hasNext()) {
      MudObject o = i.next();

      if (o instanceof Room) {
        ((Room) o).initialise();
      }
      Thread.yield();
View Full Code Here


  protected void doHeartBeat() {
    Set<MudObject> objects = getObjectRegistry().getMudObjects();
    Iterator<MudObject> i = objects.iterator();
    while (i.hasNext()) {
      MudObject o = i.next();

      if (o instanceof HeartBeatListener) {
        try {
          ((HeartBeatListener) o).heartBeat();
        } catch (Exception e) {
View Full Code Here

  protected void resetRooms() {
    logger.info("Resetting rooms");
    Iterator<MudObject> i = getObjectRegistry().getMudObjects().iterator();
    while (i.hasNext()) {
      MudObject o = i.next();

      if (o instanceof Room) {
        ((Room) o).initialise();
      }
      Thread.yield();
View Full Code Here

  protected void doHeartBeat() {
    Set<MudObject> objects = getObjectRegistry().getMudObjects();
    Iterator<MudObject> i = objects.iterator();
    while (i.hasNext()) {
      MudObject o = i.next();

      if (o instanceof HeartBeatListener) {
        try {
          ((HeartBeatListener) o).heartBeat();
        } catch (Exception e) {
View Full Code Here

   * Test method for
   * 'org.groovymud.object.registry.MudObjectAttendant.load(String, boolean)'
   */
  public void testLoadToRegistry() throws ResourceException, ScriptException, InstantiationException, IllegalAccessException, CompilationFailedException, FileNotFoundException, MalformedURLException {
    final String scriptName = "/mockScriptName.groovy";
    final MudObject mudObject = (MudObject) ctrl.getMock();

    MockControl ctxCtrl = MockControl.createControl(ApplicationContext.class);

    final ApplicationContext mockApplicationContext = (ApplicationContext) ctxCtrl.getMock();
    mockApplicationContext.containsBean("beanId");
    ctxCtrl.setDefaultReturnValue(false);
    ctxCtrl.replay();

    MockControl regCtrl = MockClassControl.createControl(Registry.class);
    final Registry reg = (Registry) regCtrl.getMock();
    reg.getMudObject("beanId");
    regCtrl.setDefaultReturnValue(mudObject);
   
    regCtrl.replay();
    MudObjectAttendant attnd = new MudObjectAttendant() {
      @Override
      protected void loadDefinition(String scriptLocation) {
        assertEquals(scriptName, scriptLocation);
      }
     
      @Override
      public ApplicationContext getApplicationContext() {
        // TODO Auto-generated method stub
        return mockApplicationContext;
      }
            @Override
            public Registry getObjectRegistry() {
              // TODO Auto-generated method stub
              return reg;
            }

    };

    ObjectLocation location = new ObjectLocation();
    location.setDefinition(scriptName);
    location.setBeanId("beanId");
    MudObject myObj = attnd.load(location);

    assertEquals(mudObject.getClass(), myObj.getClass());
    ctxCtrl.verify();
    regCtrl.verify();
  }
View Full Code Here

      argHolder.parse(nextCommand, player);

      Container container = player.getCurrentContainer();
      boolean commandRun = false;
      MudObject containerMO = (MudObject) container;
      if (containerMO != null) {
        // the object means to do the action with the container, it
        // holds a list of
        // local commands that need to be run.
        commandRun = containerMO.doCommand(player, argHolder.command, argHolder.args);
      }

      if (!commandRun) {
        // run through a privileged action so we don't access stuff we
        // shouldn't
View Full Code Here

   * Test method for
   * 'org.groovymud.object.registry.MudObjectAttendant.load(String, boolean)'
   */
  public void testLoadAsBean() throws ResourceException, ScriptException, InstantiationException, IllegalAccessException, CompilationFailedException, FileNotFoundException, MalformedURLException {
    final String scriptName = "/mockScriptName.groovy";
    final MudObject mudObject = (MudObject) ctrl.getMock();

    MockControl ctxCtrl = MockControl.createControl(ApplicationContext.class);

    final ApplicationContext mockApplicationContext = (ApplicationContext) ctxCtrl.getMock();
    mockApplicationContext.containsBean("beanId");
    ctxCtrl.setReturnValue(false);
    mockApplicationContext.getBean("beanId");
    ctxCtrl.setDefaultReturnValue(mudObject);
   
    mockApplicationContext.containsBean("beanId");
    ctxCtrl.setReturnValue(true);
    ctxCtrl.replay();

    MockControl regCtrl = MockClassControl.createControl(Registry.class);
    final Registry reg = (Registry) regCtrl.getMock();
    reg.getMudObject("beanId");
    regCtrl.setDefaultReturnValue(null);
   
    regCtrl.replay();
    MudObjectAttendant attnd = new MudObjectAttendant() {
      @Override
      protected void loadDefinition(String scriptLocation) {
        assertEquals(scriptName, scriptLocation);
      }
     
      @Override
      public ApplicationContext getApplicationContext() {
        // TODO Auto-generated method stub
        return mockApplicationContext;
      }
            @Override
            public Registry getObjectRegistry() {
              // TODO Auto-generated method stub
              return reg;
            }

    };

    ObjectLocation location = new ObjectLocation();
    location.setDefinition(scriptName);
    location.setBeanId("beanId");
    MudObject myObj = attnd.load(location);

    assertEquals(mudObject.getClass(), myObj.getClass());
    ctxCtrl.verify();
    regCtrl.verify();
  }
View Full Code Here

  }

  public void addAllMudObjects(Set<MudObject> objects) {
    Iterator<MudObject> hashIterator = objects.iterator();
    while (hashIterator.hasNext()) {
      MudObject next = (MudObject) hashIterator.next();
      addMudObject(next);
      Thread.yield();
    }
    hashIterator = null;
  }
View Full Code Here

      Iterator<Set<MudObject>> x = values.iterator();
      while (x.hasNext()) {
        Set<MudObject> next = x.next();
        Iterator<MudObject> hashIter = next.iterator();
        while (hashIter.hasNext()) {
          MudObject mo = hashIter.next();
          if (alive == (mo instanceof Alive)) {
            allObjects.add(mo);
          }
          Thread.yield();
        }
View Full Code Here

        String key = moi.next();
        Set<MudObject> set = getMudObjectHashSets().get(key);
        if (set != null) {
          Iterator<MudObject> setI = set.iterator();
          while (setI.hasNext()) {
            MudObject x = setI.next();
            if (alive == (x instanceof Alive)) {
              addMudObjectToMap(x.getName(), x, objs);
            }
            Thread.yield();
          }
          setI = null;
        }
View Full Code Here

TOP

Related Classes of org.groovymud.object.MudObject

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.