use of com.cloud.common.request.ResourceWrapper in project cosmic by MissionCriticalCloud.
the class LibvirtRequestWrapper method processAnnotations.
protected Hashtable<Class<? extends Command>, LibvirtCommandWrapper> processAnnotations(final Set<Class<? extends LibvirtCommandWrapper>> wrappers) {
final String errorMessage = "Error when adding Xen command to map ==> '{0}'. LibvirtCommandWrapper class is ==> '{1}'";
final Hashtable<Class<? extends Command>, LibvirtCommandWrapper> commands = new Hashtable<>();
for (final Class<? extends LibvirtCommandWrapper> wrapper : wrappers) {
final ResourceWrapper annotation = wrapper.getAnnotation(ResourceWrapper.class);
if (annotation == null) {
// Just in case people add classes without the annotation in the package and we don't see it.
continue;
}
try {
commands.put(annotation.handles(), wrapper.newInstance());
} catch (final InstantiationException | IllegalAccessException e) {
s_logger.warn(MessageFormat.format(errorMessage, e.getLocalizedMessage(), wrapper.toString()));
}
}
return commands;
}
Aggregations