T getAopProxy(T invoker) {
+ return (T) AopContext.currentProxy();
+ }
+
+ /**
+ * 获取{@link ConfigurableListableBeanFactory}
+ *
+ * @return {@link ConfigurableListableBeanFactory}
+ * @throws Admin4jException 当上下文非ConfigurableListableBeanFactory抛出异常
+ * @since 5.7.7
+ */
+ public static ConfigurableListableBeanFactory getConfigurableBeanFactory() {
+ final ConfigurableListableBeanFactory factory;
+ if (null != beanFactory) {
+ factory = beanFactory;
+ } else if (applicationContext instanceof ConfigurableApplicationContext) {
+ factory = ((ConfigurableApplicationContext) applicationContext).getBeanFactory();
+ } else {
+ throw new RuntimeException("No ConfigurableListableBeanFactory from context!");
+ }
+ return factory;
+ }
+
+ /**
+ * 获取配置文件配置项的值
+ *
+ * @param key 配置项key
+ * @return 属性值
+ */
+ public static String getProperty(String key) {
+ if (null == applicationContext) {
+ return null;
+ }
+ return applicationContext.getEnvironment().getProperty(key);
+ }
+
+ public static String getProperty(String key, String defaultValue) {
+ if (null == applicationContext) {
+ return null;
+ }
+ return applicationContext.getEnvironment().getProperty(key, defaultValue);
+ }
+
+ /**
+ * 获取应用程序名称
+ *
+ * @return 应用程序名称
+ */
+ public static String getApplicationName() {
+ return getProperty("spring.application.name");
+ }
+
+ /**
+ * 获取当前的环境配置,无配置返回null
+ *
+ * @return 当前的环境配置
+ */
+ public static String[] getActiveProfiles() {
+ if (null == applicationContext) {
+ return null;
+ }
+ return applicationContext.getEnvironment().getActiveProfiles();
+ }
+
+ /**
+ * 获取当前的环境配置,当有多个环境配置时,只获取第一个
+ *
+ * @return 当前的环境配置
+ */
+ public static String getActiveProfile() {
+ final String[] activeProfiles = getActiveProfiles();
+ return ObjectUtils.isEmpty(activeProfiles) ? Objects.requireNonNull(activeProfiles)[0] : null;
+ }
+
+ /**
+ * 动态向Spring注册Bean
+ *
+ * 由{@link org.springframework.beans.factory.BeanFactory} 实现,通过工具开放API
+ *
+ *
+ * @param Bean类型
+ * @param beanName 名称
+ * @param bean bean
+ */
+ public static void registerBean(String beanName, T bean) {
+ final ConfigurableListableBeanFactory factory = getConfigurableBeanFactory();
+ factory.autowireBean(bean);
+ factory.registerSingleton(beanName, bean);
+ }
+
+ /**
+ * 注销bean
+ *
+ * 将Spring中的bean注销,请谨慎使用
+ *
+ * @param beanName bean名称
+ */
+ public static void unregisterBean(String beanName) {
+ final ConfigurableListableBeanFactory factory = getConfigurableBeanFactory();
+ if (factory instanceof DefaultSingletonBeanRegistry) {
+ DefaultSingletonBeanRegistry registry = (DefaultSingletonBeanRegistry) factory;
+ registry.destroySingleton(beanName);
+ } else {
+ throw new RuntimeException("Can not unregister bean, the factory is not a DefaultSingletonBeanRegistry!");
+ }
+ }
+}
diff --git a/components/pom.xml b/components/pom.xml
index 12fb1c0..a52011b 100644
--- a/components/pom.xml
+++ b/components/pom.xml
@@ -26,6 +26,7 @@
fluent-datafactory
fluent-testlibs
fleunt-clients
+ fluent-spring
diff --git a/docs/references.yaml b/docs/references.yaml
index 79adeaf..d922654 100644
--- a/docs/references.yaml
+++ b/docs/references.yaml
@@ -4,4 +4,7 @@ blogs:
- https://github.com/camunda/camunda-bpm-platform.git
resources:
- - https://itnext.io/
\ No newline at end of file
+ - https://itnext.io/
+
+build-in:
+ - https://github.com/admin4j/admin4j-framework.git
\ No newline at end of file
diff --git a/fluent-apps/qaserver/src/main/java/io/fluentqa/jobs/GithubStarredCollectorJob.java b/fluent-apps/qaserver/src/main/java/io/fluentqa/jobs/GithubStarredCollectorJob.java
index 7407de7..12d132b 100644
--- a/fluent-apps/qaserver/src/main/java/io/fluentqa/jobs/GithubStarredCollectorJob.java
+++ b/fluent-apps/qaserver/src/main/java/io/fluentqa/jobs/GithubStarredCollectorJob.java
@@ -5,6 +5,7 @@
import io.fluentqa.github.service.GithubService;
import io.fluentqa.jobs.github.GithubJobFetchParameters;
import lombok.extern.slf4j.Slf4j;
+import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import xyz.erupt.core.annotation.EruptHandlerNaming;
import xyz.erupt.job.handler.EruptJobHandler;
@@ -23,18 +24,17 @@ public class GithubStarredCollectorJob implements EruptJobHandler {
* @param code 任务编码
* @param param 任务参数
*/
+
@Override
public String exec(String code, String param) {
log.info("start job %s with parameter %s".formatted(code,param));
GithubJobFetchParameters parameters ;
- List userNames = new ArrayList<>();
if(StringUtils.isAllEmpty(param)){
parameters = new GithubJobFetchParameters();
}else {
parameters = JSONUtil.toBean(param, GithubJobFetchParameters.class);
}
- //TODO: make it async
- userNames=StringUtils.split(parameters.getUserNames(),",");
+ List userNames=StringUtils.split(parameters.getUserNames(),",");
for (String userName : userNames) {
githubService.saveUserStarredRepo(userName,parameters.getFromPage());
}