Skip to content

Commit bc0ae81

Browse files
committed
refactor(server): Move provideReflections method to private scope for better encapsulation
1 parent b3427bd commit bc0ae81

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/main/java/com/github/codeboyzhou/mcp/declarative/common/InjectorModule.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
import com.github.codeboyzhou.mcp.declarative.server.factory.McpStdioServerFactory;
1818
import com.github.codeboyzhou.mcp.declarative.server.factory.McpStreamableServerFactory;
1919
import com.google.inject.AbstractModule;
20-
import com.google.inject.Provides;
21-
import com.google.inject.Singleton;
2220
import com.google.inject.name.Names;
2321
import java.util.Set;
2422
import org.reflections.Reflections;
@@ -33,15 +31,6 @@ public InjectorModule(Class<?> mainClass) {
3331
this.mainClass = mainClass;
3432
}
3533

36-
@Provides
37-
@Singleton
38-
@SuppressWarnings("unused")
39-
public Reflections provideReflections() {
40-
McpServerApplication application = mainClass.getAnnotation(McpServerApplication.class);
41-
final String basePackage = determineBasePackage(application);
42-
return new Reflections(basePackage, TypesAnnotated, MethodsAnnotated, FieldsAnnotated);
43-
}
44-
4534
@Override
4635
protected void configure() {
4736
// Bind classes annotated by McpResources, McpPrompts, McpTools
@@ -70,6 +59,12 @@ protected void configure() {
7059
.toInstance(i18nEnabled);
7160
}
7261

62+
private Reflections provideReflections() {
63+
McpServerApplication application = mainClass.getAnnotation(McpServerApplication.class);
64+
final String basePackage = determineBasePackage(application);
65+
return new Reflections(basePackage, TypesAnnotated, MethodsAnnotated, FieldsAnnotated);
66+
}
67+
7368
private String determineBasePackage(McpServerApplication application) {
7469
if (application != null) {
7570
if (!application.basePackage().trim().isBlank()) {

0 commit comments

Comments
 (0)