??xml version="1.0" encoding="utf-8" standalone="yes"?>人成在线免费网站,欧美日韩亚洲一区二区,亚洲综合色网站http://www.aygfsteel.com/leekiang/category/21130.htmlMDA/MDD/TDD/DDD/DDDDDDDzh-cnTue, 15 Mar 2011 23:44:03 GMTTue, 15 Mar 2011 23:44:03 GMT60Z么要使用springhttp://www.aygfsteel.com/leekiang/archive/2011/03/16/346354.htmlleekiangleekiangTue, 15 Mar 2011 18:13:00 GMThttp://www.aygfsteel.com/leekiang/archive/2011/03/16/346354.htmlhttp://www.aygfsteel.com/leekiang/comments/346354.htmlhttp://www.aygfsteel.com/leekiang/archive/2011/03/16/346354.html#Feedback0http://www.aygfsteel.com/leekiang/comments/commentRss/346354.htmlhttp://www.aygfsteel.com/leekiang/services/trackbacks/346354.html真实对象实现的是同一接口Q将真实对象作ؓ代理的一个属性,向客L(fng)公开的是代理Q当客户端调用代理的Ҏ(gu)Ӟ代理扑ֈ真实对象Q调用真实对?br />Ҏ(gu)Q在调用之前之后提供相关的服务,如事务、安全、日志。其名词分别是代理、真实对象、装备、关切点、连接点?br />动态代?不用写代理类Q虚拟机Ҏ(gu)真实对象实现的接口生一个类Q通过cd例化一个动态代理,在实例化动态代理时真实对?br />及装备注入到动态代理中Q向客户端公开的是动态代理,当客L(fng)调用动态代理方法时Q动态代理根据类的返得
到真实对象的Method,调用装备的invokeҎ(gu)Q将动态代理、Method、方法参C与装备的invokeҎ(gu)QinvokeҎ(gu)在唤
起methodҎ(gu)前或后做一些处理?、生动态代理的c?java.lang.refect.Proxy 2、装备必d现InvocationHandler接口实现invokeҎ(gu)


http://enjoyjavaeye.javaeye.com/blog/268816
http://hi.baidu.com/golotus/blog/item/fd9b8cf973d0d45f242df2f2.html
http://byduke.javaeye.com/blog/392850
Spring的v源和背景以及你ؓ什么要使用Spring
http://topic.csdn.net/u/20110224/14/ac48a152-7595-4f6f-b877-2905258b38ef.html
Spring工作原理探秘
http://www.360doc.com/content/10/1215/11/4957029_78291485.shtml


leekiang 2011-03-16 02:13 发表评论
]]>
flashhttp://www.aygfsteel.com/leekiang/archive/2010/06/07/322962.htmlleekiangleekiangMon, 07 Jun 2010 05:34:00 GMThttp://www.aygfsteel.com/leekiang/archive/2010/06/07/322962.htmlhttp://www.aygfsteel.com/leekiang/comments/322962.htmlhttp://www.aygfsteel.com/leekiang/archive/2010/06/07/322962.html#Feedback0http://www.aygfsteel.com/leekiang/comments/commentRss/322962.htmlhttp://www.aygfsteel.com/leekiang/services/trackbacks/322962.htmlPost/Redirect/Get (PRG) is a common design pattern for web developers to help avoid certain duplicate form  submissions and allow user agents to behave more intuitively with bookmarks and the refresh button.
PRG模式也称为post-redirect pattern或Redirect-After-Post pattern

http://forum.springsource.org/showthread.php?t=73939
http://jira.springframework.org/browse/MOD-458
http://jira.springframework.org/browse/SPR-6464
http://blog.vichasconsulting.com/archives/12
http://forum.springsource.org/showthread.php?t=38466
http://www.docin.com/p-56268947.html


leekiang 2010-06-07 13:34 发表评论
]]>
JdbcTemplateZ末不用connectionQconnectionZ末不能共??http://www.aygfsteel.com/leekiang/archive/2010/05/06/320171.htmlleekiangleekiangThu, 06 May 2010 02:21:00 GMThttp://www.aygfsteel.com/leekiang/archive/2010/05/06/320171.htmlhttp://www.aygfsteel.com/leekiang/comments/320171.htmlhttp://www.aygfsteel.com/leekiang/archive/2010/05/06/320171.html#Feedback0http://www.aygfsteel.com/leekiang/comments/commentRss/320171.htmlhttp://www.aygfsteel.com/leekiang/services/trackbacks/320171.html
JdbcTemplateZ末包含javax.sql.DataSource Q而不是用connectionsQ因Z用DataSource有很多优点,
我们在复杂的应用中如果用connectionsQ当然可以?DataSource.getConnection()得到Q,
必须捕捉SQLExceptionsQ这样spring框架无法处理 SQLException异常Q在抛出异常Ӟ无法关闭connection?br />connectionZ末不能共享?DataSource.getConnection()得到connection实例Q一般都不相同,q由q接池的具体实现控制Q?br />所以大家不要用oracle的(f)时表Q因为如果每ơ连接都不一L(fng)话,下次没有(f)时表了?br />建立q接是消耗时间的Q在一D|间内Qconnection只能׃个用户用,Z避免transaction产生冲突Q一些jdbc驱动不支持多U程讉K同一个connection。还有一个更致命的问题,众所周知Qtransaction是基于connection的,即多个用户使用一个连接,大家在一个事务内操作数据库,一个数据库操作rollbackQ所有的数据库操作全部rollbackQ所以一直保持一个打开的connection代h(hun)是很大的?br />我只有在两个Ҏ(gu)中处理一个事务时Q把 connection作ؓ变量传递?br />
关于statement,resultset和connection的问?br />
statement,resultset属于弱refrenceQ即如果statementxQresultset׃被自动释??refrence的做法不保险Q所以JDBC3.0开始明规定了如果connection被关Q所有statement都应该关,不过q取决于使用的数据库驱动?br />应该DBMS 执行操作后,昑ּ的关闭statement Q因为在connection关闭前,JDBC statement仍旧处于打开状态,当返回resultset后,关闭statement是必要的Q尤其在遇到异常的时候?br />如果不?connection pool可以直接关闭connectionQ不考虑statement的关闭,使用q接池的时候,务必关闭statementQ否则你的连接马上被用光Q用statement pooling除外?img src ="http://www.aygfsteel.com/leekiang/aggbug/320171.html" width = "1" height = "1" />

