예제 #1
0
  /** Read PROPRIATIARY: .ico file and return Icon Image */
  public BufferedImage getIcoImage(URL iconurl) throws IOException {
    try {
      InputStream inps = resourceLoader.createInputStream(iconurl);
      List<BufferedImage> icoImages = ICODecoder.read(inps);

      BufferedImage biggestImage = null;
      int biggestSize = 0;

      for (BufferedImage im : icoImages) {
        // use surface metrics to get 'biggest' image
        int size = im.getWidth() * im.getHeight();
        if (size > biggestSize) {
          biggestSize = size;
          biggestImage = im;
        }
      }

      try {
        inps.close();
      } catch (IOException e) {
      }
      ; // ignore

      return biggestImage;

    } catch (Exception e) {
      throw new IOException("Read error:" + iconurl, e);
    }
  }
예제 #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;
    }
  }