Package aQute.bnd.osgi.Descriptors

Examples of aQute.bnd.osgi.Descriptors.TypeRef


        try {
          for (Map.Entry<String,Resource> entry : jar.getResources().entrySet()) {
            String key = entry.getKey();
            Resource r = entry.getValue();
            if (key.endsWith(".class")) {
              TypeRef ref = analyzer.getTypeRefFromPath(key);
              if (filter.matches(ref.toString())) {
                set.add(ref);

                InputStream in = r.openInputStream();
                Clazz clazz = new Clazz(analyzer, key, r);

                // TODO use the proper bcp instead
                // of using the default layout
                Set<TypeRef> s = clazz.parseClassFile();
                for (Iterator<TypeRef> t = s.iterator(); t.hasNext();) {
                  TypeRef tr = t.next();
                  if (tr.isJava() || tr.isPrimitive())
                    t.remove();
                  else
                    packages.add(ref.getPackageRef(), tr.getPackageRef());
                }
                table.addAll(ref, s);
                set.addAll(s);
                in.close();
              }
View Full Code Here


        rtype = rtype.substring(0, rtype.indexOf('<'));
      }
      ad.type = getType(rtype);

      ad.required = true;
      TypeRef typeRef = analyzer.getTypeRefFromFQN(rtype);
      try {
        Clazz c = analyzer.findClass(typeRef);
        if (c != null && c.isEnum()) {
          parseOptionValues(c, ad.options);
        }
      }
      catch (Exception e) {
        analyzer.error(
            "AD for %s.%s Can not parse option values from type (%s), %s",
            clazz.getClassName().getFQN(), defined.getName(), defined.getType().getFQN(), e.getMessage());
      }
      if (entry.getValue() != null) {
        doAD(ad, entry.getValue());
      }
      if (ad.defaults == null && clazz.isAnnotation() && defined.getConstant() != null) {
        //defaults from annotation default
        Object value = defined.getConstant();
        boolean isClass = false;
        TypeRef type = defined.getType().getClassRef();
        if (!type.isPrimitive()) {
          if (Class.class.getName().equals(type.getFQN())) {
            isClass = true;
          } else {
            try {
              Clazz r = analyzer.findClass(type);
              if (r.isAnnotation()) {
                analyzer.warning("Nested annotation type found in field % s, %s", defined.getName(), type.getFQN());
                return;
              }
            } catch (Exception e) {
              analyzer.error("Exception looking at annotation type default for element with descriptor %s,  type %s", e, defined, type);
            }
View Full Code Here

                || identifiableCollection(intf.getFQN(), true, false)) {
              return true;
            }
          }
        }
        TypeRef ext = clazz.getSuper();
        return ext != null && identifiableCollection(ext.getFQN(), false, false);
      }
    }
    catch (Exception e) {
      return false;
    }
View Full Code Here

      }
    }
   
  private boolean acceptableType(String rtype) {
    TypeRef ref = analyzer.getTypeRefFromFQN(rtype);
    try {
      Clazz returnType = analyzer.findClass(ref);
      if (returnType.isEnum()) {
        return true;
      }
View Full Code Here

public class DescriptorsTest extends TestCase {

  public static void testReferences() {
    Descriptors d = new Descriptors();
    TypeRef r = d.getTypeRef("[B");
    assertNotNull(r);
    assertEquals("byte[]", r.getFQN());
    assertNotNull(r.getPackageRef());
    assertEquals(".", r.getPackageRef().getFQN());

    PackageRef a = d.getPackageRef("a.b.c");
    PackageRef b = d.getPackageRef("a/b/c");
    assertTrue(a == b);
View Full Code Here

        try {
          for (Map.Entry<String,Resource> entry : jar.getResources().entrySet()) {
            String key = entry.getKey();
            Resource r = entry.getValue();
            if (key.endsWith(".class")) {
              TypeRef ref = analyzer.getTypeRefFromPath(key);
              if (filter.matches(ref.toString())) {
                set.add(ref);

                InputStream in = r.openInputStream();
                Clazz clazz = new Clazz(analyzer, key, r);

                // TODO use the proper bcp instead
                // of using the default layout
                Set<TypeRef> s = clazz.parseClassFile();
                for (Iterator<TypeRef> t = s.iterator(); t.hasNext();) {
                  TypeRef tr = t.next();
                  if (tr.isJava() || tr.isPrimitive())
                    t.remove();
                  else
                    packages.add(ref.getPackageRef(), tr.getPackageRef());
                }
                table.addAll(ref, s);
                set.addAll(s);
                in.close();
              }
View Full Code Here

      // 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

    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

  }
 
  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)) {
        Clazz activatorClazz = analyzer.getClassspace().get(ref);
       
        if (activatorClazz.isInterface()) {
          registerActivatorErrorLocation(error("The Bundle Activator " + bactivator +
              " is an interface and therefore cannot be instantiated."),
              bactivator, ActivatorErrorType.IS_INTERFACE);
        } else {
          if(activatorClazz.isAbstract()) {
            registerActivatorErrorLocation(error("The Bundle Activator " + bactivator +
                " is abstract and therefore cannot be instantiated."),
                bactivator, ActivatorErrorType.IS_ABSTRACT);
          }
          if(!activatorClazz.isPublic()) {
            registerActivatorErrorLocation(error("Bundle Activator classes must be public, and " +
                bactivator + " is not."), bactivator, ActivatorErrorType.NOT_PUBLIC);
          }
          if(!activatorClazz.hasPublicNoArgsConstructor()) {
            registerActivatorErrorLocation(error("Bundle Activator classes must have a public zero-argument constructor and " +
                bactivator + " does not."), bactivator, ActivatorErrorType.NO_SUITABLE_CONSTRUCTOR);
          }

          if (!activatorClazz.is(QUERY.IMPLEMENTS,
              new Instruction("org.osgi.framework.BundleActivator"), analyzer)) {
            registerActivatorErrorLocation(error("The Bundle Activator " + bactivator +
                " does not implement BundleActivator."), bactivator, ActivatorErrorType.NOT_AN_ACTIVATOR);
          }
        }
        return;
      }

      PackageRef packageRef = ref.getPackageRef();
      if (packageRef.isDefaultPackage())
        registerActivatorErrorLocation(error("The Bundle Activator is not in the bundle and it is in the default package "),
            bactivator, ActivatorErrorType.DEFAULT_PACKAGE);
      else if (!analyzer.isImported(packageRef)) {
        registerActivatorErrorLocation(error(Constants.BUNDLE_ACTIVATOR +
View Full Code Here

      return false;

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

    TypeRef pt = getTypeRefFromFQN(ProviderType.class.getName());
    TypeRef r6pt = getTypeRefFromFQN("org.osgi.annotation.versioning.ProviderType");
    boolean result = c.annotations.contains(pt) || c.annotations.contains(r6pt);
    return result;
  }
View Full Code Here

TOP

Related Classes of aQute.bnd.osgi.Descriptors.TypeRef

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.