leekiang 2010-05-06 10:21 发表评论
]]>
Spring AOP应该用到Spring MVC上不起作?http://www.aygfsteel.com/leekiang/archive/2010/01/27/311013.htmlleekiangleekiangWed, 27 Jan 2010 15:53:00 GMThttp://www.aygfsteel.com/leekiang/archive/2010/01/27/311013.htmlhttp://www.aygfsteel.com/leekiang/comments/311013.htmlhttp://www.aygfsteel.com/leekiang/archive/2010/01/27/311013.html#Feedback0http://www.aygfsteel.com/leekiang/comments/commentRss/311013.htmlhttp://www.aygfsteel.com/leekiang/services/trackbacks/311013.html
后来我查了一下,Spring对自qMVCQControllerQ有Ҏ(gu)的拦截方法,需要在URLHandlerMapping中配|? Interceptor实现Q它可以对请求进行拦截。因此直接用Spring AOP切面拦截Controller中的MҎ(gu)都是不v作用的。(具体的实现过E我不是很清楚,但是很多文章和脓(chung)子表辄意思是q样的)

后来Q我做了一个实验。通过IOC一个业务对象注入Controller中,然后AOP配置成作用于该业务对象的Ҏ(gu)上,l果q是不v作用? 我几乎试验了所有的Spring AOP和AspectJ的实现和配置Ҏ(gu)Q都不v作用。后来我用同L(fng)cL法和同样的配|方式,写了一个脱MSpring MVC的测试程序,一切正常,切面能够起到作用?

如果说Spring AOP对Spring MVC的Controller的方法不起作用,NҎ(gu)入到Controller的类Ҏ(gu)也不起作用吗Q?Q我惛_C个准的{案Q谢谢!Q! (bryantd)

我对Spring的MVCq不是很熟,不过刚才仔细看了一下源码,我觉得应该之所以Spring的AOP没有对Controller应用成功的原? 是:Spring MVC在启动的时候会Ҏ(gu)处理器策略加载handler映射C个map中,q个时候因为配|的原因它从容器中取到的对象是原生对象,而不是我们代理的? 象;所以不我们的Controller做了什么操作都不会l过我们的代理,q样AOP失M作用Q获取handler的方法应该是 DefaultListableBeanFactory的getBeanNamesForTypeҎ(gu)Q这是我自己在查看源码后ȝ出来的,如果有什么不 对的地方大家讨论下?(layer555)

转自http://www.javaeye.com/problems/20363


leekiang 2010-01-27 23:53 发表评论
]]>
aop配置事务http://www.aygfsteel.com/leekiang/archive/2009/12/24/307216.htmlleekiangleekiangThu, 24 Dec 2009 14:04:00 GMThttp://www.aygfsteel.com/leekiang/archive/2009/12/24/307216.htmlhttp://www.aygfsteel.com/leekiang/comments/307216.htmlhttp://www.aygfsteel.com/leekiang/archive/2009/12/24/307216.html#Feedback0http://www.aygfsteel.com/leekiang/comments/commentRss/307216.htmlhttp://www.aygfsteel.com/leekiang/services/trackbacks/307216.html 事务直接配到DAO?br /><bean id="transactionManager"
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource" />
    </bean>

    <bean id="baseTxProxy"
        class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
        lazy-init="true" abstract="true">
        <property name="transactionManager">
            <ref bean="transactionManager" />
        </property>
        <property name="transactionAttributes">
            <props>
                <prop key="update*">PROPAGATION_REQUIRED</prop>
            </props>
        </property>
    </bean>

    <bean id="studentDaoProxy" parent="baseTxProxy">
        <property name="target">
            <ref bean="studentDao" />
        </property>
    </bean>

    <bean id="studentDao" class="com.dao.StudentDaoImpl">
        <property name="dataSource" ref="dataSource" />
    </bean>
    
    StudentDao st = (StudentDao) context.getBean("studentDaoProxy");
    
    两个bean也可以合qؓ
    <bean id="studentDao" parent="baseTxProxy">
        <property name="target">
            <bean class="com.dao.StudentDaoImpl">
                <property name="dataSource" ref="dataSource" />
                <property name="kpiDao" ref="kpiDao" />
            </bean>
        </property>
    </bean>
    StudentDao st = (StudentDao) context.getBean("studentDao");
    上述q种方式必须使用接口Qؓ什么?br />    
    
    W二U同样必ȝ接口?b style="color: black; background-color: rgb(160, 255, 255);">配置h比第一U麻?br />        <bean id="transactionManager"
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource" />
    </bean>

    <bean id="transactionInterceptor"
        class="org.springframework.transaction.interceptor.TransactionInterceptor">
        <property name="transactionManager" ref="transactionManager" />
        <property name="transactionAttributes">
            <props>
                <prop key="update*">PROPAGATION_REQUIRED</prop>
            </props>
        </property>
    </bean>
    <bean id="studentDaoProxy"
        class="org.springframework.aop.framework.ProxyFactoryBean">
        <property name="target" ref="studentDao" />
        <property name="interceptorNames">
            <list>
                <value>transactionInterceptor</value>
            </list>
        </property>
    </bean>
    
    <bean id="studentDao" class="com.dao.StudentDaoImpl">
        <property name="dataSource" ref="dataSource" />
    </bean>
    ApplicationContext context=new ClassPathXmlApplicationContext("applicationContext.xml");
    StudentDao st = (StudentDao) context.getBean("studentDaoProxy");
    
    如果使用的都是接口,那么׃需要用cglib-nodep-2.1_3.jar
    如果service调dao没有用到接口Q那么必ȝcglib-nodep-2.1_3.jar


