mirror of
https://github.com/PowerJob/PowerJob.git
synced 2025-07-17 00:00:04 +08:00
feat: optimize code of BuiltInSpringProcessorFactory
This commit is contained in:
parent
cc7a63c69f
commit
4d2e037107
@ -52,4 +52,18 @@ public class SpringUtils {
|
||||
return (T) ctx.getBean(beanName0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否处在 Spring 环境中
|
||||
* @return true or false
|
||||
*/
|
||||
public static boolean inSpringEnv() {
|
||||
try {
|
||||
ApplicationContext.class.getClassLoader();
|
||||
return true;
|
||||
} catch (Throwable ignore) {
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -55,13 +55,10 @@ public class BuiltInSpringProcessorFactory implements ProcessorFactory {
|
||||
}
|
||||
|
||||
private boolean checkCanLoad() {
|
||||
try {
|
||||
ApplicationContext.class.getClassLoader();
|
||||
} catch (NoClassDefFoundError ndf) {
|
||||
return false;
|
||||
if (SpringUtils.inSpringEnv()) {
|
||||
return applicationContext != null;
|
||||
}
|
||||
|
||||
return applicationContext != null;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user