Skip to content

Commit

Permalink
optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
ponfee committed Feb 4, 2024
1 parent f1f6460 commit c41cdba
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public WorkerRegistry workerRegistry(DatabaseRegistryProperties config,

// -------------------------------------------------------------------------destroy datasource

@ConditionalOnMissingBean
@Bean
private DatabaseRegistryDataSourceDestroy databaseRegistryDataSourceDestroy(@Qualifier(SPRING_BEAN_NAME_JTW) JdbcTemplateWrapper wrapper) {
return new DatabaseRegistryDataSourceDestroy(wrapper);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ class EnableSupervisorConfiguration {

@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)
@Order(Ordered.HIGHEST_PRECEDENCE)
@ConditionalOnMissingBean
@Bean(JobConstants.SPRING_BEAN_NAME_CURRENT_SUPERVISOR)
public Supervisor.Current currentSupervisor(@Value("${" + JobConstants.SPRING_WEB_SERVER_PORT + "}") int port,
@Value("${" + JobConstants.DISJOB_BOUND_SERVER_HOST + ":}") String boundHost) {
Expand All @@ -106,7 +105,6 @@ public Supervisor.Current currentSupervisor(@Value("${" + JobConstants.SPRING_WE
}

@DependsOn(JobConstants.SPRING_BEAN_NAME_CURRENT_SUPERVISOR)
@ConditionalOnMissingBean
@Bean
public GroupedServerInvoker<WorkerRpcService> workerRpcServiceClient(HttpProperties http,
RetryProperties retry,
Expand All @@ -127,17 +125,16 @@ public GroupedServerInvoker<WorkerRpcService> workerRpcServiceClient(HttpPropert
);
}

// 如果注解没有参数,则默认以方法的返回类型判断,即容器中不存在类型为`LocalizedMethodArgumentConfigurer`的实例才创建
@ConditionalOnMissingBean
@Bean
public LocalizedMethodArgumentConfigurer localizedMethodArgumentConfigurer() {
return new LocalizedMethodArgumentConfigurer();
public AuthenticationConfigurer authenticationConfigurer() {
return new AuthenticationConfigurer();
}

// 如果注解没有参数,则默认以方法的返回类型判断,即容器中不存在类型为`LocalizedMethodArgumentConfigurer`的实例才创建
@ConditionalOnMissingBean
@Bean
public AuthenticationConfigurer authenticationConfigurer() {
return new AuthenticationConfigurer();
public LocalizedMethodArgumentConfigurer localizedMethodArgumentConfigurer() {
return new LocalizedMethodArgumentConfigurer();
}

@ConditionalOnMissingBean
Expand Down Expand Up @@ -178,7 +175,6 @@ public DoInLocked scanRunningInstanceLocker(@Qualifier(JDBC_TEMPLATE_SPRING_BEAN
class EnableSupervisorAdapter {

@DependsOn(JobConstants.SPRING_BEAN_NAME_CURRENT_SUPERVISOR)
@ConditionalOnMissingBean
@Bean
public SupervisorRpcService supervisorRpcService(DistributedJobManager jobManager,
DistributedJobQuerier jobQuerier) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class EnableWorkerConfiguration {

@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)
@Order(Ordered.HIGHEST_PRECEDENCE)
@ConditionalOnMissingBean
@Bean(JobConstants.SPRING_BEAN_NAME_TIMING_WHEEL)
public TaskTimingWheel timingWheel(WorkerProperties config) {
return new TaskTimingWheel(config.getTimingWheelTickMs(), config.getTimingWheelRingSize());
Expand All @@ -72,7 +71,6 @@ public TaskTimingWheel timingWheel(WorkerProperties config) {
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)
@Order(Ordered.HIGHEST_PRECEDENCE)
@DependsOn(JobConstants.SPRING_BEAN_NAME_TIMING_WHEEL)
@ConditionalOnMissingBean
@Bean(JobConstants.SPRING_BEAN_NAME_CURRENT_WORKER)
public Worker.Current currentWorker(@Value("${" + JobConstants.SPRING_WEB_SERVER_PORT + "}") int port,
@Value("${" + JobConstants.DISJOB_BOUND_SERVER_HOST + ":}") String boundHost,
Expand All @@ -93,7 +91,6 @@ public Worker.Current currentWorker(@Value("${" + JobConstants.SPRING_WEB_SERVER
}

@DependsOn(JobConstants.SPRING_BEAN_NAME_CURRENT_WORKER)
@ConditionalOnMissingBean
@Bean
public WorkerRpcService workerRpcService(Worker.Current currentWork,
WorkerRegistry registry) {
Expand Down

0 comments on commit c41cdba

Please sign in to comment.