File tree Expand file tree Collapse file tree 1 file changed +9
-19
lines changed
mongodb/fragment-spi/atlas-api/src/main/java/com/example/spi/mongodb/atlas Expand file tree Collapse file tree 1 file changed +9
-19
lines changed Original file line number Diff line number Diff line change 15
15
*/
16
16
package com .example .spi .mongodb .atlas ;
17
17
18
- import java .lang .reflect .Field ;
19
- import java .util .Arrays ;
20
-
21
18
import org .springframework .beans .BeansException ;
22
19
import org .springframework .beans .factory .config .BeanPostProcessor ;
23
20
import org .springframework .data .repository .core .support .RepositoryFactoryBeanSupport ;
24
- import org .springframework .stereotype .Component ;
25
- import org .springframework .util .ReflectionUtils ;
26
21
27
22
/**
28
23
* @author Christoph Strobl
29
24
*/
30
25
class AtlasRepositoryPostProcessor implements BeanPostProcessor {
31
26
32
- @ Override
33
- public Object postProcessBeforeInitialization (Object bean , String beanName ) throws BeansException {
27
+ @ Override
28
+ public Object postProcessBeforeInitialization (Object bean , String beanName ) throws BeansException {
34
29
35
- if (bean instanceof RepositoryFactoryBeanSupport rfbs ) {
30
+ if (bean instanceof RepositoryFactoryBeanSupport rfbs ) {
36
31
37
- Field field = ReflectionUtils .findField (RepositoryFactoryBeanSupport .class , "repositoryInterface" );
38
- ReflectionUtils .makeAccessible (field );
39
- if (Arrays .stream (((Class <?>) ReflectionUtils .getField (field , rfbs )).getInterfaces ())
40
- .anyMatch (iface -> {
41
- return iface .equals (AtlasRepository .class );
42
- })) {
43
- rfbs .setExposeMetadata (true );
44
- }
45
- }
46
- return bean ;
47
- }
32
+ if (AtlasRepository .class .isAssignableFrom (rfbs .getObjectType ())) {
33
+ rfbs .setExposeMetadata (true );
34
+ }
35
+ }
36
+ return bean ;
37
+ }
48
38
}
You can’t perform that action at this time.
0 commit comments