|
17 | 17 |
|
18 | 18 | import java.io.IOException; |
19 | 19 | import java.lang.reflect.Method; |
20 | | -import java.util.Arrays; |
21 | 20 | import java.util.Set; |
22 | 21 |
|
23 | 22 | import org.jline.reader.LineReader; |
@@ -62,7 +61,6 @@ public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionR |
62 | 61 | // register user defined commands |
63 | 62 | Class<?>[] candidateClasses = shellAnnotation.value(); |
64 | 63 | for (Class<?> candidateClass : candidateClasses) { |
65 | | - registerCommands(candidateClass, registry); |
66 | 64 | registerAnnotatedMethods(candidateClass, registry); |
67 | 65 | } |
68 | 66 |
|
@@ -108,16 +106,6 @@ public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionR |
108 | 106 | } |
109 | 107 | } |
110 | 108 |
|
111 | | - private void registerCommands(Class<?> candidateClass, BeanDefinitionRegistry registry) { |
112 | | - Arrays.stream(candidateClass.getDeclaredMethods()) |
113 | | - .filter(method -> method.getReturnType().equals(org.springframework.shell.core.command.Command.class)) |
114 | | - .forEach(method -> { |
115 | | - RootBeanDefinition beanDefinition = new RootBeanDefinition( |
116 | | - org.springframework.shell.core.command.Command.class); |
117 | | - registry.registerBeanDefinition(method.getName(), beanDefinition); |
118 | | - }); |
119 | | - } |
120 | | - |
121 | 109 | private void registerAnnotatedMethods(Class<?> candidateClass, BeanDefinitionRegistry registry) { |
122 | 110 | ReflectionUtils.MethodFilter filter = method -> AnnotatedElementUtils.hasAnnotation(method, Command.class); |
123 | 111 | Set<Method> methods = MethodIntrospector.selectMethods(candidateClass, filter); |
|
0 commit comments