用Spring大概有3个月,一直都是张口AOP,闭口AOP,但是Spring的AOP具体是怎么实现的,现在也不是十分清楚.
只知道可以用JDK的动态代理,基于接口,或者是cglib方式字节码增强.目前对JDK的动态代理方式不是很理解,固拿出来探讨下,我知道这应该是个新手贴,但还是请大家给点意见.如果真正理解了动态代理,那么对基于Spring AOP出现的各种现象就比较容易理解了.
先贴上一段代码.
package com.jamesby.proxy;
public interface CarCompany {
public void makeCar();
public v ...
项目使用iWebOffice2006,本来可以正常使用,但是系统有文件上传需求,故定义了一个multipartResolver,后发现 iWebOffice2006 控件不能正常使用!
解决办法有两个,一是不使用Spring 的 multipartResolver 进行文件上传,二是将iWebOffice2006 的serverurl替换成一个jsp或者servlet实现,而不用spring 的 controller来实现。
public ModelAndView handelXqResourcePublish(HttpServletRequest request,
HttpServletResponse response) throws ServletException {
Map model = new HashMap();
try {
//绑定
XqZyfbFormBean formBean = new XqZyfbFormBean();
BindException errorModule = bindObject(request, formBean,
...
软件采用SpringMVC+Spring+iBatis进行设计的,在Service出现NullPointer异常的时候会提示FastClassByCGLIB$$c8ef9cf1.invoke(<generated>),这属于正常情况,检查Service层的出错代码,排除代码错误就可以了.
一、基本原理
Acegi认证授权主要基于两大技术,一是Filter机制,二是AOP的拦截机制。通过FilterSecurityInterceptor很好地实现了对URI的保护,通过MethodSecurityInterceptor实现了对Service的方法的拦截保护,通过ACL 实现了对prototype类型的Object进行过滤和保护。
二、基本概念
HttpSessionContextIntegrationFilter 存储SecurityContext in HttpSession
ChannelProcessingFilter 重定向到另一种协议,如http到https
Conc ...
Before Advice
package test3;
public class MessageWriter {
public void writeMessage() {
System.out.print("World");
}
}
package test3;
import java.lang.reflect.Method;
import org.springframework.aop.MethodBeforeAdvice;
import org.springframework.aop.framework.ProxyFactory;
public clas ...
一、AOP 概念
Joinpoint:它定义在哪里加入你的逻辑功能,对于Spring AOP,Jointpoint指的就是Method。
Advice:特定的Jointpoint处运行的代码,对于Spring AOP 来讲,有Before advice、AfterreturningAdvice、ThrowAdvice、AroundAdvice(MethodInteceptor)等。
Pointcut:一组Joinpoint,就是说一个Advice可能在多个地方织入,
Aspect:这个我一直迷惑,它实际是Advice和Pointcut的组合,但是Spring AOP 中的Advi ...
Spring AOP 部分Class的UML
以下内容是从书中摘录来的,但是我发现即使摘录一遍,对其内容的理解也会更加深入!
一、Spring装配Bean的过程
1. 实例化;
2. 设置属性值;
3. 如果实现了BeanNameAware接口,调用setBeanName设置Bean的ID或者Name;
4. 如果实现BeanFactoryAware接口,调用setBeanFactory 设置BeanFactory;
5. 如果实现ApplicationContextAware,调用setApplicationContext设置ApplicationContext
6. 调用BeanPostProcessor的预先初始化方法;
7. 调 ...
package com.cm.main.dao.impl;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import com.cm.main.dao.AbstractDao;
import com.cm.main.dao.TestJdbcTemplateDao ...
Controller
protected BindException bindObject(HttpServletRequest request,
Object command, Validator validator) throws Exception {
ServletRequestDataBinder binder = createBinder(request, command);
binder.bind(request);
BindException errors = new BindException(command,
getCommandNam ...
DAO代码如下:
public class UserDAO extends BaseDAO {
public void insertTestData() {
Connection con = null;
PreparedStatement ps = null;
String sql = null;
try {
con = getConnection();
sql = "insert into oa_test_1(description) values(?)";
ps = con.prepareStatement(sql);
ps.setString( ...
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www. ...
<bean id="dataSource">
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource"><ref local="dataSource"/></property>
</bean>
<bean id="accountManagerTarget" class="serviceClass">
<prop ...
- 浏览: 129505 次
- 性别:


- 详细资料
搜索本博客
最近加入圈子
最新评论
-
iBatis学习小结
感谢辛勤劳动,希望能贡献更好的东西 :
-- by xuguangyun -
为什么我的Spring的声明事 ...
不要自己抛异常,spring不知道那是什么异常,在catch中直接抛出原来的异常 ...
-- by sinoalex -
Spring AOP 学习小结
写得非常好! 关于 AOP 的几个基础概念,我感觉Spring 的参考文档上面 ...
-- by Hejrcc -
Spring AOP 部分Class的 ...
是的,通过UML的类图,从整体上面了解类之间的关系,是一种不错的方式,理清类之间 ...
-- by rainlife -
Spring AOP 部分Class的 ...
感谢共享
-- by wangzhongjie






评论排行榜