事务{略: 了解事务陷阱 http://www.ibm.com/developerworks/cn/java/j-ts1.html 事务{略: 高ƈ发策? http://www.ibm.com/developerworks/cn/java/j-ts5/index.html q是一个系?

http://beet.sourceforge.net
Beet records user behavior and performance data for your Spring-based Java application.  It can thus help you to analyze usage patterns and research production performance issues.


leekiang 2009-12-24 22:04 发表评论
]]>
spring jdbcW记http://www.aygfsteel.com/leekiang/archive/2009/12/23/307061.htmlleekiangleekiangWed, 23 Dec 2009 09:29:00 GMThttp://www.aygfsteel.com/leekiang/archive/2009/12/23/307061.htmlhttp://www.aygfsteel.com/leekiang/comments/307061.htmlhttp://www.aygfsteel.com/leekiang/archive/2009/12/23/307061.html#Feedback0http://www.aygfsteel.com/leekiang/comments/commentRss/307061.htmlhttp://www.aygfsteel.com/leekiang/services/trackbacks/307061.html在用IN语句Ӟ当你传入大批量的值时要小心,JDBC标准q不保过100个元素在IN语句中?有不数据库可以出q个值的限制Q但是不同的数据库会有不同的数量限制Q比如Oracle的限制数量是1000个?br />除了基本cd之外Q你q可以创Z个java.util.List的对象数l,q可以让你支持在IN表达式中~写多重表达式,例如"select * from T_ACTOR where (id, last_name) in ((1, 'Johnson'), (2, 'Harrop'))". 当然Q这样做的前提是数据库底层的语法支持?

http://www.javaeye.com/problems/6124
select count(*) num from lottery_term where term_issuenum in (?) and term_lotteryid = ?
Ҏ(gu)getJdbcTemplate().queryForInt(sql,new Object[]{new String[]{"2008326","2008325","2008324"},103});
List list=new ArrayList();
list.add("****");
getJdbcTemplate().queryForInt(sql,new Object[]{list,103});
?br />select count(*) from info_document where category_id in (:category_id_list);
Map<String,Object> parm = new HashMap<String,Object>();
parm.put("category_id_list", idList);


  public List getAllStu() {

       String sql="select s_id as sid,s_name as sname,s_sex as ssex,s_brith as sbrith from stu";

       List list=this.getJdbcTemplate().query(sql,new BeanPropertyRowMapper(Stu.class));

       return list;

    }


关于execute和updateҎ(gu)之间的区别,updateҎ(gu)q回的是受媄响的记录数目?一个计敎ͼq且如果传入参数的话Q用的是java.sql.PreparedStatement,而executeҎ(gu)L使用 java.sql.Statement,不接受参敎ͼ而且他不q回受媄响记录的计数Q更适合于创建和丢弃表的语句Q而updateҎ(gu)更适合于插入,更新 和删除操作,q也是我们在使用旉要注意的?/span>



Connection conn=DataSourceUtils.getConnection(getJdbcTempldate().getDataSource());

conn=getJdbcTemplate().getNativeJdbcExtractor().getNativeConnection(conn);

OracleConnection oconn=(OracleConnection)conn;

通过DataSourceUtils获取当前U程l定的数据连接,Z使用U程上下文相关的事务Q这样写是正的写法Q如果直接从DataSource获取q接Q得到的是和当前U程上下文无关的新的数据库连接实例?/span>

http://www.javaeye.com/topic/49932?page=2

http://www.javaeye.com/problems/15846

http://www.javaeye.com/topic/87034

http://www.javaeye.com/topic/508799

http://ttitfly.javaeye.com/blog/151560


jdbcTemplate的方式里如果带上int[] argTypes昄指定每个占位W所对应的字D|据类型,可以保证cd安全Q当参数gؓnullӞ提供了更好的支持?/p>

-----------------------

上面q句话如何理解?


后在http://javazoo.bokee.com/viewdiary.15850865.html扑ֈ原因?/p>

