Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix tct demo getBean use invalid name #44

Open
wants to merge 2 commits into
base: release/1.23-greenwich
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
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;
import org.springframework.context.ApplicationContext;
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 {
Expand All @@ -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);
}
}
Expand Down