log.debug("GetState: agent=" + agentId + " state=" + state);
  public String getState() {    //return currentState;    try {      Attributes attrs =        commSvc.getEntityAttributes(communityName, agentId.toString());      Attribute stateAttr = attrs.get("RunState");      if (stateAttr != null) {        String state = (String)stateAttr.get();        if (state == null || state.trim().length() == 0) {          setState(currentState);          log.debug("GetState: agent=" + agentId +            " state is null/empty, setting state to " + currentState);          return currentState;        } else {          log.debug("GetState: agent=" + agentId + " state=" + state);          return state;        }      } else {        log.debug("GetState: agent=" + agentId +          " state attribute not defined, setting state to " + currentState);        setState(currentState);        return currentState;      }    } catch (Exception ex) {      ex.printStackTrace();      return new String();    }  }