소스 검색

change to autowired annotation (#8240)

yimaixinchen 3 년 전
부모
커밋
896dec21e7

+ 4 - 10
dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/HostUpdateProcessor.java

@@ -17,22 +17,19 @@
 
 package org.apache.dolphinscheduler.server.worker.processor;
 
+import com.google.common.base.Preconditions;
+import io.netty.channel.Channel;
 import org.apache.dolphinscheduler.common.utils.JSONUtils;
 import org.apache.dolphinscheduler.remote.command.Command;
 import org.apache.dolphinscheduler.remote.command.CommandType;
 import org.apache.dolphinscheduler.remote.command.HostUpdateCommand;
 import org.apache.dolphinscheduler.remote.processor.NettyRemoteChannel;
 import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
-import org.apache.dolphinscheduler.service.bean.SpringApplicationContext;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import com.google.common.base.Preconditions;
-
-import io.netty.channel.Channel;
-
 /**
  * update process host
  * this used when master failover
@@ -45,6 +42,7 @@ public class HostUpdateProcessor implements NettyRequestProcessor {
     /**
      * task callback service
      */
+    @Autowired
     private TaskCallbackService taskCallbackService;
 
     @Override
@@ -52,10 +50,6 @@ public class HostUpdateProcessor implements NettyRequestProcessor {
         Preconditions.checkArgument(CommandType.PROCESS_HOST_UPDATE_REQUEST == command.getType(), String.format("invalid command type : %s", command.getType()));
         HostUpdateCommand updateCommand = JSONUtils.parseObject(command.getBody(), HostUpdateCommand.class);
         logger.info("received host update command : {}", updateCommand);
-
-        if (taskCallbackService == null) {
-            taskCallbackService = SpringApplicationContext.getBean(TaskCallbackService.class);
-        }
         taskCallbackService.changeRemoteChannel(updateCommand.getTaskInstanceId(), new NettyRemoteChannel(channel, command.getOpaque()));
 
     }