Package aQute.lib.osgi

Examples of aQute.lib.osgi.Clazz


   *
   * @param path
   * @return
   */
  public Clazz findClass(String path) throws Exception {
    Clazz c = classspace.get(path);
    if (c != null)
      return c;

    c = importedClassesCache.get(path);
    if (c != null)
      return c;

    Resource r = findResource(path);
    if (r != null) {
      c = new Clazz(path, r);
      c.parseClassFile();
      importedClassesCache.put(path, c);
    }
    return c;
  }
View Full Code Here


        }

        // Check class resources, we need to analyze them
        if (path.endsWith(".class")) {
          Resource resource = jar.getResource(path);
          Clazz clazz;

          try {
            InputStream in = resource.openInputStream();
            clazz = new Clazz(relativePath, resource);
            try {
              // Check if we have a package-info
              if (relativePath.endsWith("/package-info.class")) {
                // package-info can contain an Export annotation
                Map<String, String> info = contained.get(pack);
                parsePackageInfoClass(clazz, info);
              } else {
                // Otherwise we just parse it simply
                clazz.parseClassFile();
              }
            } finally {
              in.close();
            }
          } catch (Throwable e) {
            error("Invalid class file: " + relativePath, e);
            e.printStackTrace();
            continue next;
          }

          String calculatedPath = clazz.getClassName() + ".class";
          if (!calculatedPath.equals(relativePath)) {
            if (!isNoBundle()) {
              error("Class in different directory than declared. Path from class name is "
                  + calculatedPath
                  + " but the path in the jar is "
                  + relativePath + " from " + jar);
            }
          }

          classSpace.put(relativePath, clazz);

          // Look at the referred packages
          // and copy them to our baseline
          for (String p : clazz.getReferred()) {
            Map<String, String> attrs = referred.get(p);
            if (attrs == null) {
              attrs = newMap();
              referred.put(p, attrs);
            }
          }

          // Add all the used packages
          // to this package
          Set<String> t = uses.get(pack);
          if (t == null)
            uses.put(pack, t = new LinkedHashSet<String>());
          t.addAll(clazz.getReferred());
          t.remove(pack);
        }
      }
    }
  }
View Full Code Here

          }
        }
        instr = Instruction.getPattern(sb.toString());
      }
      for (Iterator<Clazz> c = matched.iterator(); c.hasNext();) {
        Clazz clazz = c.next();
        if (!clazz.is(type, instr, this)) {
          c.remove();
        }
      }
    }
    return matched;
View Full Code Here

   *
   * @param path
   * @return
   */
  public Clazz findClass(String path) throws Exception {
    Clazz c = classspace.get(path);
    if (c != null)
      return c;

    c = importedClassesCache.get(path);
    if (c != null)
      return c;

    Resource r = findResource(path);
    if (r != null) {
      c = new Clazz(path, r);
      c.parseClassFile();
      importedClassesCache.put(path, c);
    }
    return c;
  }
View Full Code Here

TOP

Related Classes of aQute.lib.osgi.Clazz

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.