package com.ruoyi.device.websocket;

import com.ruoyi.common.utils.spring.SpringUtils;
import jakarta.websocket.server.ServerEndpointConfig;
import org.springframework.stereotype.Component;

/**
 * 使 {@link jakarta.websocket.server.ServerEndpoint} 支持 Spring Bean 注入
 * <p>
 * 须与 {@link TsbWebSocketServer} 位于同一模块，避免 @ServerEndpoint configurator 跨模块类加载失败
 *
 * @author lwm
 */
@Component
public class TsbSpringWebSocketConfigurator extends ServerEndpointConfig.Configurator
{
    @Override
    public <T> T getEndpointInstance(Class<T> clazz) throws InstantiationException
    {
        return SpringUtils.getBean(clazz);
    }
}
