Skip to content

[DSIP-28] Donot scan whole project beans under classpath #15877

@ruanwenjun

Description

@ruanwenjun

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

@ComponentScan(value = "org.apache.dolphinscheduler", excludeFilters = {
@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = JdbcRegistryAutoConfiguration.class)
})
public class AlertServer {

ApiServer

@ComponentScan(value = "org.apache.dolphinscheduler", excludeFilters = {
@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = JdbcRegistryAutoConfiguration.class)
})
@Slf4j
public class ApiApplicationServer {

MasterServer

@ComponentScan(value = "org.apache.dolphinscheduler", excludeFilters = {
@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = JdbcRegistryAutoConfiguration.class)
})
@EnableTransactionManagement
@EnableCaching
@Slf4j
public class MasterServer implements IStoppable {

WorkerServer.

@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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions