use of aQute.bnd.osgi.Annotation in project bnd by bndtools.
the class Target method testSimple.
public void testSimple() throws Exception {
Analyzer analyzer = new Analyzer();
Clazz clazz = new Clazz(analyzer, "", null);
ClassDataCollector cd = new ClassDataCollector() {
@Override
public void addReference(TypeRef token) {
}
@Override
public void annotation(Annotation annotation) {
System.err.println("Annotation " + annotation);
}
@Override
public void classBegin(int access, TypeRef name) {
System.err.println("Class " + name);
}
@Override
public void classEnd() {
System.err.println("Class end ");
}
@Override
public void extendsClass(TypeRef name) {
System.err.println("extends " + name);
}
@Override
public void implementsInterfaces(TypeRef[] name) {
System.err.println("implements " + Arrays.toString(name));
}
@Override
public void parameter(int p) {
System.err.println("parameter " + p);
}
};
clazz.parseClassFile(getClass().getResourceAsStream("Target.class"), cd);
}
use of aQute.bnd.osgi.Annotation in project felix by apache.
the class AnnotationCollector method parseMetaTypes.
/**
* Parse optional meta types annotation attributes
* @param annotation
*/
private void parseMetaTypes(Annotation annotation, String pid, boolean factory) {
if (annotation.get("metadata") != null) {
String propertiesHeading = annotation.get("heading");
String propertiesDesc = annotation.get("description");
MetaType.OCD ocd = new MetaType.OCD(pid, propertiesHeading, propertiesDesc);
for (Object p : (Object[]) annotation.get("metadata")) {
Annotation property = (Annotation) p;
String heading = property.get("heading");
String id = property.get("id");
String type = parseClassAttrValue(property.get("type"));
Object[] defaults = (Object[]) property.get("defaults");
String description = property.get("description");
Integer cardinality = property.get("cardinality");
Boolean required = property.get("required");
MetaType.AD ad = new MetaType.AD(id, type, defaults, heading, description, cardinality, required);
Object[] optionLabels = property.get("optionLabels");
Object[] optionValues = property.get("optionValues");
if (optionLabels == null && optionValues != null || optionLabels != null && optionValues == null || (optionLabels != null && optionValues != null && optionLabels.length != optionValues.length)) {
throw new IllegalArgumentException("invalid option labels/values specified for property " + id + " in PropertyMetadata annotation from class " + m_currentClassName);
}
if (optionValues != null) {
for (int i = 0; i < optionValues.length; i++) {
ad.add(new MetaType.Option(optionValues[i].toString(), optionLabels[i].toString()));
}
}
ocd.add(ad);
}
m_metaType.add(ocd);
MetaType.Designate designate = new MetaType.Designate(pid, factory);
m_metaType.add(designate);
m_logger.info("Parsed MetaType Properties from class " + m_componentClassName);
}
}
Aggregations