-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): find channels defined via bean configuration
add SpringwolfClassScanner
- Loading branch information
Showing
16 changed files
with
179 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 13 additions & 8 deletions
21
.../io/github/stavshamir/springwolf/asyncapi/scanners/classes/ConfigurationClassScanner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package io.github.stavshamir.springwolf.asyncapi.scanners.classes; | ||
|
||
import io.github.stavshamir.springwolf.configuration.AsyncApiDocketService; | ||
import io.github.stavshamir.springwolf.asyncapi.scanners.channels.annotation.AnnotationUtil; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.core.env.Environment; | ||
|
||
public class ConfigurationClassScanner extends AbstractAnnotatedClassScanner<Configuration> implements ClassScanner { | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
public ConfigurationClassScanner(AsyncApiDocketService asyncApiDocketService, Environment environment) { | ||
super(asyncApiDocketService, environment); | ||
} | ||
@RequiredArgsConstructor | ||
public class ConfigurationClassScanner implements ClassScanner { | ||
|
||
private final ComponentClassScanner scanner; | ||
|
||
@Override | ||
protected Class<Configuration> getAnnotationClass() { | ||
return Configuration.class; | ||
public Set<Class<?>> scan() { | ||
return scanner.scan().stream() | ||
// All Configurations are also Components | ||
.filter((cls) -> AnnotationUtil.findAnnotation(Configuration.class, cls) != null) | ||
.collect(Collectors.toSet()); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...ava/io/github/stavshamir/springwolf/asyncapi/scanners/classes/SpringwolfClassScanner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package io.github.stavshamir.springwolf.asyncapi.scanners.classes; | ||
|
||
import io.github.stavshamir.springwolf.asyncapi.scanners.beans.BeanMethodsScanner; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.lang.reflect.Method; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
@RequiredArgsConstructor | ||
public class SpringwolfClassScanner implements ClassScanner { | ||
|
||
private final ComponentClassScanner scanner; | ||
private final BeanMethodsScanner beanMethodsScanner; | ||
|
||
@Override | ||
public Set<Class<?>> scan() { | ||
Stream<Class<?>> components = scanner.scan().stream(); | ||
Stream<Class<?>> configurationBeans = | ||
beanMethodsScanner.getBeanMethods().stream().map(Method::getReturnType); | ||
|
||
return Stream.concat(components, configurationBeans).collect(Collectors.toSet()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.