« | August 2025 | » | 日 | 一 | 二 | 三 | 四 | 五 | 六 | | | | | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | | | | | | | |
| 公告 |
戒除浮躁,读好书,交益友 |
Blog信息 |
blog名称:邢红瑞的blog 日志总数:523 评论数量:1142 留言数量:0 访问次数:9693604 建立时间:2004年12月20日 |

| |
[java语言]深入浅出 spring AOP (二) 原创空间, 软件技术
邢红瑞 发表于 2005/11/19 18:11:12 |
有人问我,为什末使用CGLIB proxy而不使用JDK Dynamic Proxies,这和spring aop使用的原则相关。
1.使用AOP的时候,尽可能的使用接口,而不是使用具体的类,这样就可以使用JDK Dynamic Proxies,
如果目标类没有实现接口,spring使用CGLIB生成目标类的子类。
下面给个例子
接口类
package org.tatan.test;
public interface Worker {
void doSomeWork(int numOfTimes);
}
目标类
package org.tatan.test;
public class WorkerBean implements Worker { |
|
[java语言]深入浅出 spring AOP (一) 原创空间, 软件技术
邢红瑞 发表于 2005/11/13 14:09:02 |
先不讨论AOP的各种名词,也不作各种AOP的比较,我将在例子中介绍各种名词。 1。先写一个javabean,就是target object。 package org.tatan.test;
public class MessageBean { public void write() { System.out.print("AOP example"); } } 2。写一个AOP的advice类 MethodInterceptor是AOP联盟的标准接口,它是最简单最实用的连接点(joinpoint),实现了around advice ,你可以在他返回前调用target的方法。 package org.tatan.test; import org.aopalliance.intercept.MethodInterceptor; import or |
|
[java语言]spring JdbcTemplate 的queryForObject的若干问题 原创空间, 软件技术
邢红瑞 发表于 2005/11/12 15:33:39 |
spring的javadoc上讲getObject(String, Object[], Class) will return NULL if the result of the query is NUL 这里有0行和nullresult的区别 0行: select salary from user where 1 = 2 null result: select max(salary) from user where 1 = 2 返回就是null 0行一定抛出IncorrectResultSizeDataAccessException异常 原因如下 ResultSetMetaData rsmd = rs.getMetaData(); int nrOfColumns = rsmd.getColumnCount();这里返回ResultSet的列数 if (nrOfColumns != 1) { throw new Incor |
|
|