管道流设计模式结合业务

文章目录

    • 流程图
    • 代码实现
      • pom
      • context
        • EventContext
        • BizType
        • AbstractEventContext
      • filter
        • EventFilter
        • AbstractEventFilter
        • EventFilterChain
        • FilterChainPipeline
        • DefaultEventFilterChain
      • selector
        • FilterSelector
        • DefaultFilterSelector
    • 调用代码
      • PipelineApplication
      • controller
      • entity
      • service
      • service.business1
      • service.business1.context
      • service.business1.filters
      • service.business1.plugins
      • service.business2
      • service.business2.context
      • service.business2.filters
      • service.business2.plugins
      • service.config
      • service.selector
      • application.yml

流程图

请添加图片描述

代码实现

请添加图片描述

完整代码:https://gitee.com/gitee_pikaqiu/easy-pipeline

pom

<dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.plugin</groupId><artifactId>spring-plugin-core</artifactId><version>${spring.plugin.core.version}</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional></dependency><dependency><groupId>cn.hutool</groupId><artifactId>hutool-all</artifactId><version>${hutool.version}</version></dependency>
</dependencies>

context

EventContext
public interface EventContext {/*** 是否继续调用链*/boolean continueChain();/*** 获取当前过滤器选择器*/FilterSelector getFilterSelector();}
BizType
public interface BizType {/*** 获取业务类型码值*/Integer getCode();/*** 业务类型名称**/String getName();}
AbstractEventContext
public abstract class AbstractEventContext implements EventContext{private final BizType businessType;private final FilterSelector filterSelector;protected AbstractEventContext(BizType businessType, FilterSelector filterSelector) {this.businessType = businessType;this.filterSelector = filterSelector;}@Overridepublic boolean continueChain() {return true;}@Overridepublic FilterSelector getFilterSelector() {return filterSelector;}}

filter

