示例#1
0
  /**
   * This method loads the class from a jar file. Beta jars are supported if the beta flag is on.
   */
  @Override
  protected byte[] loadClassBytes(String className) {

    // Support the MultiClassLoader's class name munging facility.
    className = formatClassName(className);
    byte[] resource = null;

    if (jarResources == null) {
      return null;
    }

    // If beta flag is on first check beta versions of jar files before other jars.
    if (beta && betaJarResources != null) {

      Iterator<JarResources> allResources = betaJarResources.iterator();

      while (allResources.hasNext()) {

        JarResources d = allResources.next();

        try {

          resource = d.getResource(className);

          if (resource != null) {
            return resource;
          }
        } catch (Exception e) {

        }
      }
    }

    if (resource == null) {

      Iterator<JarResources> allResources = jarResources.iterator();

      while (allResources.hasNext()) {

        JarResources d = allResources.next();

        try {

          resource = d.getResource(className);

          if (resource != null) {
            break;
          }
        } catch (Exception e) {

        }
      }
    }

    return resource;
  }
示例#2
0
  @Override
  public InputStream getResourceAsStream(String name) {

    if (jarResources == null || betaJarResources == null) {
      initializeJarResources();
    }

    if (jarResources == null) {
      return getParent().getResourceAsStream(name);
    }

    // If beta classloader first try betaJarResources.
    if (beta) {
      Iterator<JarResources> allResources = betaJarResources.iterator();
      while (allResources.hasNext()) {

        JarResources d = allResources.next();

        try {

          byte[] resource = d.getResource(name);
          if (resource != null) {
            return new java.io.ByteArrayInputStream(resource);
          }
        } catch (Exception e) {
        }
      }

      return this.getClass().getClassLoader().getResourceAsStream(name);
    }

    Iterator<JarResources> allResources = jarResources.iterator();
    while (allResources.hasNext()) {

      JarResources d = allResources.next();

      try {

        byte[] resource = d.getResource(name);
        if (resource != null) {
          return new java.io.ByteArrayInputStream(resource);
        }
      } catch (Exception e) {
      }
    }

    return this.getClass().getClassLoader().getResourceAsStream(name);
  }