Example #1
0
  private void processSingleBestRecordConfiguration(MpiConfigDocument configuration) {
    checkConfiguration(configuration);
    if (configuration.getMpiConfig().sizeOfSingleBestRecordArray() == 0) {
      log.warn("No single best record configuration has been specified.");
      return;
    }
    SingleBestRecordType obj = configuration.getMpiConfig().getSingleBestRecordArray(0);
    log.debug("Object is of type: " + obj.getDomNode().getNamespaceURI());
    String namespaceUriStr = obj.getDomNode().getNamespaceURI();
    URI namespaceURI = getNamespaceURI(namespaceUriStr);

    String resourcePath = generateComponentResourcePath(namespaceURI);
    Component component = loadAndRegisterComponentFromNamespaceUri(resourcePath);

    String configurationLoaderBean = getExtensionBeanNameFromComponent(component);

    ConfigurationLoader loader =
        (ConfigurationLoader) Context.getApplicationContext().getBean(configurationLoaderBean);
    loader.loadAndRegisterComponentConfiguration(this, obj);

    Component.Extension extension =
        component.getExtensionByExtensionInterface(ExtensionInterface.IMPLEMENTATION);
    if (extension == null) {
      log.error(
          "Encountered a custom single best record component with no implementation extension: "
              + component);
      throw new InitializationException(
          "Unable to locate an implementation component for custom single best record component "
              + component.getName());
    }
    log.debug(
        "Registering implementation of single best record component named "
            + extension.getName()
            + " and implementation key "
            + extension.getImplementationKey());
    SingleBestRecordService singleBestRecordService =
        (SingleBestRecordService)
            Context.getApplicationContext().getBean(extension.getImplementationKey());
    Context.registerCustomSingleBestRecordService(singleBestRecordService);
  }