Initial commit: five Maven reactors and docs only

Track maven-cloudwalk-cloud, maven-cw-elevator-application,
maven-intelligent-cwoscomponent, maven-ninca-crk, maven-ninca-qk-alarm,
and docs/. Other workspace paths ignored via .gitignore.

Made-with: Cursor
This commit is contained in:
反编译工作区
2026-04-24 10:35:31 +08:00
commit e2ac14719b
653 changed files with 50372 additions and 0 deletions
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.18.RELEASE</version>
<relativePath/>
</parent>
<groupId>cn.cloudwalk.cloud</groupId>
<artifactId>cloudwalk-cloud-common</artifactId>
<version>3.7.2-Brussels-SRX</version>
<packaging>pom</packaging>
<name>cloudwalk-cloud-common (stub parent)</name>
<description>与历史/私服已发布 JAR 中声明的 parent 对齐;反编译聚合工程见 cloudwalk-cloud-decompiled-reactor。</description>
</project>
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.cloudwalk.cloud</groupId>
<artifactId>cloudwalk-cloud-decompiled-reactor</artifactId>
<version>3.7.2-Brussels-SRX</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>cloudwalk-common-event</artifactId>
<packaging>jar</packaging>
<description>云从科技-消息总线封装(源码已迁入本模块 src/main/java</description>
<properties>
<alibaba.eclipse.codestyle.path>${project.basedir}/../../docs/style/alibaba-eclipse-codestyle.xml</alibaba.eclipse.codestyle.path>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
</dependency>
<dependency>
<groupId>cn.cloudwalk.cloud</groupId>
<artifactId>cwos-sdk-event</artifactId>
<!-- 旧版 cwos-sdk-event POM 依赖 reflections-maven,会解析到 JFrog 已下线构件,编译不需要 -->
<exclusions>
<exclusion>
<groupId>org.reflections</groupId>
<artifactId>reflections-maven</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,361 @@
package cn.cloudwalk.event;
import cn.cloudwalk.cwos.client.event.EventClient;
import cn.cloudwalk.cwos.client.event.event.BaseEvent;
import cn.cloudwalk.cwos.client.event.event.CustomEvent;
import cn.cloudwalk.cwos.client.event.event.EventType;
import cn.cloudwalk.cwos.client.event.handler.EventListener;
import cn.cloudwalk.event.annotation.ConsumerGroup;
import cn.cloudwalk.event.annotation.CustomTopic;
import cn.cloudwalk.event.annotation.EventTopicSuffix;
import cn.cloudwalk.event.autoconfig.EventProperties;
import cn.cloudwalk.event.handler.CustomEventHandler;
import cn.cloudwalk.event.handler.EventHandler;
import cn.cloudwalk.event.handler.EventHandlerMapping;
import cn.cloudwalk.event.handler.EventHandlerWorker;
import cn.cloudwalk.event.handler.NamedThreadFactory;
import cn.cloudwalk.event.listener.CloudwalkEventListener;
import cn.cloudwalk.event.listener.GroupEventListener;
import cn.cloudwalk.event.listener.GroupListnerClassMapping;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.ApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
/**
* 应用启动阶段扫描 Spring 容器中的监听器与处理器,构建 {@link cn.cloudwalk.event.handler.EventHandlerMapping} 等运行时结构。
*/
public class CloudwalkEventInitializing implements CommandLineRunner {
private static final Logger LOGGER = LoggerFactory.getLogger(CloudwalkEventInitializing.class);
@Autowired(required = false)
private List<EventHandler> eventHandlers;
@Autowired
private CloudwalkEventManager cloudwalkEventManager;
@Autowired
private Environment environment;
private static final Pattern pattern = Pattern.compile("^\\$\\{(.*?)\\}$");
private static final String DEFAULT_SUFFIX = "";
private String defaultGroup;
private EventClient defaultEventClient;
private Map<String, EventClient> eventClientMap = new HashMap<>();
private EventProperties eventProperties;
private static boolean isHandlerEnable = false;
public void run(String... args) throws Exception {
init();
}
public void init() throws Exception {
initEventClient();
initHandlerMapping();
initHandlerExecutor();
subscribeEvent();
}
public CloudwalkEventInitializing(EventProperties eventProperties) {
this.eventProperties = eventProperties;
}
private void initEventClient() throws ClassNotFoundException {
String[] groupIds = this.eventProperties.getGroupId().split(",");
if (groupIds.length == 0) {
throw new IllegalArgumentException("消费组ID不能为空");
}
Map<String, String> listenerClassMap = this.eventProperties.getListenerClass();
GroupListnerClassMapping groupListnerClassMapping = new GroupListnerClassMapping();
for (int i = 0; i < groupIds.length; i++) {
Class<? extends EventListener> listenerClass;
boolean isFirst = (i == 0);
String groupId = groupIds[i];
if (null == listenerClassMap || StringUtils.isEmpty(listenerClassMap.get(groupId))) {
if (isFirst) {
listenerClass = CloudwalkEventListener.class;
} else {
throw new IllegalArgumentException(
String.format("groupId[%s]缺少listener-class的配置", new Object[] {groupId}));
}
} else {
listenerClass = (Class)Class.forName(listenerClassMap.get(groupId));
}
initEventClient(this.eventProperties.getBootstrapServers(), groupId, listenerClass, isFirst);
groupListnerClassMapping.register(listenerClass, groupId);
}
this.cloudwalkEventManager.setGroupListnerClassMapping(groupListnerClassMapping);
this.cloudwalkEventManager.setEventClient(this.defaultEventClient);
}
@Autowired
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
GroupEventListener.applicationContext = applicationContext;
}
private List<String> extractGroupIds(EventHandler eventHandler) {
if (eventHandler.getClass().isAnnotationPresent((Class)ConsumerGroup.class)) {
ConsumerGroup consumerGroup = eventHandler.getClass().<ConsumerGroup>getAnnotation(ConsumerGroup.class);
List<String> groupIds = new LinkedList<>();
for (String groupId : consumerGroup.groupIds()) {
Matcher matcher = pattern.matcher(groupId);
if (matcher.find()) {
String propertyKey = groupId.substring(2, groupId.length() - 1).trim();
String propertyValue = this.environment.getProperty(propertyKey);
if (!StringUtils.isEmpty(propertyValue)) {
groupId = propertyValue;
}
}
groupIds.add(groupId);
}
return groupIds;
}
return new ArrayList<>(Collections.singletonList(this.defaultGroup));
}
private void initHandlerMapping() {
if (CollectionUtils.isEmpty(this.eventHandlers)) {
return;
}
isHandlerEnable = true;
EventHandlerMapping eventHandlerMapping = new EventHandlerMapping();
for (EventHandler<BaseEvent> handler : this.eventHandlers) {
if (handler.getClass().isAnnotationPresent((Class)EventTopicSuffix.class)) {
Type type = handler.getClass().getGenericInterfaces()[0];
ParameterizedType p = (ParameterizedType)type;
Class<BaseEvent> eventClass = (Class)p.getActualTypeArguments()[0];
EventTopicSuffix eventTopicSuffix =
handler.getClass().<EventTopicSuffix>getAnnotation(EventTopicSuffix.class);
registerHandlerMapping(eventHandlerMapping, handler, eventClass, eventTopicSuffix.value());
continue;
}
if (handler.getClass().isAnnotationPresent((Class)CustomTopic.class)) {
CustomTopic customTopic = handler.getClass().<CustomTopic>getAnnotation(CustomTopic.class);
String topic = customTopic.topic();
if (StringUtils.isEmpty(topic)) {
continue;
}
registerCustomHandlerMapping(eventHandlerMapping, (EventHandler)handler, topic, customTopic.suffix());
}
}
this.cloudwalkEventManager.setEventHandlerMapping(eventHandlerMapping);
}
private void initHandlerExecutor() {
if (isHandlerEnable) {
EventHandlerWorker eventHandlerWorker = new EventHandlerWorker();
EventProperties.HandlerExecutorConfig handlerExecutorConfig =
this.eventProperties.getHandlerExecutorConfig();
eventHandlerWorker
.setPoolExecutor(new ThreadPoolExecutor(handlerExecutorConfig.getCorePoolSize().intValue(),
handlerExecutorConfig.getMaximumPoolSize().intValue(), 1000L, TimeUnit.MILLISECONDS,
new SynchronousQueue<>(),
(ThreadFactory)new NamedThreadFactory(this.eventProperties.getWorkerNamePrefix()),
new ThreadPoolExecutor.CallerRunsPolicy()));
this.cloudwalkEventManager.setEventHandlerWorker(eventHandlerWorker);
}
}
private EventType getEventType(Class<? extends BaseEvent> eventClass) {
for (EventType eventType : EventType.values()) {
if (eventType.getEventClass().getClass().equals(eventClass)) {
return eventType;
}
}
return null;
}
private void subscribeEvent() throws IllegalAccessException, InstantiationException {
EventHandlerMapping eventHandlerMapping = this.cloudwalkEventManager.getEventHandlerMapping();
Map<String, Map<EventType, Set<String>>> subscribedMap = new HashMap<>();
for (Map.Entry<String, Map<EventType, Map<String, List<EventHandler>>>> entry : (Iterable<
Map.Entry<String, Map<EventType, Map<String, List<EventHandler>>>>>)eventHandlerMapping.getHandlerMap()
.entrySet()) {
for (Map.Entry<EventType, Map<String, List<EventHandler>>> eventTypeMapEntry : (Iterable<
Map.Entry<EventType, Map<String, List<EventHandler>>>>)((Map)entry.getValue()).entrySet()) {
for (Object serviceCodeObj : ((Map)eventTypeMapEntry.getValue()).keySet()) {
String serviceCode = (String)serviceCodeObj;
subscribe(subscribedMap, entry.getKey(), eventTypeMapEntry.getKey(), serviceCode);
}
}
}
Map<String, Map<String, Set<String>>> customSubscribedMap = new HashMap<>();
for (Map.Entry<String, Map<String, Map<String, List<CustomEventHandler>>>> entry : (Iterable<
Map.Entry<String, Map<String, Map<String, List<CustomEventHandler>>>>>)eventHandlerMapping
.getCustomHandlerMap().entrySet()) {
for (Map.Entry<String, Map<String, List<CustomEventHandler>>> subEntry : (Iterable<
Map.Entry<String, Map<String, List<CustomEventHandler>>>>)((Map)entry.getValue()).entrySet()) {
for (Map.Entry<String, List<CustomEventHandler>> handlerEntry : (Iterable<
Map.Entry<String, List<CustomEventHandler>>>)((Map)subEntry.getValue()).entrySet()) {
for (CustomEventHandler customEventHandler : handlerEntry.getValue()) {
Type type = customEventHandler.getClass().getGenericInterfaces()[0];
ParameterizedType p = (ParameterizedType)type;
Class<? extends CustomEvent> eventClass = (Class)p.getActualTypeArguments()[0];
customSubscribe(customSubscribedMap, entry.getKey(), subEntry.getKey(), handlerEntry.getKey(),
eventClass);
}
}
}
}
}
private void subscribe(Map<String, Map<EventType, Set<String>>> subscribedMap, String groupId, EventType eventType,
String serviceCode) {
if (StringUtils.isEmpty(groupId)) {
groupId = this.defaultGroup;
}
Map<EventType, Set<String>> eventTypeServiceCodeMap = subscribedMap.get(groupId);
if (null != eventTypeServiceCodeMap) {
Set<String> serviceCodesSet = eventTypeServiceCodeMap.get(eventType);
if (CollectionUtils.isEmpty(serviceCodesSet)) {
eventTypeServiceCodeMap.put(eventType, new HashSet<>(Collections.singleton(serviceCode)));
} else {
serviceCodesSet.add(serviceCode);
}
} else {
eventTypeServiceCodeMap = new HashMap<>();
eventTypeServiceCodeMap.put(eventType, new HashSet<>(Collections.singleton(serviceCode)));
subscribedMap.put(groupId, eventTypeServiceCodeMap);
}
((EventClient)this.eventClientMap.get(groupId)).subEvent(eventType, serviceCode);
}
private void customSubscribe(Map<String, Map<String, Set<String>>> customSubscribedMap, String groupId,
String topic, String serviceCode, Class<? extends CustomEvent> eventClass)
throws IllegalAccessException, InstantiationException {
if (StringUtils.isEmpty(groupId)) {
groupId = this.defaultGroup;
}
Map<String, Set<String>> topicServiceCodeMap = customSubscribedMap.get(groupId);
if (null != topicServiceCodeMap) {
Set<String> serviceCodesSet = topicServiceCodeMap.get(topic);
if (CollectionUtils.isEmpty(serviceCodesSet)) {
topicServiceCodeMap.put(topic, new HashSet<>(Collections.singleton(serviceCode)));
} else {
serviceCodesSet.add(serviceCode);
}
} else {
topicServiceCodeMap = new HashMap<>();
topicServiceCodeMap.put(topic, new HashSet<>(Collections.singleton(serviceCode)));
customSubscribedMap.put(groupId, topicServiceCodeMap);
}
EventClient eventClient = this.eventClientMap.get(groupId);
if (null == eventClient) {
throw new IllegalArgumentException(
String.format("没有找到groupId[%s]对应的配置,请检查 ${cloudwalk.event.group-id} 配置", new Object[] {groupId}));
}
eventClient.subEvent(topic, serviceCode, eventClass.newInstance());
}
private void initEventClient(String bootstrapServers, String groupId, Class<? extends EventListener> listenerClass,
boolean isDefault) {
EventClient eventClient = this.eventClientMap.get(groupId);
if (null == eventClient) {
eventClient = EventClient.getInstance(bootstrapServers, groupId);
eventClient.init();
if (null != this.eventProperties.getFetchDataWorkerNumber()) {
eventClient.setWorkNum(this.eventProperties.getFetchDataWorkerNumber());
}
eventClient.setListenerClass(listenerClass);
this.eventClientMap.put(groupId, eventClient);
}
if (isDefault) {
this.defaultGroup = groupId;
this.defaultEventClient = eventClient;
}
}
private <E extends BaseEvent> void registerHandlerMapping(EventHandlerMapping eventHandlerMapping,
EventHandler<E> handler, Class<E> eventClass, String[] suffixes) {
List<String> groupIds = extractGroupIds(handler);
EventType eventType = getEventType(eventClass);
for (String groupId : groupIds) {
Map<String, List<EventHandler>> handlers =
eventHandlerMapping.getServiceCodeHandlerListMap(groupId, eventType);
if (CollectionUtils.isEmpty(handlers)) {
handlers = new HashMap<>();
if (null == suffixes || suffixes.length == 0) {
handlers.put("", new ArrayList<EventHandler>(Collections.singletonList((EventHandler)handler)));
} else {
for (String suffix : suffixes) {
handlers.put(suffix, new ArrayList<EventHandler>(Collections.singletonList((EventHandler)handler)));
}
}
eventHandlerMapping.registerHandlers(groupId, eventType, handlers);
continue;
}
if (null == suffixes || suffixes.length == 0) {
List<EventHandler> currentHandlers = handlers.get("");
if (CollectionUtils.isEmpty(currentHandlers)) {
currentHandlers = new ArrayList<>();
}
currentHandlers.add(handler);
handlers.put("", currentHandlers);
continue;
}
for (String suffix : suffixes) {
List<EventHandler> currentHandlers = handlers.get(suffix);
if (CollectionUtils.isEmpty(currentHandlers)) {
currentHandlers = new ArrayList<>();
}
currentHandlers.add(handler);
handlers.put(suffix, currentHandlers);
}
}
}
private void registerCustomHandlerMapping(EventHandlerMapping eventHandlerMapping,
EventHandler<? extends CustomEvent> handler, String topic, String serviceCode) {
List<String> groupIds = extractGroupIds(handler);
for (String groupId : groupIds) {
Map<String, List<CustomEventHandler>> customHandlers =
eventHandlerMapping.getServiceCodeCustomHandlerListMap(groupId, topic);
if (null == customHandlers) {
customHandlers = new HashMap<>();
if (StringUtils.isEmpty(topic)) {
customHandlers.put("",
new ArrayList<CustomEventHandler>(
Collections.singletonList((CustomEventHandler)handler)));
} else {
customHandlers.put(serviceCode,
new ArrayList<CustomEventHandler>(
Collections.singletonList((CustomEventHandler)handler)));
}
eventHandlerMapping.registerCustomHandlers(groupId, topic, customHandlers);
continue;
}
if (StringUtils.isEmpty(serviceCode)) {
List<CustomEventHandler> list = customHandlers.get("");
if (CollectionUtils.isEmpty(list)) {
list = new ArrayList<>();
}
list.add((CustomEventHandler)handler);
customHandlers.put("", list);
continue;
}
List<CustomEventHandler> currentHandlers = customHandlers.get(serviceCode);
if (CollectionUtils.isEmpty(currentHandlers)) {
currentHandlers = new ArrayList<>();
}
currentHandlers.add((CustomEventHandler)handler);
customHandlers.put(serviceCode, currentHandlers);
}
}
}
@@ -0,0 +1,76 @@
package cn.cloudwalk.event;
import cn.cloudwalk.cwos.client.event.EventClient;
import cn.cloudwalk.cwos.client.event.event.BaseEvent;
import cn.cloudwalk.cwos.client.event.event.CustomEvent;
import cn.cloudwalk.event.handler.CustomEventHandler;
import cn.cloudwalk.event.handler.EventHandler;
import cn.cloudwalk.event.handler.EventHandlerMapping;
import cn.cloudwalk.event.handler.EventHandlerWorker;
import cn.cloudwalk.event.listener.GroupEventListener;
import cn.cloudwalk.event.listener.GroupListnerClassMapping;
import cn.cloudwalk.event.task.EventHandleTask;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.CollectionUtils;
/**
* 事件派发入口:基于 {@link cn.cloudwalk.event.handler.EventHandlerMapping} 选择处理器并委托
* {@link cn.cloudwalk.event.handler.EventHandlerWorker} 执行。
*/
public class CloudwalkEventManager {
private static final Logger LOGGER = LoggerFactory.getLogger(CloudwalkEventManager.class);
private EventHandlerMapping eventHandlerMapping;
private EventHandlerWorker eventHandlerWorker;
private GroupListnerClassMapping groupListnerClassMapping;
private EventClient eventClient;
public void handle(Class<? extends GroupEventListener> eventListnerClass, BaseEvent baseEvent) {
String groupId = this.groupListnerClassMapping.getGroupId(eventListnerClass);
if (baseEvent instanceof CustomEvent) {
List<CustomEventHandler> customEventHandlers = (List<CustomEventHandler>)this.eventHandlerMapping
.getServiceCodeCustomHandlerListMap(groupId, ((CustomEvent)baseEvent).getTopic())
.get(baseEvent.getServiceCode());
eventHandle(baseEvent, customEventHandlers);
return;
}
List<EventHandler> handlerList = (List<EventHandler>)this.eventHandlerMapping
.getServiceCodeHandlerListMap(groupId, baseEvent.getClass()).get(baseEvent.getServiceCode());
eventHandle(baseEvent, handlerList);
}
private <H extends EventHandler> void eventHandle(BaseEvent baseEvent, List<H> handlers) {
if (CollectionUtils.isEmpty(handlers)) {
LOGGER.error("没有相应的事件处理程序");
return;
}
for (EventHandler eventHandler : handlers) {
this.eventHandlerWorker.work(new EventHandleTask(baseEvent, eventHandler));
}
}
public void publish(BaseEvent baseEvent) {
this.eventClient.pubEvent(baseEvent);
}
public void setEventHandlerMapping(EventHandlerMapping eventHandlerMapping) {
this.eventHandlerMapping = eventHandlerMapping;
}
public EventHandlerMapping getEventHandlerMapping() {
return this.eventHandlerMapping;
}
public void setEventHandlerWorker(EventHandlerWorker eventHandlerWorker) {
this.eventHandlerWorker = eventHandlerWorker;
}
public void setEventClient(EventClient eventClient) {
this.eventClient = eventClient;
}
public void setGroupListnerClassMapping(GroupListnerClassMapping groupListnerClassMapping) {
this.groupListnerClassMapping = groupListnerClassMapping;
}
}
@@ -0,0 +1,18 @@
package cn.cloudwalk.event;
import cn.cloudwalk.event.autoconfig.EventConfiguration;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.context.annotation.Import;
/**
* 启用云从事件总线自动配置,导入 {@link EventConfiguration} 并绑定 {@code cloudwalk.event.*} 配置项。
*/
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Import({EventConfiguration.class})
public @interface EnableCloudwalkEvent {}
@@ -0,0 +1,18 @@
package cn.cloudwalk.event.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 声明类型级 Kafka 消费组标识,用于与事件监听/路由配置对齐。
*/
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface ConsumerGroup {
/** 消费组 ID 列表,与平台侧配置保持一致。 */
String[] groupIds() default {};
}
@@ -0,0 +1,26 @@
package cn.cloudwalk.event.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.core.annotation.AliasFor;
/**
* 为自定义事件主题提供显式 {@code topic},并通过 {@link EventTopicSuffix} 组合后缀。
*/
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@EventTopicSuffix
public @interface CustomTopic {
/** 逻辑主题名。 */
String topic();
/**
* 与 {@link EventTopicSuffix#suffix()} 互为别名,用于拼接完整主题。
*/
@AliasFor(annotation = EventTopicSuffix.class)
String suffix() default "";
}
@@ -0,0 +1,24 @@
package cn.cloudwalk.event.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.core.annotation.AliasFor;
/**
* 为主题名追加可配置后缀,避免多环境/多租户下 Kafka Topic 冲突。
*/
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface EventTopicSuffix {
/** 与 {@link #suffix()} 互为别名。 */
@AliasFor(attribute = "suffix")
String[] value() default {};
/** 追加在基础主题后的后缀片段。 */
@AliasFor(attribute = "value")
String[] suffix() default {};
}
@@ -0,0 +1,22 @@
package cn.cloudwalk.event.autoconfig;
import cn.cloudwalk.event.CloudwalkEventInitializing;
import cn.cloudwalk.event.CloudwalkEventManager;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
/**
* 事件模块 Spring 配置:注册 {@link cn.cloudwalk.event.CloudwalkEventManager} 与初始化组件。
*/
@EnableConfigurationProperties({EventProperties.class})
public class EventConfiguration {
@Bean
public CloudwalkEventManager cloudwalkEventManager() {
return new CloudwalkEventManager();
}
@Bean
public CloudwalkEventInitializing CloudwalkEventInitializing(EventProperties eventProperties) {
return new CloudwalkEventInitializing(eventProperties);
}
}
@@ -0,0 +1,93 @@
package cn.cloudwalk.event.autoconfig;
import java.util.Map;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* {@code cloudwalk.event} 前缀下的绑定配置:Kafka 地址、消费组、监听器映射与线程池等。
*/
@ConfigurationProperties(prefix = "cloudwalk.event")
public class EventProperties {
protected static final String CONF_PREFIX = "cloudwalk.event";
private String bootstrapServers;
private String groupId;
private Map<String, String> listenerClass;
private Integer fetchDataWorkerNumber;
private String workerNamePrefix;
private HandlerExecutorConfig handlerExecutorConfig =
new HandlerExecutorConfig(Integer.valueOf(5), Integer.valueOf(10));
public static class HandlerExecutorConfig {
private Integer corePoolSize;
private Integer maximumPoolSize;
public HandlerExecutorConfig(Integer corePoolSize, Integer maximumPoolSize) {
this.corePoolSize = corePoolSize;
this.maximumPoolSize = maximumPoolSize;
}
public Integer getCorePoolSize() {
return this.corePoolSize;
}
public void setCorePoolSize(Integer corePoolSize) {
this.corePoolSize = corePoolSize;
}
public Integer getMaximumPoolSize() {
return this.maximumPoolSize;
}
public void setMaximumPoolSize(Integer maximumPoolSize) {
this.maximumPoolSize = maximumPoolSize;
}
}
public String getBootstrapServers() {
return this.bootstrapServers;
}
public void setBootstrapServers(String bootstrapServers) {
this.bootstrapServers = bootstrapServers;
}
public String getGroupId() {
return this.groupId;
}
public void setGroupId(String groupId) {
this.groupId = groupId;
}
public Map<String, String> getListenerClass() {
return this.listenerClass;
}
public void setListenerClass(Map<String, String> listenerClass) {
this.listenerClass = listenerClass;
}
public Integer getFetchDataWorkerNumber() {
return this.fetchDataWorkerNumber;
}
public void setFetchDataWorkerNumber(Integer fetchDataWorkerNumber) {
this.fetchDataWorkerNumber = fetchDataWorkerNumber;
}
public HandlerExecutorConfig getHandlerExecutorConfig() {
return this.handlerExecutorConfig;
}
public void setHandlerExecutorConfig(HandlerExecutorConfig handlerExecutorConfig) {
this.handlerExecutorConfig = handlerExecutorConfig;
}
public String getWorkerNamePrefix() {
return this.workerNamePrefix;
}
public void setWorkerNamePrefix(String workerNamePrefix) {
this.workerNamePrefix = workerNamePrefix;
}
}
@@ -0,0 +1,35 @@
package cn.cloudwalk.event.client;
import cn.cloudwalk.cwos.client.event.event.EventType;
import cn.cloudwalk.event.handler.EventHandler;
import java.util.List;
public class EventSubscribeHandlers {
private EventType eventType;
private String serviceCode;
private List<EventHandler> eventHandlerList;
public EventType getEventType() {
return this.eventType;
}
public void setEventType(EventType eventType) {
this.eventType = eventType;
}
public String getServiceCode() {
return this.serviceCode;
}
public void setServiceCode(String serviceCode) {
this.serviceCode = serviceCode;
}
public List<EventHandler> getEventHandlerList() {
return this.eventHandlerList;
}
public void setEventHandlerList(List<EventHandler> eventHandlerList) {
this.eventHandlerList = eventHandlerList;
}
}
@@ -0,0 +1,4 @@
package cn.cloudwalk.event.handler;
public interface CustomEventHandler<E extends cn.cloudwalk.cwos.client.event.event.CustomEvent>
extends EventHandler<E> {}
@@ -0,0 +1,5 @@
package cn.cloudwalk.event.handler;
public interface EventHandler<E extends cn.cloudwalk.cwos.client.event.event.BaseEvent> {
void onEvent(E paramE);
}
@@ -0,0 +1,74 @@
package cn.cloudwalk.event.handler;
import cn.cloudwalk.cwos.client.event.event.BaseEvent;
import cn.cloudwalk.cwos.client.event.event.EventType;
import cn.cloudwalk.cwos.client.event.handler.EventListener;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class EventHandlerMapping {
private final Map<String, Map<EventType, Map<String, List<EventHandler>>>> handlerMap = new HashMap<>();
private final Map<String, Map<String, Map<String, List<CustomEventHandler>>>> customHandlerMap = new HashMap<>();
private final Map<Class<? extends EventListener>, String> listenerClassGroupMap = new HashMap<>();
public void registerHandlers(String groupId, EventType eventType, Map<String, List<EventHandler>> handlers) {
Map<EventType, Map<String, List<EventHandler>>> map = this.handlerMap.get(groupId);
if (null == map) {
map = new HashMap<>();
map.put(eventType, handlers);
this.handlerMap.put(groupId, map);
} else {
map.put(eventType, handlers);
}
}
public Map<String, List<EventHandler>> getServiceCodeHandlerListMap(String groupId,
Class<? extends BaseEvent> eventClass) {
for (EventType eventType : EventType.values()) {
if (eventType.getEventClass().getClass().equals(eventClass)) {
return getServiceCodeHandlerListMap(groupId, eventType);
}
}
throw new IllegalArgumentException("没有找到合适的事件类型");
}
public Map<String, List<EventHandler>> getServiceCodeHandlerListMap(String groupId, EventType eventType) {
Map<EventType, Map<String, List<EventHandler>>> map = this.handlerMap.get(groupId);
if (null != map) {
return map.get(eventType);
}
return null;
}
public Map<String, List<CustomEventHandler>> getServiceCodeCustomHandlerListMap(String groupId, String topic) {
Map<String, Map<String, List<CustomEventHandler>>> map = this.customHandlerMap.get(groupId);
if (null != map) {
return map.get(topic);
}
return null;
}
public void registerCustomHandlers(String groupId, String topic, Map<String, List<CustomEventHandler>> handlers) {
Map<String, Map<String, List<CustomEventHandler>>> map = this.customHandlerMap.get(groupId);
if (null == map) {
map = new HashMap<>();
map.put(topic, handlers);
this.customHandlerMap.put(groupId, map);
} else {
map.put(topic, handlers);
}
}
public Map<String, Map<EventType, Map<String, List<EventHandler>>>> getHandlerMap() {
return this.handlerMap;
}
public Map<String, Map<String, Map<String, List<CustomEventHandler>>>> getCustomHandlerMap() {
return this.customHandlerMap;
}
public Map<Class<? extends EventListener>, String> getListenerClassGroupMap() {
return this.listenerClassGroupMap;
}
}
@@ -0,0 +1,22 @@
package cn.cloudwalk.event.handler;
import cn.cloudwalk.event.task.EventHandleTask;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadPoolExecutor;
public class EventHandlerWorker {
private ThreadPoolExecutor poolExecutor;
public void setPoolExecutor(ThreadPoolExecutor poolExecutor) {
this.poolExecutor = poolExecutor;
}
public Future<String> work(final EventHandleTask task) {
return this.poolExecutor.submit(new Callable<String>() {
public String call() throws Exception {
return task.start();
}
});
}
}
@@ -0,0 +1,36 @@
package cn.cloudwalk.event.handler;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;
public class NamedThreadFactory implements ThreadFactory {
private static final String DEFAULT_POOL_NAME = "cloudwalk-common-event";
protected static final AtomicInteger POOL_SEQ = new AtomicInteger(1);
private final AtomicInteger threadNumber = new AtomicInteger(1);
private final String namePrefix;
private final ThreadGroup threadGroup;
public NamedThreadFactory() {
this("cloudwalk-common-event");
}
public NamedThreadFactory(String namePrefix) {
SecurityManager s = System.getSecurityManager();
this.threadGroup = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup();
if (null == namePrefix || "".equals(namePrefix.trim())) {
namePrefix = "cloudwalk-common-event";
}
this.namePrefix = namePrefix + "-" + POOL_SEQ.getAndIncrement() + "-thread-";
}
public Thread newThread(Runnable r) {
Thread t = new Thread(this.threadGroup, r, this.namePrefix + this.threadNumber.getAndIncrement(), 0L);
if (t.isDaemon()) {
t.setDaemon(false);
}
if (t.getPriority() != 5) {
t.setPriority(5);
}
return t;
}
}
@@ -0,0 +1,3 @@
package cn.cloudwalk.event.listener;
public class CloudwalkEventListener extends GroupEventListener {}
@@ -0,0 +1,24 @@
package cn.cloudwalk.event.listener;
import cn.cloudwalk.cwos.client.event.event.BaseEvent;
import cn.cloudwalk.cwos.client.event.handler.EventListener;
import cn.cloudwalk.event.CloudwalkEventManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
public abstract class GroupEventListener implements EventListener {
public static ApplicationContext applicationContext;
private static final Logger LOGGER = LoggerFactory.getLogger(CloudwalkEventListener.class);
public void messageListener(BaseEvent baseEvent) throws RuntimeException {
try {
CloudwalkEventManager cloudwalkEventManager =
(CloudwalkEventManager)applicationContext.getBean(CloudwalkEventManager.class);
cloudwalkEventManager.handle(getClass(), baseEvent);
} catch (Exception e) {
LOGGER.error("事件处理出现异常,原因:", e);
throw new RuntimeException(e);
}
}
}
@@ -0,0 +1,26 @@
package cn.cloudwalk.event.listener;
import cn.cloudwalk.cwos.client.event.handler.EventListener;
import java.util.HashMap;
import java.util.Map;
/**
* 监听类型与 Kafka 消费组 ID 的注册表。
* <p>
* 类名中的 {@code Listner} 为历史产物,与既有字节码/配置引用保持一致,请勿随意重命名。
*/
public class GroupListnerClassMapping {
private final Map<Class<? extends EventListener>, String> mapping = new HashMap<>();
public void register(Class<? extends EventListener> eventListnerClass, String groupId) {
if (this.mapping.containsKey(eventListnerClass)) {
throw new IllegalArgumentException(
String.format("eventListnerClass[%s]已经存在,不允许重复", new Object[] {eventListnerClass.toString()}));
}
this.mapping.put(eventListnerClass, groupId);
}
public String getGroupId(Class<? extends EventListener> eventListnerClass) {
return this.mapping.get(eventListnerClass);
}
}
@@ -0,0 +1,7 @@
/**
* 云从消息总线(Kafka)封装:监听器注册、事件处理链、与 CWOS SDK 的集成。
* <p>
* 入口:在 Spring Boot 启动类或配置类上使用 {@link cn.cloudwalk.event.EnableCloudwalkEvent} 通过 {@code cloudwalk.event.*} 配置项(参见
* {@link cn.cloudwalk.event.autoconfig.EventProperties})完成连接与线程池等参数绑定。
*/
package cn.cloudwalk.event;
@@ -0,0 +1,35 @@
package cn.cloudwalk.event.task;
import cn.cloudwalk.cwos.client.event.event.BaseEvent;
import cn.cloudwalk.event.handler.EventHandler;
public class EventHandleTask<E extends BaseEvent> {
private E event;
private EventHandler<E> handler;
public EventHandleTask(E event, EventHandler<E> handler) {
this.event = event;
this.handler = handler;
}
public String start() {
this.handler.onEvent(this.event);
return this.event.getMessageId();
}
public E getEvent() {
return this.event;
}
public void setEvent(E event) {
this.event = event;
}
public EventHandler<E> getHandler() {
return this.handler;
}
public void setHandler(EventHandler<E> handler) {
this.handler = handler;
}
}
@@ -0,0 +1,6 @@
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Built-By: hechunjie
Created-By: Apache Maven 3.6.0
Build-Jdk: 1.8.0_191
@@ -0,0 +1,58 @@
{
"hints": [],
"groups": [
{
"sourceType": "cn.cloudwalk.event.autoconfig.EventProperties",
"name": "cloudwalk.event",
"type": "cn.cloudwalk.event.autoconfig.EventProperties"
},
{
"sourceType": "cn.cloudwalk.event.autoconfig.EventProperties",
"name": "cloudwalk.event.handler-executor-config",
"sourceMethod": "getHandlerExecutorConfig()",
"type": "cn.cloudwalk.event.autoconfig.EventProperties$HandlerExecutorConfig"
}
],
"properties": [
{
"sourceType": "cn.cloudwalk.event.autoconfig.EventProperties",
"name": "cloudwalk.event.bootstrap-servers",
"description": "服务器地址",
"type": "java.lang.String"
},
{
"sourceType": "cn.cloudwalk.event.autoconfig.EventProperties",
"name": "cloudwalk.event.fetch-data-worker-number",
"description": "获取数据的工作线程数",
"type": "java.lang.Integer"
},
{
"sourceType": "cn.cloudwalk.event.autoconfig.EventProperties",
"name": "cloudwalk.event.group-id",
"description": "组ID",
"type": "java.lang.String"
},
{
"sourceType": "cn.cloudwalk.event.autoconfig.EventProperties$HandlerExecutorConfig",
"name": "cloudwalk.event.handler-executor-config.core-pool-size",
"type": "java.lang.Integer"
},
{
"sourceType": "cn.cloudwalk.event.autoconfig.EventProperties$HandlerExecutorConfig",
"name": "cloudwalk.event.handler-executor-config.maximum-pool-size",
"type": "java.lang.Integer"
},
{
"sourceType": "cn.cloudwalk.event.autoconfig.EventProperties",
"name": "cloudwalk.event.listener-class",
"description": "组与EventListener对应关系",
"type": "java.util.Map<java.lang.String,java.lang.String>"
},
{
"sourceType": "cn.cloudwalk.event.autoconfig.EventProperties",
"name": "cloudwalk.event.worker-name-prefix",
"description": "工作线程名字前缀",
"type": "java.lang.String"
}
]
}
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.cloudwalk.cloud</groupId>
<artifactId>cloudwalk-cloud-decompiled-reactor</artifactId>
<version>3.7.2-Brussels-SRX</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>cloudwalk-common-service</artifactId>
<packaging>jar</packaging>
<description>云从科技-公共组件 service 通用层(源码已迁入本模块 src/main/java</description>
<properties>
<alibaba.eclipse.codestyle.path>${project.basedir}/../../docs/style/alibaba-eclipse-codestyle.xml</alibaba.eclipse.codestyle.path>
</properties>
<dependencies>
<dependency>
<groupId>cn.cloudwalk.cloud</groupId>
<artifactId>cloudwalk-common-result</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,79 @@
package cn.cloudwalk.service.aop;
import cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate;
import cn.cloudwalk.cloud.result.CloudwalkResult;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
import javax.validation.groups.Default;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
/**
* 对标注了 {@link cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate} 的入口进行 Bean Validation 校验。
*/
@Aspect
@Order(-100)
@Component
public class CloudwalkParamsValidateAspect {
private final Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private Validator validator;
@Autowired
private MessageSource messageSource;
public String getMessage(String code) {
return this.messageSource.getMessage(code, null, LocaleContextHolder.getLocale());
}
@Pointcut("@annotation(cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate)")
public void validatePointcat() {}
@Around("validatePointcat()")
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
MethodSignature methodSignature = (MethodSignature)joinPoint.getSignature();
Method targetMethod =
joinPoint.getTarget().getClass().getMethod(methodSignature.getName(), methodSignature.getParameterTypes());
this.logger.debug("正在进行对类{}中方法{}进行参数检查开始", joinPoint.getTarget().getClass().getName(), targetMethod.getName());
CloudwalkParamsValidate paramsValidate =
targetMethod.<CloudwalkParamsValidate>getAnnotation(CloudwalkParamsValidate.class);
if (paramsValidate == null) {
return joinPoint.proceed();
}
int[] needCheckParamIndexs = paramsValidate.argsIndexs();
if (needCheckParamIndexs == null) {
return joinPoint.proceed();
}
Class<?>[] groupsClazz = paramsValidate.groups();
if (groupsClazz == null) {
groupsClazz = new Class[] {Default.class};
}
Object[] args = joinPoint.getArgs();
for (int index : needCheckParamIndexs) {
Object arg = args[index];
Set<ConstraintViolation<Object>> constraintViolationSet = this.validator.validate(arg, groupsClazz);
if (constraintViolationSet != null && constraintViolationSet.size() > 0) {
Iterator<ConstraintViolation<Object>> iterator = constraintViolationSet.iterator();
if (iterator.hasNext()) {
ConstraintViolation<Object> constraintViolation = iterator.next();
String code = constraintViolation.getMessage();
return CloudwalkResult.fail(code, getMessage(code));
}
}
}
this.logger.debug("正在进行对类{}中方法{}进行参数检查通过", joinPoint.getTarget().getClass().getName(), targetMethod.getName());
return joinPoint.proceed();
}
}
@@ -0,0 +1,31 @@
package cn.cloudwalk.service.config;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import org.hibernate.validator.HibernateValidator;
import org.hibernate.validator.HibernateValidatorConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.validation.beanvalidation.MethodValidationPostProcessor;
/**
* Hibernate Validator 与 Spring {@link org.springframework.validation.beanvalidation.MethodValidationPostProcessor} 注册。
*/
@Configuration
public class ValidatorConfig {
@Bean
public Validator validator() {
ValidatorFactory validatorFactory =
((HibernateValidatorConfiguration)Validation.byProvider(HibernateValidator.class).configure())
.failFast(true).buildValidatorFactory();
return validatorFactory.getValidator();
}
@Bean
public MethodValidationPostProcessor methodValidationPostProcessor() {
MethodValidationPostProcessor postProcessor = new MethodValidationPostProcessor();
postProcessor.setValidator(validator());
return postProcessor;
}
}
@@ -0,0 +1,6 @@
/**
* 云从公共 Web/Service 横切能力:参数校验 AOP、校验器与 Spring 集成等。
* <p>
* 典型用法:在依赖了 {@code cloudwalk-common-result} 的应用中注册切面与 {@link org.springframework.validation.Validator}。
*/
package cn.cloudwalk.service;
@@ -0,0 +1,6 @@
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Built-By: hechunjie
Created-By: Apache Maven 3.6.0
Build-Jdk: 1.8.0_191
+150
View File
@@ -0,0 +1,150 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.18.RELEASE</version>
<relativePath/>
</parent>
<groupId>cn.cloudwalk.cloud</groupId>
<artifactId>cloudwalk-cloud-decompiled-reactor</artifactId>
<version>3.7.2-Brussels-SRX</version>
<packaging>pom</packaging>
<name>cloudwalk-cloud (decompiled reactor)</name>
<description>聚合反编译模块:cloudwalk-common-event、cloudwalk-common-service。原父 POM cloudwalk-cloud-common 缺失,由本工程继承 Spring Boot 并集中管理云从内部构件版本。</description>
<modules>
<!-- 先安装到本地 ~/.m2,供其它工程解析私服 JAR 的 parentcloudwalk-cloud-common -->
<module>cloudwalk-cloud-common</module>
<module>cloudwalk-common-event</module>
<module>cloudwalk-common-service</module>
</modules>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.SR6</spring-cloud.version>
<cloudwalk.internal.version>3.7.2-Brussels-SRX</cloudwalk.internal.version>
<!-- 与 V1 运行包 lib 内 cwos-sdk-event 一致(私服常见为 1.5.0-SNAPSHOT,非 3.7.2 坐标) -->
<cwos.sdk.event.version>1.5.0-SNAPSHOT</cwos.sdk.event.version>
<!-- Nexus UI: http://192.168.3.12/#browse/welcome -->
<nexus.baseUrl>http://192.168.3.12</nexus.baseUrl>
<nexus.public.repo>${nexus.baseUrl}/repository/maven-public/</nexus.public.repo>
<formatter.maven.plugin.version>2.24.1</formatter.maven.plugin.version>
<!-- P3C Eclipse 码风格(阿里巴巴 Java 开发手册配套),文件见 ../docs/style/alibaba-eclipse-codestyle.xml -->
<alibaba.eclipse.codestyle.path>${project.basedir}/../docs/style/alibaba-eclipse-codestyle.xml</alibaba.eclipse.codestyle.path>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>cn.cloudwalk.cloud</groupId>
<artifactId>cloudwalk-common-result</artifactId>
<version>${cloudwalk.internal.version}</version>
</dependency>
<dependency>
<groupId>cn.cloudwalk.cloud</groupId>
<artifactId>cwos-sdk-event</artifactId>
<version>${cwos.sdk.event.version}</version>
</dependency>
<!-- 子模块未写版本;Boot 父 POM 对部分坐标未集中管理,在此补齐 -->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.22.Final</version>
</dependency>
</dependencies>
</dependencyManagement>
<repositories>
<repository>
<id>nexus-public</id>
<name>Nexus maven-public</name>
<url>${nexus.public.repo}</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus-public-plugins</id>
<name>Nexus maven-public</name>
<url>${nexus.public.repo}</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<version>${formatter.maven.plugin.version}</version>
<configuration>
<configFile>${alibaba.eclipse.codestyle.path}</configFile>
<lineEnding>LF</lineEnding>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.4.1</version>
<executions>
<execution>
<id>enforce-jdk8</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireJavaVersion>
<version>[1.8,1.9)</version>
<message>与原始运行包一致须使用 JDK 8 启动 Maven;见 docs/build/ORIGINAL_BUILD_JDK.txt</message>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>