今天在调试程序的时?在后C务逻辑cM利用JdbcTemplateq行数据同步操作?发现?br />执行jdbcTemplate.update(?的SQL语句,new Object[]{tmp.getName( ),tmp.getNo( ),tmp.getSpeciality( ),tmp.getMounterofficer( ),tmp.getDesigner( ),tmp.getProductivity( ),tmp.getState( ))
q种操作?如果后面参数中有gؓnull?后台会报异常,l想下也?如果是null,那就要执行jdbc的setNull(Spring底层q是用JDBC做的)Ҏ(gu)?但是setNullҎ(gu)要知道具体的数据库字D늚cd.如setNull(1,Types.VARCHAR).而在上面的方法没有体?
l于体会到updateҎ(gu)中第三个参数new int[]的作用了.!
springq是很伟大的.


如果字段名和属性名是严格对应的Q那么就可以不用自己写RowMapper了,使用BeanPropertyRowMapper:

getJdbcTemplate().query(sql, new BeanPropertyRowMapper(User.class));  

cȝ属性字D名U要数据库中的字D名UCh者数据库字段名ؓs_idcȝ名称为SId,
如果你没有遵守这个规范则可以在select语句后面l数据库字段名取别名


//l定参数Ӟ日期cd的写?未经q验?br />

    public void updStu(Stu stu) {
String sql = "update stu set s_name=?,s_sex=?,s_brith=? where s_id=?";
Object[] obj = new Object[] { stu.getSname(), stu.getSsex(),new java.sql.Date(stu.getSbrith().getTime()), stu.getSid() };
      getJdbcTemplate().update(sql, obj, new int[] { Types.VARCHAR, Types.VARCHAR,Types.DATE, Types.INTEGER });
    }



ConnectionCallback的用法,使用完要手动关闭q接吗?

spring的AbstractRoutingDataSourceQ可以多态切换数据库?


事务抽象层http://blog.csdn.net/congqian1120/archive/2008/01/16/2046311.aspx




http://www.oracle.com/technology/global/cn/pub/articles/marx_spring.html

leekiang 2009-12-23 17:29 发表评论
]]>
Are you running on Java 1.4 or below with Apache Crimson? Upgrade to Apache Xerces (or Java 1.5) for full XSD supporthttp://www.aygfsteel.com/leekiang/archive/2009/12/21/306768.htmlleekiangleekiangMon, 21 Dec 2009 02:41:00 GMThttp://www.aygfsteel.com/leekiang/archive/2009/12/21/306768.htmlhttp://www.aygfsteel.com/leekiang/comments/306768.htmlhttp://www.aygfsteel.com/leekiang/archive/2009/12/21/306768.html#Feedback0http://www.aygfsteel.com/leekiang/comments/commentRss/306768.htmlhttp://www.aygfsteel.com/leekiang/services/trackbacks/306768.htmljfreechart里的gnujaxp.jar
cewolf里的crimson-1.1.3.jar
j2ee自带?span class="hilite21">xml-apis.jar
xercesImpl.jar
q些jar与Your JAXP provider有何关系

leekiang 2009-12-21 10:41 发表评论
]]>
spring的JdbcTemplate用法http://www.aygfsteel.com/leekiang/archive/2009/11/30/304186.htmlleekiangleekiangSun, 29 Nov 2009 20:46:00 GMThttp://www.aygfsteel.com/leekiang/archive/2009/11/30/304186.htmlhttp://www.aygfsteel.com/leekiang/comments/304186.htmlhttp://www.aygfsteel.com/leekiang/archive/2009/11/30/304186.html#Feedback0http://www.aygfsteel.com/leekiang/comments/commentRss/304186.htmlhttp://www.aygfsteel.com/leekiang/services/trackbacks/304186.htmlhttp://blog.163.com/fxf_java/blog/static/59268637200822833715185/
2,JdbcTemplate的连?br />http://www.javaeye.com/topic/89845
http://forum.springsource.org/showthread.php?t=63444
3,ConnectionCallback
http://blog.csdn.net/lin49940/archive/2009/10/22/4712883.aspx

public interface ConnectionCallback

Generic callback interface for code that operates on a JDBC Connection. Allows to execute any number of operations on a single Connection, using any type and number of Statements.

This is particularly useful for delegating to existing data access code that expects a Connection to work on and throws SQLException. For newly written code, it is strongly recommended to use JdbcTemplate's more specific operations, for example a query or updat variant.

doInConnection

ObjectdoInConnection(Connection con)
throws SQLException,
DataAccessException
Gets called by JdbcTemplate.execute with an active JDBC Connection. Does not need to care about activating or closing the Connection, or handling transactions.

If called without a thread-bound JDBC transaction (initiated by DataSourceTransactionManager), the code will simply get executed on the JDBC connection with its transactional semantics. If JdbcTemplate is configured to use a JTA-aware DataSource, the JDBC Connection and thus the callback code will be transactional if a JTA transaction is active.

Allows for returning a result object created within the callback, i.e. a domain object or a collection of domain objects. Note that there's special support for single step actions: see JdbcTemplate.queryForObject etc. A thrown RuntimeException is treated as application exception: it gets propagated to the caller of the template.

Parameters:
con - active JDBC Connection
Returns:
a result object, or null if none
Throws:
SQLException - if thrown by a JDBC method, to be auto-converted to a DataAccessException by a SQLExceptionTranslator
DataAccessException - in case of custom exceptions
See Also:
JdbcTemplate.queryForObject(String, Class), JdbcTemplate.queryForRowSet(String)


2,


leekiang 2009-11-30 04:46 发表评论
]]>
spring securityW记http://www.aygfsteel.com/leekiang/archive/2009/02/03/253015.htmlleekiangleekiangMon, 02 Feb 2009 19:29:00 GMThttp://www.aygfsteel.com/leekiang/archive/2009/02/03/253015.htmlhttp://www.aygfsteel.com/leekiang/comments/253015.htmlhttp://www.aygfsteel.com/leekiang/archive/2009/02/03/253015.html#Feedback0http://www.aygfsteel.com/leekiang/comments/commentRss/253015.htmlhttp://www.aygfsteel.com/leekiang/services/trackbacks/253015.htmlhttp://www.javaeye.com/topic/113436
http://www.aygfsteel.com/redhatlinux/archive/2008/09/01/226010.html
http://www.webasp.net/article/29/28097_print.htm

定义好角色与url的关p,同时告诉acegi该用h有的角色Q那么acegi会根据投规则去验证是否有权限?br />
2Q必要讄httpSessionContextIntegrationFilterQ否则就会报
org.springframework.security.AuthenticationCredentialsNotFoundException: An Authentication object was not found in the SecurityContext

