Examples of TypeRef


Examples of aQute.bnd.osgi.Descriptors.TypeRef

  /*
   * Called when an annotation is found. Dispatch on the known types.
   */
  public void annotation(Annotation annotation) throws Exception {
    TypeRef name = annotation.getName();
    if (interesting.contains(name)) {
      if (name == bundleLicenseRef)
        doLicense(annotation.getAnnotation(BundleLicense.class));
      else if (name == requireCapabilityRef)
        doRequireCapability(annotation.getAnnotation(RequireCapability.class));
View Full Code Here

Examples of aQute.bnd.osgi.Descriptors.TypeRef

    final Set<Element> members = new HashSet<Element>();
    final Set<MethodDef> methods = Create.set();
    final Set<Clazz.FieldDef> fields = Create.set();
    final MultiMap<Clazz.Def,Element> annotations = new MultiMap<Clazz.Def,Element>();

    final TypeRef name = clazz.getClassName();

    final String fqn = name.getFQN();
    final String shortName = name.getShortName();

    // Check if this clazz is actually a provider or not
    // providers must be listed in the exported package in the
    // PROVIDER_TYPE directive.
    Instructions matchers = providerMatcher.get(name.getPackageRef());
    boolean p = matchers != null && matchers.matches(shortName);
    final AtomicBoolean provider = new AtomicBoolean(p);

    //
    // Check if we already had this clazz in the cache
    //

    Element before = cache.get(clazz); // for super classes
    if (before != null)
      return before;

    clazz.parseClassFileWithCollector(new ClassDataCollector() {
      boolean      memberEnd;
      Clazz.FieldDef  last;

      @Override
      public void version(int minor, int major) {
        javas.add(Clazz.JAVA.getJava(major, minor));
      }

      @Override
      public void method(MethodDef defined) {
        if ((defined.isProtected() || defined.isPublic())) {
          last = defined;
          methods.add(defined);
        } else {
          last = null;
        }
      }

      @Override
      public void deprecated() {
        if (memberEnd)
          clazz.setDeprecated(true);
        else if (last != null)
          last.setDeprecated(true);
      }

      @Override
      public void field(Clazz.FieldDef defined) {
        if (defined.isProtected() || defined.isPublic()) {
          last = defined;
          fields.add(defined);
        } else
          last = null;
      }

      @Override
      public void constant(Object o) {
        if (last != null) {
          // Must be accessible now
          last.setConstant(o);
        }
      }

      @Override
      public void extendsClass(TypeRef name) throws Exception {
        String comment = null;
        if (!clazz.isInterface())
          comment = inherit(members, name);

        Clazz c = analyzer.findClass(name);
        if ((c == null || c.isPublic()) && !name.isObject())
          members.add(new Element(Type.EXTENDS, name.getFQN(), null, MICRO, MAJOR, comment));
      }

      @Override
      public void implementsInterfaces(TypeRef names[]) throws Exception {
        // TODO is interface reordering important for binary
        // compatibility??

        for (TypeRef name : names) {

          String comment = null;
          if (clazz.isInterface() || clazz.isAbstract())
            comment = inherit(members, name);
          members.add(new Element(Type.IMPLEMENTS, name.getFQN(), null, MINOR, MAJOR, comment));
        }
      }

      /**
       * @param members
       * @param name
       * @param comment
       * @return
       */
      Set<Element>  OBJECT  = Create.set();

      public String inherit(final Set<Element> members, TypeRef name) throws Exception {
        if (name.isObject()) {
          if (OBJECT.isEmpty()) {
            Clazz c = analyzer.findClass(name);
            Element s = classElement(c);
            for (Element child : s.children) {
              if (INHERITED.contains(child.type)) {
View Full Code Here

Examples of aQute.bnd.osgi.Descriptors.TypeRef

      // Assume the impl==name, but allow override
      String impl = name;
      if (info.containsKey(COMPONENT_IMPLEMENTATION))
        impl = info.get(COMPONENT_IMPLEMENTATION);

      TypeRef implRef = analyzer.getTypeRefFromFQN(impl);
      // Check if such a class exists
      analyzer.referTo(implRef);

      boolean designate = designate(name, info.get(COMPONENT_DESIGNATE), false)
          || designate(name, info.get(COMPONENT_DESIGNATEFACTORY), true);
View Full Code Here

Examples of aQute.bnd.osgi.Descriptors.TypeRef

    private boolean designate(String name, String config, boolean factory) {
      if (config == null)
        return false;

      for (String c : Processor.split(config)) {
        TypeRef ref = analyzer.getTypeRefFromFQN(c);
        Clazz clazz = analyzer.getClassspace().get(ref);
        if (clazz != null) {
          analyzer.referTo(ref);
          MetaTypeReader r = new MetaTypeReader(clazz, analyzer);
          r.setDesignate(name, factory);
View Full Code Here

Examples of aQute.bnd.osgi.Descriptors.TypeRef

    String min = null;
    String[] optionLabels = null;
    String[] optionValues = null;
    String description = null;

    TypeRef typeRef = reporter.getTypeRefFromFQN(rtype);
    Clazz c = reporter.findClass(typeRef);
    if (c != null && c.isEnum()) {
      optionValues = parseOptionValues(c);
    }
View Full Code Here

Examples of aQute.bnd.osgi.Descriptors.TypeRef

    }
   
    //analyze the class for suitable methods.
    final Map<String, MethodDef> lifecycleMethods = new HashMap<String, MethodDef>();
    final Map<String, MethodDef> bindmethods = new HashMap<String, MethodDef>();
    TypeRef typeRef = analyzer.getTypeRefFromFQN(impl);
    Clazz clazz = analyzer.findClass(typeRef);
    boolean privateAllowed = true;
    boolean defaultAllowed = true;
    String topPackage = typeRef.getPackageRef().getFQN();
    while (clazz != null) {
      final boolean pa = privateAllowed;
      final boolean da = defaultAllowed;
      final Map<String, MethodDef> classLifecyclemethods = new HashMap<String, MethodDef>();
      final Map<String, MethodDef> classBindmethods = new HashMap<String, MethodDef>();
     
      clazz.parseClassFileWithCollector(new ClassDataCollector() {
       
        @Override
        public void method(MethodDef md) {
          Set<String> allowedParams = allowed;
          String lifecycleName = null;
         
          boolean isLifecycle = (cd.activate == null? "activate": cd.activate).equals(md.getName()) ||
            md.getName().equals(cd.modified)
          if (!isLifecycle && (cd.deactivate == null? "deactivate": cd.deactivate).equals(md.getName())) {
            isLifecycle = true;
            allowedParams = allowedDeactivate;
          }
          if (isLifecycle && !lifecycleMethods.containsKey(md.getName()) &&
              (md.isPublic() ||
                  md.isProtected() ||
                  (md.isPrivate() && pa) ||
                  (!md.isPrivate()) && da) &&
              isBetter(md, classLifecyclemethods.get(md.getName()), allowedParams)) {
            classLifecyclemethods.put(md.getName(), md);
          }
          if (!bindmethods.containsKey(md.getName()) &&
              (md.isPublic() ||
                  md.isProtected() ||
                  (md.isPrivate() && pa) ||
                  (!md.isPrivate()) && da) &&
              isBetterBind(md, classBindmethods.get(md.getName()))) {
            classBindmethods.put(md.getName(), md);
          }
        }

        private boolean isBetter(MethodDef test, MethodDef existing, Set<String> allowedParams) {
          int testRating = rateLifecycle(test, allowedParams);
          if (existing == null)
            return testRating < 6;// ignore invalid methods
          if (testRating < rateLifecycle(existing, allowedParams))
            return true;
         
          return false;
        }

        private boolean isBetterBind(MethodDef test, MethodDef existing) {
          int testRating = rateBind(test);
          if (existing == null)
            return testRating < 6;// ignore invalid methods
          if (testRating < rateBind(existing))
            return true;
         
          return false;
        }

      });
      lifecycleMethods.putAll(classLifecyclemethods);
      bindmethods.putAll(classBindmethods);
      typeRef = clazz.getSuper();
      if (typeRef == null)
        break;
      clazz = analyzer.findClass(typeRef);
      privateAllowed = false;
      defaultAllowed = defaultAllowed && topPackage.equals(typeRef.getPackageRef().getFQN());
    }
   
   
    if (cd.activate != null && !lifecycleMethods.containsKey(cd.activate)) {
      error("in component %s, activate method %s specified but not found", cd.implementation.getFQN(), cd.activate);
View Full Code Here

Examples of aQute.bnd.osgi.Descriptors.TypeRef

    if (provides != null) {
      StringTokenizer st = new StringTokenizer(provides, ",");
      List<TypeRef> provide = new ArrayList<TypeRef>();
      while (st.hasMoreTokens()) {
        String interfaceName = st.nextToken();
        TypeRef ref = analyzer.getTypeRefFromFQN(interfaceName);
        provide.add(ref);
        analyzer.referTo(ref);

        // TODO verifies the impl. class extends or implements the
        // interface
View Full Code Here

Examples of aQute.bnd.osgi.Descriptors.TypeRef

      Matcher m = REFERENCE.matcher(interfaceName);
      if (m.matches()) {
        interfaceName = m.group(1);
        target = m.group(2);
      }
      TypeRef ref = analyzer.getTypeRefFromFQN(interfaceName);
      analyzer.referTo(ref);
      ReferenceDef rd = new ReferenceDef();
      rd.name = referenceName;
      rd.service = interfaceName;
View Full Code Here

Examples of aQute.bnd.osgi.Descriptors.TypeRef

      return false;

    if (c.annotations == null)
      return false;

    TypeRef pt = getTypeRefFromFQN(ProviderType.class.getName());
    boolean result = c.annotations.contains(pt);
    return result;
  }
View Full Code Here

Examples of aQute.bnd.osgi.Descriptors.TypeRef

    if (!referred.containsKey(pack))
      referred.put(pack, new Attrs());
  }

  public void referToByBinaryName(String binaryClassName) {
    TypeRef ref = descriptors.getTypeRef(binaryClassName);
    referTo(ref);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.