Skip to content

Commit 8d42485

Browse files
christophstroblmp911de
authored andcommitted
Resolve package cycle between repository.config and repository.aot.
Closes #2708
1 parent 0e00d5f commit 8d42485

20 files changed

+209
-109
lines changed

src/main/java/org/springframework/data/aot/ManagedTypesBeanRegistrationAotProcessor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
import org.springframework.beans.factory.support.RootBeanDefinition;
3232
import org.springframework.core.ResolvableType;
3333
import org.springframework.data.domain.ManagedTypes;
34+
import org.springframework.data.util.TypeContributor;
35+
import org.springframework.data.util.TypeUtils;
3436
import org.springframework.lang.Nullable;
3537
import org.springframework.util.ClassUtils;
3638
import org.springframework.util.StringUtils;

src/main/java/org/springframework/data/aot/ManagedTypesRegistrationAotContribution.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.springframework.core.ResolvableType;
3636
import org.springframework.data.domain.ManagedTypes;
3737
import org.springframework.data.util.Lazy;
38+
import org.springframework.data.util.TypeCollector;
3839
import org.springframework.javapoet.ClassName;
3940
import org.springframework.javapoet.CodeBlock;
4041
import org.springframework.javapoet.MethodSpec.Builder;

src/main/java/org/springframework/data/aot/Predicates.java

Lines changed: 0 additions & 52 deletions
This file was deleted.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright 2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.data.querydsl.aot;
17+
18+
import java.util.Arrays;
19+
20+
import org.springframework.aot.hint.MemberCategory;
21+
import org.springframework.aot.hint.RuntimeHints;
22+
import org.springframework.aot.hint.RuntimeHintsRegistrar;
23+
import org.springframework.aot.hint.TypeReference;
24+
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
25+
import org.springframework.data.querydsl.ReactiveQuerydslPredicateExecutor;
26+
import org.springframework.lang.Nullable;
27+
import org.springframework.util.ClassUtils;
28+
29+
import com.querydsl.core.types.Predicate;
30+
31+
/**
32+
* @author Christoph Strobl
33+
* @since 4.0
34+
*/
35+
public class QuerydslHints implements RuntimeHintsRegistrar {
36+
37+
@Override
38+
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
39+
40+
if (ClassUtils.isPresent("com.querydsl.core.types.Predicate", classLoader)) {
41+
42+
// repository infrastructure
43+
hints.reflection().registerTypes(Arrays.asList( //
44+
TypeReference.of(Predicate.class), //
45+
TypeReference.of(QuerydslPredicateExecutor.class)), builder -> {
46+
builder.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS);
47+
});
48+
49+
if (ClassUtils.isPresent("reactor.core.publisher.Flux", classLoader)) {
50+
// repository infrastructure
51+
hints.reflection().registerTypes(Arrays.asList( //
52+
TypeReference.of(ReactiveQuerydslPredicateExecutor.class)), builder -> {
53+
builder.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS);
54+
});
55+
}
56+
}
57+
}
58+
}

src/main/java/org/springframework/data/repository/aot/hint/RepositoryRuntimeHints.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
import org.springframework.core.io.InputStreamSource;
2727
import org.springframework.data.domain.Example;
2828
import org.springframework.data.mapping.context.MappingContext;
29-
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
30-
import org.springframework.data.querydsl.QuerydslUtils;
31-
import org.springframework.data.querydsl.ReactiveQuerydslPredicateExecutor;
3229
import org.springframework.data.repository.core.RepositoryMetadata;
3330
import org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport;
3431
import org.springframework.data.repository.core.support.RepositoryFragment;
@@ -42,8 +39,6 @@
4239
import org.springframework.lang.Nullable;
4340
import org.springframework.util.ClassUtils;
4441

45-
import com.querydsl.core.types.Predicate;
46-
4742
/**
4843
* {@link RuntimeHintsRegistrar} holding required hints to bootstrap data repositories. <br />
4944
* Already registered via {@literal aot.factories}.
@@ -87,24 +82,6 @@ public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader)
8782
});
8883
}
8984

90-
if (QuerydslUtils.QUERY_DSL_PRESENT) {
91-
92-
// repository infrastructure
93-
hints.reflection().registerTypes(Arrays.asList( //
94-
TypeReference.of(Predicate.class), //
95-
TypeReference.of(QuerydslPredicateExecutor.class)), builder -> {
96-
builder.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS);
97-
});
98-
99-
if (PROJECT_REACTOR_PRESENT) {
100-
// repository infrastructure
101-
hints.reflection().registerTypes(Arrays.asList( //
102-
TypeReference.of(ReactiveQuerydslPredicateExecutor.class)), builder -> {
103-
builder.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS);
104-
});
105-
}
106-
}
107-
10885
// named queries
10986
hints.reflection().registerTypes(Arrays.asList( //
11087
TypeReference.of(Properties.class), //

src/main/java/org/springframework/data/repository/aot/AotRepositoryContext.java renamed to src/main/java/org/springframework/data/repository/config/AotRepositoryContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.springframework.data.repository.aot;
16+
package org.springframework.data.repository.config;
1717

1818
import java.lang.annotation.Annotation;
1919
import java.util.Set;

src/main/java/org/springframework/data/repository/aot/AotRepositoryInformation.java renamed to src/main/java/org/springframework/data/repository/config/AotRepositoryInformation.java

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1+
/*
2+
* Copyright 2022. the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/*
18+
* Copyright 2022. the original author or authors.
19+
*
20+
* Licensed under the Apache License, Version 2.0 (the "License");
21+
* you may not use this file except in compliance with the License.
22+
* You may obtain a copy of the License at
23+
*
24+
* http://www.apache.org/licenses/LICENSE-2.0
25+
*
26+
* Unless required by applicable law or agreed to in writing, software
27+
* distributed under the License is distributed on an "AS IS" BASIS,
28+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29+
* See the License for the specific language governing permissions and
30+
* limitations under the License.
31+
*/
32+
133
/*
234
* Copyright 2022 the original author or authors.
335
*
@@ -13,7 +45,7 @@
1345
* See the License for the specific language governing permissions and
1446
* limitations under the License.
1547
*/
16-
package org.springframework.data.repository.aot;
48+
package org.springframework.data.repository.config;
1749

