for (int i = 0; i < parameterTypes.length; i++) {
if (SecurityActions.isAnnotationPresent(parameterAnnotations[i], Drone.class)) {
Validate.notNull(methodContext.get(), "Drone registry should not be null");
Class<? extends Annotation> qualifier = SecurityActions.getQualifier(parameterAnnotations[i]);
@SuppressWarnings("rawtypes")
Destructor destructor = getDestructorFor(parameterTypes[i]);
DroneContext context = methodContext.get().get(method);
Validate.notNull(context, "Method context should not be null");
// get instance to be destroyed
// if deployment failed, there is nothing to be destroyed
Object instance = context.get(parameterTypes[i], qualifier);
if (instance != null) {
destructor.destroyInstance(instance);
}
context.remove(parameterTypes[i], qualifier);
}
}