Blog

  • 首页

  • 关于

  • 标签

  • 分类

  • 归档

  • 搜索

Mybatis_参数处理过程

发表于 2019-08-15 分类于 Mybatis
本文字数: 5.3k

Mybatis参数处理过程

测试类

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
public class MybatisTest {

public SqlSessionFactory getSqlSessionFactory() throws IOException {
String resource = "mybatisconfig.xml";
InputStream inputStream = Resources.getResourceAsStream(resource);
SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
return sqlSessionFactory;
}
@Test
public void test1() throws IOException {
SqlSessionFactory sqlSessionFactory = getSqlSessionFactory();
SqlSession sqlSession = sqlSessionFactory.openSession();
TestMapper mapper = sqlSession.getMapper(TestMapper.class);
User user = mapper.selectUserById(20);
System.out.println(user);

List<User> userList = mapper.selectUserByNameAndId(20, "测试员一号");
System.out.println(userList);

}
}
阅读全文 »

Proxy

发表于 2019-08-11 分类于 代理模式
本文字数: 3.4k

简介

代理模式的定义:代理模式给某一个对象提供一个代理对象,并由代理对象控制对原对象的引用。通俗的来讲代理模式就是我们生活中常见的中介。

阅读全文 »

SpringAop------代理对象的创建(二)

发表于 2019-08-11
本文字数: 6.2k

简介

之前在调试的过程中一步一步的找到了代理对象创建的位置,现在就来看一下具体是如何创建的

源码分析

1
2
3
4
5
6
7
8
9
// Create proxy if we have advice.
Object[] specificInterceptors = getAdvicesAndAdvisorsForBean(bean.getClass(), beanName, null);
if (specificInterceptors != DO_NOT_PROXY) {
this.advisedBeans.put(cacheKey, Boolean.TRUE);
Object proxy = createProxy(
bean.getClass(), beanName, specificInterceptors, new SingletonTargetSource(bean));
this.proxyTypes.put(cacheKey, proxy.getClass());
return proxy;
}
阅读全文 »

SpringAop------代理对象的创建(一)

发表于 2019-08-10 更新于 2019-08-11
本文字数: 8.8k

简介

了解一下Aop中的目标对象和代理对象

测试代码(切面类和测试类在之前的aop基本使用中)

1
2
3
4
5
public class Application {
public static void main(String[] args) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext("com.yb");
SpringAopTest springaoptest = (SpringAopTest) context.getBean(SpringAopTest.class);
}
阅读全文 »

SpringAop

发表于 2019-08-09 分类于 Spring
本文字数: 5.2k

简介

面向方面编程(AOP)通过提供另一种思考程序结构的方式来补充面向对象编程(OOP)。OOP中模块化的关键单元是类,而在AOP中,模块化单元是方面。方面实现了跨越多种类型和对象的关注点(例如事务管理)的模块化。(这些担忧在AOP文献中通常被称为“横切”问题。)

概念和术语

  • Aspect(切面):横切关注点被模块化的特殊对象。即,它是一个类
  • Join point(连接点):程序执行期间的一个点,例如执行方法或处理异常。在Spring AOP中,连接点始终表示方法执行。
  • Advice(通知):切面必须要完成的工作。即,它是类中的一个方法。
  • Pointcut(切点):由切入点表达式匹配的连接点(就是符合表达式的连接点的集合)
  • Introduction(引入):Spring AOP允许您向任何建议的对象引入新接口(以及相应的实现),就是在给类添加接口。
  • Target object(目标对象):被通知对象。
  • AOP proxy(AOP代理):在ioc容器初始化时,将目标对象变成代理对象
  • Weaving(织入)
    阅读全文 »
1…345
麻辣香锅不要辣

麻辣香锅不要辣

21 日志
11 分类
20 标签
GitHub 简书
© 2019 – 2020 麻辣香锅不要辣 | 站点总字数: 20.4k字
|
0%