Class ConfigServiceReflectionBridge

java.lang.Object
org.bloomreach.forge.brut.resources.bootstrap.ConfigServiceReflectionBridge

public final class ConfigServiceReflectionBridge extends Object
Bridge for invoking package-private methods in ConfigurationConfigService via reflection.

brXM's ConfigurationConfigService has several methods that are package-private but are needed for test environment bootstrap. This class encapsulates the reflection logic needed to access these methods.

Method references are resolved once at class-load time to avoid per-invocation getDeclaredMethod() overhead and to surface Java module-system failures deterministically at class load rather than at runtime per test.

Methods accessed via reflection:

  • applyNamespacesAndNodeTypes(ConfigurationModel, ConfigurationModel, Session)
  • computeAndWriteDelta(ConfigurationModel, ConfigurationModel, Session, boolean)
Since:
5.2.0
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    applyConfigDeltaWithRetries(org.onehippo.cm.engine.ConfigurationConfigService configService, org.onehippo.cm.model.impl.ConfigurationModelImpl baseline, org.onehippo.cm.model.impl.ConfigurationModelImpl update, Session session)
    Applies configuration delta with automatic retry on ItemExistsException.
    static String
    Extracts the path from an ItemExistsException message.
    Finds an ItemExistsException in the exception chain.
    static void
    invokeApplyNamespacesAndNodeTypes(org.onehippo.cm.engine.ConfigurationConfigService configService, org.onehippo.cm.model.impl.ConfigurationModelImpl baseline, org.onehippo.cm.model.impl.ConfigurationModelImpl update, Session session)
    Invokes package-private applyNamespacesAndNodeTypes method via reflection.
    static void
    invokeComputeAndWriteDelta(org.onehippo.cm.engine.ConfigurationConfigService configService, org.onehippo.cm.model.impl.ConfigurationModelImpl baseline, org.onehippo.cm.model.impl.ConfigurationModelImpl update, Session session, boolean forceApply)
    Invokes package-private computeAndWriteDelta method via reflection.
    static boolean
    Removes an existing node at the given path.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • invokeApplyNamespacesAndNodeTypes

      public static void invokeApplyNamespacesAndNodeTypes(org.onehippo.cm.engine.ConfigurationConfigService configService, org.onehippo.cm.model.impl.ConfigurationModelImpl baseline, org.onehippo.cm.model.impl.ConfigurationModelImpl update, Session session) throws Exception
      Invokes package-private applyNamespacesAndNodeTypes method via reflection.
      Parameters:
      configService - the ConfigurationConfigService instance
      baseline - the baseline configuration model
      update - the update configuration model
      session - the JCR session
      Throws:
      Exception - if invocation fails
    • invokeComputeAndWriteDelta

      public static void invokeComputeAndWriteDelta(org.onehippo.cm.engine.ConfigurationConfigService configService, org.onehippo.cm.model.impl.ConfigurationModelImpl baseline, org.onehippo.cm.model.impl.ConfigurationModelImpl update, Session session, boolean forceApply) throws Exception
      Invokes package-private computeAndWriteDelta method via reflection.
      Parameters:
      configService - the ConfigurationConfigService instance
      baseline - the baseline configuration model
      update - the update configuration model
      session - the JCR session
      forceApply - whether to force apply changes
      Throws:
      Exception - if invocation fails
    • applyConfigDeltaWithRetries

      public static void applyConfigDeltaWithRetries(org.onehippo.cm.engine.ConfigurationConfigService configService, org.onehippo.cm.model.impl.ConfigurationModelImpl baseline, org.onehippo.cm.model.impl.ConfigurationModelImpl update, Session session) throws RepositoryException
      Applies configuration delta with automatic retry on ItemExistsException.

      When ConfigService encounters a node that already exists, this method removes the conflicting node and retries the operation.

      Parameters:
      configService - the ConfigurationConfigService instance
      baseline - the baseline configuration model
      update - the update configuration model
      session - the JCR session
      Throws:
      RepositoryException - if the operation fails after all retries
    • extractItemExistsPath

      public static String extractItemExistsPath(Throwable error)
      Extracts the path from an ItemExistsException message.
      Parameters:
      error - the exception to extract from
      Returns:
      the path, or null if not found
    • findItemExistsException

      public static ItemExistsException findItemExistsException(Throwable error)
      Finds an ItemExistsException in the exception chain.
      Parameters:
      error - the exception to search
      Returns:
      the ItemExistsException, or null if not found
    • removeExistingNode

      public static boolean removeExistingNode(Session session, String path) throws RepositoryException
      Removes an existing node at the given path.
      Parameters:
      session - the JCR session
      path - the path to remove
      Returns:
      true if the node was removed, false otherwise
      Throws:
      RepositoryException - if operation fails