Skip to content

Introduce ManagedTypes. #2635

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 7 commits into from
Closed

Introduce ManagedTypes. #2635

wants to merge 7 commits into from

Conversation

christophstrobl
Copy link
Member

See: #2634

@christophstrobl christophstrobl linked an issue May 18, 2022 that may be closed by this pull request
* @since 3.0
*/
@FunctionalInterface
public interface ManagedTypes {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about implementing Streamable<Class<?>> here?

Supplier<Set<String>> basePackages) {

String beanName = String.format("%s.managed-types", extension.getModulePrefix());
if (!registry.isBeanNameInUse(beanName)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using multiple times @Enable…Repositories can cause conflicts. Spring has somewhere a utility to generate unique bean names from a bean base name.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved by not not scanning for types here. (see comment below).

@@ -45,6 +49,10 @@ public class AnnotatedTypeScanner implements ResourceLoaderAware, EnvironmentAwa
private @Nullable ResourceLoader resourceLoader;
private @Nullable Environment environment;

private Consumer<ClassNotFoundException> classNotFoundAction = ex -> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the idea behind the ClassNotFoundException handling? Is this a response to a certain use case? If so, then we should make this concept more explicit with an ErrorHandler.

* @return
* @since 3.0
*/
default Collection<Class<? extends Annotation>> getIdentifyingAnnotations() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels a bit weird handing out identifying annotations to the outside of the config extension as the managed type scanning vs. repository scanning are located at two different abstractions.

Repository type scanning happens inside the RepositoryConfigurationExtension. We still need to merge repository-managed types with the ones that we discover through the classpath scan.

How about returning a RepositoryConfigurations object from getRepositoryConfigurations that wraps Collection<RepositoryConfiguration<T>> and provides a ManagedTypes object?

Doing so would allow keeping all scanning-related operations within the extension.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not be doing the ManagedType scanning in the RepositoryConfigurationDelegate and just consider the domain types exposed by the repository declaration.
ManagedTypes may be contributed by an external configuration source, such as Boot.

* @return new instance of {@link TypeScanner}.
* @see #scanPackages(Collection)
*/
default TypeScanner scanPackages(String... packageNames) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scanPackages should be renamed to a name that is less imperative and expresses rather that this is a config option packagesToScan or something like that, so that the imperative names (forEach, collectAsSet) remain as terminal methods.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taking this 1 step further, perhaps all the typeScanner(..) factory methods could be renamed to from(..) and the scanPackages(..) method could be renamed to inPackages(..).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

considered - TypeScanner is likely to be dropped from this PR and move to another one.

* @return new instance of {@link TypeScanner}.
* @see #scanPackages(String...)
*/
TypeScanner scanPackages(Collection<String> packageNames);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note comment above.

@christophstrobl christophstrobl marked this pull request as ready for review June 13, 2022 11:25
mp911de pushed a commit that referenced this pull request Jun 14, 2022
We now provide an abstraction to describe a collection of entity types that can be provided to the mapping context as improvement over `Set<Class>` for easier context setup.

Original pull request: #2635.
Closes #2634.
mp911de added a commit that referenced this pull request Jun 14, 2022
Add assertions, refine Javadoc.

Original pull request: #2635.
See #2634.
mp911de added a commit that referenced this pull request Jun 14, 2022
…ion`.

This is a breaking change as many modules implement a protected method. We're going to change this later with #2644.

Original pull request: #2635.
See #2634.
@mp911de
Copy link
Member

mp911de commented Jun 14, 2022

That's merged and polished now.

@mp911de mp911de closed this Jun 14, 2022
@mp911de mp911de deleted the issue/2634 branch June 14, 2022 08:06
@mp911de mp911de added this to the 3.0 M5 (2022.0.0) milestone Jun 14, 2022
@mp911de mp911de added the type: enhancement A general enhancement label Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add infrastructure to provide/identify managed types.
3 participants