Skip to content

DATACMNS-1172 - Limit repository custom implementation scanning by default to repository interface packages. #248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

mp911de
Copy link
Member

@mp911de mp911de commented Sep 27, 2017

Custom repository implementation scan defaults to the repository interface package and its subpackages and no longer scans all configured base packages. Scan for fragment implementations defaults to the fragment interface package. Using the interface package for scanning aligns the behavior with the documentation.

This default can be changed with @Enable…Repositories annotations that support the limitImplementationBasePackages parameter to scan in repository base packages for custom implementations:

@EnableJpaRepositories(limitImplementationBasePackages = false)
@Configuration
class AppConfiguration {
  // …
}

Declaring the implementation along with the interface in the same package is an established design pattern allowing to limit the scanning scope. A limited scope improves scanning performance as it can skip elements on the classpath, that do not provide that particular package.

Previously, we scanned for implementations using the configured base packages that were also used to discover repository interfaces. These base packages can be broader for applications that spread repository interfaces across multiple packages.


Related ticket: DATACMNS-1172.

…ector.detectCustomImplementation().

Prepare issue branch.
…fault to repository interface packages.

Custom repository implementation scan defaults to the repository interface package and its subpackages and no longer scans all configured base packages. Scan for fragment implementations defaults to the fragment interface package. Using the interface package for scanning aligns the behavior with the documentation.

This default can be changed with @enable…Repositories annotations that support the limitImplementationBasePackages parameter to scan in repository base packages for custom implementations:

@EnableJpaRepositories(limitImplementationBasePackages = false)
@configuration
class AppConfiguration {
  // …
}

Declaring the implementation along with the interface in the same package is an established design pattern allowing to limit the scanning scope. A limited scope improves scanning performance as it can skip elements on the classpath, that do not provide that particular package.

Previously, we scanned for implementations using the configured base packages that were also used to discover repository interfaces. These base packages can be broader for applications that spread repository interfaces across multiple packages.
odrotbohm pushed a commit that referenced this pull request Sep 27, 2017
…pository interface packages.

Custom repository implementation scan uses the repository interface package and its subpackages and no longer scans all configured base packages. Scan for fragment implementations defaults to the fragment interface package. Using the interface package for scanning aligns the behavior with the documentation.

Declaring the implementation along with the interface in the same package is an established design pattern allowing to limit the scanning scope. A limited scope improves scanning performance as it can skip elements on the classpath, that do not provide that particular package.

Previously, we scanned for implementations using the configured base packages that were also used to discover repository interfaces. These base packages can be broader for applications that spread repository interfaces across multiple packages.

Original pull request: #248.
odrotbohm added a commit that referenced this pull request Sep 27, 2017
Tweaked newly introduced RepositoryConfiguration.getImplementationBasePackage() to not require a parameter but use internal information instead (the repository interface in DefaultRepositoryConfiguration).

Original pull request: #248.
odrotbohm added a commit that referenced this pull request Sep 27, 2017
We now use FragmentMetadata to control the way fragement interfaces and base packages to scan are calculated. Refactored RepositoryConfiguration.getImplementationBasePackages() to not take a parameter.

Original pull request: #248.
odrotbohm added a commit that referenced this pull request Sep 27, 2017
…sitory implementations again.

Kept in a separate commit, so that it's easy to add again by reverting this commit. Removed, as the new behavior is effectively what had been documented as intended behavior all the time.

Original pull request: #248.
odrotbohm pushed a commit that referenced this pull request Sep 27, 2017
…pository interface packages.

Custom repository implementation scan uses the repository interface package and its subpackages and no longer scans all configured base packages. Scan for fragment implementations defaults to the fragment interface package. Using the interface package for scanning aligns the behavior with the documentation.

Declaring the implementation along with the interface in the same package is an established design pattern allowing to limit the scanning scope. A limited scope improves scanning performance as it can skip elements on the classpath, that do not provide that particular package.

Previously, we scanned for implementations using the configured base packages that were also used to discover repository interfaces. These base packages can be broader for applications that spread repository interfaces across multiple packages.

Original pull request: #248.
odrotbohm added a commit that referenced this pull request Sep 27, 2017
Tweaked newly introduced RepositoryConfiguration.getImplementationBasePackage() to not require a parameter but use internal information instead (the repository interface in DefaultRepositoryConfiguration).

Original pull request: #248.
odrotbohm pushed a commit that referenced this pull request Oct 1, 2017
…pository interface packages.

Custom repository implementation scan uses the repository interface package and its subpackages and no longer scans all configured base packages. Scan for fragment implementations defaults to the fragment interface package. Using the interface package for scanning aligns the behavior with the documentation.

Declaring the implementation along with the interface in the same package is an established design pattern allowing to limit the scanning scope. A limited scope improves scanning performance as it can skip elements on the classpath, that do not provide that particular package.

Previously, we scanned for implementations using the configured base packages that were also used to discover repository interfaces. These base packages can be broader for applications that spread repository interfaces across multiple packages.

Original pull request: #248.
odrotbohm added a commit that referenced this pull request Oct 1, 2017
Tweaked newly introduced RepositoryConfiguration.getImplementationBasePackage() to not require a parameter but use internal information instead (the repository interface in DefaultRepositoryConfiguration).

Original pull request: #248.
@odrotbohm odrotbohm closed this Oct 4, 2017
@odrotbohm odrotbohm self-assigned this Oct 4, 2017
@odrotbohm odrotbohm deleted the issue/DATACMNS-1172 branch October 30, 2017 10:46
Aloren pushed a commit to Aloren/spring-data-commons that referenced this pull request Jun 20, 2019
Aloren pushed a commit to Aloren/spring-data-commons that referenced this pull request Jun 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants