Skip to content

Commit a51b482

Browse files
committed
Replace getClassesToScan with getBasePackage to simplify inheriting ChannelScanners
1 parent de5a862 commit a51b482

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/AbstractChannelScanner.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.github.stavshamir.springwolf.asyncapi.scanners.channels;
22

33
import com.google.common.collect.Maps;
4+
import io.github.stavshamir.springwolf.asyncapi.scanners.components.ComponentsScanner;
45
import io.github.stavshamir.springwolf.asyncapi.types.channel.Channel;
56
import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.Operation;
67
import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.bindings.OperationBinding;
@@ -20,21 +21,26 @@
2021
@Slf4j
2122
public abstract class AbstractChannelScanner<T extends Annotation> implements ChannelsScanner {
2223

24+
@Autowired
25+
private ComponentsScanner componentsScanner;
26+
2327
@Autowired
2428
private SchemasService schemasService;
2529

2630
@Override
2731
public Map<String, Channel> scan() {
28-
return getClassesToScan().stream()
32+
String basePackage = getBasePackage();
33+
34+
return componentsScanner.scanForComponents(basePackage).stream()
2935
.map(this::getAnnotatedMethods).flatMap(Collection::stream)
3036
.map(this::mapMethodToChannel)
3137
.collect(toMap(Map.Entry::getKey, Map.Entry::getValue));
3238
}
3339

3440
/**
35-
* @return The @Component classes to scan for listener annotations.
41+
* @return The base package containing @Component classes with listener annotations.
3642
*/
37-
protected abstract Set<Class<?>> getClassesToScan();
43+
protected abstract String getBasePackage();
3844

3945
/**
4046
* @return The class object of the listener annotation.

0 commit comments

Comments
 (0)