Пример #1
0
  /**
   * Saves the ServerInfo Registry if the current configuration allows a persistant Registry !
   *
   * <p>By default this is false, but when MyVle is initialized by the VBrowser the persistant
   * ServerInfo Registry will be enabled.
   */
  public void save() {
    // Check new Configuration Manager !
    ConfigManager confMan = this.context.getConfigManager();

    if (confMan.getUsePersistantUserConfiguration() == false) return;

    VRL loc = confMan.getServerRegistryLocation();

    // is synchronized will return consistant list of configs

    ArrayList<AttributeSet> sets = this.getInfoAttrSets();
    // ResourceLoader loader=new ResourceLoader(context);

    XMLData xmlifier = new XMLData();
    xmlifier.setVAttributeElementName("vlet:ServerInfoProperty");
    xmlifier.setVAttributeSetElementName("vlet:ServerInfo");
    // xmlifier.setPersistanteNodeElementName("vlet:ServerInfo2"); // No
    // Nodes!

    try {
      // bootstrap warning: use default ResourceLoader here: VRS might not be initialized!
      ResourceLoader writer = new ResourceLoader();
      String xmlString =
          xmlifier.createXMLString(XML_SERVER_CONFIG_HEADER_TAG, sets, XML_SERVER_CONFIG_HEADER);
      writer.writeTextTo(loc.toURI(), xmlString);
      this.isSaved = true;
    } catch (Exception e) {
      // check persistant user configuration:
      logger.logException(ClassLogger.ERROR, e, "Couldn't save ServerInfo registry to:%s\n", loc);
      // but continue!
    }
  }
Пример #2
0
  /**
   * Load saved server configuration.
   *
   * <p>Currently when MyVLe object is initialized the ServerInfoRegistry will be loaded.
   */
  protected void load() throws VrsException {
    logger.debugPrintf(">>> load() <<<\n");

    //
    // use serverInfo as mutex !
    //
    synchronized (this.serverInfos) {
      // Use new Configuration Manager
      ConfigManager confMan = this.context.getConfigManager();
      VRL loc = confMan.getServerRegistryLocation();

      // is synchronized will return consistant list of configs

      ArrayList<AttributeSet> sets = this.getInfoAttrSets();
      // No Context!
      ResourceLoader loader = new ResourceLoader();

      XMLData xmlifier = new XMLData();
      xmlifier.setVAttributeElementName("vlet:ServerInfoProperty");
      xmlifier.setVAttributeSetElementName("vlet:ServerInfo");

      InputStream inps;
      try {
        inps = loader.createInputStream(loc.toURL());
      } catch (IOException e) {
        throw new NestedIOException(e);
      } catch (Exception e) {
        throw new VRLSyntaxException(e);
      }

      sets = xmlifier.parseVAttributeSets(inps, XML_SERVER_CONFIG_HEADER_TAG);
      // for (VAttributeSet set:sets)
      // {
      // logger.debugPrintln(this,"Adding ServerInfo Set:"+set);
      // }

      // ===
      // Do not clear: just merge current with save ones !
      // serverInfos.clear();
      // ===
      for (AttributeSet set : sets) {
        ServerInfo info = new ServerInfo(context, set);
        logger.debugPrintf("Adding Server Config:%s\n", info);
        // actual store method:
        put(info);
      }

      this.isLoaded = true;
    }
  }