@Override
  public int compareTo(final Prioritized that) {
    if (that == null) return 1;

    // compare priorities
    final int priorityCompare = Priority.compare(this, that);
    if (priorityCompare != 0) return priorityCompare;

    // compare classes
    return ClassUtils.compare(getClass(), that.getClass());
  }
  @Override
  public Module createModule(final ModuleInfo info) {
    final Module existing = getRegisteredModuleInstance(info);
    if (existing != null) return existing;

    try {
      final Module module = info.createModule();
      getContext().inject(module);
      Priority.inject(module, info.getPriority());
      return module;
    } catch (final ModuleException exc) {
      log.error("Cannot create module: " + info.getDelegateClassName());
    }
    return null;
  }