Example #1
0
  private void processShallowMatchConfiguration(MpiConfigDocument configuration) {
    if (configuration.getMpiConfig().getShallowMatchingConfigurationArray() == null) {
      return;
    }

    int count = configuration.getMpiConfig().getShallowMatchingConfigurationArray().length;
    for (int i = 0; i < count; i++) {
      ShallowMatchingConfigurationType obj =
          configuration.getMpiConfig().getShallowMatchingConfigurationArray(i);
      if (obj == null) {
        log.warn("No shallow matching service configuration has been specified.");
        return;
      }
      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 matching component with no implementation extension: "
                + component);
        throw new InitializationException(
            "Unable to locate an implementation component for custom matching component "
                + component.getName());
      }
      log.debug(
          "Registering implementation of matching component named "
              + extension.getName()
              + " and implementation key "
              + extension.getImplementationKey());

      String entity = loader.getComponentEntity();

      ShallowMatchingService matchingService =
          (ShallowMatchingService)
              Context.getApplicationContext().getBean(extension.getImplementationKey());
      log.info("Registering shallow matching service " + matchingService + " for entity " + entity);
      Context.registerCustomShallowMatchingService(entity, matchingService);
    }
  }