Uploaded image for project: 'Jackrabbit Oak'
  1. Jackrabbit Oak
  2. OAK-2909 Review and improve Oak and Jcr repository setup
  3. OAK-2828

Jcr builder class does not allow overriding most of its dependencies

    XMLWordPrintableJSON

Details

    Description

      The Jcr class is the entry point for configuring a JCR repository using an Oak backend. However, it always use a hardcoded set of dependencies ( IndexEditorProvider, SecurityProvider, etc ) which cannot be reset, as they are defined in the constructor and the builder with methods eagerly configure the backing Oak instance with those dependencies.

      As an example

      Jcr.java
          @Nonnull
          public final Jcr with(@Nonnull SecurityProvider securityProvider) {
              oak.with(checkNotNull(securityProvider));
              this.securityProvider = securityProvider;
              return this;
          }
      

      injects the security provider which in turn starts configuring the Oak repository provider

      Oak.java
          @Nonnull
          public Oak with(@Nonnull SecurityProvider securityProvider) {
              this.securityProvider = checkNotNull(securityProvider);
              if (securityProvider instanceof WhiteboardAware) {
                  ((WhiteboardAware) securityProvider).setWhiteboard(whiteboard);
              }
              for (SecurityConfiguration sc : securityProvider.getConfigurations()) {
                  RepositoryInitializer ri = sc.getRepositoryInitializer();
                  if (ri != RepositoryInitializer.DEFAULT) {
                      initializers.add(ri);
                  }
              }
              return this;
          }
      

      Instead, the Jcr class should store the configured dependencies and only configure the Oak instance when createRepository is invoked.

      Attachments

        1. OAK-2828.patch
          26 kB
          Robert Munteanu
        2. 0001-OAK-2828-Jcr-builder-class-does-not-allow-overriding.patch
          11 kB
          Robert Munteanu

        Issue Links

          Activity

            People

              stillalex Alex Deparvu
              rombert Robert Munteanu
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: