Search in sources :

Example 1 with ResourceWrapper

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;
}
Also used : ResourceWrapper(com.cloud.common.request.ResourceWrapper) Command(com.cloud.legacymodel.communication.command.Command) Hashtable(java.util.Hashtable)

Aggregations

ResourceWrapper (com.cloud.common.request.ResourceWrapper)1 Command (com.cloud.legacymodel.communication.command.Command)1 Hashtable (java.util.Hashtable)1