Uploaded image for project: 'Spring Data Commons'
  1. Spring Data Commons
  2. DATACMNS-542

Simplify the process of adding custom methods to all repositories

    XMLWordPrintable

    Details

    • Sprint:
      51 - Dijkstra SR2, 52 - Evans RC1, 56 - Fowler RC1, 57 - Fowler Aftermath

      Description

      If you want to add a single method to all of the repositories declared in your app, you need to follow a 3 step process, e.g. described in the documentation.

      Step three is rather awkward and effectively only necessary as we don't know about the exact arguments necessary to construct the store specific factory instance. If implementors provided the arguments and we assume that users stick to exactly that list of arguments (probably a very reasonable assumption) we could add an additional way of customizing the instantiation by exposing a configuration property repositoryBaseClass and reflectively instantiate that one instead of calling the template methods.

      Changes required:

      • a setter to configure the repository base class on RepositoryFactorySupport
      • a template method to let implementors provide constructor arguments for the reflective invocation
      • change the behavior of RepositoryFactorySupport.getRepository(‚Ķ) to prefer the configured type over triggering the repository creation in subclasses.
      • expose configuration means in @Enable‚ĶRepositories and XML namespace (will require changes to store implementations as well)

      Optional changes:

      • improve the naming of the methods in RepositoryFactorySupport as what's currently called getTargetRepository will become more of a default repository target (used if nothing special is configured)

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              olivergierke Oliver Drotbohm
              Reporter:
              olivergierke Oliver Drotbohm
              Last updater:
              Oliver Drotbohm
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: