古道长亭

Contact me with ixiaoqiang0011@gmail.com


  • 首页

  • 归档

  • 分类

  • 关于

  • Book

  • 搜索

项目架构演变过程

时间: 2022-10-16   |   分类: dubbo   | 字数: 1267 字 | 阅读约: 3分钟

项目架构演变过程

1.单体架构

单体架构所有模块和功能都集中在一个项目中 ,部署时也是将项目所有功能部整体署到服务器中。不做详细介绍

2.垂直架构

根据业务把项目垂直切割成多个项目,因此这种架构称之为垂直架构。

阅读全文 »

SSM整合

时间: 2022-10-15   |   分类: Spring mvc   | 字数: 592 字 | 阅读约: 2分钟

SSM整合

整合策略

  • 先Spring + Mybatis
  • 再整合Spring mvc

示例需求:查询user表全部数据并展示的页面

1. Spring + Mybatis

  • 整合目标

    • 数据库连接池及事务管理器都交给Spring容器完成
    • SqlSessionFactory对象放到Spring容器中,作为单例对象管理
    • Mapper动态代理对象交给Spring管理,我们从容器中直接获得Mapper代理对象
  • 整合所需依赖

阅读全文 »

zookeeper深入进阶

时间: 2022-10-15   |   分类: zookeeper   | 字数: 9571 字 | 阅读约: 20分钟

zookeeper深入进阶

1.zab协议

在深⼊了解zookeeper之前,很多同学可能会认为zookeeper就是paxos算法的⼀个实现,但事实上,zookeeper并没有完全采⽤paxos算法,⽽是使⽤了⼀种称为ZookeeperAtomicBroadcast(ZAB,Zookeeper原⼦消息⼴播协议)的协议作为其数据⼀致性的核⼼算法。

阅读全文 »

Spring mvc 源码剖析

时间: 2022-10-14   |   分类: Spring mvc   | 字数: 1304 字 | 阅读约: 3分钟

Spring mvc 源码剖析

一、DispatcherServlet继承结构

二、重要时机点分析

1.handler方法执行时机

doDispatch方法的 ha.handle方法调用

2.页面渲染时机

jsp页面打断点

调用了 processDispatchResult

Spring处理请求的流程为:

  1. 调⽤getHandler()获取到能够处理当前请求的执⾏链 HandlerExecutionChain(handler+拦截器)
  2. 调⽤getHandlerAdapter();获取能够执⾏1中Handler的适配器
  3. 适配器调⽤Handler执⾏ha.handle(总会返回⼀个ModelAndView对象)
  4. 调⽤processDispatchResult()⽅法完成视图渲染跳转
protected void doDispatch(HttpServletRequest request, HttpServletResponse response) throws Exception {
		HttpServletRequest processedRequest = request;
		HandlerExecutionChain mappedHandler = null;
		boolean multipartRequestParsed = false;

		WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request);

		try {
			ModelAndView mv = null;
			Exception dispatchException = null;

			try {
        //检查是否是文件上传请求
				processedRequest = checkMultipart(request);
				multipartRequestParsed = (processedRequest != request);

				// Determine handler for the current request.
        //取得处理当前请求的Controller,这⾥也称为Handler,即处理器
        //这⾥并不是直接返回 Controller,⽽是返回 HandlerExecutionChain 请求处理链对象
				//该对象封装了Handler和Inteceptor
				mappedHandler = getHandler(processedRequest);
				if (mappedHandler == null) {
					// 如果 handler 为空,则返回404
					noHandlerFound(processedRequest, response);
					return;
				}

				// Determine handler adapter for the current request.
        //获取处理请求的处理器适配器 HandlerAdapter
				HandlerAdapter ha = getHandlerAdapter(mappedHandler.getHandler());

				// Process last-modified header, if supported by the handler.
        //处理 last-modified 请求头
				String method = request.getMethod();
				boolean isGet = "GET".equals(method);
				if (isGet || "HEAD".equals(method)) {
					long lastModified = ha.getLastModified(request, mappedHandler.getHandler());
					if (new ServletWebRequest(request, response).checkNotModified(lastModified) && isGet) {
						return;
					}
				}

				if (!mappedHandler.applyPreHandle(processedRequest, response)) {
					return;
				}

				// Actually invoke the handler.
        //实际处理器处理请求,返回结果视图对象
				mv = ha.handle(processedRequest, response, mappedHandler.getHandler());

				if (asyncManager.isConcurrentHandlingStarted()) {
					return;
				}
				//结果视图对象的处理
				applyDefaultViewName(processedRequest, mv);
				mappedHandler.applyPostHandle(processedRequest, response, mv);
			}
			catch (Exception ex) {
				dispatchException = ex;
			}
			catch (Throwable err) {
				// As of 4.3, we're processing Errors thrown from handler methods as well,
				// making them available for @ExceptionHandler methods and other scenarios.
				dispatchException = new NestedServletException("Handler dispatch failed", err);
			}
      //跳转⻚⾯,渲染视图
			processDispatchResult(processedRequest, response, mappedHandler, mv, dispatchException);
		}
		catch (Exception ex) {
      //最终会调⽤HandlerInterceptor的afterCompletion ⽅法
			triggerAfterCompletion(processedRequest, response, mappedHandler, ex);
		}
		catch (Throwable err) {
      //最终会调⽤HandlerInterceptor的afterCompletion ⽅法
			triggerAfterCompletion(processedRequest, response, mappedHandler,
					new NestedServletException("Handler processing failed", err));
		}
		finally {
			if (asyncManager.isConcurrentHandlingStarted()) {
				// Instead of postHandle and afterCompletion
				if (mappedHandler != null) {
					mappedHandler.applyAfterConcurrentHandlingStarted(processedRequest, response);
				}
			}
			else {
				// Clean up any resources used by a multipart request.
				if (multipartRequestParsed) {
					cleanupMultipart(processedRequest);
				}
			}
		}
	}

三、核心步骤getHandler剖析

阅读全文 »

zookeeper应用场景

时间: 2022-10-14   |   分类: zookeeper   | 字数: 9020 字 | 阅读约: 19分钟

zookeeper应用场景

1.数据发布/订阅

数据发布/订阅(Publish/Subscribe)系统,即所谓的配置中⼼,顾名思义就是发布者将数据发布到 ZooKeeper的⼀个或⼀系列节点上,供订阅者进⾏数据订阅,进⽽达到动态获取数据的⽬的,实现配置信息的集中式管理和数据的动态更新。

阅读全文 »
28 29 30 31 32 33 34 35 36
古道长亭

古道长亭

Always remember that your present situation is not your final destination. The best is yet to come.

226 日志
57 分类
104 标签
GitHub Gitee
友情链接
  • 古道长亭的BOOK
  • JAVA学习
标签云
  • Mysql
  • 搜索引擎
  • Mybatis
  • 容器
  • 架构
  • 消息队列
  • Flink
  • Sharding sphere
  • 流处理
  • 缓存
© 2019 - 2024 京ICP备19012088号-1
0%