-
Notifications
You must be signed in to change notification settings - Fork 5k
[DSIP-28] Donot scan whole project beans under classpath #15877
Description
Search before asking
- I had searched in the issues and found no similar feature requirement.
Motivation
Right now we will scan all beans under org.apache.dolphinscheduler in
AlertServer
Lines 45 to 48 in 325bfa8
| @ComponentScan(value = "org.apache.dolphinscheduler", excludeFilters = { | |
| @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = JdbcRegistryAutoConfiguration.class) | |
| }) | |
| public class AlertServer { |
ApiServer
Lines 47 to 51 in 325bfa8
| @ComponentScan(value = "org.apache.dolphinscheduler", excludeFilters = { | |
| @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = JdbcRegistryAutoConfiguration.class) | |
| }) | |
| @Slf4j | |
| public class ApiApplicationServer { |
MasterServer
Lines 54 to 60 in 325bfa8
| @ComponentScan(value = "org.apache.dolphinscheduler", excludeFilters = { | |
| @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = JdbcRegistryAutoConfiguration.class) | |
| }) | |
| @EnableTransactionManagement | |
| @EnableCaching | |
| @Slf4j | |
| public class MasterServer implements IStoppable { |
WorkerServer.
Lines 56 to 60 in 325bfa8
| @ComponentScan(value = "org.apache.dolphinscheduler", excludeFilters = { | |
| @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = JdbcRegistryAutoConfiguration.class) | |
| }) | |
| @Slf4j | |
| public class WorkerServer implements IStoppable { |
This will allow us to know the module relation difficultly, furthermore, if there exists an unexpected module in the application, the beans in this module will be loaded into memory, e.g. worker load dao module.
So it's better avoid scan whole project.
Design Detail
First, the application should only scan the package of the bootstrap class. Other package beans should be import by Configuration.
Second, the plugin beans should be registered by AutoConfiguration.
Compatibility, Deprecation, and Migration Plan
Compatibility with 3.x version.
Test Plan
Test by UT and E2E
Are you willing to submit a PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct