Skip to content

Commit b09f84d

Browse files
Move auditing hints into dedicated HintRegistrar to be included optionally via @EnableAuditing in the store modules
@ImportRuntimeHints(DataAuditingRuntimeHints.class) public @interface EnableMongoAuditing { ... }
1 parent 3b0ca6e commit b09f84d

File tree

3 files changed

+76
-30
lines changed

3 files changed

+76
-30
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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.aot;
17+
18+
import org.springframework.aop.SpringProxy;
19+
import org.springframework.aop.framework.Advised;
20+
import org.springframework.aot.hint.RuntimeHints;
21+
import org.springframework.aot.hint.RuntimeHintsRegistrar;
22+
import org.springframework.aot.hint.TypeReference;
23+
import org.springframework.core.DecoratingProxy;
24+
import org.springframework.data.domain.AuditorAware;
25+
import org.springframework.lang.Nullable;
26+
27+
/**
28+
* @author Christoph Strobl
29+
* @since 3.0
30+
*/
31+
public class DataAuditingRuntimeHints implements RuntimeHintsRegistrar {
32+
33+
@Override
34+
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
35+
hints.proxies().registerJdkProxy(TypeReference.of(AuditorAware.class), TypeReference.of(SpringProxy.class),
36+
TypeReference.of(Advised.class), TypeReference.of(DecoratingProxy.class));
37+
}
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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.aot;
17+
18+
import org.springframework.aop.SpringProxy;
19+
import org.springframework.aop.framework.Advised;
20+
import org.springframework.aot.hint.RuntimeHints;
21+
import org.springframework.aot.hint.RuntimeHintsRegistrar;
22+
import org.springframework.aot.hint.TypeReference;
23+
import org.springframework.core.DecoratingProxy;
24+
import org.springframework.data.domain.ReactiveAuditorAware;
25+
import org.springframework.lang.Nullable;
26+
27+
/**
28+
* @author Christoph Strobl
29+
* @since 3.0
30+
*/
31+
public class DataReactiveAuditingRuntimeHints implements RuntimeHintsRegistrar {
32+
33+
@Override
34+
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
35+
hints.proxies().registerJdkProxy(TypeReference.of(ReactiveAuditorAware.class), TypeReference.of(SpringProxy.class),
36+
TypeReference.of(Advised.class), TypeReference.of(DecoratingProxy.class));
37+
}
38+
}

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

-30
Original file line numberDiff line numberDiff line change
@@ -43,34 +43,6 @@
4343
*/
4444
public class DataRuntimeHints implements RuntimeHintsRegistrar {
4545

46-
/*
47-
NativeHint(trigger = MappingContext.class,
48-
types = {
49-
@TypeHint(types = {
50-
RepositoryFactoryBeanSupport.class,
51-
RepositoryFragmentsFactoryBean.class,
52-
RepositoryFragment.class,
53-
TransactionalRepositoryFactoryBeanSupport.class,
54-
QueryByExampleExecutor.class,
55-
MappingContext.class,
56-
RepositoryMetadata.class,
57-
RepositoryMetadata.class,
58-
}),
59-
@TypeHint(types = {ReadingConverter.class, WritingConverter.class}),
60-
@TypeHint(types = {Properties.class, BeanFactory.class, InputStreamSource[].class}),
61-
@TypeHint(types = Throwable.class, access = { TypeAccess.DECLARED_CONSTRUCTORS, TypeAccess.DECLARED_FIELDS}),
62-
@TypeHint(typeNames = {
63-
"org.springframework.data.projection.SpelEvaluatingMethodInterceptor$TargetWrapper",
64-
}, access = { TypeAccess.DECLARED_CONSTRUCTORS, TypeAccess.DECLARED_METHODS, TypeAccess.PUBLIC_METHODS })
65-
},
66-
jdkProxies = @JdkProxyHint(typeNames = {
67-
"org.springframework.data.annotation.QueryAnnotation",
68-
"org.springframework.core.annotation.SynthesizedAnnotation" }
69-
),
70-
initialization = @InitializationHint(types = AbstractMappingContext.class, initTime = InitializationTime.BUILD)
71-
)
72-
*/
73-
7446
@Override
7547
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
7648

@@ -99,7 +71,5 @@ public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader)
9971

10072
hints.proxies().registerJdkProxy(TypeReference.of("org.springframework.data.annotation.QueryAnnotation"),
10173
TypeReference.of("org.springframework.core.annotation.SynthesizedAnnotation"));
102-
103-
hints.proxies().registerJdkProxy(TypeReference.of(AuditorAware.class), TypeReference.of(SpringProxy.class), TypeReference.of(Advised.class), TypeReference.of(DecoratingProxy.class));
10474
}
10575
}

0 commit comments

Comments
 (0)