spring技术总结

☆Spring技术总结
※1个容器
  ProxyFactoryBean factory

1、自己创建容器
  1)不用配置文件,用纯java代码自己创建
ProxyFactoryBean factory = new ProxyFactoryBean();//底层,一般不用
  2)从Spring配置文件创建(位置在src根目录
ApplicationContext ctx = new ClassPathXmlApplicationContext("cn/hncu/aop/demo6/demo6.xml");

2、拿项目中已经创建好的Application容器(有两种技术):
  1)在普通Java类中,通过实现ApplicationContextAware接口,该接口中的抽象
方法的参数即是当前项目的容器对象。
  2)在Web环境(如Servlet,Filter等能够获取ServletContext这个Web容器的类)中,通过:
ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(getServletContext());


※AOP
公式: 
  切面=切点+通知   advisor=pointcut+advice( before,after,around, afterreturning, afterthrowing)
  @Aspect = @Pointcut + (@Before+@After+...)
  @Aspect = 字符串常量CUT + (@Before+@After+...)
<aop:config>
   <aop:aspect>
       <aop:before method="..."  pointcut="..."/>
       <aop:around method="..."  pointcut-ref="..."/>
   </aop:aspect>
</aop:config>

※4种切面技术(根据切点分类):
1、RegexpMethodPointcutAdvisor---用正则表达式来定义切点 --最底层
2、AspectJExpressionPointcut ---用AspectJ切点语言来定义切点
3、注解 部分POJO--- @Transactional
4、标签 完全POJO


 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

文生同学

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值