/** @throws IOException If failed. */
  private void initFavicon() throws IOException {
    assert favicon == null;

    InputStream in = getClass().getResourceAsStream("favicon.ico");

    if (in != null) {
      BufferedInputStream bis = new BufferedInputStream(in);

      ByteArrayOutputStream bos = new ByteArrayOutputStream();

      try {
        byte[] buf = new byte[2048];

        while (true) {
          int n = bis.read(buf);

          if (n == -1) break;

          bos.write(buf, 0, n);
        }

        favicon = bos.toByteArray();
      } finally {
        U.closeQuiet(bis);
      }
    }
  }
  /**
   * Converts given input stream expecting XML inside to {@link GridUriDeploymentSpringDocument}.
   *
   * <p>This is a workaround for the {@link InputStreamResource} which does not work properly.
   *
   * @param in Input stream with XML.
   * @param log Logger
   * @return Grid wrapper for the input stream.
   * @throws GridSpiException Thrown if incoming input stream could not be read or parsed by {@code
   *     Spring} {@link XmlBeanFactory}.
   * @see XmlBeanFactory
   */
  static GridUriDeploymentSpringDocument parseTasksDocument(InputStream in, GridLogger log)
      throws GridSpiException {
    assert in != null;

    // Note: use ByteArrayResource instead of InputStreamResource because InputStreamResource
    // doesn't work.
    ByteArrayOutputStream out = new ByteArrayOutputStream();

    try {
      U.copy(in, out);

      XmlBeanFactory factory = new XmlBeanFactory(new ByteArrayResource(out.toByteArray()));

      return new GridUriDeploymentSpringDocument(factory);
    } catch (BeansException e) {
      throw new GridSpiException("Failed to parse spring XML file.", e);
    } catch (IOException e) {
      throw new GridSpiException("Failed to parse spring XML file.", e);
    } finally {
      U.close(out, log);
    }
  }