Examples of TypeRef


Examples of aQute.bnd.osgi.Descriptors.TypeRef

    Object o = pool[methodRefPoolIndex];
    if (o != null && o instanceof Assoc) {
      Assoc assoc = (Assoc) o;
      if (assoc.tag == 10) {
        int string_index = intPool[assoc.a];
        TypeRef className = analyzer.getTypeRef((String) pool[string_index]);
        int name_and_type_index = assoc.b;
        Assoc name_and_type = (Assoc) pool[name_and_type_index];
        if (name_and_type.tag == 12) {
          // Name and Type
          int name_index = name_and_type.a;
View Full Code Here

Examples of aQute.bnd.osgi.Descriptors.TypeRef

      if (cc.referred)
        return;
      cc.referred = true;
      String name = cc.getName();
      if (name != null) {
        TypeRef tr = analyzer.getTypeRef(name);
        referTo(tr, 0);
      }
    }

  }
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

      // 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) throws Exception {
      if (config == null)
        return false;

      for (String c : Processor.split(config)) {
        TypeRef ref = analyzer.getTypeRefFromFQN(c);
        Clazz clazz = analyzer.findClass(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

      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

Examples of aQute.bnd.osgi.Descriptors.TypeRef

  }

  private void verifyActivator() throws Exception {
    String bactivator = main.get(Constants.BUNDLE_ACTIVATOR);
    if (bactivator != null) {
      TypeRef ref = analyzer.getTypeRefFromFQN(bactivator);
      if (analyzer.getClassspace().containsKey(ref))
        return;

      PackageRef packageRef = ref.getPackageRef();
      if (packageRef.isDefaultPackage())
        error("The Bundle Activator is not in the bundle and it is in the default package ");
      else if (!analyzer.isImported(packageRef)) {
        error(Constants.BUNDLE_ACTIVATOR + " not found on the bundle class path nor in imports: " + bactivator);
      }
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.