// It is the responsibility of the corresponding facility to
// pick it up.
continue;
}
if (classCycle != null) {
throw new DefinitionException("Duplicate class cycle " +
"annotation @" + annotationName);
}
cycle.init(annotations[i]);
classCycle = cycle;
}
// Now we make the same set of tests at the operation level
for (BenchmarkDefinition.Operation o : operations) {
annotations = o.m.getAnnotations();
for (int i = 0; i < annotations.length; i++) {
String typeName = annotations[i].annotationType().getName();
int cnBegin = typeName.lastIndexOf('.');
++cnBegin;
String annotationName = typeName.substring(cnBegin);
String pkgName = typeName.substring(0, cnBegin);
String cycleName = pkgName + "engine." + annotationName;
Cycle cycle = null;
try {
cycle = Class.forName(cycleName).
asSubclass(Cycle.class).newInstance();
} catch (Exception e) {
// If the annotation is not a cycle, we just ignore it here.
// It is the responsibility of the corresponding facility to
// pick it up.
continue;
}
if (o.cycle != null) {
throw new DefinitionException("Duplicate operation cycle " +
"annotation for operation " +
o.name + " @" + annotationName);
}
cycle.init(annotations[i]);
o.cycle = cycle;
}
// Finally, we need to test for no cycle at all and handle the case
if (o.cycle == null) {
o.cycle = classCycle;
}
if (o.cycle == null) {
throw new DefinitionException("No cycle distribution " +
"annotation for operation " + o.name);
}
}
}