3,
其实所有的权限问题最l可以ȝ? 当前的登陆用h谁,他拥有那些资源,
他现在所讉K的资源是否与与其匚w?q个是最基本?用户-资源 后来因用户和资源l常性变化,
单一的用戯源模型会Dl常性维护的ȝQ所以h们加入了角色一层,以方便更好的理Q?br />q就?用户-角色-资源(RBAC)模型。随着pȝ的不断增大,用户和资源越来越多,
Ҏ(gu)不同的项目的需要,Z又按需开发了不少模型Q如 用户-角色-权限-资源 模型,
用户-角色-角色l?权限-资源 模型Q用?角色-角色l?权限-操作-资源 模型{,
其实无论中间加入多少层,如何扩展Q也都是万变不离其宗Q用?资源?br />
4Q?br />手册 http://family168.com/oa/springsecurity/html/

http://www.javaeye.com/topic/17896


leekiang 2009-02-03 03:29 发表评论
]]>
对org.springframework.beans. CachedIntrospectionResults 的理?/title><link>http://www.aygfsteel.com/leekiang/archive/2009/02/02/252896.html</link><dc:creator>leekiang</dc:creator><author>leekiang</author><pubDate>Sun, 01 Feb 2009 20:56:00 GMT</pubDate><guid>http://www.aygfsteel.com/leekiang/archive/2009/02/02/252896.html</guid><wfw:comment>http://www.aygfsteel.com/leekiang/comments/252896.html</wfw:comment><comments>http://www.aygfsteel.com/leekiang/archive/2009/02/02/252896.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/leekiang/comments/commentRss/252896.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/leekiang/services/trackbacks/252896.html</trackback:ping><description><![CDATA[CachedIntrospectionResults ~存了所有的bean的信?主要是属?Q是用static~存的,对于同一个class的信息只要执行一ơ就可以了,所以采用了工厂模式。我怎么觉得是单例模式?br />q个c里有很多东西,什么弱引用之类。与内存泄漏有关pR?br /><br />参见:<br />http://www.aygfsteel.com/killme2008/archive/2007/06/26/126282.html<br />http://calvin.redsaga.com/viewthread.php?tid=391<br /><br /><img src ="http://www.aygfsteel.com/leekiang/aggbug/252896.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/leekiang/" target="_blank">leekiang</a> 2009-02-02 04:56 <a href="http://www.aygfsteel.com/leekiang/archive/2009/02/02/252896.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>spring试W记http://www.aygfsteel.com/leekiang/archive/2009/02/02/252895.htmlleekiangleekiangSun, 01 Feb 2009 19:38:00 GMThttp://www.aygfsteel.com/leekiang/archive/2009/02/02/252895.htmlhttp://www.aygfsteel.com/leekiang/comments/252895.htmlhttp://www.aygfsteel.com/leekiang/archive/2009/02/02/252895.html#Feedback0http://www.aygfsteel.com/leekiang/comments/commentRss/252895.htmlhttp://www.aygfsteel.com/leekiang/services/trackbacks/252895.htmlSoftware Testing With Spring Framework



软g开发者面试百?/a>



leekiang 2009-02-02 03:38 发表评论
]]>
spring mvcW记http://www.aygfsteel.com/leekiang/archive/2009/01/08/250444.htmlleekiangleekiangThu, 08 Jan 2009 01:31:00 GMThttp://www.aygfsteel.com/leekiang/archive/2009/01/08/250444.htmlhttp://www.aygfsteel.com/leekiang/comments/250444.htmlhttp://www.aygfsteel.com/leekiang/archive/2009/01/08/250444.html#Feedback0http://www.aygfsteel.com/leekiang/comments/commentRss/250444.htmlhttp://www.aygfsteel.com/leekiang/services/trackbacks/250444.html2,public ModelAndView login(HttpServletRequest request,
            HttpServletResponse response,HttpSession session,User user)
  public ModelAndView login(HttpServletRequest request,
            HttpServletResponse response,User user)
MultiActionController自动把最后一个参数当作Command对象?br />也可以覆盖protected Object newCommandObject(Class clazz)Ҏ(gu)Q但q样每个 Controller的Command对象是同一个ieleQ?br />同时要改?br />public ModelAndView login(HttpServletRequest request,
            HttpServletResponse response,Object command)再对command造型
            
3Q重定向写法
return new ModelAndView("redirect:/system/user.do?do=addUserForm");

4Q有2个JsonView的,或者更适合AjaxQ当然自己写一个JsonView都很?
1) json-lib-ext-spring
http://sourceforge.net/projects/json-lib/files/
2) spring json view
http://spring-json.sourceforge.net/download.html
http://article.yeeyan.org/view/jdonee/10145

5, l定的基本写?br />ServletRequestDataBinder binder = new ServletRequestDataBinder(obj);
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        binder.registerCustomEditor(Date.class, new CustomDateEditor(
                dateFormat, true));
        binder.setDisallowedFields(new String[]{"endtime"});
        binder.bind(request);


