diff --git a/caf-boot-autoconfigure/pom.xml b/caf-boot-autoconfigure/pom.xml index bfa6df26bb32ffcf22e54a771a01c7b2760956ac..1d377366f7df4d3c14265792f771c5b110d6e74a 100644 --- a/caf-boot-autoconfigure/pom.xml +++ b/caf-boot-autoconfigure/pom.xml @@ -29,7 +29,7 @@ io.iec.edp - caf-commons-utils + caf-commons-serialization io.iec.edp diff --git a/caf-boot-parent/pom.xml b/caf-boot-parent/pom.xml index f6f17687b4e3e17d17dcbdaf7620992d3c755607..cbc18d069c3c57fcd158221e83cb230bef6ca501 100644 --- a/caf-boot-parent/pom.xml +++ b/caf-boot-parent/pom.xml @@ -194,6 +194,16 @@ caf-boot-autoconfigure ${caf-framework.version} + + io.iec.edp + caf-boot-starter-i18n-provider + ${caf-framework.version} + + + io.iec.edp + caf-boot-starter-session-provider + ${caf-framework.version} + diff --git a/caf-boot-starters/caf-boot-starter-base/pom.xml b/caf-boot-starters/caf-boot-starter-base/pom.xml index 0b85714d7de06e889d5663406139458bfbb9165f..fc7d98c908d99e661d91db72f9c8e189f73a146e 100644 --- a/caf-boot-starters/caf-boot-starter-base/pom.xml +++ b/caf-boot-starters/caf-boot-starter-base/pom.xml @@ -50,19 +50,7 @@ io.iec.edp - caf-commons-serialization-core - - - io.iec.edp - caf-commons-serialization-json - - - io.iec.edp - caf-commons-serialization-protobuf - - - io.iec.edp - caf-commons-utils + caf-commons-serialization diff --git a/caf-boot-starters/caf-boot-starter-context/pom.xml b/caf-boot-starters/caf-boot-starter-context/pom.xml index 11ff1596c91841cc6fb73a7241384e04c11af77f..8f2d857fe8553243fb78961130175ebadae5d24c 100644 --- a/caf-boot-starters/caf-boot-starter-context/pom.xml +++ b/caf-boot-starters/caf-boot-starter-context/pom.xml @@ -64,5 +64,9 @@ io.iec.edp caf-rest-server + + io.iec.edp + caf-tenancy-core + diff --git a/caf-boot-starters/caf-boot-starter-context/src/main/java/io/iec/edp/caf/context/config/BizContextAutoConfiguration.java b/caf-boot-starters/caf-boot-starter-context/src/main/java/io/iec/edp/caf/context/config/BizContextAutoConfiguration.java index ca33be05fa0816bb6a3d0686e30b0a9fe9d9e32c..d47abd4b18125b7d6d92503e9c6e3436c21bd1bc 100644 --- a/caf-boot-starters/caf-boot-starter-context/src/main/java/io/iec/edp/caf/context/config/BizContextAutoConfiguration.java +++ b/caf-boot-starters/caf-boot-starter-context/src/main/java/io/iec/edp/caf/context/config/BizContextAutoConfiguration.java @@ -21,6 +21,7 @@ import io.iec.edp.caf.boot.context.event.FilterInvokeEventBroker; import io.iec.edp.caf.commons.event.config.EventListenerSettings; import io.iec.edp.caf.commons.runtime.redis.properties.CafRedisConfiguration; import io.iec.edp.caf.commons.transaction.service.DBTransactionService; +import io.iec.edp.caf.context.AuditorAwareImpl; import io.iec.edp.caf.context.core.BizContextUpdateService; import io.iec.edp.caf.context.core.listener.CafSessionExpiredEventListener; import io.iec.edp.caf.context.dist.RedisBizContextManager; @@ -39,11 +40,13 @@ import org.springframework.beans.factory.InitializingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Lazy; +import org.springframework.data.domain.AuditorAware; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.data.redis.connection.RedisConnectionFactory; @@ -126,5 +129,11 @@ public class BizContextAutoConfiguration { return new CAFContextFilter(contextManager, filterInvokeEventBroker, properties, suAware, tenantResolveContributor, dbTransactionService); } + @Bean + @ConditionalOnProperty("caf-boot.persistence.gsp-cloud.compatibility-mode") + public AuditorAware cafAuditorAware(ICAFContextService context) { + return new AuditorAwareImpl(context); + } + } diff --git a/caf-boot-starters/caf-boot-starter-data/src/main/java/io/iec/edp/caf/data/AuditorAwareImpl.java b/caf-boot-starters/caf-boot-starter-context/src/main/java/io/iec/edp/caf/data/AuditorAwareImpl.java similarity index 100% rename from caf-boot-starters/caf-boot-starter-data/src/main/java/io/iec/edp/caf/data/AuditorAwareImpl.java rename to caf-boot-starters/caf-boot-starter-context/src/main/java/io/iec/edp/caf/data/AuditorAwareImpl.java diff --git a/caf-boot-starters/caf-boot-starter-data/pom.xml b/caf-boot-starters/caf-boot-starter-data/pom.xml index 63341d43ec45a5eee3c4cced70875f231bbbaa38..cfbc555fbb690ac35f3a76093b2a4a75b715d5fc 100644 --- a/caf-boot-starters/caf-boot-starter-data/pom.xml +++ b/caf-boot-starters/caf-boot-starter-data/pom.xml @@ -29,14 +29,6 @@ - - io.iec.edp - caf-data-entity - - - io.iec.edp - caf-data-entity-service - io.iec.edp caf-data-jdbc @@ -45,25 +37,13 @@ io.iec.edp caf-data-jpa - - io.iec.edp - caf-data-source - - - io.iec.edp - caf-data-transaction - - - io.iec.edp - caf-context-api - io.iec.edp caf-commons-exception io.iec.edp - caf-commons-utils + caf-commons-runtime diff --git a/caf-boot-starters/caf-boot-starter-data/src/main/java/io/iec/edp/caf/data/config/CAFPersistenceAutoConfiguration.java b/caf-boot-starters/caf-boot-starter-data/src/main/java/io/iec/edp/caf/data/config/CAFPersistenceAutoConfiguration.java index dbbe02b1e7fe13974a5d40fff69c5151aa00fd08..6e956d6766feb18190e4c17325bb5a9ffe996bb3 100644 --- a/caf-boot-starters/caf-boot-starter-data/src/main/java/io/iec/edp/caf/data/config/CAFPersistenceAutoConfiguration.java +++ b/caf-boot-starters/caf-boot-starter-data/src/main/java/io/iec/edp/caf/data/config/CAFPersistenceAutoConfiguration.java @@ -18,20 +18,16 @@ package io.iec.edp.caf.data.config; import io.iec.caf.data.jpa.repository.support.event.CafJpaRepositoryPublish; -import io.iec.edp.caf.boot.context.event.FilterInvokeEventBroker; +import io.iec.edp.caf.commons.runtime.msu.ServiceUnitConfigService; import io.iec.edp.caf.commons.transaction.service.DBTransactionService; -import io.iec.edp.caf.core.context.ICAFContextService; -import io.iec.edp.caf.data.AuditorAwareImpl; import io.iec.edp.caf.data.filter.CAFDataFilter; import io.iec.edp.caf.data.orm.jpa.CAFImplicitNamingStrategy; import io.iec.edp.caf.data.orm.jpa.CAFPhysicalNamingStrategy; -import io.iec.edp.caf.msu.api.ServiceUnitAwareService; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.data.domain.AuditorAware; /** * This is {@link CAFPersistenceAutoConfiguration}. @@ -57,17 +53,16 @@ public class CAFPersistenceAutoConfiguration { return new CAFPhysicalNamingStrategy(); } - @Bean - @ConditionalOnProperty("caf-boot.persistence.gsp-cloud.compatibility-mode") - public AuditorAware cafAuditorAware(ICAFContextService context) { - return new AuditorAwareImpl(context); - } +// @Bean +// @ConditionalOnProperty("caf-boot.persistence.gsp-cloud.compatibility-mode") +// public AuditorAware cafAuditorAware(ICAFContextService context) { +// return new AuditorAwareImpl(context); +// } @Bean - public CAFDataFilter cafDataFilter(FilterInvokeEventBroker filterInvokeEventBroker, - ServiceUnitAwareService suAware, + public CAFDataFilter cafDataFilter(ServiceUnitConfigService suAware, DBTransactionService dbTransactionService) { - return new CAFDataFilter(filterInvokeEventBroker, suAware,dbTransactionService); + return new CAFDataFilter(suAware,dbTransactionService); } @Bean diff --git a/caf-boot-starters/caf-boot-starter-data/src/main/java/io/iec/edp/caf/data/filter/CAFDataFilter.java b/caf-boot-starters/caf-boot-starter-data/src/main/java/io/iec/edp/caf/data/filter/CAFDataFilter.java index c139609089bcdbfe3a8fcd1ae98a7de91821c4c2..67f1a7d14d938b70016320288d69c40be378277c 100644 --- a/caf-boot-starters/caf-boot-starter-data/src/main/java/io/iec/edp/caf/data/filter/CAFDataFilter.java +++ b/caf-boot-starters/caf-boot-starter-data/src/main/java/io/iec/edp/caf/data/filter/CAFDataFilter.java @@ -17,13 +17,12 @@ package io.iec.edp.caf.data.filter; -import io.iec.edp.caf.boot.context.event.FilterInvokeEventBroker; import io.iec.edp.caf.commons.exception.CAFRuntimeException; +import io.iec.edp.caf.commons.runtime.msu.ServiceUnitConfigService; import io.iec.edp.caf.commons.transaction.service.DBTransactionService; import io.iec.edp.caf.data.orm.jpa.DynamicTableContext; import io.iec.edp.caf.data.orm.jpa.DynamticTableInfo; import io.iec.edp.caf.database.DatabaseManager; -import io.iec.edp.caf.msu.api.ServiceUnitAwareService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.lang.NonNull; @@ -46,19 +45,17 @@ import java.util.*; public class CAFDataFilter extends OncePerRequestFilter { private Map suNames; - private ServiceUnitAwareService suAware; + private ServiceUnitConfigService suAware; private DBTransactionService dbTransactionService; private final Logger logger = LoggerFactory.getLogger(CAFDataFilter.class); - private final FilterInvokeEventBroker filterInvokeEventBroker; - public CAFDataFilter(FilterInvokeEventBroker filterInvokeEventBroker, - ServiceUnitAwareService suAware, + + public CAFDataFilter(ServiceUnitConfigService suAware, DBTransactionService dbTransactionService){ - this.filterInvokeEventBroker = filterInvokeEventBroker; this.suAware = suAware; this.dbTransactionService = dbTransactionService; suNames = new HashMap<>(); - for (String name : this.suAware.getEnabledServiceUnits()) { + for (String name : this.suAware.getEnableSu()) { suNames.put(name.toLowerCase(), name); } } diff --git a/caf-boot-starters/caf-boot-starter-i18n-provider/pom.xml b/caf-boot-starters/caf-boot-starter-i18n-provider/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..b52b9ca6efeb9b87be9796d1f9f5d8540630bb82 --- /dev/null +++ b/caf-boot-starters/caf-boot-starter-i18n-provider/pom.xml @@ -0,0 +1,39 @@ + + + + + + caf-boot-starters + io.iec.edp + 1.5.0-SNAPSHOT + + 4.0.0 + + caf-boot-starter-i18n-provider + + + + + io.iec.edp + caf-i18n-provider + + + + diff --git a/caf-boot-starters/caf-boot-starter-i18n-provider/src/main/java/io/iec/edp/caf/i18n/config/I18nProviderConfig.java b/caf-boot-starters/caf-boot-starter-i18n-provider/src/main/java/io/iec/edp/caf/i18n/config/I18nProviderConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..46b23d462b36b4ef3fee801180672036d53d7a2d --- /dev/null +++ b/caf-boot-starters/caf-boot-starter-i18n-provider/src/main/java/io/iec/edp/caf/i18n/config/I18nProviderConfig.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.i18n.config; + +import io.iec.edp.caf.i18n.framework.api.language.ILanguageService; +import io.iec.edp.caf.i18n.utils.CAFLanguageTranslator; +import io.iec.edp.caf.security.core.spring.language.LanguageTranslator; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * i18n-provider 配置类 + * + * @author manwenxing01 + */ +@Configuration(proxyBeanMethods = false) +public class I18nProviderConfig { + + @Bean + public LanguageTranslator defaultLanguageTranslator(ILanguageService languageService) { + return new CAFLanguageTranslator(languageService); + } + +} diff --git a/caf-boot-starters/caf-boot-starter-i18n-provider/src/main/resources/META-INF/spring.factories b/caf-boot-starters/caf-boot-starter-i18n-provider/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000000000000000000000000000000000000..64959e67baa8a704070d20160910f09371ea1972 --- /dev/null +++ b/caf-boot-starters/caf-boot-starter-i18n-provider/src/main/resources/META-INF/spring.factories @@ -0,0 +1,2 @@ +# Auto Configure +org.springframework.boot.autoconfigure.EnableAutoConfiguration=io.iec.edp.caf.i18n.config.I18nProviderConfig diff --git a/caf-boot-starters/caf-boot-starter-i18n/pom.xml b/caf-boot-starters/caf-boot-starter-i18n/pom.xml index ee0472c817cf68d278b304df14b2afe65cb5e2e0..71ddb067fff82b9b599f285745cbbe72b36f5123 100644 --- a/caf-boot-starters/caf-boot-starter-i18n/pom.xml +++ b/caf-boot-starters/caf-boot-starter-i18n/pom.xml @@ -36,18 +36,15 @@ io.iec.edp caf-i18n-runtime - - - com.fasterxml.jackson.core - jackson-databind - io.iec.edp caf-commons-exception + + - io.iec.edp - caf-security-api + com.fasterxml.jackson.core + jackson-databind diff --git a/caf-boot-starters/caf-boot-starter-i18n/src/main/java/io/iec/edp/caf/i18n/config/I18nConfig.java b/caf-boot-starters/caf-boot-starter-i18n/src/main/java/io/iec/edp/caf/i18n/config/I18nConfig.java index bf4e57272fa4cd4560bc204b5bee94187d119da9..b3fa8d5b3193ba7e65b0a1671cc5e84c4854a56e 100644 --- a/caf-boot-starters/caf-boot-starter-i18n/src/main/java/io/iec/edp/caf/i18n/config/I18nConfig.java +++ b/caf-boot-starters/caf-boot-starter-i18n/src/main/java/io/iec/edp/caf/i18n/config/I18nConfig.java @@ -27,8 +27,6 @@ import io.iec.edp.caf.i18n.framework.api.resource.IResourceLocalizer; import io.iec.edp.caf.i18n.framework.localclient.i18nresource.IResourceLocalizerImpl; import io.iec.edp.caf.i18n.framework.localclient.language.LanguageServiceImpl; import io.iec.edp.caf.i18n.manager.*; -import io.iec.edp.caf.i18n.utils.CAFLanguageTranslator; -import io.iec.edp.caf.security.core.spring.language.LanguageTranslator; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.context.annotation.Bean; @@ -75,8 +73,10 @@ public class I18nConfig { return new LanguageSuffixProviderImpl(); } + @ConditionalOnMissingBean({CurrentLanguageProvider.class}) @Bean - public LanguageTranslator defaultLanguageTranslator(ILanguageService languageService) { - return new CAFLanguageTranslator(languageService); + public CurrentLanguageProvider getCurrentLanguageProvider() { + return new CurrentLanguageProviderImpl(); } + } diff --git a/caf-boot-starters/caf-boot-starter-lock/pom.xml b/caf-boot-starters/caf-boot-starter-lock/pom.xml index 777ee3592ba7ab263cbda1543e2296a84ab98cf3..f9255b262e2af8508bf88288a591ff29bba55a59 100644 --- a/caf-boot-starters/caf-boot-starter-lock/pom.xml +++ b/caf-boot-starters/caf-boot-starter-lock/pom.xml @@ -30,23 +30,19 @@ io.iec.edp - caf-lock-service-api + caf-lock-api io.iec.edp - caf-lock-service-memory + caf-lock-memory io.iec.edp - caf-lock-service-redis + caf-lock-redis io.iec.edp - caf-context-api - - - io.iec.edp - caf-data-jpa + caf-lock-extension-jpa diff --git a/caf-boot-starters/caf-boot-starter-lock/src/main/java/io/iec/edp/caf/lock/config/LockServiceAutoConfiguration.java b/caf-boot-starters/caf-boot-starter-lock/src/main/java/io/iec/edp/caf/lock/config/LockServiceAutoConfiguration.java index 3ee73e3893047de46a29e2c58b91704d61f9f1e2..03ce6594683ba4ac7dd98f04659f2a96472af8b7 100644 --- a/caf-boot-starters/caf-boot-starter-lock/src/main/java/io/iec/edp/caf/lock/config/LockServiceAutoConfiguration.java +++ b/caf-boot-starters/caf-boot-starter-lock/src/main/java/io/iec/edp/caf/lock/config/LockServiceAutoConfiguration.java @@ -18,9 +18,9 @@ package io.iec.edp.caf.lock.config; import io.iec.caf.data.jpa.repository.config.EnableCafJpaRepositories; -import io.iec.edp.caf.core.context.*; -import io.iec.edp.caf.core.session.ICafSessionService; +import io.iec.edp.caf.lock.extension.jpa.JpaLockExtensionImpl; import io.iec.edp.caf.lock.service.api.api.DistributedLockFactory; +import io.iec.edp.caf.lock.service.api.api.LockExtension; import io.iec.edp.caf.lock.service.api.api.LockService; import io.iec.edp.caf.lock.service.api.repositories.BatchLockRepo; import io.iec.edp.caf.lock.service.api.repositories.LockRepo; @@ -86,11 +86,16 @@ public class LockServiceAutoConfiguration { return new MemoryLockFactoryImpl(); } + + @Bean + public LockExtension getLockExtension(LockRepo repo, BatchLockRepo batchRepo){ + return new JpaLockExtensionImpl(repo,batchRepo); + } @Bean //声明单例还是原型 @Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON) - public LockService getLockService(DistributedLockFactory factory, ICAFContextService context, BizContextManager bizContextManager, ICafSessionService sessionService, LockRepo repo, BatchLockRepo batchRepo) { - return new DistributedLockServiceImpl(factory, context, bizContextManager, sessionService,repo,batchRepo); + public LockService getLockService(DistributedLockFactory factory,LockExtension lockExtension) { + return new DistributedLockServiceImpl(factory, lockExtension); } @@ -98,7 +103,7 @@ public class LockServiceAutoConfiguration { @Bean // @ConditionalOnMissingBean @ConditionalOnExpression("#{!'false'.equals(environment['redis.enabled'])}") - public IDistributedLockFactory getOldStandardDistributedLockFactory(RedissonClient redisson,RedisLockProperties redisLockProperties) { + public IDistributedLockFactory getOldStandardDistributedLockFactory(RedissonClient redisson, RedisLockProperties redisLockProperties) { Config config = getRedissonConfig(redisson,redisLockProperties); return new DistributedLocksFactory(config); } @@ -112,8 +117,8 @@ public class LockServiceAutoConfiguration { @Bean //声明单例还是原型i @Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON) - public ILockService getOldLockService(DistributedLockFactory factory, ICAFContextService context, BizContextManager bizContextManager, ICafSessionService sessionService, LockRepo repo, BatchLockRepo batchRepo) { - return new DistributedLockService(factory, context, bizContextManager, sessionService,repo,batchRepo); + public ILockService getOldLockService(DistributedLockFactory factory, LockExtension lockExtension) { + return new DistributedLockService(factory,lockExtension); } private InputStream getConfigStream(String config) throws IOException { diff --git a/caf-boot-starters/caf-boot-starter-rest/pom.xml b/caf-boot-starters/caf-boot-starter-rest/pom.xml index 4da5092f2765c44ddb9b41c8eb10a05da29611c5..efab44c876091e06e3e25740a834466e240f54f0 100644 --- a/caf-boot-starters/caf-boot-starter-rest/pom.xml +++ b/caf-boot-starters/caf-boot-starter-rest/pom.xml @@ -40,10 +40,6 @@ io.iec.edp caf-rest-server - - io.iec.edp - caf-multicontext - org.springframework.boot diff --git a/caf-boot-starters/caf-boot-starter-rest/src/main/java/io/iec/edp/caf/rest/filter/ServiceNotFoundFilter.java b/caf-boot-starters/caf-boot-starter-rest/src/main/java/io/iec/edp/caf/rest/filter/ServiceNotFoundFilter.java index 5e983b154d83b18e3395beddf1ea2512293ee473..a55eeaf38a952c2e0f2e8f3a589aa0f3c227ea3f 100644 --- a/caf-boot-starters/caf-boot-starter-rest/src/main/java/io/iec/edp/caf/rest/filter/ServiceNotFoundFilter.java +++ b/caf-boot-starters/caf-boot-starter-rest/src/main/java/io/iec/edp/caf/rest/filter/ServiceNotFoundFilter.java @@ -1,6 +1,6 @@ package io.iec.edp.caf.rest.filter; import lombok.extern.slf4j.Slf4j; -import org.jetbrains.annotations.NotNull; +//import org.jetbrains.annotations.NotNull; import org.springframework.web.filter.OncePerRequestFilter; import javax.servlet.*; @@ -19,7 +19,7 @@ public class ServiceNotFoundFilter extends OncePerRequestFilter { private static boolean isFinishRegistered = false; @Override - protected void doFilterInternal(@NotNull HttpServletRequest request, @NotNull HttpServletResponse httpResponse, FilterChain filterChain) throws ServletException, IOException { + protected void doFilterInternal(HttpServletRequest request, HttpServletResponse httpResponse, FilterChain filterChain) throws ServletException, IOException { filterChain.doFilter(request, httpResponse); if(isFinishRegistered) return; diff --git a/caf-boot-starters/caf-boot-starter-security/pom.xml b/caf-boot-starters/caf-boot-starter-security/pom.xml index 4ded7ad0168370facff1b777547e0f0954c9cfba..7b12483bc865a1c2d5613986b358d91c64581f2d 100644 --- a/caf-boot-starters/caf-boot-starter-security/pom.xml +++ b/caf-boot-starters/caf-boot-starter-security/pom.xml @@ -31,17 +31,18 @@ io.iec.edp - caf-session-core + caf-security-api io.iec.edp - caf-session-web + caf-commons-runtime + + - io.iec.edp - caf-security-api + org.springframework.security + spring-security-config - jakarta.servlet jakarta.servlet-api diff --git a/caf-boot-starters/caf-boot-starter-session-provider/pom.xml b/caf-boot-starters/caf-boot-starter-session-provider/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..885ace160abf0ac416a7b83daf7a1fde912f21df --- /dev/null +++ b/caf-boot-starters/caf-boot-starter-session-provider/pom.xml @@ -0,0 +1,49 @@ + + + + + + caf-boot-starters + io.iec.edp + 1.5.0-SNAPSHOT + + 4.0.0 + + caf-boot-starter-session-provider + + + + + io.iec.edp + caf-session-provider + + + io.iec.edp + caf-rest-api + + + + + org.springframework.boot + spring-boot-autoconfigure + + + + diff --git a/caf-boot-starters/caf-boot-starter-session-provider/src/main/java/io/iec/edp/caf/session/config/CafSessionProviderConfiguration.java b/caf-boot-starters/caf-boot-starter-session-provider/src/main/java/io/iec/edp/caf/session/config/CafSessionProviderConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..fb07547eee98ae5eac5c78a8ed64d46bda442f56 --- /dev/null +++ b/caf-boot-starters/caf-boot-starter-session-provider/src/main/java/io/iec/edp/caf/session/config/CafSessionProviderConfiguration.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.iec.edp.caf.session.config; + +import io.iec.edp.caf.core.session.filter.SessionRpcClientFilter; +import io.iec.edp.caf.core.session.filter.SessionRpcServerFilter; +import io.iec.edp.caf.core.session.service.CafSessionService; +import io.iec.edp.caf.core.session.service.Impl.CafSessionServiceHelper; +import io.iec.edp.caf.rest.RESTEndpoint; +import io.iec.edp.caf.rpc.api.filter.RpcClientFilter; +import io.iec.edp.caf.rpc.api.filter.RpcServerFilter; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * session provider配置类 + * + * @author manwenxing01 + */ +@Configuration(proxyBeanMethods = false) +public class CafSessionProviderConfiguration { + + @Bean + public RESTEndpoint cafSessionServiceHelperRest(CafSessionService sessionService) { + return new RESTEndpoint("/runtime/sys/v1.0/session", sessionService); + } + + @Bean + public CafSessionService cafSessionServiceHelper() { + return new CafSessionServiceHelper(); + } + + @Bean + public RpcServerFilter rpcSessionServerInterceptor() { + return new SessionRpcServerFilter(); + } + + @Bean + public RpcClientFilter rpcSessionClientInterceptor() { + return new SessionRpcClientFilter(); + } + +} diff --git a/caf-boot-starters/caf-boot-starter-session-provider/src/main/resources/META-INF/spring.factories b/caf-boot-starters/caf-boot-starter-session-provider/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000000000000000000000000000000000000..36c8f5f7f09ec601c7073fae2ecb927b1a1b3deb --- /dev/null +++ b/caf-boot-starters/caf-boot-starter-session-provider/src/main/resources/META-INF/spring.factories @@ -0,0 +1 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=io.iec.edp.caf.session.config.CafSessionProviderConfiguration diff --git a/caf-boot-starters/caf-boot-starter-session/pom.xml b/caf-boot-starters/caf-boot-starter-session/pom.xml index 3f1ef09d59e37d8442da25d34df9b69de3f63d90..e7a3fc4739cfaef2704e9f5641523406b630f8fe 100644 --- a/caf-boot-starters/caf-boot-starter-session/pom.xml +++ b/caf-boot-starters/caf-boot-starter-session/pom.xml @@ -31,21 +31,21 @@ io.iec.edp - caf-session-backend + caf-session-api io.iec.edp - caf-session-core + caf-session-backend io.iec.edp - caf-session-web + caf-session-core - io.iec.edp - caf-rest-api + caf-session-web + org.springframework diff --git a/caf-boot-starters/caf-boot-starter-session/src/main/java/io/iec/edp/caf/session/config/CafSessionAutoConfiguration.java b/caf-boot-starters/caf-boot-starter-session/src/main/java/io/iec/edp/caf/session/config/CafSessionAutoConfiguration.java index 846b400ca77d2571888ad1ed7c5b04950ceebadc..feebb854fda01cbcf322706ed8efeb0e94fb44cd 100644 --- a/caf-boot-starters/caf-boot-starter-session/src/main/java/io/iec/edp/caf/session/config/CafSessionAutoConfiguration.java +++ b/caf-boot-starters/caf-boot-starter-session/src/main/java/io/iec/edp/caf/session/config/CafSessionAutoConfiguration.java @@ -19,14 +19,7 @@ package io.iec.edp.caf.session.config; import io.iec.edp.caf.core.session.CafSessionServiceImpl; import io.iec.edp.caf.core.session.ICafSessionService; -import io.iec.edp.caf.core.session.filter.SessionRpcClientFilter; -import io.iec.edp.caf.core.session.filter.SessionRpcServerFilter; import io.iec.edp.caf.core.session.properties.CAFBootBSessionConfigurationProperties; -import io.iec.edp.caf.core.session.service.CafSessionService; -import io.iec.edp.caf.core.session.service.Impl.CafSessionServiceHelper; -import io.iec.edp.caf.rest.RESTEndpoint; -import io.iec.edp.caf.rpc.api.filter.RpcClientFilter; -import io.iec.edp.caf.rpc.api.filter.RpcServerFilter; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; @@ -52,23 +45,4 @@ public class CafSessionAutoConfiguration { return new CafSessionServiceImpl(repo); } - @Bean - public RESTEndpoint cafSessionServiceHelperRest(CafSessionService sessionService) { - return new RESTEndpoint("/runtime/sys/v1.0/session", sessionService); - } - - @Bean - public CafSessionService cafSessionServiceHelper() { - return new CafSessionServiceHelper(); - } - - @Bean - public RpcServerFilter rpcSessionServerInterceptor(){ - return new SessionRpcServerFilter(); - } - - @Bean - public RpcClientFilter rpcSessionClientInterceptor(){ - return new SessionRpcClientFilter(); - } } diff --git a/caf-boot-starters/caf-boot-starter-tenancy/pom.xml b/caf-boot-starters/caf-boot-starter-tenancy/pom.xml index d560624f55f30f1c9a051fd4506e4a6de8e74158..09b191e494998b0e0fce2f76c3e23224e42fde6e 100644 --- a/caf-boot-starters/caf-boot-starter-tenancy/pom.xml +++ b/caf-boot-starters/caf-boot-starter-tenancy/pom.xml @@ -38,7 +38,7 @@ io.iec.edp - caf-multicontext + caf-tenancy-repository-jpa diff --git a/caf-boot-starters/caf-boot-starter-tenancy/src/main/java/io/iec/edp/caf/tenancy/config/TenantAutoConfiguration.java b/caf-boot-starters/caf-boot-starter-tenancy/src/main/java/io/iec/edp/caf/tenancy/config/TenantAutoConfiguration.java index 79b1361d29762fcc8ac2251c449bbf6f85a67a76..cb7900474fa42e3c373416261dcf866a89342304 100644 --- a/caf-boot-starters/caf-boot-starter-tenancy/src/main/java/io/iec/edp/caf/tenancy/config/TenantAutoConfiguration.java +++ b/caf-boot-starters/caf-boot-starter-tenancy/src/main/java/io/iec/edp/caf/tenancy/config/TenantAutoConfiguration.java @@ -23,6 +23,7 @@ import io.iec.edp.caf.data.source.ConnectionProvider; import io.iec.edp.caf.data.source.DataSourceIdentifierResolver; import io.iec.edp.caf.multicontext.annotation.BeanCollector; import io.iec.edp.caf.tenancy.api.*; +import io.iec.edp.caf.tenancy.api.service.*; import io.iec.edp.caf.tenancy.core.TenantCache; import io.iec.edp.caf.tenancy.core.context.MultiTenantInterceptor; import io.iec.edp.caf.tenancy.core.event.DataSourceProcessingEventPublisher; @@ -67,25 +68,25 @@ public class TenantAutoConfiguration { } @Bean - public ClusterAppMgr appInstClusterRelationMgr(ClusterAppRepository instanceClusterRelationRepository, TenantCache tenantCache) + public ClusterAppService appInstClusterRelationMgr(ClusterAppRepository instanceClusterRelationRepository, TenantCache tenantCache) { return new ClusterAppMgr(instanceClusterRelationRepository, tenantCache); } @Bean - public DbConnectionManager dbConnectionManager(DbConnectionRepository repository, SuDbMappingRepository mappingRepository, TenantCache tenantCache) + public DbConnectionService dbConnectionManager(DbConnectionRepository repository, SuDbMappingRepository mappingRepository, TenantCache tenantCache) { return new DbConnectionManager(repository, mappingRepository, tenantCache); } @Bean - public DbMappingManager dbMappingManager(SuDbMappingRepository repository, TenantCache tenantCache) + public DbMappingService dbMappingManager(SuDbMappingRepository repository, TenantCache tenantCache) { return new DbMappingManager(repository, tenantCache); } @Bean - public ClusterManager instanceClusterManager(ClusterRepository repo, TenantCache tenantCache) + public ClusterService instanceClusterManager(ClusterRepository repo, TenantCache tenantCache) { return new ClusterManager(repo, tenantCache); } @@ -96,29 +97,30 @@ public class TenantAutoConfiguration { } @Bean - public TenantAppInstanceMgr tenantAppInstanceMgr(DbConnectionManager dbMgr, DbMappingManager mappingMgr, ClusterManager clusterManager, ClusterAppMgr relationManager, - AppInstanceRepository appRepository, TenantCache tenantCache) + public TenantAppInstanceService tenantAppInstanceMgr(DbConnectionService dbMgr, DbMappingService mappingMgr, ClusterService clusterManager, ClusterAppService relationManager, + AppInstanceRepository appRepository, TenantCache tenantCache) { return new TenantAppInstanceMgr(dbMgr, mappingMgr, clusterManager, relationManager, appRepository, tenantCache); } @Bean - public TenantManager tenantManager(TenantRepository repository, TenantCache tenantCache) + public TenantPersistenceService tenantManager(TenantRepository repository, TenantCache tenantCache,TenantAppInstanceService appInstMgr) { - return new TenantManager(repository, tenantCache); + return new TenantManager(repository, tenantCache,appInstMgr); } @ConditionalOnMissingBean(ITenantService.class) @Bean - public ITenantService tenantService(MultiTenantProperties properties, TenantManager tenantmgr, DbMappingManager dbMappingMgr, DbConnectionManager dbMgr, TenantAppInstanceMgr appInstMgr, ClusterManager clusterMgr) + public ITenantService tenantService(MultiTenantProperties properties, TenantPersistenceService tenantmgr, DbMappingService dbMappingMgr, DbConnectionService dbMgr, + TenantAppInstanceService appInstMgr, ClusterService clusterMgr) { return new TenantService(properties,tenantmgr, dbMappingMgr, dbMgr, appInstMgr, clusterMgr); } @Bean @BeanCollector - public ITenantRouteService tenantRouteService(List customRouters, TenantRoutingManager tenantRoutingManager) + public ITenantRouteService tenantRouteService(List customRouters, TenantRoutingService tenantRoutingManager) { return new TenantRouteServiceImpl(customRouters,tenantRoutingManager); } @@ -141,7 +143,7 @@ public class TenantAutoConfiguration { } @Bean - public TenantRoutingManager tenantRoutingManager(TenantRoutingRepository repository) { + public TenantRoutingService tenantRoutingManager(TenantRoutingRepository repository) { return new TenantRoutingManager(repository); } diff --git a/caf-boot-starters/caf-boot-starter-web/pom.xml b/caf-boot-starters/caf-boot-starter-web/pom.xml index 5b2bc3e869a5a6c78f03c056fefe1f3bfb61058d..6d3436b7d847502f1d4fc4c2c1dc0f74d773e1b0 100644 --- a/caf-boot-starters/caf-boot-starter-web/pom.xml +++ b/caf-boot-starters/caf-boot-starter-web/pom.xml @@ -56,10 +56,6 @@ io.iec.edp caf-commons-runtime - - io.iec.edp - caf-msu-common - com.bes.appserver diff --git a/caf-boot-starters/caf-boot-starter-web/src/main/java/io/iec/edp/caf/boot/starter/middleware/config/ServletSpringApplicationRunListener.java b/caf-boot-starters/caf-boot-starter-web/src/main/java/io/iec/edp/caf/boot/starter/middleware/config/ServletSpringApplicationRunListener.java index 1d1810b7b1f60781981cb4c8ae6d9dac607df038..d3a2474e7828f60a5ca9e1c5a573ebb6250998b6 100644 --- a/caf-boot-starters/caf-boot-starter-web/src/main/java/io/iec/edp/caf/boot/starter/middleware/config/ServletSpringApplicationRunListener.java +++ b/caf-boot-starters/caf-boot-starter-web/src/main/java/io/iec/edp/caf/boot/starter/middleware/config/ServletSpringApplicationRunListener.java @@ -18,14 +18,13 @@ package io.iec.edp.caf.boot.starter.middleware.config; import io.iec.edp.caf.app.manager.classloader.CAFClassLoader; +import io.iec.edp.caf.boot.starter.middleware.spi.utils.ClassLoaderResolverUtils; import io.iec.edp.caf.commons.runtime.CafEnvironment; import io.iec.edp.caf.commons.utils.JarUtil; -import io.iec.edp.caf.multicontext.classloader.PlatformClassloader; import lombok.var; import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplicationRunListener; -import org.springframework.boot.loader.LaunchedURLClassLoader; import org.springframework.context.ApplicationContext; import org.springframework.core.env.ConfigurableEnvironment; import sun.misc.URLClassPath; @@ -71,27 +70,28 @@ public class ServletSpringApplicationRunListener implements SpringApplicationRun Path path = Paths.get(CafEnvironment.getStartupPath(), "middleware", "servlet", container); URL[] urls = JarUtil.getJarPathFromDirPaths(path.toString()); ClassLoader cl = Thread.currentThread().getContextClassLoader(); + ClassLoaderResolverUtils.addUrl(cl,urls); //并行启动时,将URL加入平台底座 - if( cl instanceof PlatformClassloader){ - ((PlatformClassloader)cl).addPlatformURL(urls); - }else if(cl instanceof CAFClassLoader){ - //非并行启动时,将URL加入CAFClassLoader的父中 - CAFClassLoader cafClassLoader = (CAFClassLoader)cl; - this.addUrl((LaunchedURLClassLoader)cafClassLoader.getParent(),urls); - } +// if( cl instanceof PlatformClassloader){ +// ((PlatformClassloader)cl).addPlatformURL(urls); +// }else if(cl instanceof CAFClassLoader){ +// //非并行启动时,将URL加入CAFClassLoader的父中 +// CAFClassLoader cafClassLoader = (CAFClassLoader)cl; +// this.addUrl((LaunchedURLClassLoader)cafClassLoader.getParent(),urls); +// } } - private void addUrl(LaunchedURLClassLoader launchedURLClassLoader, URL[] urls) { - URLClassPath ucp; - try { - Field ucpField = URLClassLoader.class.getDeclaredField("ucp"); - ucpField.setAccessible(true); - ucp = (URLClassPath) ucpField.get(launchedURLClassLoader); - for (URL url : urls) { - ucp.addURL(url); - } - } catch (NoSuchFieldException | IllegalAccessException e) { - e.printStackTrace(); - } - } +// private void addUrl(LaunchedURLClassLoader launchedURLClassLoader, URL[] urls) { +// URLClassPath ucp; +// try { +// Field ucpField = URLClassLoader.class.getDeclaredField("ucp"); +// ucpField.setAccessible(true); +// ucp = (URLClassPath) ucpField.get(launchedURLClassLoader); +// for (URL url : urls) { +// ucp.addURL(url); +// } +// } catch (NoSuchFieldException | IllegalAccessException e) { +// e.printStackTrace(); +// } +// } } diff --git a/caf-boot-starters/caf-boot-starter-web/src/main/java/io/iec/edp/caf/boot/starter/middleware/spi/utils/ClassLoaderResolverUtils.java b/caf-boot-starters/caf-boot-starter-web/src/main/java/io/iec/edp/caf/boot/starter/middleware/spi/utils/ClassLoaderResolverUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..ff5375d0fffb61a8dcbaa82ed6be728a74936ccc --- /dev/null +++ b/caf-boot-starters/caf-boot-starter-web/src/main/java/io/iec/edp/caf/boot/starter/middleware/spi/utils/ClassLoaderResolverUtils.java @@ -0,0 +1,44 @@ +package io.iec.edp.caf.boot.starter.middleware.spi.utils; + +import io.iec.edp.caf.commons.runtime.CafEnvironment; +import io.iec.edp.caf.commons.runtime.env.enums.StartupMode; +import io.iec.edp.caf.middleware.spi.ClassUrlResolver; +import lombok.extern.slf4j.Slf4j; +import org.springframework.util.Assert; + +import java.net.URL; +import java.util.HashMap; +import java.util.Map; +import java.util.ServiceLoader; + +@Slf4j +public class ClassLoaderResolverUtils { + + private static Map ClassLoaderResolverMap = new HashMap(); + + private static ClassUrlResolver currentClassLoaderResolver = null; + + static { + ServiceLoader resolvers = ServiceLoader.load(ClassUrlResolver.class); + for (ClassUrlResolver resolver : resolvers) { + ClassLoaderResolverMap.put(resolver.getId(), resolver); + } + + if (CafEnvironment.getStartupMode() == StartupMode.Parallel) { + currentClassLoaderResolver = ClassLoaderResolverMap.get("1"); + } else { + currentClassLoaderResolver = ClassLoaderResolverMap.get("0"); + } + Assert.notNull(currentClassLoaderResolver, "[currentClassLoaderResolver] is null, please check."); + } + + + public static void addUrl(ClassLoader cl, URL[] urls){ + if (log.isDebugEnabled()) { + log.debug("CurrentClassLoaderResolver type [{}].", currentClassLoaderResolver.getClass().getName()); + } + currentClassLoaderResolver.addUrl(cl,urls); + } + + +} diff --git a/caf-boot-starters/pom.xml b/caf-boot-starters/pom.xml index a7dedceb3c919164ca6a760cf875a6f851b0050d..0cd22e59b71a40b63a94e699b28e054abaa79c52 100644 --- a/caf-boot-starters/pom.xml +++ b/caf-boot-starters/pom.xml @@ -48,6 +48,8 @@ caf-boot-starter-msu caf-boot-starter-logging caf-boot-starter-provider + caf-boot-starter-session-provider + caf-boot-starter-i18n-provider diff --git a/pom.xml b/pom.xml index 88d6bb953fbd9dae0b68d464ca1c6005fbb7cb6a..d75950caa58d92ec791644e7c32f2df0272f008f 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ 1.8 2.4.13 5.3.26 - 1.5.0-rc.4 + 1.7.0-SNAPSHOT https://git.iec.io/caf/caf-boot