diff --git a/task-schedule-demo/src/main/java/com/tencent/cloud/task/factory/SpringExecuteTaskFactory.java b/task-schedule-demo/src/main/java/com/tencent/cloud/task/factory/SpringExecuteTaskFactory.java index cec97cc..1127bf7 100644 --- a/task-schedule-demo/src/main/java/com/tencent/cloud/task/factory/SpringExecuteTaskFactory.java +++ b/task-schedule-demo/src/main/java/com/tencent/cloud/task/factory/SpringExecuteTaskFactory.java @@ -1,10 +1,7 @@ package com.tencent.cloud.task.factory; -import com.tencent.cloud.task.sdk.client.DefaultTaskFactory; -import com.tencent.cloud.task.sdk.client.exception.InstancingException; -import com.tencent.cloud.task.sdk.client.model.ExecutableTaskData; -import com.tencent.cloud.task.sdk.client.spi.ExecutableTask; -import com.tencent.cloud.task.sdk.client.spi.ExecutableTaskFactory; +import java.lang.invoke.MethodHandles; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeansException; @@ -12,7 +9,11 @@ import org.springframework.context.ApplicationContextAware; import org.springframework.stereotype.Component; -import java.lang.invoke.MethodHandles; +import com.tencent.cloud.task.sdk.client.DefaultTaskFactory; +import com.tencent.cloud.task.sdk.client.exception.InstancingException; +import com.tencent.cloud.task.sdk.client.model.ExecutableTaskData; +import com.tencent.cloud.task.sdk.client.spi.ExecutableTask; +import com.tencent.cloud.task.sdk.client.spi.ExecutableTaskFactory; @Component public class SpringExecuteTaskFactory implements ExecutableTaskFactory, ApplicationContextAware { @@ -26,11 +27,11 @@ public class SpringExecuteTaskFactory implements ExecutableTaskFactory, Applicat @Override public ExecutableTask newExecutableTask(ExecutableTaskData executableTaskData) throws InstancingException { try { - ExecutableTask executableTask = (ExecutableTask)applicationContext.getBean(Class.forName(executableTaskData.getTaskContent())); - applicationContext.getBean(executableTaskData.getTaskContent(),ExecutableTask.class); + ExecutableTask executableTask = (ExecutableTask) applicationContext.getBean(Class.forName(executableTaskData.getTaskContent())); LOG.info("generate executableTask bean SpringExecutableTaskFactory. taskName: {}", executableTaskData.getTaskContent()); return executableTask; } catch (Throwable t) { + LOG.warn("executableTask bean not found, try default factory. taskName: {}", executableTaskData.getTaskContent()); return defaultFactory.newExecutableTask(executableTaskData); } }