leekiang 2009-01-08 09:31 发表评论
]]>
spring2.5与junit整合的笔?/title><link>http://www.aygfsteel.com/leekiang/archive/2009/01/04/249776.html</link><dc:creator>leekiang</dc:creator><author>leekiang</author><pubDate>Sun, 04 Jan 2009 10:13:00 GMT</pubDate><guid>http://www.aygfsteel.com/leekiang/archive/2009/01/04/249776.html</guid><wfw:comment>http://www.aygfsteel.com/leekiang/comments/249776.html</wfw:comment><comments>http://www.aygfsteel.com/leekiang/archive/2009/01/04/249776.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/leekiang/comments/commentRss/249776.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/leekiang/services/trackbacks/249776.html</trackback:ping><description><![CDATA[1,Z量q稳q渡Ql用junit3.8,而不是直接用junit4<br />2,@ContextConfiguration(locations = { "classpath:applicationContext-sys.xml",<br />        "classpath:applicationContext.xml" })<br />public class BaseTests extends AbstractTransactionalJUnit38SpringContextTests {<br />}<br />所有的TestCase都承上面这个类Q得spring配置文g重用Q同时ApplicationContext也是同一个?br /><br />3,要测试的servicec通过@Autowired注入Q例?br />    @Autowired<br />    private UserDAO  userDAO;<br />    <br />4Q注意,对于l承了BaseTests的测试类里的每一个testҎ(gu)Q运行测试时都会?br />   setUp()-->testҎ(gu)-->tearDown()的顺序执行,而且q?个组成一个事务,执行完后默认会回滚?br />   如果不想回滚Q在cd前面@TransactionConfiguration(defaultRollback = false)<br />   <br />5Q因是用的junit3.8,故TestSuite的写法照?br />  public class SuiteTests {<br />    public static Test suite() {<br />        TestSuite suite = new TestSuite("q行所有测?);<br />        suite.addTestSuite(UserServiceTests.class);<br />        suite.addTestSuite(RoleServiceTests.class);<br />        return suite;<br />    }<br />}<br /><br />6Q测试类q没有当作bean配置在application.xml文g中,<br />   spring试框架是如何"setUp()-->testҎ(gu)-->tearDown()"处于同一个事务的呢?<br />   具体p看AbstractTransactionalJUnit38SpringContextTests了,是通过注解实现的?br />   serviceҎ(gu)在testҎ(gu)里面Q这两个Ҏ(gu)都配|有事务Q即形成了事务的嵌套Q这里有点复杂了Q我q没x楚?br />   不过可以肯定的是Q如果testҎ(gu)的事务不提交Q那么serviceҎ(gu)的事务也不会提交?br />   <br />7Q如果想在jdk1.4下重用ApplicationContextQ可采用以下的办法,出处再补上。这个办法与前面的进行比较,<br />   我觉得最大的区别是这U写法要手动q行试数据的清除?br />public class BaseTestCase extends TestCase {<br />     static ApplicationContext context = null;<br /><br />    static {<br />        // perform the "global" set up logic<br />        // q里的代码会在类初始化时执行Q所以相当于BeforeClass<br />        String[] CONFIG_FILES_MIN = { "applicationContext-sys.xml",<br />                "applicationContext.xml" };<br />        context = new ClassPathXmlApplicationContext(CONFIG_FILES_MIN);<br />        System.out.println("setup");<br /><br />        // and now register the shutdown hook for tear down logic<br />        // 一个匿名方法写到这里,q当于AfterClass<br />        Runtime.getRuntime().addShutdownHook(new Thread() {<br />            public void run() {<br />                System.out.println("shutdown");<br />            }<br />        });<br />    }<br /><br />    protected void setUp() throws Exception {<br />    }<br />}<br /><br />8Q如果用junit-4.jarQ去官网下蝲junit4.4.jar。不要采用myeclipse自带的junit4.jarQ因个不带JUnit4ClassRunnercR?br />   另外不要用junit-4.5.jar,据说与spring2.5有冲H,<br />   详见Spring Test Context Framework not compatible with JUnit 4.5Qhttp://jira.springframework.org/browse/SPR-5145<br /><br /><br />9QString htmlContent = "<html><head></head><body>html content</body></html>";<br /> String plainContent = "plain content";<br /><br /> MockMultipartHttpServletRequest req = new MockMultipartHttpServletRequest();<br />req.setContentType("multipart/form-data");<br />//req.addHeader("Content-type", "multipart/form-data");//q样写应该是一L(fng)<br /> req.setMethod("POST");<br /> req.addFile( new MockMultipartFile("file","test1.html","text/html", htmlContent.getBytes( "US-ASCII" ) ) );<br /> req.addFile( new MockMultipartFile("file","test2.html","text/html", htmlContent.getBytes( "US-ASCII" ) ) );<br /> req.addFile( new MockMultipartFile("file","test.txt", "text/plain",plainContent.getBytes( "US-ASCII" ) ) );<br />assertTrue( ServletFileUpload.isMultipartContent( req ) );<br />int content_length = req.getContentLength();<br /><br />10QAbstractTransactionalJUnit38SpringContextTests<br />    AbstractTransactionalSpringContextTests<br />    AbstractTransactionalDataSourceSpringContextTests<br />的区?<br /><br />11,MockHttpServletRequest的addParameterҎ(gu)和setParameter的区?br /><br /><br />参?<br /><a >详细讲解在Spring中进行集成测?/a><br />http://www.javaeye.com/topic/68185<br />http://www.google.cn/codesearch/p?hl=zh-CN#Vq-IOboH1tI/trunk/test/es/peerreview/service/TestPeerReviewSpring.java<br /><a >用Spring提供的JUnit框架扩展对DAO或Service层进行单元测?/a><br />http://code.google.com/p/anewssystem/source/browse/trunk/anewssystem/parent/core/src/main/java/anni/core/test/?r=105<br />http://docs.huihoo.com/spring/2.5.x/zh-cn/testing.html<br />http://arkxu.javaeye.com/blog/261679<br />http://www.ibm.com/developerworks/cn/java/j-cb06066.html<br />http://www.ibm.com/developerworks/cn/java/j-lo-spring25-test/<br /><a >Zmock对象和JUnit框架化Spring Weblg单元试</a><br />http://www.aygfsteel.com/calvin/archive/2005/09/21/13628.html<br />http://www.yybean.com/testing-framework-to-use-spring-integration-testing<br /><br /><br /><img src ="http://www.aygfsteel.com/leekiang/aggbug/249776.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/leekiang/" target="_blank">leekiang</a> 2009-01-04 18:13 <a href="http://www.aygfsteel.com/leekiang/archive/2009/01/04/249776.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在spring中用quartzhttp://www.aygfsteel.com/leekiang/archive/2008/07/11/214364.htmlleekiangleekiangFri, 11 Jul 2008 15:44:00 GMThttp://www.aygfsteel.com/leekiang/archive/2008/07/11/214364.htmlhttp://www.aygfsteel.com/leekiang/comments/214364.htmlhttp://www.aygfsteel.com/leekiang/archive/2008/07/11/214364.html#Feedback0http://www.aygfsteel.com/leekiang/comments/commentRss/214364.htmlhttp://www.aygfsteel.com/leekiang/services/trackbacks/214364.html0 0/5 * * * ?     每隔5分钟触发一?br />0 15 10 L * ?     每月最后一日的上午10:15触发

