headers, Long tenantId) {
- if (tenantId != null) {
- headers.put(HEADER_TENANT_ID, tenantId.toString());
- }
- }
-
-}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/web/TenantContextWebFilter.java b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/web/TenantContextWebFilter.java
deleted file mode 100644
index 41b7b4d..0000000
--- a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/web/TenantContextWebFilter.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package cn.iocoder.yudao.framework.tenant.core.web;
-
-import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
-import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
-import org.springframework.web.filter.OncePerRequestFilter;
-
-import jakarta.servlet.FilterChain;
-import jakarta.servlet.ServletException;
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-/**
- * 多租户 Context Web 过滤器
- * 将请求 Header 中的 tenant-id 解析出来,添加到 {@link TenantContextHolder} 中,这样后续的 DB 等操作,可以获得到租户编号。
- *
- * @author 芋道源码
- */
-public class TenantContextWebFilter extends OncePerRequestFilter {
-
- @Override
- protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
- throws ServletException, IOException {
- // 设置
- Long tenantId = WebFrameworkUtils.getTenantId(request);
- if (tenantId != null) {
- TenantContextHolder.setTenantId(tenantId);
- }
- try {
- chain.doFilter(request, response);
- } finally {
- // 清理
- TenantContextHolder.clear();
- }
- }
-
-}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/package-info.java b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/package-info.java
deleted file mode 100644
index aa22cdb..0000000
--- a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/package-info.java
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * 多租户,支持如下层面:
- * 1. DB:基于 MyBatis Plus 多租户的功能实现。
- * 2. Redis:通过在 Redis Key 上拼接租户编号的方式,进行隔离。
- * 3. Web:请求 HTTP API 时,解析 Header 的 tenant-id 租户编号,添加到租户上下文。
- * 4. Security:校验当前登陆的用户,是否越权访问其它租户的数据。
- * 5. Job:在 JobHandler 执行任务时,会按照每个租户,都独立并行执行一次。
- * 6. MQ:在 Producer 发送消息时,Header 带上 tenant-id 租户编号;在 Consumer 消费消息时,将 Header 的 tenant-id 租户编号,添加到租户上下文。
- * 7. Async:异步需要保证 ThreadLocal 的传递性,通过使用阿里开源的 TransmittableThreadLocal 实现。相关的改造点,可见:
- * 1)Spring Async:
- * {@link cn.iocoder.yudao.framework.quartz.config.YudaoAsyncAutoConfiguration#threadPoolTaskExecutorBeanPostProcessor()}
- * 2)Spring Security:
- * TransmittableThreadLocalSecurityContextHolderStrategy
- * 和 YudaoSecurityAutoConfiguration#securityContextHolderMethodInvokingFactoryBean() 方法
- *
- */
-package cn.iocoder.yudao.framework.tenant;
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/org/springframework/messaging/handler/invocation/InvocableHandlerMethod.java b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/org/springframework/messaging/handler/invocation/InvocableHandlerMethod.java
deleted file mode 100644
index de330fd..0000000
--- a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/org/springframework/messaging/handler/invocation/InvocableHandlerMethod.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * Copyright 2002-2023 the original author or authors.
- *
- * 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
- *
- * https://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 org.springframework.messaging.handler.invocation;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import java.util.Arrays;
-
-import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
-import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
-import org.springframework.core.DefaultParameterNameDiscoverer;
-import org.springframework.core.MethodParameter;
-import org.springframework.core.ParameterNameDiscoverer;
-import org.springframework.core.ResolvableType;
-import org.springframework.lang.Nullable;
-import org.springframework.messaging.Message;
-import org.springframework.messaging.handler.HandlerMethod;
-import org.springframework.util.ObjectUtils;
-
-import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.HEADER_TENANT_ID;
-
-/**
- * Extension of {@link HandlerMethod} that invokes the underlying method with
- * argument values resolved from the current HTTP request through a list of
- * {@link HandlerMethodArgumentResolver}.
- *
- * 针对 rabbitmq-spring 和 kafka-spring,不存在合适的拓展点,可以实现 Consumer 消费前,读取 Header 中的 tenant-id 设置到 {@link TenantContextHolder} 中
- * TODO 芋艿:持续跟进,看看有没新的拓展点
- *
- * @author Rossen Stoyanchev
- * @author Juergen Hoeller
- * @since 4.0
- */
-public class InvocableHandlerMethod extends HandlerMethod {
-
- private static final Object[] EMPTY_ARGS = new Object[0];
-
-
- private HandlerMethodArgumentResolverComposite resolvers = new HandlerMethodArgumentResolverComposite();
-
- private ParameterNameDiscoverer parameterNameDiscoverer = new DefaultParameterNameDiscoverer();
-
-
- /**
- * Create an instance from a {@code HandlerMethod}.
- */
- public InvocableHandlerMethod(HandlerMethod handlerMethod) {
- super(handlerMethod);
- }
-
- /**
- * Create an instance from a bean instance and a method.
- */
- public InvocableHandlerMethod(Object bean, Method method) {
- super(bean, method);
- }
-
- /**
- * Construct a new handler method with the given bean instance, method name and parameters.
- * @param bean the object bean
- * @param methodName the method name
- * @param parameterTypes the method parameter types
- * @throws NoSuchMethodException when the method cannot be found
- */
- public InvocableHandlerMethod(Object bean, String methodName, Class>... parameterTypes)
- throws NoSuchMethodException {
-
- super(bean, methodName, parameterTypes);
- }
-
-
- /**
- * Set {@link HandlerMethodArgumentResolver HandlerMethodArgumentResolvers} to use for resolving method argument values.
- */
- public void setMessageMethodArgumentResolvers(HandlerMethodArgumentResolverComposite argumentResolvers) {
- this.resolvers = argumentResolvers;
- }
-
- /**
- * Set the ParameterNameDiscoverer for resolving parameter names when needed
- * (e.g. default request attribute name).
- * Default is a {@link org.springframework.core.DefaultParameterNameDiscoverer}.
- */
- public void setParameterNameDiscoverer(ParameterNameDiscoverer parameterNameDiscoverer) {
- this.parameterNameDiscoverer = parameterNameDiscoverer;
- }
-
-
- /**
- * Invoke the method after resolving its argument values in the context of the given message.
- *
Argument values are commonly resolved through
- * {@link HandlerMethodArgumentResolver HandlerMethodArgumentResolvers}.
- * The {@code providedArgs} parameter however may supply argument values to be used directly,
- * i.e. without argument resolution.
- *
Delegates to {@link #getMethodArgumentValues} and calls {@link #doInvoke} with the
- * resolved arguments.
- * @param message the current message being processed
- * @param providedArgs "given" arguments matched by type, not resolved
- * @return the raw value returned by the invoked method
- * @throws Exception raised if no suitable argument resolver can be found,
- * or if the method raised an exception
- * @see #getMethodArgumentValues
- * @see #doInvoke
- */
- @Nullable
- public Object invoke(Message> message, Object... providedArgs) throws Exception {
- Object[] args = getMethodArgumentValues(message, providedArgs);
- if (logger.isTraceEnabled()) {
- logger.trace("Arguments: " + Arrays.toString(args));
- }
- // 注意:如下是本类的改动点!!!
- // 情况一:无租户编号的情况
- Long tenantId= parseTenantId(message);
- if (tenantId == null) {
- return doInvoke(args);
- }
- // 情况二:有租户的情况下
- return TenantUtils.execute(tenantId, () -> doInvoke(args));
- }
-
- private Long parseTenantId(Message> message) {
- Object tenantId = message.getHeaders().get(HEADER_TENANT_ID);
- if (tenantId == null) {
- return null;
- }
- if (tenantId instanceof Long) {
- return (Long) tenantId;
- }
- if (tenantId instanceof Number) {
- return ((Number) tenantId).longValue();
- }
- if (tenantId instanceof String) {
- return Long.parseLong((String) tenantId);
- }
- if (tenantId instanceof byte[]) {
- return Long.parseLong(new String((byte[]) tenantId));
- }
- throw new IllegalArgumentException("未知的数据类型:" + tenantId);
- }
-
- /**
- * Get the method argument values for the current message, checking the provided
- * argument values and falling back to the configured argument resolvers.
- *
The resulting array will be passed into {@link #doInvoke}.
- * @since 5.1.2
- */
- protected Object[] getMethodArgumentValues(Message> message, Object... providedArgs) throws Exception {
- MethodParameter[] parameters = getMethodParameters();
- if (ObjectUtils.isEmpty(parameters)) {
- return EMPTY_ARGS;
- }
-
- Object[] args = new Object[parameters.length];
- for (int i = 0; i < parameters.length; i++) {
- MethodParameter parameter = parameters[i];
- parameter.initParameterNameDiscovery(this.parameterNameDiscoverer);
- args[i] = findProvidedArgument(parameter, providedArgs);
- if (args[i] != null) {
- continue;
- }
- if (!this.resolvers.supportsParameter(parameter)) {
- throw new MethodArgumentResolutionException(
- message, parameter, formatArgumentError(parameter, "No suitable resolver"));
- }
- try {
- args[i] = this.resolvers.resolveArgument(parameter, message);
- }
- catch (Exception ex) {
- // Leave stack trace for later, exception may actually be resolved and handled...
- if (logger.isDebugEnabled()) {
- String exMsg = ex.getMessage();
- if (exMsg != null && !exMsg.contains(parameter.getExecutable().toGenericString())) {
- logger.debug(formatArgumentError(parameter, exMsg));
- }
- }
- throw ex;
- }
- }
- return args;
- }
-
- /**
- * Invoke the handler method with the given argument values.
- */
- @Nullable
- protected Object doInvoke(Object... args) throws Exception {
- try {
- return getBridgedMethod().invoke(getBean(), args);
- }
- catch (IllegalArgumentException ex) {
- assertTargetBean(getBridgedMethod(), getBean(), args);
- String text = (ex.getMessage() == null || ex.getCause() instanceof NullPointerException) ?
- "Illegal argument": ex.getMessage();
- throw new IllegalStateException(formatInvokeError(text, args), ex);
- }
- catch (InvocationTargetException ex) {
- // Unwrap for HandlerExceptionResolvers ...
- Throwable targetException = ex.getTargetException();
- if (targetException instanceof RuntimeException runtimeException) {
- throw runtimeException;
- }
- else if (targetException instanceof Error error) {
- throw error;
- }
- else if (targetException instanceof Exception exception) {
- throw exception;
- }
- else {
- throw new IllegalStateException(formatInvokeError("Invocation failure", args), targetException);
- }
- }
- }
-
- MethodParameter getAsyncReturnValueType(@Nullable Object returnValue) {
- return new AsyncResultMethodParameter(returnValue);
- }
-
-
- private class AsyncResultMethodParameter extends AnnotatedMethodParameter {
-
- @Nullable
- private final Object returnValue;
-
- private final ResolvableType returnType;
-
- public AsyncResultMethodParameter(@Nullable Object returnValue) {
- super(-1);
- this.returnValue = returnValue;
- this.returnType = ResolvableType.forType(super.getGenericParameterType()).getGeneric();
- }
-
- protected AsyncResultMethodParameter(AsyncResultMethodParameter original) {
- super(original);
- this.returnValue = original.returnValue;
- this.returnType = original.returnType;
- }
-
- @Override
- public Class> getParameterType() {
- if (this.returnValue != null) {
- return this.returnValue.getClass();
- }
- if (!ResolvableType.NONE.equals(this.returnType)) {
- return this.returnType.toClass();
- }
- return super.getParameterType();
- }
-
- @Override
- public Type getGenericParameterType() {
- return this.returnType.getType();
- }
-
- @Override
- public AsyncResultMethodParameter clone() {
- return new AsyncResultMethodParameter(this);
- }
- }
-
-}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/resources/META-INF/spring.factories b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/resources/META-INF/spring.factories
deleted file mode 100644
index a495842..0000000
--- a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/resources/META-INF/spring.factories
+++ /dev/null
@@ -1,2 +0,0 @@
-org.springframework.boot.env.EnvironmentPostProcessor=\
- cn.iocoder.yudao.framework.tenant.core.mq.kafka.TenantKafkaEnvironmentPostProcessor
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
deleted file mode 100644
index 603831e..0000000
--- a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
+++ /dev/null
@@ -1 +0,0 @@
-cn.iocoder.yudao.framework.tenant.config.YudaoTenantAutoConfiguration
\ No newline at end of file
diff --git a/yudao-framework/yudao-spring-boot-starter-websocket/pom.xml b/yudao-framework/yudao-spring-boot-starter-websocket/pom.xml
index b534f10..282077c 100644
--- a/yudao-framework/yudao-spring-boot-starter-websocket/pom.xml
+++ b/yudao-framework/yudao-spring-boot-starter-websocket/pom.xml
@@ -60,14 +60,14 @@