Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f36bc6d

Browse files
committed
Adapt to AOT Infrastructure changes in Commons.
See spring-projects/spring-data-commons#3267
1 parent 454b53d commit f36bc6d

File tree

3 files changed

+20
-77
lines changed

3 files changed

+20
-77
lines changed

‎spring-data-cassandra/src/main/java/org/springframework/data/cassandra/repository/config/CassandraRepositoryConfigurationExtension.java‎

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
import org.jspecify.annotations.Nullable;
2424

25-
import org.springframework.aot.generate.GenerationContext;
2625
import org.springframework.beans.factory.aot.BeanRegistrationAotProcessor;
2726
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
2827
import org.springframework.data.cassandra.config.DefaultBeanNames;
@@ -38,7 +37,6 @@
3837
import org.springframework.data.repository.config.RepositoryRegistrationAotProcessor;
3938
import org.springframework.data.repository.config.XmlRepositoryConfigurationSource;
4039
import org.springframework.data.repository.core.RepositoryMetadata;
41-
import org.springframework.data.util.TypeUtils;
4240
import org.springframework.util.StringUtils;
4341

4442
import org.w3c.dom.Element;
@@ -129,8 +127,7 @@ public static class CassandraRepositoryRegistrationAotProcessor extends Reposito
129127

130128
private static final String MODULE_NAME = "cassandra";
131129

132-
protected @Nullable CassandraRepositoryContributor contribute(AotRepositoryContext repositoryContext,
133-
GenerationContext generationContext) {
130+
protected @Nullable CassandraRepositoryContributor contributeAotRepository(AotRepositoryContext repositoryContext) {
134131

135132
if (!repositoryContext.isGeneratedRepositoriesEnabled(MODULE_NAME)) {
136133
return null;
@@ -139,16 +136,6 @@ public static class CassandraRepositoryRegistrationAotProcessor extends Reposito
139136
return new CassandraRepositoryContributor(repositoryContext);
140137
}
141138

142-
@Override
143-
protected void contributeType(Class<?> type, GenerationContext generationContext) {
144-
145-
if (TypeUtils.type(type).isPartOf("org.springframework.data.cassandra", "org.apache.cassandra", "com.datastax")) {
146-
return;
147-
}
148-
149-
super.contributeType(type, generationContext);
150-
}
151-
152139
}
153140

154141
}