bean配置的顺?
定时器的工厂bean-->cronbean-->具体实现的bean

<bean
        
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        
<property name="triggers">
            
<list>
                
<ref bean="cronExpReport" />
            
</list>
        
</property>
    
</bean>

    
<!-- 每天23:00?3:15每分钟一ơ触发?/span>-->
    
<bean id="cronExpReport"
        class
="org.springframework.scheduling.quartz.CronTriggerBean">
        
<property name="jobDetail">
            
<ref bean="detailBean" />
        
</property>
        
<property name="cronExpression">
            
<value>0 0-15 23 * * ?</value>
        
</property>
    
</bean>

<bean id="detailBean"
        class
="org.springframework.scheduling.quartz.JobDetailBean">
        
<property name="jobClass">
            
<value>com.bo.detailBO</value>
        
</property>
        
<property name="jobDataAsMap">
            
<map>
                 
<entry key="baseBO">
                    
<ref bean="baseBO" />
                
</entry>
            
</map>
        
</property>
 
</bean>

Define of cronExpression

+------------------------------------+
| Position | Meaning | Value Scope   |
+------------------------------------+
| 1        | second  | 0-59          |
+------------------------------------+
| 2        | minute  | 0-59          |
+------------------------------------+
| 3        | hour    | 0-23          |
+------------------------------------+
| 4        | day     | 1-31          |
+------------------------------------+
| 5        | month   | 1-12          |
+------------------------------------+
| 6        | week    | 1-7           |
+------------------------------------+
| 7  可选?| year    | 1970-2099     |
+------------------------------------+

http://hi.baidu.com/tonent/blog/item/894e8b525124960a0cf3e3a1.html
http://blog.csdn.net/changsure/archive/2007/03/27/1542194.aspx
http://www.xici.net/b391997/d26742282.htm


leekiang 2008-07-11 23:44 发表评论
]]>
spring使用W记http://www.aygfsteel.com/leekiang/archive/2008/07/11/214361.htmlleekiangleekiangFri, 11 Jul 2008 15:36:00 GMThttp://www.aygfsteel.com/leekiang/archive/2008/07/11/214361.htmlhttp://www.aygfsteel.com/leekiang/comments/214361.htmlhttp://www.aygfsteel.com/leekiang/archive/2008/07/11/214361.html#Feedback0http://www.aygfsteel.com/leekiang/comments/commentRss/214361.htmlhttp://www.aygfsteel.com/leekiang/services/trackbacks/214361.html批处理中出现错误: ORA-01456: 不可以在 READ ONLY 事务处理中执行插?删除/更新操作

2,Failed to convert property value of type
错误的原因是service属性应该是接口Q而不能是一个类

3,spring2.5支持jdk1.4
readme.txt里有q样一?
The Spring Framework 2.5 requires JDK 1.4.2 and J2EE 1.3 (Servlet 2.3, JSP 1.2, JTA 1.0, EJB 2.0). JDK 1.6 is
required for building the framework; for the full build including all aspects, AspectJ is required as well.
core包下有个JdkVersionc,用来判断jdk版本.代码里的相关位置对环境变量进行了判断Q有时候做同一件事提供了两套方?高于1.5(?.6)一U?低于1.5(?.6)又是一U?构徏时用1.6版本?.4~译,p?.4上用了?br />
4,spring启动时ApplicationContext
http://www.aygfsteel.com/jiake/archive/2009/01/07/250235.html

5,属性命名时不支持第一个字母是写Q而第二个字母是大写?br />也就是说Q对于JavaBean来讲Q第一个与W二个字母都要小?br />参考:
http://www.javaeye.com/topic/103184
http://www.javaeye.com/topic/88921
http://www.javaeye.com/problems/6293
javabean specificationQ规定了一般的属性名U首字母写Q如果遇到前两个字母大写的属性,则getterҎ(gu)保持属性名UC变,例如URL属性的 getterҎ(gu)为getURLQ但是ƈ没有规定cMeTypeNameq样的属性的getterҎ(gu)写成geteTypeName的Ş式?br />如果要符合javabean规范Q则只能eTypeNameҎ(gu)ETypeName


8,springfuse
Code generation for Spring-based Web applications 


leekiang 2008-07-11 23:36 发表评论
]]>
spring的缺??http://www.aygfsteel.com/leekiang/archive/2007/11/21/162228.htmlleekiangleekiangWed, 21 Nov 2007 14:44:00 GMThttp://www.aygfsteel.com/leekiang/archive/2007/11/21/162228.htmlhttp://www.aygfsteel.com/leekiang/comments/162228.htmlhttp://www.aygfsteel.com/leekiang/archive/2007/11/21/162228.html#Feedback2http://www.aygfsteel.com/leekiang/comments/commentRss/162228.htmlhttp://www.aygfsteel.com/leekiang/services/trackbacks/162228.html问题是我觉得rich domain object 和domain Dao双向依赖的关pL也很不喜Ƣ。我觉得那么像现在那么Pthin domain objectQ外加Dao层和Service层,单向依赖Q分层很清楚Q要么就向rails那样Q就是一个modelQ管你daoq是serviceQ全 部都在model里面?br />赫赫Q请问,没有domain model ,何来dao Q何来敲击键盘而来的代码?
dao依赖domain model是很理所当然的?不过让domain model依赖于daoQ确实很拗口Q所以dao肯定需要一个接口,domain model依赖于dao的接口也是很合理的。这里的关键在于Q?
把DAO已经published的接口作为整个领域模型比较核心的一部分?如果设计比较好的ORM 兌可能会把引入query D的双向依赖的危险减至最,不会因ؓDAO接口实现的失败导致整个领域模型的错误Q而把q种错误转变为领域模型关联关pȝ设计错误?

q里有个publish接口Ҏ(gu)D被误用的危险QDAO接口如果是领域模型提出的h实现Q那么这个设计就会很冒风险,因ؓ如果一旦你的DAO? 口publish了,你就要冒着别的正在写domain model的开发h员会耦合于你的接口,一旦你的接口publish了,改动非常困难了Q而且如果一旦发现因为需求分析不够导致的DAO接口逻辑有问 题,那么q个是非常痛苦的重?修改q程?
所以关键在于让合理的关联代替复杂的查询?/p>

说到接口Q顺便说说对满天飞的interface的反感,我以前就是那h天飞的,先在感觉飞的太高了?/p>

接口其实q同于代码隐藏Q说句不好听的话是代码U有化?我发布一个接口,加上一些比较清晰的说明? 调用着一般都会只看接口说明感觉合适就直接IOCq来用了Q久而久之就有可能被误用接口的危险? 如果没有接口Q依赖代码就是文档的和相互可以修改的原则Q那么大安可以直入Ҏ(gu)的正体,看一下对方代码的具体实现逻辑Q有问题可以直接提出来探讨,q样 减了E序风险Q而且也省M来来回回反反复复修改interface 和实现的ȝ?
接口如同是一个盖子,盖住了很多东西,然而在代码极度׃n和互改的环境中,q是用为妙?/p>我的观点是一个重要的接口都应该提供一个抽象类来实现基本的骨架!q样当你的接口改动时只媄响你的抽象类。而对实现接口的承抽象类的子cL有媄响? 其实接口只是定义mixin(混合cd)的理想选择(java中接口才允许多?Q? 例如Q一个教l本w也是球员。那么我们可以定义一个mixin接口Q组合一些新的方法让实现q个mixin的抽象类不仅hTrain和Play的职责, q有l合产生的特性?br />一个缺点:不支持分布式部v。无法把一个beanlfail over或者re-deploy?
实际上,所有轻量ioc容器真用h都没什么用处,因ؓ它们都无法应付分布式的需求。(jboss mc的作者跟我说的)

呵呵Q谁有分布式的需求?

spring不是支持集群了吗Q分布式q不着了吧

有一个收费的T字头的方案能帮助spring实现分布式吧Q没有免费的实现是挺ȝ的?/p>

我们的做法是?台tomcat服务器前面放一台四层交换机之类的硬Ӟq样Q相同的ip来访问时会被指派到同一台tomcat,因此不需要http session׃nQ也能达到类似的分布式效果,q节U了session׃n的消耗?/p>

说到接口Q顺便说说对满天飞的interface的反感,我以前就是那h天飞的,先在感觉飞的太高了?

一直觉得interface是C++里的.h 头文Ӟ好不Ҏ(gu)java里不需?h,׃苦vQ现在大家又争先恐后再入火坑?

其实如果把interface用于动态proxy, cglib已经提供了解x案,spring的OAOP,试时的easyMock,都有cglib实现Q性能比基于interface proxy的更高一点点?/p>

如果是代码设计方面的Q一定要看清楚实际情况再军_是否抽象interface。我觉得interface在代码设计方面最主要的应用其实是多重l承吧和firebody说的盖子功能吧?/p>

所以springside里只有几个用到多重承和webservice盖子的时候才用了interface. 比如dao, appfuse{sampleZ演示多种daoҎ(gu)才用interface阿,我们没事又不会换ormҎ(gu)的,忙活q个接口没意义呀?/p>


leekiang 2007-11-21 22:44 发表评论
]]>
事务http://www.aygfsteel.com/leekiang/archive/2007/05/14/117419.htmlleekiangleekiangMon, 14 May 2007 11:53:00 GMThttp://www.aygfsteel.com/leekiang/archive/2007/05/14/117419.htmlhttp://www.aygfsteel.com/leekiang/comments/117419.htmlhttp://www.aygfsteel.com/leekiang/archive/2007/05/14/117419.html#Feedback0http://www.aygfsteel.com/leekiang/comments/commentRss/117419.htmlhttp://www.aygfsteel.com/leekiang/services/trackbacks/117419.html

leekiang 2007-05-14 19:53 发表评论
]]>
վ֩ģ壺 | Ϸ| | ԭ| | | DZ| | | ߮| ɽ| ƺ| ƺ| | ľ| ɽ| | ٳ| ͺ| ˼| | | ̨| | ޵| | | | | | ƾ| ɽ| | ϲ| ǭ| | ӳ| Ϸ| ƽ| | |