优化 solon 的适配

This commit is contained in:
noear
2024-05-11 13:45:40 +08:00
parent 89a69e5624
commit 1ab5bbe3d6
2 changed files with 15 additions and 21 deletions

View File

@@ -24,7 +24,6 @@ import org.noear.solon.annotation.Condition;
import org.noear.solon.annotation.Configuration;
import org.noear.solon.annotation.Inject;
import org.noear.solon.core.AppContext;
import org.noear.solon.core.bean.InitializingBean;
/**
* @author noear
@@ -33,12 +32,9 @@ import org.noear.solon.core.bean.InitializingBean;
@Condition(onClass = SaOAuth2Manager.class)
@Configuration
public class SaOAuth2AutoConfigure implements InitializingBean {
@Inject
private AppContext appContext;
@Override
public void afterInjection() throws Throwable {
public class SaOAuth2AutoConfigure {
@Bean
public void init(AppContext appContext) throws Throwable {
appContext.subBeansOfType(SaOAuth2Template.class, bean -> {
SaOAuth2Util.saOAuth2Template = bean;
});

View File

@@ -36,39 +36,37 @@ import org.noear.solon.core.bean.InitializingBean;
@Condition(onClass = SaSsoManager.class)
@Configuration
public class SaSsoAutoConfigure implements InitializingBean {
@Inject
private AppContext appContext;
@Override
public void afterInjection() throws Throwable {
appContext.subBeansOfType(SaSsoServerTemplate.class, bean->{
public class SaSsoAutoConfigure {
@Bean
public void init(AppContext appContext) throws Throwable {
appContext.subBeansOfType(SaSsoServerTemplate.class, bean -> {
SaSsoServerProcessor.instance.ssoServerTemplate = bean;
});
appContext.subBeansOfType(SaSsoClientTemplate.class, bean->{
appContext.subBeansOfType(SaSsoClientTemplate.class, bean -> {
SaSsoClientProcessor.instance.ssoClientTemplate = bean;
});
appContext.subBeansOfType(SaSsoServerConfig.class, bean->{
appContext.subBeansOfType(SaSsoServerConfig.class, bean -> {
SaSsoManager.setServerConfig(bean);
});
appContext.subBeansOfType(SaSsoClientConfig.class, bean->{
appContext.subBeansOfType(SaSsoClientConfig.class, bean -> {
SaSsoManager.setClientConfig(bean);
});
}
/**
* 获取 SSO Server 配置Bean
* */
*/
@Bean
public SaSsoServerConfig getConfig(@Inject(value = "${sa-token.sso-server}",required = false) SaSsoServerConfig ssoConfig) {
public SaSsoServerConfig getConfig(@Inject(value = "${sa-token.sso-server}", required = false) SaSsoServerConfig ssoConfig) {
return ssoConfig;
}
/**
* 获取 SSO Client 配置Bean
* */
*/
@Bean
public SaSsoClientConfig getClientConfig(@Inject(value = "${sa-token.sso-client}",required = false) SaSsoClientConfig ssoConfig) {
public SaSsoClientConfig getClientConfig(@Inject(value = "${sa-token.sso-client}", required = false) SaSsoClientConfig ssoConfig) {
return ssoConfig;
}
}