1616package org .springframework .data .jdbc .repository .aot ;
1717
1818import java .lang .annotation .Annotation ;
19- import java .util .Collection ;
20- import java .util .List ;
2119import java .util .Set ;
22- import java .util .function .Consumer ;
2320
2421import org .jspecify .annotations .Nullable ;
2522
26- import org .springframework .beans .factory .config . ConfigurableListableBeanFactory ;
23+ import org .springframework .beans .factory .BeanFactory ;
2724import org .springframework .core .annotation .MergedAnnotation ;
28- import org .springframework .core .env .Environment ;
29- import org .springframework .core .env .StandardEnvironment ;
30- import org .springframework .data .aot .AotTypeConfiguration ;
25+ import org .springframework .data .aot .AotContext ;
3126import org .springframework .data .jdbc .repository .support .SimpleJdbcRepository ;
3227import org .springframework .data .relational .core .mapping .Table ;
3328import org .springframework .data .repository .config .AotRepositoryContext ;
29+ import org .springframework .data .repository .config .AotRepositoryContextSupport ;
3430import org .springframework .data .repository .config .AotRepositoryInformation ;
3531import org .springframework .data .repository .config .RepositoryConfigurationSource ;
3632import org .springframework .data .repository .core .RepositoryInformation ;
4339 *
4440 * @author Mark Paluch
4541 */
46- public class TestJdbcAotRepositoryContext <T > implements AotRepositoryContext {
42+ public class TestJdbcAotRepositoryContext <T > extends AotRepositoryContextSupport {
4743
4844 private final AotRepositoryInformation repositoryInformation ;
49- private final Class <T > repositoryInterface ;
5045 private final RepositoryConfigurationSource configurationSource ;
51- private @ Nullable ConfigurableListableBeanFactory beanFactory ;
5246
53- public TestJdbcAotRepositoryContext (Class <T > repositoryInterface , @ Nullable RepositoryComposition composition ,
47+ public TestJdbcAotRepositoryContext (BeanFactory beanFactory , Class <T > repositoryInterface ,
48+ @ Nullable RepositoryComposition composition ,
5449 RepositoryConfigurationSource configurationSource ) {
55- this . repositoryInterface = repositoryInterface ;
50+ super ( AotContext . from ( beanFactory )) ;
5651 this .configurationSource = configurationSource ;
5752
5853 RepositoryMetadata metadata = AnnotationRepositoryMetadata .getMetadata (repositoryInterface );
@@ -63,35 +58,6 @@ public TestJdbcAotRepositoryContext(Class<T> repositoryInterface, @Nullable Repo
6358 composition .append (fragments ).getFragments ().stream ().toList ());
6459 }
6560
66- public Class <T > getRepositoryInterface () {
67- return repositoryInterface ;
68- }
69-
70- @ Override
71- public ConfigurableListableBeanFactory getBeanFactory () {
72- return beanFactory ;
73- }
74-
75- @ Override
76- public Environment getEnvironment () {
77- return new StandardEnvironment ();
78- }
79-
80- @ Override
81- public TypeIntrospector introspectType (String typeName ) {
82- return null ;
83- }
84-
85- @ Override
86- public IntrospectedBeanDefinition introspectBeanDefinition (String beanName ) {
87- return null ;
88- }
89-
90- @ Override
91- public String getBeanName () {
92- return "dummyRepository" ;
93- }
94-
9561 @ Override
9662 public String getModuleName () {
9763 return "JDBC" ;
@@ -102,11 +68,6 @@ public RepositoryConfigurationSource getConfigurationSource() {
10268 return configurationSource ;
10369 }
10470
105- @ Override
106- public Set <String > getBasePackages () {
107- return Set .of ("org.springframework.data.dummy.repository.aot" );
108- }
109-
11071 @ Override
11172 public Set <Class <? extends Annotation >> getIdentifyingAnnotations () {
11273 return Set .of (Table .class );
@@ -127,22 +88,4 @@ public Set<Class<?>> getResolvedTypes() {
12788 return Set .of (User .class );
12889 }
12990
130- @ Override
131- public Set <Class <?>> getUserDomainTypes () {
132- return Set .of ();
133- }
134-
135- @ Override
136- public void typeConfiguration (Class <?> type , Consumer <AotTypeConfiguration > configurationConsumer ) {
137-
138- }
139-
140- @ Override
141- public Collection <AotTypeConfiguration > typeConfigurations () {
142- return List .of ();
143- }
144-
145- public void setBeanFactory (ConfigurableListableBeanFactory beanFactory ) {
146- this .beanFactory = beanFactory ;
147- }
14891}
0 commit comments