当前位置: 首页 > news >正文

室内设计展厅设计seo网络推广方法

室内设计展厅设计,seo网络推广方法,知识产权教育网站建设,网站推广的方法和渠道文章目录 责任链模式工厂模式适配器模式代理模式模版方法观察者模式构造器模式 责任链模式 Spring中的Aop的通知调用会使用责任链模式责任链模式介绍 角色:抽象处理者(Handler)具体处理者(ConcreteHandler1)客户类角…

文章目录

  • 责任链模式
  • 工厂模式
  • 适配器模式
  • 代理模式
  • 模版方法
  • 观察者模式
  • 构造器模式

责任链模式

Spring中的Aop的通知调用会使用责任链模式

责任链模式介绍

角色:抽象处理者(Handler)具体处理者(ConcreteHandler1)客户类角色(Client)

Spring源码介绍

spring中Aop的责任链模式,相对于传统的责任链模式做了一定的改造。
传统的设计模式,抽象处理者会有一个方法设置和获取具体处理者的下一个处理者的方法。
如:

public abstract class Handler {private Handler next;public Handler getNext() {return next;}public void setNext(Handler next) {this.next = next;}//处理请求的方法public abstract void handleRequest(String request);
}

但是Spring中的责任链模式没有这两个方法,而是抽出一个公共的处理方法,方法内有数组和下标来完成链式。

public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Cloneable {// 环绕通知类protected final List<?> interceptorsAndDynamicMethodMatchers;// 下标private int currentInterceptorIndex = -1;
/*** 递归获取通知,然后执行* @return* @throws Throwable*/@Override@Nullablepublic Object proceed() throws Throwable {// We start with an index of -1 and increment early.// 从索引为-1的拦截器开始调用,并按序递增,如果拦截器链中的拦截器迭代调用完毕,开始调用target的函数,这个函数是通过反射机制完成的// 具体实现在AopUtils.invokeJoinpointUsingReflection方法中if (this.currentInterceptorIndex == this.interceptorsAndDynamicMethodMatchers.size() - 1) {return invokeJoinpoint();}// 获取下一个要执行的拦截器,沿着定义好的interceptorOrInterceptionAdvice链进行处理Object interceptorOrInterceptionAdvice =this.interceptorsAndDynamicMethodMatchers.get(++this.currentInterceptorIndex);if (interceptorOrInterceptionAdvice instanceof InterceptorAndDynamicMethodMatcher) {// Evaluate dynamic method matcher here: static part will already have// been evaluated and found to match.// 这里对拦截器进行动态匹配的判断,这里是对pointcut触发进行匹配的地方,如果和定义的pointcut匹配,那么这个advice将会得到执行InterceptorAndDynamicMethodMatcher dm =(InterceptorAndDynamicMethodMatcher) interceptorOrInterceptionAdvice;Class<?> targetClass = (this.targetClass != null ? this.targetClass : this.method.getDeclaringClass());if (dm.methodMatcher.matches(this.method, targetClass, this.arguments)) {return dm.interceptor.invoke(this);}else {// Dynamic matching failed.// Skip this interceptor and invoke the next in the chain.// 如果不匹配,那么proceed会被递归调用,知道所有的拦截器都被运行过位置return proceed();}}else {// It's an interceptor, so we just invoke it: The pointcut will have// been evaluated statically before this object was constructed.// 普通拦截器,直接调用拦截器,将this作为参数传递以保证当前实例中调用链的执行return ((MethodInterceptor) interceptorOrInterceptionAdvice).invoke(this);}}
}

其中的最后一句

// 普通拦截器,直接调用拦截器,将this作为参数传递以保证当前实例中调用链的执行
return ((MethodInterceptor) interceptorOrInterceptionAdvice).invoke(this);

MethodInterceptor就是抽象处理者

@FunctionalInterface
public interface MethodInterceptor extends Interceptor {/*** */Object invoke(MethodInvocation invocation) throws Throwable;
}

具体的执行者有
AspectJAfterAdvice、AspectJAfterReturningAdvice、AspectJAfterThrowingAdvice、AspectJMethodBeforeAdvice、AspectJAroundAdvice

工厂模式

Spring中的获取Bean就是工厂模式,如:BeanFactory获取

工厂模式介绍

角色:抽象产品具体产品抽象工厂具体工厂

Spring源码介绍

抽象工厂

public interface BeanFactory {Object getBean(String name) throws BeansException;...
}

具体工厂

适配器模式

Spring中的根据通知的时候,将Advisor适配为MethodInterceptor

适配器介绍

角色目标接口:抽象适配器:具体适配器:抽象源接口:具体源接口:适配器就是将源接口适配为目标接口

Spring中的源码介绍

抽象适配器:

public interface AdvisorAdapter {/*** 适配方法,将Advisor适配为MethodInterceptor Advisor就是源接口:MethodInterceptor就是目标接口*/MethodInterceptor getInterceptor(Advisor advisor);
}

具体适配器:
在这里插入图片描述

class AfterReturningAdviceAdapter implements AdvisorAdapter, Serializable {@Overridepublic boolean supportsAdvice(Advice advice) {return (advice instanceof AfterReturningAdvice);}@Overridepublic MethodInterceptor getInterceptor(Advisor advisor) {AfterReturningAdvice advice = (AfterReturningAdvice) advisor.getAdvice();return new AfterReturningAdviceInterceptor(advice);}
}

具体源接口:
在这里插入图片描述

代理模式

cglib、gdk代理

模版方法

Spring中的refresh方法中的postProcessFactory、onRefresh等

观察者模式

Spring中的事件监听

角色:
抽象目标,
具体目标,
具体观察者,
抽象观察者

抽象目标里面会有一个数组,存放具体的观察者,并且会有一个添加删除观察者的方法,还有一个通知所有观察者的方法。具体目标需要通知观察者的时候,遍历数组通知观察者

Spring中的事件监听做了一定的变动
有四个角色
广播器:其实就是我们的抽象目标,包含了添加删除,广播事件方法
监听器:监听广播器广播的事件
事件:
事件源:触发事件的人,将事件添加到广播器中

构造器模式

Spring中解析xml或者注解为BeanDefinition信息的时候会使用BeanDefinitionHandler类

该类里面包含了一个 BeanDefinition 字段,可以调佣BeanDefinitionHandler中的方法给该字段设值,最后可以调用方法获取BeanDefinition

http://www.15wanjia.com/news/22414.html

相关文章:

  • 网站评论回复如何做传媒公司
  • 筛网怎么做网站小红书软文案例
  • 静态双语企业网站后台源码营销策划公司经营范围
  • 天长做网站广告投放平台公司
  • 公司网站怎么做包括什么seo全国最好的公司
  • 东莞做营销型网站的成都seo优化排名公司
  • 大网站制作公司百度账号登陆入口
  • 怎么创建个网站百度认证号码平台
  • 谁有做爰网站百度云超级会员试用1天
  • 外国语学院英文网站建设windows清理优化大师
  • 网上注册平台怎么注册整站优化seo平台
  • 做零售外贸网站有哪些com域名
  • 桂林网站开发公司电话东莞推广系统
  • 网络规划设计师培训鄂州seo
  • 温州 网站网盘资源免费观看
  • 做微信封面模板下载网站查询网站备案信息
  • 黑龙江城乡建设厅网站化学sem是什么意思
  • 看门户是什么意思裤子seo关键词
  • 北京做彩右影影视公司网站百度经验发布平台
  • uni做网站首页网站seo是什么意思
  • 大连做环评网站蚂蚁链接bt链接
  • 微网站 模板软件推广赚佣金渠道
  • 印度喜欢用什么框架做外贸网站个人博客网站模板
  • 石家庄网站建设seo做网站怎么做
  • 徐汇网站制作长沙专业seo优化推荐
  • 烟台哪里做网站企业网站设计方案
  • 天津网站优化公司哪家好合肥网站优化排名推广
  • 网页设计的合适尺寸是多少芭嘞seo
  • 网站服务器ecs重庆森林经典台词截图
  • a片做视频网站济南优化seo公司