コード例 #1
0
ファイル: AppLoaderBase.java プロジェクト: hoenninger/openxma
  /**
   * constructs a AppLoaderBase
   *
   * @param pnew the boot runtime properties
   */
  protected AppLoaderBase(Properties pnew) {

    if (pnew != null) {
      props = pnew;
    } else props = new Properties();

    log_ = Logger.getLogger("boot.appLoader"); // $NON-NLS-1$
    parseLog_ = Logger.getLogger("boot.parser"); // $NON-NLS-1$
  }
コード例 #2
0
ファイル: AppLoaderBase.java プロジェクト: hoenninger/openxma
  /**
   * merge plugin information into the main descriptor.
   *
   * @param main application descriptor
   * @param plugins import this
   */
  protected void mergeInto(XMAApp main, XMAApp plugins) {

    if (plugins.components_.size() > 0) {
      log_.warning("Plug-In Descriptor contains components. They will be ignored"); // $NON-NLS-1$
    }
    if (plugins.pluginspec_.size() > 0) {
      log_.warning(
          "Plug-In Descriptor contains plugin-specs. It should only contain plugin implementations. They will be ignored"); //$NON-NLS-1$
    }

    // this.pluginimpl_.put( pi.getStrImplements_(), pi);

    for (Iterator iter = plugins.pluginimpl_.values().iterator(); iter.hasNext(); ) {
      XMAPluginImpl el = (XMAPluginImpl) iter.next();

      XMAPluginImpl old = (XMAPluginImpl) main.pluginimpl_.get(el.getStrImplements_());
      if (old != null) {
        log_.warning(
            "Application Descriptor already contains a plug-in implementation for: "
                + el.getStrImplements_()
                + " it will be replaced the implementation of this plugins.xml"); //$NON-NLS-1$
                                                                                  // //$NON-NLS-2$
      }
      main.pluginimpl_.put(el.getStrImplements_(), el);
    }

    for (Iterator iter = plugins.res_.values().iterator(); iter.hasNext(); ) {
      XMAResource el = (XMAResource) iter.next();

      XMAResource old = (XMAResource) main.res_.get(el.getHref_());
      if (old != null) {
        log_.warning(
            "Application Descriptor already contains a resource for: "
                + el.getHref_()
                + " it will be replaced the resource of this plugins.xml"); //$NON-NLS-1$
                                                                            // //$NON-NLS-2$
      }
      main.addResource(el);
    }
  } // mergeInto
コード例 #3
0
ファイル: AppLoaderBase.java プロジェクト: hoenninger/openxma
  /**
   * creates the has value for the application. This is done by concatenating the content of the two
   * given input streams and calculating the MD5-hash over this combined content.
   *
   * @param isApp first description file (xma-app.xml)
   * @param isPi second description file (plugin.xml)
   * @return the calculated hash value
   * @throws IOException in case of errors reading the streams
   */
  protected byte[] createApplicationHash(InputStream isApp, InputStream isPi) throws IOException {
    MessageDigest md;
    try {
      md = MessageDigest.getInstance("MD5");
    } catch (NoSuchAlgorithmException e) {
      log_.log(LogLevel.SEVERE, "error preventing hash calculations: ", e);
      throw new RuntimeException(e);
    }
    int b = -1;
    ByteArrayOutputStream os = new ByteArrayOutputStream();

    while ((b = isApp.read()) != -1) {
      os.write(b);
    }

    while ((b = isPi.read()) != -1) {
      os.write(b);
    }

    md.update(os.toByteArray());
    byte[] digest = md.digest();

    return digest;
  }