aQute.bnd.osgi.Analyzer.exception()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(10.5k)|赞(0)|评价(0)|浏览(127)

本文整理了Java中aQute.bnd.osgi.Analyzer.exception()方法的一些代码示例,展示了Analyzer.exception()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Analyzer.exception()方法的具体详情如下:
包路径:aQute.bnd.osgi.Analyzer
类名称:Analyzer
方法名:exception

Analyzer.exception介绍

暂无

代码示例

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib

/**
 *
 */
void doPlugins() {
  for (AnalyzerPlugin plugin : getPlugins(AnalyzerPlugin.class)) {
    try {
      boolean reanalyze;
      Processor previous = beginHandleErrors(plugin.toString());
      try {
        reanalyze = plugin.analyzeJar(this);
      } finally {
        endHandleErrors(previous);
      }
      if (reanalyze) {
        classspace.clear();
        analyzeBundleClasspath();
      }
    } catch (Exception e) {
      exception(e, "Analyzer Plugin %s failed %s", plugin, e);
    }
  }
}

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib

Verifier.verifyFilter(filter, 0);
} catch (Exception e) {
  analyzer.exception(e,
    "The Requirement annotation with namespace %s applied to class %s has invalid filter information.",
    annotation.namespace(), current.getFQN());

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd

Verifier.verifyFilter(filter, 0);
} catch (Exception e) {
  analyzer.exception(e,
    "The Requirement annotation with namespace %s applied to class %s has invalid filter information.",
    annotation.namespace(), current.getFQN());

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd

/**
 *
 */
void doPlugins() {
  for (AnalyzerPlugin plugin : getPlugins(AnalyzerPlugin.class)) {
    try {
      boolean reanalyze;
      Processor previous = beginHandleErrors(plugin.toString());
      try {
        reanalyze = plugin.analyzeJar(this);
      } finally {
        endHandleErrors(previous);
      }
      if (reanalyze) {
        classspace.clear();
        analyzeBundleClasspath();
      }
    } catch (Exception e) {
      exception(e, "Analyzer Plugin %s failed %s", plugin, e);
    }
  }
}

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib

@Override
public void classBegin(int access, TypeRef name) {
  definitions.get(0).implementation = name;
  PackageDef packageDef = packageInfos.computeIfAbsent(name.getPackageRef(), k -> {
    Clazz packageInfoClazz = analyzer.getPackageInfo(k);
    if (packageInfoClazz != null) {
      try {
        PackageDef pd = new PackageDef();
        packageInfoClazz.parseClassFileWithCollector(pd);
        return pd;
      } catch (Exception e) {
        analyzer.exception(e, "Error while processing package-info of class %s", clazz);
      }
    }
    return new PackageDef();
  });
  if (packageDef.marked != null) {
    definitions.get(0).marked = packageDef.marked.matches(name.getFQN());
  }
}

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib

Version.parseVersion(annotation.version());
} catch (Exception e) {
  analyzer.exception(e,
    "The version declared by the Capability annotation attached to type %s is invalid",
    current.getFQN());

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd

@Override
public void classBegin(int access, TypeRef name) {
  definitions.get(0).implementation = name;
  PackageDef packageDef = packageInfos.computeIfAbsent(name.getPackageRef(), k -> {
    Clazz packageInfoClazz = analyzer.getPackageInfo(k);
    if (packageInfoClazz != null) {
      try {
        PackageDef pd = new PackageDef();
        packageInfoClazz.parseClassFileWithCollector(pd);
        return pd;
      } catch (Exception e) {
        analyzer.exception(e, "Error while processing package-info of class %s", clazz);
      }
    }
    return new PackageDef();
  });
  if (packageDef.marked != null) {
    definitions.get(0).marked = packageDef.marked.matches(name.getFQN());
  }
}

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib

@Override
public void annotation(Annotation annotation) {
  try {
    switch (annotation.getName()
      .getFQN()) {
      case "org.osgi.service.cdi.annotations.Bean" :
        definitions.get(0).marked = true;
        break;
      case "org.osgi.service.cdi.annotations.Service" :
        doService(annotation);
        break;
      case "org.osgi.service.cdi.annotations.MinimumCardinality" :
        int minimumCardinality = (int) annotation.get("value");
        if (minimumCardinality > 0) {
          if (referenceDef == null) {
            referenceDef = new ReferenceDef();
          }
          referenceDef.cardinality = ReferenceCardinality.AT_LEAST_ONE;
        }
        break;
      case "org.osgi.service.cdi.annotations.Reference" :
        doReference(annotation, parameter);
        break;
    }
  } catch (Exception e) {
    analyzer.exception(e, "During bean processing on class %s, exception %s", clazz, e);
  }
}

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib

/**
 * Ensure that we are running on the correct bnd.
 */
protected void doRequireBnd() {
  Attrs require = OSGiHeader.parseProperties(getProperty(REQUIRE_BND));
  if (require == null || require.isEmpty())
    return;
  Hashtable<String, String> map = new Hashtable<>();
  map.put(Constants.VERSION_FILTER, getBndVersion());
  for (String filter : require.keySet()) {
    try {
      Filter f = new Filter(filter);
      if (f.match(map))
        continue;
      error("%s fails for filter %s values=%s", REQUIRE_BND, require.get(filter), map);
    } catch (Exception t) {
      exception(t, "%s with value %s throws exception", REQUIRE_BND, require);
    }
  }
}

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd

/**
 * Ensure that we are running on the correct bnd.
 */
protected void doRequireBnd() {
  Attrs require = OSGiHeader.parseProperties(getProperty(REQUIRE_BND));
  if (require == null || require.isEmpty())
    return;
  Hashtable<String, String> map = new Hashtable<>();
  map.put(Constants.VERSION_FILTER, getBndVersion());
  for (String filter : require.keySet()) {
    try {
      Filter f = new Filter(filter);
      if (f.match(map))
        continue;
      error("%s fails for filter %s values=%s", REQUIRE_BND, require.get(filter), map);
    } catch (Exception t) {
      exception(t, "%s with value %s throws exception", REQUIRE_BND, require);
    }
  }
}

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd

@Override
public void annotation(Annotation annotation) {
  try {
    switch (annotation.getName()
      .getFQN()) {
      case "org.osgi.service.cdi.annotations.Bean" :
        definitions.get(0).marked = true;
        break;
      case "org.osgi.service.cdi.annotations.Service" :
        doService(annotation);
        break;
      case "org.osgi.service.cdi.annotations.MinimumCardinality" :
        int minimumCardinality = (int) annotation.get("value");
        if (minimumCardinality > 0) {
          if (referenceDef == null) {
            referenceDef = new ReferenceDef();
          }
          referenceDef.cardinality = ReferenceCardinality.AT_LEAST_ONE;
        }
        break;
      case "org.osgi.service.cdi.annotations.Reference" :
        doReference(annotation, parameter);
        break;
    }
  } catch (Exception e) {
    analyzer.exception(e, "During bean processing on class %s, exception %s", clazz, e);
  }
}

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib

private boolean acceptableType(String rtype) {
  TypeRef ref = analyzer.getTypeRef(rtype);
  try {
    Clazz returnType = analyzer.findClass(ref);
    if (returnType.isEnum()) {
      return true;
    }
    // TODO check this is true for interfaces and annotations
    if (!returnType.isAbstract() || (returnType.isInterface() && options.contains(Options.nested))) {
      return true;
    }
    if (!returnType.isInterface()) {
      analyzer.error("Abstract classes not allowed as interface method return values: %s", rtype);
    } else {
      analyzer.error("Nested metatype only allowed with option: nested type %s", rtype);
    }
    return false;
  } catch (Exception e) {
    analyzer.exception(e, "could not examine class for return type %s, exception message: %s", rtype, e);
    return false;
  }
}

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd

private boolean acceptableType(String rtype) {
  TypeRef ref = analyzer.getTypeRef(rtype);
  try {
    Clazz returnType = analyzer.findClass(ref);
    if (returnType.isEnum()) {
      return true;
    }
    // TODO check this is true for interfaces and annotations
    if (!returnType.isAbstract() || (returnType.isInterface() && options.contains(Options.nested))) {
      return true;
    }
    if (!returnType.isInterface()) {
      analyzer.error("Abstract classes not allowed as interface method return values: %s", rtype);
    } else {
      analyzer.error("Nested metatype only allowed with option: nested type %s", rtype);
    }
    return false;
  } catch (Exception e) {
    analyzer.exception(e, "could not examine class for return type %s, exception message: %s", rtype, e);
    return false;
  }
}

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib

@Override
public void annotation(Annotation annotation) throws Exception {
  try {
    switch (annotation.getName()
      .getFQN()) {
      case "org.osgi.service.metatype.annotations.ObjectClassDefinition" :
        doOCD(annotation.getAnnotation(ObjectClassDefinition.class), annotation);
        break;
      case "org.osgi.service.metatype.annotations.AttributeDefinition" :
        current.ad = annotation.getAnnotation(AttributeDefinition.class);
        current.a = annotation;
        break;
      default :
        XMLAttribute xmlAttr = finder.getXMLAttribute(annotation);
        if (xmlAttr != null) {
          doXmlAttribute(annotation, xmlAttr);
        }
        break;
    }
  } catch (Exception e) {
    analyzer.exception(e, "During generation of a component on class %s, exception %s", clazz, e);
  }
}

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd

@Override
public void annotation(Annotation annotation) throws Exception {
  try {
    switch (annotation.getName()
      .getFQN()) {
      case "org.osgi.service.metatype.annotations.ObjectClassDefinition" :
        doOCD(annotation.getAnnotation(ObjectClassDefinition.class), annotation);
        break;
      case "org.osgi.service.metatype.annotations.AttributeDefinition" :
        current.ad = annotation.getAnnotation(AttributeDefinition.class);
        current.a = annotation;
        break;
      default :
        XMLAttribute xmlAttr = finder.getXMLAttribute(annotation);
        if (xmlAttr != null) {
          doXmlAttribute(annotation, xmlAttr);
        }
        break;
    }
  } catch (Exception e) {
    analyzer.exception(e, "During generation of a component on class %s, exception %s", clazz, e);
  }
}

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib

private void parseExtends(Clazz clazz) {
  TypeRef[] inherits = clazz.getInterfaces();
  if (inherits != null) {
    for (TypeRef typeRef : inherits) {
      if (!typeRef.isJava() && analyzed.add(typeRef)) {
        try {
          Clazz inherit = analyzer.findClass(typeRef);
          if (inherit != null) {
            inherit.parseClassFileWithCollector(new OCDDataCollector(ocd));
            parseExtends(inherit);
          } else {
            analyzer.error("Could not obtain super class %s of class %s", typeRef.getFQN(),
              clazz.getClassName()
                .getFQN());
          }
        } catch (Exception e) {
          analyzer.exception(e, "Could not obtain super class %s of class %s; exception %s",
            typeRef.getFQN(), clazz.getClassName()
              .getFQN(),
            e);
        }
      }
    }
  }
}

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd

private void parseExtends(Clazz clazz) {
  TypeRef[] inherits = clazz.getInterfaces();
  if (inherits != null) {
    for (TypeRef typeRef : inherits) {
      if (!typeRef.isJava() && analyzed.add(typeRef)) {
        try {
          Clazz inherit = analyzer.findClass(typeRef);
          if (inherit != null) {
            inherit.parseClassFileWithCollector(new OCDDataCollector(ocd));
            parseExtends(inherit);
          } else {
            analyzer.error("Could not obtain super class %s of class %s", typeRef.getFQN(),
              clazz.getClassName()
                .getFQN());
          }
        } catch (Exception e) {
          analyzer.exception(e, "Could not obtain super class %s of class %s; exception %s",
            typeRef.getFQN(), clazz.getClassName()
              .getFQN(),
            e);
        }
      }
    }
  }
}

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib

.exception(e, "An error occurred when attempting to process annotation %s, applied to component %s",
  annotation.getName()
    .getFQN(),

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib

.exception(e,
  "Exception looking at annotation type for activation object with descriptor %s, type %s",
  memberDescriptor, param.binary)

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd

.exception(e, "An error occurred when attempting to process annotation %s, applied to component %s",
  annotation.getName()
    .getFQN(),

相关文章

Analyzer类方法