Class<?> clazz = event.getTestClass().getJavaClass();
for (Field f : SecurityActions.getFieldsWithAnnotation(clazz, Drone.class)) {
Class<?> typeClass = f.getType();
Class<? extends Annotation> qualifier = SecurityActions.getQualifier(f);
@SuppressWarnings("rawtypes")
Destructor destructor = getDestructorFor(typeClass);
// get instance to be destroyed
// if deployment failed, there is nothing to be destroyed
Object instance = droneContext.get(typeClass, qualifier);
if (instance != null) {
destructor.destroyInstance(instance);
}
droneContext.remove(typeClass, qualifier);
}
}