EventFilter
public interface EventFilter<T extends EventContext> {/*** 过滤逻辑封装点** @param context 上下文对象* @param chain   调用链*/void doFilter(T context, EventFilterChain<T> chain);}
AbstractEventFilter
public abstract class AbstractEventFilter<T extends EventContext> implements EventFilter<T> {@Overridepublic void doFilter(T context, EventFilterChain<T> chain) {// 执行if (context.getFilterSelector().matchFilter(this.getClass().getSimpleName())) {handler(context);}// 是否继续执行调用链if (context.continueChain()) {chain.nextHandler(context);}}/*** 执行器** @param context 上下文对象*/protected abstract void handler(T context);}
EventFilterChain
public interface EventFilterChain<T extends EventContext> {/*** 执行当前过滤器** @param context 上下文对象*/void handler(T context);/*** 跳过当前过滤器 执行下一个执行过滤器** @param context 上下文对象*/void nextHandler(T context);}
FilterChainPipeline
@Slf4j
@Component
public class FilterChainPipeline<F extends EventFilter>{private DefaultEventFilterChain<EventContext> last;public FilterChainPipeline<F> append(F filter){last = new DefaultEventFilterChain<>(last, filter);return this;}public FilterChainPipeline<F> append(String description, F filter){log.debug("过滤器调用链管道开始设置 {} 过滤器",description);last = new DefaultEventFilterChain<>(last, filter);return this;}public DefaultEventFilterChain<EventContext> getFilterChain() {return this.last;}}
DefaultEventFilterChain
public class DefaultEventFilterChain<T extends EventContext> implements EventFilterChain<T> {private final EventFilterChain<T> next;private final EventFilter<T> filter;public DefaultEventFilterChain(EventFilterChain<T> next, EventFilter<T> filter) {this.next = next;this.filter = filter;}@Overridepublic void handler(T context) {filter.doFilter(context,this);}@Overridepublic void nextHandler(T context) {if (next != null) {next.handler(context);}}}

selector

FilterSelector
public interface FilterSelector {/*** 匹配过滤器** @param currentFilterName 过滤器名称* @return true 匹配成功*/boolean matchFilter(String currentFilterName);/*** 获取当前所有过滤器名称** @return 过滤器名称*/List<String> getAllFilterNames();
}
DefaultFilterSelector
public class DefaultFilterSelector implements FilterSelector{@Setterprivate  List<String> filterNames = CollUtil.newArrayList();@Overridepublic boolean matchFilter(String currentFilterName) {return filterNames.stream().anyMatch(s -> Objects.equals(s,currentFilterName));}@Overridepublic List<String> getAllFilterNames() {return filterNames;}}

调用代码

请添加图片描述

PipelineApplication

@SpringBootApplication
@EnablePluginRegistries(value = {Business1PostPlugin.class, Business2PostPlugin.class})
public class PipelineApplication {public static void main(String[] args) {SpringApplication.run(PipelineApplication.class, args);}
}

controller

@RestController
@RequestMapping("/pipelineTest")
public class PipelineController {@Autowiredprivate Business1Service business1PipelineTestService;@Autowiredprivate Business2Service business2PipelineTestService;@GetMapping("/business1")public void business1(){PipelineRequestVo pipelineTestRequest = new PipelineRequestVo();pipelineTestRequest.setUuid("business1-1110-1111231afsas-123adss");pipelineTestRequest.setBusinessCode("business1");pipelineTestRequest.setModel2(new Business1Model2());pipelineTestRequest.setModel1(new Business1Model1());business1PipelineTestService.doService(pipelineTestRequest);}@GetMapping("/business2")public void business2(){PipelineRequestVo pipelineTestRequest = new PipelineRequestVo();pipelineTestRequest.setUuid("business2-1110-1111231afsas-123adss");pipelineTestRequest.setBusinessCode("business2");pipelineTestRequest.setModel3(new Business2Model1());pipelineTestRequest.setModel4(new Business2Model2());business2PipelineTestService.doService(pipelineTestRequest);}}

entity

@Data
public class PipelineRequestVo {private String uuid;private String businessCode;/*** 在自定义的filter中处理*/@Setter@Getterprivate Business1Model1 model1;/*** 在自定义的filter中处理*/@Setter@Getterprivate Business1Model2 model2;/*** 在自定义的filter中处理*/@Setter@Getterprivate Business2Model1 model3;/*** 在自定义的filter中处理*/@Setter@Getterprivate Business2Model2 model4;}

service

@Getter
@AllArgsConstructor
public enum BusinessTypeEnum implements BizType {BUSINESS_1(1,"业务1"),BUSINESS_2(2,"业务2"),BUSINESS_3(3,"业务3"),;private Integer code;private String name;}

service.business1

public interface Business1Service {void doService(PipelineRequestVo pipelineTestRequest);
}
@Slf4j
@Service
public class Business1ServiceImpl implements Business1Service {@Qualifier("business1PipelineSelectorFactory")@Autowiredprivate  PipelineSelectorFactory business1PipelineSelectorFactory;@Autowiredprivate  FilterChainPipeline<Business1PipelineFilter> filterChainPipeline;@Autowiredprivate  PluginRegistry<Business1PostPlugin, Business1Model1> business1PostPlugin;@Overridepublic void doService(PipelineRequestVo pipelineTestRequest) {log.info("===============business1开始===============");// 处理器参数log.info("===============开始获取FilterSelector===============");FilterSelector filterSelector = business1PipelineSelectorFactory.getFilterSelector(pipelineTestRequest);Business1Context pipelineEventContext = new Business1Context(BusinessTypeEnum.BUSINESS_1, filterSelector);log.info("获取FilterSelector完成: {}",filterSelector.getAllFilterNames());log.info("===============获取FilterSelector完成===============");// 处理log.info("===============开始执行过滤器===============");pipelineEventContext.setPipelineTestRequest(pipelineTestRequest);pipelineEventContext.setModel2(pipelineTestRequest.getModel2());pipelineEventContext.setModel1(pipelineTestRequest.getModel1());filterChainPipeline.getFilterChain().handler(pipelineEventContext);log.info("===============执行过滤器完成===============");// 处理后获取值log.info("===============开始执行后置处理器===============");Business1Model2 model2 = pipelineEventContext.getModel2();Business1Model1 model1 = pipelineEventContext.getModel1();PipelineRequestVo pipelineTestRequest1 = pipelineEventContext.getPipelineTestRequest();business1PostPlugin.getPluginsFor(model1).forEach(handler -> handler.postProcessing(model1));log.info("===============执行后置处理器完成===============");log.info("===============business1结束===============");}}

service.business1.context

public class Business1Context extends AbstractEventContext {/*** 在自定义的filter中处理*/@Setter@Getterprivate Business1Model1 model1;/*** 在自定义的filter中处理*/@Setter@Getterprivate Business1Model2 model2;/*** 在自定义的filter中处理*/@Setter@Getterprivate PipelineRequestVo pipelineTestRequest;public Business1Context(BizType businessType, FilterSelector filterSelector) {super(businessType, filterSelector);}@Overridepublic boolean continueChain() {return true;}}
@Data
public class Business1Model1 {private Integer id;private String name1;private String name2;private String name3;}
@Data
public class Business1Model2 {private Integer id;private String name;private String desc;private String age;}

service.business1.filters

public interface Business1PipelineFilter extends EventFilter<Business1Context> {int order();
}
@Slf4j
@Component
public class Business1Filter1 extends AbstractEventFilter<Business1Context> implements Business1PipelineFilter {@Overridepublic void handler(Business1Context context) {// 模拟操作数据库 等业务操作 可以利用门面模式进行解耦Business1Model1 model1 = context.getModel1();model1.setName1("张三");model1.setName2("李四");model1.setName3("王五");model1.setId(1);Business1Model2 model2 = context.getModel2();model2.setId(2);model2.setDesc("");model2.setAge("18");model2.setName("小白");log.info("Filter1执行完毕...");// 存入新的值到上下文对象中 下个处理器继续处理context.setModel1(model1);context.setModel2(model2);}@Overridepublic int order() {return 1;}
}
@Slf4j
@Component
public class Business1Filter2 extends AbstractEventFilter<Business1Context>  implements Business1PipelineFilter {@Overridepublic void handler(Business1Context context) {// 模拟操作数据库 等业务操作 可以利用门面模式进行解耦Business1Model1 model1 = context.getModel1();model1.setName1(model1.getName1() + "-------------");model1.setName2(model1.getName2() + "-------------");model1.setName3(model1.getName3() + "-------------");model1.setId(100);log.info("Filter2执行完毕...");// 存入新的值到上下文对象中 下个处理器继续处理context.setModel1(model1);context.setModel2(context.getModel2());}@Overridepublic int order() {return 2;}
}

service.business1.plugins

public interface Business1PostPlugin extends Plugin<Business1Model1> {/*** 后置处理** @param model 处理参数*/void postProcessing(Business1Model1 model);}
@Slf4j
@Component
public class Business1ServicePluginImpl implements Business1PostPlugin {@Overridepublic boolean supports(Business1Model1 pipelineEventContext) {return true;}@Overridepublic void postProcessing(Business1Model1 model) {log.info("===>{}",model.getId());}}
@Slf4j
@Component
public class Business1ServicePluginImpl2 implements Business1PostPlugin {@Overridepublic boolean supports(Business1Model1 model) {return true;}@Overridepublic void postProcessing(Business1Model1 model) {log.info("===>{}",model.getId());}}

service.business2

public interface Business2Service {void doService(PipelineRequestVo pipelineTestRequest);
}
@Slf4j
@Service
public class Business2ServiceImpl implements Business2Service {@Qualifier("business2PipelineSelectorFactory")@Autowiredprivate PipelineSelectorFactory business2PipelineSelectorFactory;@Autowiredprivate FilterChainPipeline<Business2PipelineFilter> filterChainPipeline;@Autowiredprivate PluginRegistry<Business2PostPlugin, Business2Model1> business2PostPlugin;@Overridepublic void doService(PipelineRequestVo pipelineTestRequest) {log.info("===============business2开始===============");// 处理器参数log.info("===============开始获取FilterSelector===============");FilterSelector filterSelector = business2PipelineSelectorFactory.getFilterSelector(pipelineTestRequest);Business2Context pipelineEventContext = new Business2Context(BusinessTypeEnum.BUSINESS_2, filterSelector);log.info("获取FilterSelector完成: {}",filterSelector.getAllFilterNames());log.info("===============获取FilterSelector完成===============");// 处理log.info("===============开始执行过滤器===============");pipelineEventContext.setPipelineTestRequest(pipelineTestRequest);pipelineEventContext.setModel2(pipelineTestRequest.getModel4());pipelineEventContext.setModel1(pipelineTestRequest.getModel3());filterChainPipeline.getFilterChain().handler(pipelineEventContext);log.info("===============执行过滤器完成===============");// 处理后获取值log.info("===============开始执行后置处理器===============");Business2Model2 model2 = pipelineEventContext.getModel2();Business2Model1 model1 = pipelineEventContext.getModel1();PipelineRequestVo pipelineTestRequest1 = pipelineEventContext.getPipelineTestRequest();business2PostPlugin.getPluginsFor(model1).forEach(handler -> handler.postProcessing(model1));log.info("===============执行后置处理器完成===============");log.info("===============business2结束===============");}}

service.business2.context

public class Business2Context extends AbstractEventContext {/*** 在自定义的filter中处理*/@Setter@Getterprivate Business2Model1 model1;/*** 在自定义的filter中处理*/@Setter@Getterprivate Business2Model2 model2;/*** 在自定义的filter中处理*/@Setter@Getterprivate PipelineRequestVo pipelineTestRequest;public Business2Context(BizType businessType, FilterSelector filterSelector) {super(businessType, filterSelector);}@Overridepublic boolean continueChain() {return true;}}
@Data
public class Business2Model1 {private Integer id;private String name1;private String name2;private String name3;}
@Data
public class Business2Model2 {private Integer id;private String name;private String desc;private String age;}

service.business2.filters

public interface Business2PipelineFilter extends EventFilter<Business2Context> {int order();
}
@Slf4j
@Component
public class Business2Filter1 extends AbstractEventFilter<Business2Context> implements Business2PipelineFilter {@Overridepublic void handler(Business2Context context) {// 模拟操作数据库 等业务操作 可以利用门面模式进行解耦Business2Model1 model1 = context.getModel1();model1.setName1("张三");model1.setName2("李四");model1.setName3("王五");model1.setId(1);Business2Model2 model2 = context.getModel2();model2.setId(2);model2.setDesc("");model2.setAge("18");model2.setName("小白");log.info("Filter1执行完毕...");// 存入新的值到上下文对象中 下个处理器继续处理context.setModel1(model1);context.setModel2(model2);}@Overridepublic int order() {return 1;}
}
@Slf4j
@Component
public class Business2Filter2 extends AbstractEventFilter<Business2Context>  implements Business2PipelineFilter {@Overridepublic void handler(Business2Context context) {// 模拟操作数据库 等业务操作 可以利用门面模式进行解耦Business2Model1 model1 = context.getModel1();model1.setName1(model1.getName1() + "-------------");model1.setName2(model1.getName2() + "-------------");model1.setName3(model1.getName3() + "-------------");model1.setId(100);log.info("Filter2执行完毕...");// 存入新的值到上下文对象中 下个处理器继续处理context.setModel1(model1);context.setModel2(context.getModel2());}@Overridepublic int order() {return 2;}
}

service.business2.plugins

public interface Business2PostPlugin extends Plugin<Business2Model1> {/*** 后置处理** @param model 处理参数*/void postProcessing(Business2Model1 model);}
@Slf4j
@Component
public class Business2ServicePluginImpl implements Business2PostPlugin {@Overridepublic boolean supports(Business2Model1 pipelineEventContext) {return true;}@Overridepublic void postProcessing(Business2Model1 model) {log.info("===>{}",model.getId());}}
@Slf4j
@Component
public class Business2ServicePluginImpl2 implements Business2PostPlugin {@Overridepublic boolean supports(Business2Model1 model) {return true;}@Overridepublic void postProcessing(Business2Model1 model) {log.info("===>{}",model.getId());}}

service.config

@ConfigurationProperties(prefix = "test")
@Component
@Data
public class FilterConfigProperties {private Map<String, List<String>> configs;public Map<String, List<String>> getConfigs() {if (configs == null) {configs = MapUtil.newHashMap(16);}return configs;}}
@Component
@RequiredArgsConstructor
public class PipelineFilterConfig {private final List<Business1PipelineFilter> business1PipelineFilter;private final FilterChainPipeline<Business1PipelineFilter> business1FilterChainPipeline;private final List<Business2PipelineFilter> business2PipelineFilter;private final FilterChainPipeline<Business2PipelineFilter> business2FilterChainPipeline;private final FilterConfigProperties filterConfigProperties;@Beanpublic FilterChainPipeline<Business1PipelineFilter> business1ChargePipeline() {Map<String, List<String>> configs = filterConfigProperties.getConfigs();if (business1PipelineFilter.isEmpty() || configs.isEmpty()){return business1FilterChainPipeline;}Set<Map.Entry<String, List<String>>> filtersName = configs.entrySet();long distinctCount = filtersName.stream().distinct().count();if (distinctCount > business1PipelineFilter.size()) {throw new IllegalArgumentException("设置的过滤器数量大于实际过滤器数量");}business1PipelineFilter.stream().sorted(Comparator.comparing(Business1PipelineFilter::order)).forEach(business1FilterChainPipeline::append);return business1FilterChainPipeline;}@Beanpublic FilterChainPipeline<Business2PipelineFilter> business2ChargePipeline() {Map<String, List<String>> configs = filterConfigProperties.getConfigs();if (business2PipelineFilter.isEmpty() || configs.isEmpty()){return business2FilterChainPipeline;}Set<Map.Entry<String, List<String>>> filtersName = configs.entrySet();long distinctCount = filtersName.stream().distinct().count();if (distinctCount > business2PipelineFilter.size()) {throw new IllegalArgumentException("设置的过滤器数量大于实际过滤器数量");}business2PipelineFilter.stream().sorted(Comparator.comparing(Business2PipelineFilter::order)).forEach(business2FilterChainPipeline::append);return business2FilterChainPipeline;}}

service.selector

public interface PipelineSelectorFactory {FilterSelector  getFilterSelector(PipelineRequestVo request);
}
@Component("business1PipelineSelectorFactory")
public class Business1PipelineSelectorFactory implements PipelineSelectorFactory {@Autowiredprivate FilterConfigProperties filterConfigProperties;@Overridepublic FilterSelector getFilterSelector(PipelineRequestVo request) {String businessCode = request.getBusinessCode();DefaultFilterSelector defaultFilterSelector = new DefaultFilterSelector();if (businessCode.equals("business1")){defaultFilterSelector.setFilterNames(filterConfigProperties.getConfigs().getOrDefault(businessCode, Collections.unmodifiableList(new ArrayList<>())));}return defaultFilterSelector;}
}
@Component("business2PipelineSelectorFactory")
public class Business2PipelineSelectorFactory implements PipelineSelectorFactory {@Autowiredprivate FilterConfigProperties filterConfigProperties;@Overridepublic FilterSelector getFilterSelector(PipelineRequestVo request) {String businessCode = request.getBusinessCode();DefaultFilterSelector defaultFilterSelector = new DefaultFilterSelector();if (businessCode.equals("business2")){defaultFilterSelector.setFilterNames(filterConfigProperties.getConfigs().getOrDefault(businessCode, Collections.unmodifiableList(new ArrayList<>())));}return defaultFilterSelector;}}

application.yml

server:port: 8080test:configs:business1:- Business1Filter1- Business1Filter2business2:- Business2Filter1- Business2Filter2

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/371.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

浅析binance新币OMNI的前世今生

大盘跌跌不休&#xff0c;近期唯一的指望就是binance即将上线的OMNI 。虽然目前查到的空投数量不及预期&#xff0c;但OMNI能首发币安&#xff0c;确实远超预期了。 OMNI代币总量1亿&#xff0c;初始流通仅10,391,492枚&#xff0c;其中币安Lanchpool可挖350万枚 对于OMNI这个…

设计模式——模版模式21

模板方法模式在超类中定义了一个事务流程的框架&#xff0c; 允许子类在不修改结构的情况下重写其中一个或者多个特定步骤。下面以ggbond的校招礼盒发放为例。 设计模式&#xff0c;一定要敲代码理解 模版抽象 /*** author ggbond* date 2024年04月18日 17:32* 发送奖品*/ p…

50.HarmonyOS鸿蒙系统 App(ArkUI)web组件实现简易浏览器

50.HarmonyOS鸿蒙系统 App(ArkUI)web组件实现简易浏览器 配置网络访问权限&#xff1a; 跳转任务&#xff1a; Button(转到).onClick(() > {try {// 点击按钮时&#xff0c;通过loadUrl&#xff0c;跳转到www.example1.comthis.webviewController.loadUrl(this.get_url);} …

代码随想录第39天|62.不同路径 63. 不同路径 II

62.不同路径 62. 不同路径 - 力扣&#xff08;LeetCode&#xff09; 代码随想录 (programmercarl.com) 动态规划中如何初始化很重要&#xff01;| LeetCode&#xff1a;62.不同路径_哔哩哔哩_bilibili 一个机器人位于一个 m x n 网格的左上角 &#xff08;起始点在下图中标…

Codeforces Round 782 (Div. 2) D. Reverse Sort Sum

题目 思路&#xff1a; #include <bits/stdc.h> using namespace std; #define int long long #define pb push_back #define fi first #define se second #define lson p << 1 #define rson p << 1 | 1 const int maxn 1e6 5, inf 1e9, maxm 4e4 5; co…

【WP】猿人学4 雪碧图、样式干扰

https://match.yuanrenxue.cn/match/4 探索 首先打开Fiddler&#xff0c;发现每个包的除了page参数一样&#xff0c;然后重放攻击可以实现&#xff0c;尝试py复现 Python可以正常拿到数据&#xff0c;这题不考请求&#xff0c;这题的难点原来在于数据的加密&#xff0c;这些数字…

用10个Kimichat提示词5分钟创建一门在线课程

●研究市场并在生成式AI主题内找到一个特定细分市场&#xff0c;这一市场尚未被现有课程充分覆盖。使用在线研究来收集关于当前可用课程类型的信息&#xff0c;以及市场上存在哪些空白。利用这些信息创建一个填补空白并吸引对“生成式AI”感兴趣的特定受众群体的课程。确定课程…

面试经典算法系列之二叉树17 -- 验证二叉树

面试经典算法32 - 验证二叉树 LeetCode.98 公众号&#xff1a;阿Q技术站 问题描述 给你一个二叉树的根节点 root &#xff0c;判断其是否是一个有效的二叉搜索树。 有效 二叉搜索树定义如下&#xff1a; 节点的左子树只包含 小于 当前节点的数。节点的右子树只包含 大于 当…

ActiveMQ 如果数据处理出现异常会怎么样

我们有一个 Spring 的客户端&#xff0c;在处理消息的时候因为程序的原因出现消息处理异常。 对这种情况&#xff0c;ActiveMQ 会把出现异常的消息放在 DLQ 队列中进行持久化。 因此&#xff0c;在 ActiveMQ 消息处理队列中需要持续关注 DLQ 队列&#xff0c; DLQ 的队列都是无…

生成人工智能体:人类行为的交互式模拟论文与源码架构解析(5)——可控评估端到端评估

最后完结篇,文末有测试中发现的有趣现象,并附上了相关资料链接~ 5.可控评估 分两个阶段评估生成代理。我们从一个更加严格控制的评估开始,单独评估代理的响应,以了解它们是否在狭义上定义的上下文中产生可信的行为。然后,在我们对代理社区进行为期两天的端到端分析中,我…

蓝桥杯2024年第十五届省赛真题-数字接龙

思路&#xff1a;DFS&#xff0c;因为输入的i&#xff0c;j的顺序导致&#xff0c;方向向量中x是行编号&#xff0c;y是列编号。方向向量可能和直觉上不同。 错的 //int dx[8]{0,1,1,1,0,-1,-1,-1}; //int dy[8]{1,1,0,-1,-1,-1,0,1}; 对的 int dx[]{-1,-1,0,1,1,1,0,-1}; int…

数据结构(顺序栈

目录 1. 讲解&#xff1a;2. C代码实现&#xff1a;小结&#xff1a; 1. 讲解&#xff1a; 用顺序的物理结构&#xff08;数组&#xff09;存储栈这个数据结构&#xff0c;实现栈的创建、销毁、增删查、判空。 top指针的指向位置有两种实现方法&#xff1a;一个是指向栈顶元素…

页缓存(PageCache)和预读机制(readahead )

页缓存&#xff08;PageCache)和预读机制&#xff08;readahead &#xff09; 页缓存&#xff08;PageCache)是操作系统&#xff08;OS&#xff09;对文件的缓存&#xff0c;用于加速对文件的读写。 page 是内存管理分配的基本单位&#xff0c; Page Cache 由多个 page 构成&…

《Super Simple Skybox》天空盒 -- 创造绝美天空的神奇工具!限时免费!

《Super Simple Skybox》天空盒 -- 创造绝美天空的神奇工具&#xff01;限时免费&#xff01; 前言内容介绍资源特色动态&#xff0c;美丽的天空在几秒钟内即插即用 功能列表领取兑换码 前言 ^^在这个充满创意与想象的世界里&#xff0c;Unity 免费资源犹如一颗璀璨的明珠&…

react合成事件与原生事件区别备忘

朋友问起在做一个下拉框组件&#xff0c;下拉的点击事件是用react的onClick触发&#xff0c;外部区域点击关闭则用dom的原生点击事件绑定&#xff0c;问题是下拉的点击事件无法阻止冒泡到dom的原生事件。 我说&#xff0c;react的合成事件 和 原生事件是不一样的&#xff0c;尽…

三、fpga对完成过滤和校验的有效包数据进行有效像素提取、MATLAB对数据源进行处理与下发(完整实现pc机→显示器通信链路)

前言:上篇文章实现了MATLAB模拟发送UDP以太网协议数据包到fpga,能实现双沿数据→单沿数据转换,并将转换后的数据进行包过滤和crc校验,本篇内容要实现真正的从pc机下发视频数据,经过千兆以太网传输存储到fpga 的ddr3中,然后通过hdmi读出到显示屏上。 文章目录 一、模块设…

鸿蒙入门06-常见装饰器( 简单装饰器 )

装饰器是鸿蒙开发中非常重要的一个环节因为在很多地方我们都需要用到装饰器并且如果我们想高度的复用, 那么装饰器就是必不可少的一环接下来我们就来介绍一些常见的装饰器注意 : 所有装饰器首字母大写 Entry 用来装饰 struct 使用表示页面的入口 Component 装饰 struct, …

基于Springboot的论坛管理系统

基于SpringbootVue的论坛管理系统的设计与实现 开发语言&#xff1a;Java数据库&#xff1a;MySQL技术&#xff1a;SpringbootMybatis工具&#xff1a;IDEA、Maven、Navicat 系统展示 用户登录 首页 公告 热门帖子 论坛新天地 新闻资讯 留言反馈 后台登录 用户管理 公告管理…

java宠物领养系统的设计与实现(springboot+mysql+源码)

风定落花生&#xff0c;歌声逐流水&#xff0c;大家好我是风歌&#xff0c;混迹在java圈的辛苦码农。今天要和大家聊的是一款基于springboot的宠物领养系统的设计与实现。项目源码以及部署相关请联系风歌&#xff0c;文末附上联系信息 。 项目简介&#xff1a; 基于Spring Bo…

JavaWeb--04YApi,Vue-cli脚手架Node.js环境搭建,创建第一个Vue项目

04 1 Yapi2 Vue-cli脚手架Node.js环境搭建配置npm的全局安装路径 3 创建项目&#xff08;这个看下一篇文章吧&#xff09; 1 Yapi 前后端分离中的重要枢纽"接口文档",以下一款为Yapi的接口文档 介绍&#xff1a;YApi 是高效、易用、功能强大的 api 管理平台&#…