1850
import java.lang.reflect.Method;
1951
import java.util.Collection;

src/main/java/org/springframework/data/repository/aot/DefaultAotRepositoryContext.java renamed to src/main/java/org/springframework/data/repository/config/DefaultAotRepositoryContext.java

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1+
/*
2+
* Copyright 2022. the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/*
18+
* Copyright 2022. the original author or authors.
19+
*
20+
* Licensed under the Apache License, Version 2.0 (the "License");
21+
* you may not use this file except in compliance with the License.
22+
* You may obtain a copy of the License at
23+
*
24+
* http://www.apache.org/licenses/LICENSE-2.0
25+
*
26+
* Unless required by applicable law or agreed to in writing, software
27+
* distributed under the License is distributed on an "AS IS" BASIS,
28+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29+
* See the License for the specific language governing permissions and
30+
* limitations under the License.
31+
*/
32+
133
/*
234
* Copyright 2022 the original author or authors.
335
*
@@ -13,7 +45,7 @@
1345
* See the License for the specific language governing permissions and
1446
* limitations under the License.
1547
*/
16-
package org.springframework.data.repository.aot;
48+
package org.springframework.data.repository.config;
1749

1850
import java.lang.annotation.Annotation;
1951
import java.util.LinkedHashSet;
@@ -23,8 +55,9 @@
2355
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
2456
import org.springframework.core.annotation.MergedAnnotation;
2557
import org.springframework.data.aot.AotContext;
26-
import org.springframework.data.aot.TypeCollector;
27-
import org.springframework.data.aot.TypeUtils;
58+
import org.springframework.data.repository.config.AotRepositoryContext;
59+
import org.springframework.data.util.TypeCollector;
60+
import org.springframework.data.util.TypeUtils;
2861
import org.springframework.data.repository.core.RepositoryInformation;
2962
import org.springframework.data.util.Lazy;
3063

src/main/java/org/springframework/data/repository/aot/RepositoryBeanDefinitionReader.java renamed to src/main/java/org/springframework/data/repository/config/RepositoryBeanDefinitionReader.java

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1+
/*
2+
* Copyright 2022. the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/*
18+
* Copyright 2022. the original author or authors.
19+
*
20+
* Licensed under the Apache License, Version 2.0 (the "License");
21+
* you may not use this file except in compliance with the License.
22+
* You may obtain a copy of the License at
23+
*
24+
* http://www.apache.org/licenses/LICENSE-2.0
25+
*
26+
* Unless required by applicable law or agreed to in writing, software
27+
* distributed under the License is distributed on an "AS IS" BASIS,
28+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29+
* See the License for the specific language governing permissions and
30+
* limitations under the License.
31+
*/
32+
133
/*
234
* Copyright 2022 the original author or authors.
335
*
@@ -13,7 +45,7 @@
1345
* See the License for the specific language governing permissions and
1446
* limitations under the License.
1547
*/
16-
package org.springframework.data.repository.aot;
48+
package org.springframework.data.repository.config;
1749

1850
import java.util.ArrayList;
1951
import java.util.Collection;
@@ -23,8 +55,6 @@
2355
import java.util.stream.Collectors;
2456

2557
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
26-
import org.springframework.data.repository.config.RepositoryConfiguration;
27-
import org.springframework.data.repository.config.RepositoryFragmentConfigurationProvider;
2858
import org.springframework.data.repository.core.RepositoryInformation;
2959
import org.springframework.data.repository.core.support.DefaultRepositoryMetadata;
3060
import org.springframework.data.repository.core.support.RepositoryFragment;

src/main/java/org/springframework/data/repository/config/RepositoryConfigurationExtension.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
2424
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
2525
import org.springframework.core.io.ResourceLoader;
26-
import org.springframework.data.repository.aot.RepositoryRegistrationAotProcessor;
2726
import org.springframework.lang.NonNull;
2827

2928
/**

0 commit comments

Comments
 (0)