‎spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/aot/AotFragmentTestConfigurationSupport.java‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@
6464
public class AotFragmentTestConfigurationSupport implements BeanFactoryPostProcessor {
6565

6666
private final Class<?> repositoryInterface;
67+
private final Class<?> configClass;
6768
private final boolean registerFragmentFacade;
68-
private final TestCassandraAotRepositoryContext<?>repositoryContext;
69+
private final Class<?>[] additionalFragments;
6970

7071
public AotFragmentTestConfigurationSupport(Class<?> repositoryInterface, Class<?> configClass) {
7172
this(repositoryInterface, configClass, true);
@@ -75,22 +76,23 @@ public AotFragmentTestConfigurationSupport(Class<?> repositoryInterface, Class<?
7576
boolean registerFragmentFacade, Class<?>... additionalFragments) {
7677

7778
this.repositoryInterface = repositoryInterface;
78-
79-
RepositoryComposition composition = RepositoryComposition
80-
.of((List) Arrays.stream(additionalFragments).map(RepositoryFragment::structural).toList());
81-
this.repositoryContext = new TestCassandraAotRepositoryContext<>(repositoryInterface, composition,
82-
new AnnotationRepositoryConfigurationSource(AnnotationMetadata.introspect(configClass),
83-
EnableCassandraRepositories.class, new DefaultResourceLoader(), new StandardEnvironment(),
84-
Mockito.mock(BeanDefinitionRegistry.class), DefaultBeanNameGenerator.INSTANCE));
79+
this.configClass = configClass;
8580
this.registerFragmentFacade = registerFragmentFacade;
81+
this.additionalFragments = additionalFragments;
8682
}
8783

8884
@Override
8985
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
9086

91-
TestGenerationContext generationContext = new TestGenerationContext(repositoryInterface);
87+
RepositoryComposition composition = RepositoryComposition
88+
.of((List) Arrays.stream(additionalFragments).map(RepositoryFragment::structural).toList());
89+
AnnotationRepositoryConfigurationSource configSource = new AnnotationRepositoryConfigurationSource(
90+
AnnotationMetadata.introspect(configClass), EnableCassandraRepositories.class, new DefaultResourceLoader(),
91+
new StandardEnvironment(), Mockito.mock(BeanDefinitionRegistry.class), DefaultBeanNameGenerator.INSTANCE);
92+
TestCassandraAotRepositoryContext<?> repositoryContext = new TestCassandraAotRepositoryContext<>(beanFactory,
93+
repositoryInterface, composition, configSource);
9294

93-
repositoryContext.setBeanFactory(beanFactory);
95+
TestGenerationContextgenerationContext = newTestGenerationContext(repositoryInterface);
9496

9597
CassandraRepositoryContributor repositoryContributor = new CassandraRepositoryContributor(repositoryContext);
9698
repositoryContributor.contribute(generationContext);

‎spring-data-cassandra/src/test/java/org/springframework/data/cassandra/repository/aot/TestCassandraAotRepositoryContext.java‎

Lines changed: 7 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,18 @@
1616
package org.springframework.data.cassandra.repository.aot;
1717

1818
import java.lang.annotation.Annotation;
19-
import java.util.Collection;
20-
import java.util.List;
2119
import java.util.Set;
22-
import java.util.function.Consumer;
2320

2421
import org.jspecify.annotations.Nullable;
2522

26-
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
23+
import org.springframework.beans.factory.BeanFactory;
2724
import 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;
3126
import org.springframework.data.cassandra.core.Person;
3227
import org.springframework.data.cassandra.core.mapping.Table;
3328
import org.springframework.data.cassandra.repository.support.SimpleCassandraRepository;
3429
import org.springframework.data.repository.config.AotRepositoryContext;
30+
import org.springframework.data.repository.config.AotRepositoryContextSupport;
3531
import org.springframework.data.repository.config.AotRepositoryInformation;
3632
import org.springframework.data.repository.config.RepositoryConfigurationSource;
3733
import org.springframework.data.repository.core.RepositoryInformation;
@@ -44,15 +40,16 @@
4440
*
4541
* @author Mark Paluch
4642
*/
47-
public class TestCassandraAotRepositoryContext<T> implementsAotRepositoryContext {
43+
public class TestCassandraAotRepositoryContext<T> extendsAotRepositoryContextSupport {
4844

4945
private final AotRepositoryInformation repositoryInformation;
5046
private final Class<T> repositoryInterface;
5147
private final RepositoryConfigurationSource configurationSource;
52-
private @Nullable ConfigurableListableBeanFactory beanFactory;
5348

54-
public TestCassandraAotRepositoryContext(Class<T> repositoryInterface, @Nullable RepositoryComposition composition,
49+
public TestCassandraAotRepositoryContext(BeanFactory beanFactory, Class<T> repositoryInterface,
50+
@Nullable RepositoryComposition composition,
5551
RepositoryConfigurationSource configurationSource) {
52+
super(AotContext.from(beanFactory));
5653
this.repositoryInterface = repositoryInterface;
5754
this.configurationSource = configurationSource;
5855

@@ -68,31 +65,6 @@ public Class<T> getRepositoryInterface() {
6865
return repositoryInterface;
6966
}
7067

71-
@Override
72-
public ConfigurableListableBeanFactory getBeanFactory() {
73-
return beanFactory;
74-
}
75-
76-
@Override
77-
public Environment getEnvironment() {
78-
return new StandardEnvironment();
79-
}
80-
81-
@Override
82-
public TypeIntrospector introspectType(String typeName) {
83-
return null;
84-
}
85-
86-
@Override
87-
public IntrospectedBeanDefinition introspectBeanDefinition(String beanName) {
88-
return null;
89-
}
90-
91-
@Override
92-
public String getBeanName() {
93-
return "dummyRepository";
94-
}
95-
9668
@Override
9769
public String getModuleName() {
9870
return "Cassandra";
@@ -128,22 +100,4 @@ public Set<Class<?>> getResolvedTypes() {
128100
return Set.of(Person.class);
129101
}
130102

131-
@Override
132-
public Set<Class<?>> getUserDomainTypes() {
133-
return Set.of();
134-
}
135-
136-
@Override
137-
public void typeConfiguration(Class<?> type, Consumer<AotTypeConfiguration> configurationConsumer) {
138-
139-
}
140-
141-
@Override
142-
public Collection<AotTypeConfiguration> typeConfigurations() {
143-
return List.of();
144-
}
145-
146-
public void setBeanFactory(ConfigurableListableBeanFactory beanFactory) {
147-
this.beanFactory = beanFactory;
148-
}
149103
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /