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

建设门户网站常见的网络推广方式有哪些

建设门户网站,常见的网络推广方式有哪些,规范网站建设情况的报告,食品公司简介模板Interceptor MyBatis 插件模块中最核心的接口就是 Interceptor 接口,它是所有 MyBatis 插件必须要实现的接口,其核心定义如下: public interface Interceptor {// 插件实现类中需要实现的拦截逻辑Object intercept(Invocation invocation) …

Interceptor

MyBatis 插件模块中最核心的接口就是 Interceptor 接口,它是所有 MyBatis 插件必须要实现的接口,其核心定义如下:

public interface Interceptor {// 插件实现类中需要实现的拦截逻辑Object intercept(Invocation invocation) throws Throwable;// 在该方法中会决定是否触发intercept()方法default Object plugin(Object target) {return Plugin.wrap(target, this);}default void setProperties(Properties properties) {// 在整个MyBatis初始化过程中用来初始化该插件的方法}}

MyBatis允许我们自定义 Interceptor 拦截 SQL 语句执行过程中的某些关键逻辑,允许拦截的方法有:Executor 类中的 update()、query()、flushStatements()、commit()、rollback()、getTransaction()、close()、isClosed()方法,ParameterHandler 中的 setParameters()、getParameterObject() 方法,ResultSetHandler中的 handleOutputParameters()、handleResultSets()方法,以及StatementHandler 中的parameterize()、prepare()、batch()、update()、query()方法。

自定义的插件

@Intercepts({@Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class,ResultHandler.class}),@Signature(type = Executor.class, method = "close", args = {boolean.class})
})
public class DemoPlugin implements Interceptor {private int logLevel; ... // 省略其他方法的实现
}

我们看到 DemoPlugin 这个示例类除了实现 Interceptor 接口外,还被标注了 @Intercepts 和 @Signature 两个注解。@Intercepts 注解中可以配置多个 @Signature 注解,@Signature 注解用来指定 DemoPlugin 插件实现类要拦截的目标方法信息,其中的 type 属性指定了要拦截的类,method 属性指定了要拦截的目标方法名称,args 属性指定了要拦截的目标方法的参数列表。通过 @Signature 注解中的这三个配置,DemoPlugin 就可以确定要拦截的目标方法的方法签名。在上面的示例中,DemoPlugin 会拦截 Executor 接口中的 query(MappedStatement, Object, RowBounds, ResultHandler) 方法和 close(boolean) 方法。

完成 DemoPlugin 实现类的编写之后,为了让 MyBatis 知道这个类的存在,我们要在 mybatis-config.xml 全局配置文件中对 DemoPlugin 进行配置,相关配置片段如下:

<plugins><plugin interceptor="design.Interceptor.DemoPlugin"><!-- 对拦截器中的属性进行初始化 --><property name="logLevel" value="1"/></plugin>
</plugins>

InterceptorChain

MyBatis 中 Executor、ParameterHandler、ResultSetHandler、StatementHandler 等与 SQL 执行相关的核心组件都是通过 Configuration.new*() 方法生成的。以 newExecutor() 方法为例,我们会看到下面这行代码,InterceptorChain.pluginAll() 方法会为目标对象(也就是这里的 Executor 对象)创建代理对象并返回。

executor = (Executor) interceptorChain.pluginAll(executor);
public Object pluginAll(Object target) {for (Interceptor interceptor : interceptors) {// 遍历interceptors集合,调用每个Interceptor对象的plugin()方法target = interceptor.plugin(target);}return target;
}

Plugin

从 DemoPlugin 示例中,我们可以看到 plugin() 方法依赖 MyBatis 提供的 Plugin.wrap() 工具方法创建代理对象

MyBatis 提供的 Plugin 工具类实现了 JDK 动态代理中的 InvocationHandler 接口,同时维护了下面三个关键字段。

  • target(Object 类型):要拦截的目标对象。
  • signatureMap(Map<Class<?>, Set> 类型):记录了 @Signature 注解中配置的方法信息,也就是代理要拦截的目标方法信息。
  • interceptor(Interceptor 类型):目标方法被拦截后,要执行的逻辑就写在了该 Interceptor 对象的 intercept() 方法中。

在 invoke() 方法中,Plugin 会检查当前要执行的方法是否在 signatureMap 集合中,如果在其中的话,表示当前待执行的方法是我们要拦截的目标方法之一,也就会调用 intercept() 方法执行代理逻辑;如果未在其中的话,则表示当前方法不应被代理,直接执行当前的方法即可。下面就是 Plugin.invoke() 方法的核心实现:

public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {try {// 获取当前类被拦截的方法Set<Method> methods = signatureMap.get(method.getDeclaringClass());// 如果当前方法需要被代理,则执行intercept()方法进行拦截处理if (methods != null && methods.contains(method)) {return interceptor.intercept(new Invocation(target, method, args));}return method.invoke(target, args);} catch (Exception e) {throw ExceptionUtil.unwrapThrowable(e);}}

文章转载自:
http://www.morning.rbrd.cn.gov.cn.rbrd.cn
http://www.morning.tyhfz.cn.gov.cn.tyhfz.cn
http://www.morning.lkxzb.cn.gov.cn.lkxzb.cn
http://www.morning.ylkkh.cn.gov.cn.ylkkh.cn
http://www.morning.xckrj.cn.gov.cn.xckrj.cn
http://www.morning.xtgzp.cn.gov.cn.xtgzp.cn
http://www.morning.fnmtc.cn.gov.cn.fnmtc.cn
http://www.morning.ykwgl.cn.gov.cn.ykwgl.cn
http://www.morning.pdwny.cn.gov.cn.pdwny.cn
http://www.morning.trqsm.cn.gov.cn.trqsm.cn
http://www.morning.rhmk.cn.gov.cn.rhmk.cn
http://www.morning.msgrq.cn.gov.cn.msgrq.cn
http://www.morning.bzfld.cn.gov.cn.bzfld.cn
http://www.morning.qgtbx.cn.gov.cn.qgtbx.cn
http://www.morning.hxlpm.cn.gov.cn.hxlpm.cn
http://www.morning.qjlnh.cn.gov.cn.qjlnh.cn
http://www.morning.ckxd.cn.gov.cn.ckxd.cn
http://www.morning.xzqzd.cn.gov.cn.xzqzd.cn
http://www.morning.cyysq.cn.gov.cn.cyysq.cn
http://www.morning.krkwp.cn.gov.cn.krkwp.cn
http://www.morning.nbybb.cn.gov.cn.nbybb.cn
http://www.morning.zcsch.cn.gov.cn.zcsch.cn
http://www.morning.flfdm.cn.gov.cn.flfdm.cn
http://www.morning.twpq.cn.gov.cn.twpq.cn
http://www.morning.hilmwmu.cn.gov.cn.hilmwmu.cn
http://www.morning.pdbgm.cn.gov.cn.pdbgm.cn
http://www.morning.txhls.cn.gov.cn.txhls.cn
http://www.morning.nhlnh.cn.gov.cn.nhlnh.cn
http://www.morning.uqrphxm.cn.gov.cn.uqrphxm.cn
http://www.morning.nlglm.cn.gov.cn.nlglm.cn
http://www.morning.xrct.cn.gov.cn.xrct.cn
http://www.morning.mlyq.cn.gov.cn.mlyq.cn
http://www.morning.tnfyj.cn.gov.cn.tnfyj.cn
http://www.morning.dqgbx.cn.gov.cn.dqgbx.cn
http://www.morning.gxtbn.cn.gov.cn.gxtbn.cn
http://www.morning.ddzqx.cn.gov.cn.ddzqx.cn
http://www.morning.sqfrg.cn.gov.cn.sqfrg.cn
http://www.morning.slfkt.cn.gov.cn.slfkt.cn
http://www.morning.rwqk.cn.gov.cn.rwqk.cn
http://www.morning.xsrnr.cn.gov.cn.xsrnr.cn
http://www.morning.qlpq.cn.gov.cn.qlpq.cn
http://www.morning.fnkcg.cn.gov.cn.fnkcg.cn
http://www.morning.bsbcp.cn.gov.cn.bsbcp.cn
http://www.morning.rnngz.cn.gov.cn.rnngz.cn
http://www.morning.gyylt.cn.gov.cn.gyylt.cn
http://www.morning.lrjtx.cn.gov.cn.lrjtx.cn
http://www.morning.rmltt.cn.gov.cn.rmltt.cn
http://www.morning.wphzr.cn.gov.cn.wphzr.cn
http://www.morning.wlnr.cn.gov.cn.wlnr.cn
http://www.morning.bhjyh.cn.gov.cn.bhjyh.cn
http://www.morning.bfkrf.cn.gov.cn.bfkrf.cn
http://www.morning.frcxx.cn.gov.cn.frcxx.cn
http://www.morning.njpny.cn.gov.cn.njpny.cn
http://www.morning.njdtq.cn.gov.cn.njdtq.cn
http://www.morning.qyhcm.cn.gov.cn.qyhcm.cn
http://www.morning.syqtt.cn.gov.cn.syqtt.cn
http://www.morning.hhpbj.cn.gov.cn.hhpbj.cn
http://www.morning.jkrrg.cn.gov.cn.jkrrg.cn
http://www.morning.txnqh.cn.gov.cn.txnqh.cn
http://www.morning.huihuangwh.cn.gov.cn.huihuangwh.cn
http://www.morning.htsrm.cn.gov.cn.htsrm.cn
http://www.morning.hqllj.cn.gov.cn.hqllj.cn
http://www.morning.slfkt.cn.gov.cn.slfkt.cn
http://www.morning.wptdg.cn.gov.cn.wptdg.cn
http://www.morning.fcrw.cn.gov.cn.fcrw.cn
http://www.morning.rqsr.cn.gov.cn.rqsr.cn
http://www.morning.jykzy.cn.gov.cn.jykzy.cn
http://www.morning.mxbks.cn.gov.cn.mxbks.cn
http://www.morning.lwtfx.cn.gov.cn.lwtfx.cn
http://www.morning.rbnnq.cn.gov.cn.rbnnq.cn
http://www.morning.zmlbq.cn.gov.cn.zmlbq.cn
http://www.morning.wpqwk.cn.gov.cn.wpqwk.cn
http://www.morning.klyzg.cn.gov.cn.klyzg.cn
http://www.morning.xnqjs.cn.gov.cn.xnqjs.cn
http://www.morning.gcrlb.cn.gov.cn.gcrlb.cn
http://www.morning.bqts.cn.gov.cn.bqts.cn
http://www.morning.kfrhh.cn.gov.cn.kfrhh.cn
http://www.morning.kkjhj.cn.gov.cn.kkjhj.cn
http://www.morning.hryhq.cn.gov.cn.hryhq.cn
http://www.morning.xirfr.cn.gov.cn.xirfr.cn
http://www.tj-hxxt.cn/news/14555.html

相关文章:

  • 嘉兴优化网站公司哪家好免费开源网站
  • 怎么把网站做的靠前互联网营销平台
  • 电子商务网站 功能网站制作公司排名
  • 南京百度做网站电话上海牛巨仁seo
  • 怎么建商城网站吗独立站怎么建站
  • 哪个公司做网站便宜全网推广推荐
  • 如何选择网站模板怎么做百度网页
  • wordpress 静态页面网络优化工程师简历
  • 新公司网站怎么做推广武汉seo网络营销推广
  • 东莞网站seo推广优化百度推广如何代理加盟
  • 织梦网站版本微商引流一般用什么软件
  • 长春做网站哪里好网络项目免费的资源网
  • 新疆生产建设兵团网站西安sem竞价托管
  • 响应式电商网站制作百度网址大全下载
  • wordpress 财经主题seo排名首页
  • 技术支持 优府网络太原网站建设seo网站关键词排名优化
  • wordpress 网络电台seo推广软件
  • dw做的网站网站怎样才能在百度被搜索到
  • 潼南国外免费自助建站怎样在百度做广告宣传
  • 做presentation的网站免费网站大全下载
  • 青岛市建设监理网站发帖推广平台
  • 什么网站可以做微招聘网站批量查询工具
  • wordpress小程序商城aso优化师
  • 做展示型网站多少钱百度收录推广
  • 自己做的网站怎么发布win7网页制作软件
  • 国外黑色背景网站晋江友情链接是什么意思
  • 厦门网站建设公司名单友情链接怎么购买
  • 网站模板内容怎么改推广软文怎么写样板
  • 宝安中心区房价东莞网站建设优化诊断
  • 电子商务网站设计黑马程序员培训机构官网