Пример #1
0
  @Override
  public void refreshStatus() {
    super.refreshStatus();

    // refresh coordinates from system
    String cooString = this.getSystemProperty(CP_COORDINATE);

    InMemoSharkKB imkb = null;
    imkb = new InMemoSharkKB();

    XMLSerializer xs = new XMLSerializer();
    try {
      // create in memory copy and use it
      this.setContextCoordinates(xs.deserializeContextCoordinates(imkb, cooString));
    } catch (SharkKBException ex) {
      L.w(
          "cannot deserialize context coordinates from persistent storage: " + ex.getMessage(),
          this);
    }

    // info folder
    String foldernames = this.getSystemProperty(INFO_FOLDERNAME_PROPERTY);

    if (foldernames != null) {
      this.infoFolder = Util.string2Vector(foldernames, DELIMITER);

      if (this.infoFolder != null) {
        // recreate Information
        Enumeration<String> infoFoldernameEnum = this.infoFolder.elements();
        while (infoFoldernameEnum.hasMoreElements()) {
          String infoFoldername = infoFoldernameEnum.nextElement();

          // create property holder
          FSPropertyHolder fsph = new FSPropertyHolder(infoFoldername);

          // create cp with this propery holder
          FSInformation fsInfo;
          try {
            fsInfo = new FSInformation(fsph);
            fsInfo.refreshStatus();
            // add it to memory
            super.putInformation(fsInfo);
          } catch (SharkKBException ex) {
            //
          }
        }
      }
    } else {
      L.w(
          "strange: there was a cp read from file without information - that cp shouldn't exist: TODO",
          this);
    }
  }
Пример #2
0
  /** write status into system properties */
  @Override
  public void persist() {
    super.persist();

    XMLSerializer xs = new XMLSerializer();
    try {
      String cooString = xs.serializeSharkCS(this.getContextCoordinates());

      // save
      this.setSystemProperty(CP_COORDINATE, cooString);

    } catch (SharkKBException ex) {
      L.w(ex.getMessage(), this);
    }

    if (this.infoFolder != null) {
      // info folder
      String foldernames = Util.enumeration2String(this.infoFolder.elements(), DELIMITER);

      if (foldernames != null && foldernames.length() > 0) {
        this.setSystemProperty(INFO_FOLDERNAME_PROPERTY, foldernames);
      }
    }
  }