-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AiService support @Profile #41
AiService support @Profile #41
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Martin7-1 thank you!
if (aiServiceClass.isAnnotationPresent(Profile.class)) { | ||
Profile profileAnnotation = aiServiceClass.getAnnotation(Profile.class); | ||
String[] profiles = profileAnnotation.value(); | ||
if (!environment.matchesProfiles(profiles)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this filtering really required twice? (also in AiServiceScannerProcessor
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm.. Good question. Maybe we only need to filter it in AiServiceScannerProcessor
to skip scanning the BeanDefinition with AiService.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Now only the AiServiceScannerProcessor
do filtering with @Profile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to filter only in AiServicesAutoConfig
?
AiServiceScannerProcessor
is dealing with packages for scanning, AiServicesAutoConfig
is the one who decides if @AiService
bean should be created or not
...j-spring-boot-starter/src/main/java/dev/langchain4j/service/spring/AiServicesAutoConfig.java
Outdated
Show resolved
Hide resolved
...j-spring-boot-starter/src/main/java/dev/langchain4j/service/spring/AiServicesAutoConfig.java
Outdated
Show resolved
Hide resolved
...j-spring-boot-starter/src/main/java/dev/langchain4j/service/spring/AiServicesAutoConfig.java
Outdated
Show resolved
Hide resolved
if (aiServiceClass.isAnnotationPresent(Profile.class)) { | ||
Profile profileAnnotation = aiServiceClass.getAnnotation(Profile.class); | ||
String[] profiles = profileAnnotation.value(); | ||
if (!environment.matchesProfiles(profiles)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to filter only in AiServicesAutoConfig
?
AiServiceScannerProcessor
is dealing with packages for scanning, AiServicesAutoConfig
is the one who decides if @AiService
bean should be created or not
@langchain4j At first I did want to do filtering in I haven't found a way to do this in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Martin7-1 great job, thank you!
...ing-boot-starter/src/main/java/dev/langchain4j/service/spring/AiServiceScannerProcessor.java
Outdated
Show resolved
Hide resolved
...ing-boot-starter/src/main/java/dev/langchain4j/service/spring/AiServiceScannerProcessor.java
Outdated
Show resolved
Hide resolved
…service/spring/AiServiceScannerProcessor.java
…service/spring/AiServiceScannerProcessor.java
Close langchain4j#1430
@AiService
with@Profile
.