??xml version="1.0" encoding="utf-8" standalone="yes"?>深夜福利一区二区,av伊人久久,欧美a视频在线http://www.aygfsteel.com/liuzheng/category/25539.htmlzh-cnTue, 29 Apr 2008 06:06:42 GMTTue, 29 Apr 2008 06:06:42 GMT60Spring事务配置W记(实现不同Service间调用事? http://www.aygfsteel.com/liuzheng/articles/197097.html刘铮 刘铮 Tue, 29 Apr 2008 03:58:00 GMThttp://www.aygfsteel.com/liuzheng/articles/197097.htmlhttp://www.aygfsteel.com/liuzheng/comments/197097.htmlhttp://www.aygfsteel.com/liuzheng/articles/197097.html#Feedback0http://www.aygfsteel.com/liuzheng/comments/commentRss/197097.htmlhttp://www.aygfsteel.com/liuzheng/services/trackbacks/197097.html一、关键配|示例:(x)
<bean id="sessionFactory"
        class
="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        
<property name="dataSource">
            
<ref local="dataSource" />
        
</property>
    
        
<!-- bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/-->
    
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        
<property name="sessionFactory">
            
<ref local="sessionFactory" />
        
</property>
    
</bean>

    
<!-- Hibernate Transaction Interceptor Definition -->
    
<bean id="hibernateTransactionInterceptor"
        class
="org.springframework.transaction.interceptor.TransactionInterceptor"
        parent
="transactionIntercetorTemplate">
        
<property name="transactionManager">
            
<bean id="hibernateTransactionManager"
                class
="org.springframework.orm.hibernate3.HibernateTransactionManager">
                
<property name="sessionFactory">
                    
<ref bean="sessionFactory" />
                
</property>
            
</bean>
        
</property>
    
</bean>

    
<!-- Transction Intercetor's Template -->
    
<bean id="transactionIntercetorTemplate" abstract="true">
        
<property name="transactionAttributes">
            
<props>
                
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
                
<prop key="is*">PROPAGATION_REQUIRED,readOnly</prop>
                
<prop key="check*">PROPAGATION_REQUIRED,readOnly</prop>
                
<prop key="insert*">PROPAGATION_REQUIRED</prop>
                
<prop key="update*">PROPAGATION_REQUIRED</prop>
                
<prop key="delete*">PROPAGATION_REQUIRED,-BussException</prop>
                
<prop key="*">PROPAGATION_REQUIRED</prop>
            
</props>
        
</property>
    
</bean>

    
<!-- 定义自动代理生成?/span>-->
    
<bean id="autoProxyCreator"
        class
="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
        
<property name="interceptorNames">
            
<list>
                
<idref bean="hibernateTransactionInterceptor" />
                
<idref bean="jdbcTransactionInterceptor" />
            
</list>
        
</property>
        
<property name="beanNames">
            
<value>*Service</value> 
            
<!--list>
                <idref bean="bookService" />                                        
            </list
-->
            
<!--dService bean-->
        
</property>
    
</bean>
    
<bean id="hibernateDaoTemplate" abstract="true">
        
<property name="sessionFactory">
            
<ref bean="sessionFactory" />
        
</property>
    
</bean>
    
<!-- Dao 定义 -->
    
<bean id="imageDao" class="com.fbyssssite.dao.ImageDao"
        parent
="hibernateDaoTemplate" />
    <bean id="imageFolderDao" class="com.fbyssssite.dao.ImageFolderDao"
        parent
="hibernateDaoTemplate" />
    
<!-- Service 定义 -->
    
<bean id="imageService" class="com.fbyssssite.bo.ImageService" autowire="byName">
        
<property name="dao" ref="imageDao"></property>
    
</bean>    
    <bean id="imageFolderService" class="com.fbyssssite.bo.ImageFolderService" autowire="byName">
        
<property name="dao" ref="imageFolderDao"></property>
    
</bean>    

二、测试代码:(x)  

public void delete(Object entity,IBaseUser user) throws BussException {
   
super.delete(entity, user);
   ImageFolder folder 
= (ImageFolder)entity;
   String folderId 
= folder.getId();   
   IImageService imageService  
= ServiceFactory.getImageService();
   imageService.deleteAllInFolder(folderId,user);   
  }

  
public void deleteAllInFolder(String id,IBaseUser sysUser) throws BussException {(来源:www.iocblog.net)
   log.info(
"删除囄?"+id+"'中的囄...");
   
throw new BussException(1,"临时试Q测试事务是否生效的异常。测试完毕后删除此语句?/span>",log);
   
/*
   StringBuffer sql = new StringBuffer("delete ");
   sql.append("from ");
   sql.append(getEntityClassName());
   SqlBuilder sqlBuilder  = SqlBuilder.getInstance();
   sqlBuilder.appendWhereCondition(sql, "folderId='"+id+"'");
   bulkUpdate(sql.toString(), sysUser);
   
*/
   
  }


三、测试效果:(x)
抛出BussException之后QimageFolder实体q没有被删除Q而是回滚?jin)?br /> 四、注意事:(x)
1.其中?nbsp;BussException是一个CheckedException(l承自Exception)Q这里不q是一个例子,如果其他Ҏ(gu)需要同L(fng)方式处理事务Q也要加?BussExceptionQ否则不能回滚;如果是一个UnCheckedExceptionQ就不需要在q里配置Q默认就?x)回滚?br /> 2.如果采用MySQLQshow table status可以查看表的ENGINEcdQMyISAM是不支持事务的,如果需要事务,应该Ҏ(gu)InnoDB:alter table [tablename] engine = InnoDB;



刘铮 2008-04-29 11:58 发表评论
]]>
Spring 事务的处理(转)(j)http://www.aygfsteel.com/liuzheng/articles/192163.html刘铮 刘铮 Fri, 11 Apr 2008 05:24:00 GMThttp://www.aygfsteel.com/liuzheng/articles/192163.htmlhttp://www.aygfsteel.com/liuzheng/comments/192163.htmlhttp://www.aygfsteel.com/liuzheng/articles/192163.html#Feedback0http://www.aygfsteel.com/liuzheng/comments/commentRss/192163.htmlhttp://www.aygfsteel.com/liuzheng/services/trackbacks/192163.html阅读全文

刘铮 2008-04-11 13:24 发表评论
]]>
Spring--单用quartz实现定时作业 Q{Q?/title><link>http://www.aygfsteel.com/liuzheng/articles/179946.html</link><dc:creator>刘铮 </dc:creator><author>刘铮 </author><pubDate>Thu, 14 Feb 2008 08:11:00 GMT</pubDate><guid>http://www.aygfsteel.com/liuzheng/articles/179946.html</guid><wfw:comment>http://www.aygfsteel.com/liuzheng/comments/179946.html</wfw:comment><comments>http://www.aygfsteel.com/liuzheng/articles/179946.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/liuzheng/comments/commentRss/179946.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/liuzheng/services/trackbacks/179946.html</trackback:ping><description><![CDATA[ 定时批处理作业是J2EE企业应用里很重要的一环,用来在晚间进行胦(ch)务挂账,数据转存Q新闻联播等{操作? <p>    而在Spring里,已经很好的集成了(jin)QuartzQ简单到像配cron一P在xml文g里面配一下时间就可以自动执行Q不需要写一行代码。Spring对Quartz大刀阔斧的简化堪U范例,Quartz目l也许可以学?fn)一下?/p> <pre>    <bean id="methodInvokingJobDetail"<br />         class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"><br />         <property name="targetObject"><ref bean="financeDAO"/></property><br />         <property name="targetMethod"><value>confirmOrder</value></property><br />     </bean></pre> <pre><br />     <bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"><br />         <property name="jobDetail"><br />             <ref bean="methodInvokingJobDetail"/><br />         </property><br />         <property name="cronExpression"><br />             <value>0 0 6,12,20 * * ?</value><br />         </property><br />     </bean></pre> <pre>    <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean"><br />         <property name="triggers"><br />             <list><ref local="cronTrigger"/></list><br />         </property><br />     </bean></pre> <p>上面q段配置文g规定?jin)在早?点和晚上8Ҏ(gu)行financeDAO对象的confirmOrder()Ҏ(gu).<br /> </p> <p><br /> 附:(x)cronExpression配置说明</p> <p> <table cellspacing="8"> <tbody> <tr> <th align="left">字段</th> <th align="left"> </th> <th align="left">允许?/th> <th align="left"> </th> <th align="left">允许的特D字W?/th> </tr> <tr> <td align="left"><code>U?/code></td> <td align="left">  </td> <td align="left"><code>0-59</code></td> <td align="left">  </td> <td align="left"><code>, - * /</code></td> </tr> <tr> <td align="left"><code>?/code></td> <td align="left">  </td> <td align="left"><code>0-59</code></td> <td align="left">  </td> <td align="left"><code>, - * /</code></td> </tr> <tr> <td align="left"><code>时</code></td> <td align="left">  </td> <td align="left"><code>0-23</code></td> <td align="left">  </td> <td align="left"><code>, - * /</code></td> </tr> <tr> <td align="left"><code>日期</code></td> <td align="left">  </td> <td align="left"><code>1-31</code></td> <td align="left">  </td> <td align="left"><code>, - * ? / L W C</code></td> </tr> <tr> <td align="left"><code>月䆾</code></td> <td align="left">  </td> <td align="left"><code>1-12 或?JAN-DEC</code></td> <td align="left">  </td> <td align="left"><code>, - * /</code></td> </tr> <tr> <td align="left"><code>星期</code></td> <td align="left">  </td> <td align="left"><code>1-7 或?SUN-SAT</code></td> <td align="left">  </td> <td align="left"><code>, - * ? / L C #</code></td> </tr> <tr> <td align="left"><code>q_(d)可选)(j)</code></td> <td align="left">  </td> <td align="left"><code>留空, 1970-2099</code></td> <td align="left">  </td> <td align="left"><code>, - * /</code></td> </tr> </tbody> </table> </p> <img src ="http://www.aygfsteel.com/liuzheng/aggbug/179946.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/liuzheng/" target="_blank">刘铮 </a> 2008-02-14 16:11 <a href="http://www.aygfsteel.com/liuzheng/articles/179946.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>spring2.0中新标签的用(转)(j)http://www.aygfsteel.com/liuzheng/articles/179945.html刘铮 刘铮 Thu, 14 Feb 2008 08:09:00 GMThttp://www.aygfsteel.com/liuzheng/articles/179945.htmlhttp://www.aygfsteel.com/liuzheng/comments/179945.htmlhttp://www.aygfsteel.com/liuzheng/articles/179945.html#Feedback0http://www.aygfsteel.com/liuzheng/comments/commentRss/179945.htmlhttp://www.aygfsteel.com/liuzheng/services/trackbacks/179945.html 取代?jin)之前通过FieldRetrevingFactoryBean获取bean?rn)态常量的FactoryBeanQ?br />

老的用法
[code]<bean id="..." class="...">
  <property name="isolation">
    <bean id="java.sql.Connection.TRANSACTION_SERIALIZABLE"
    class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean" />
  </property>
</bean>[/code]

新用?br /> [code]<bean id="..." class="...">
    <property name="isolation">
        <util:constant static-field="java.sql.Connection.TRANSACTION_SERIALIZABLE"/>
    </property>
</bean>[/code]

2,<util:property-path/>
取代?jin)之前通过PropertyPathFactoryBean来指定属性\径获取属性值的FactoryBeanQ?br />
老的用法
[code]
<bean id="testBean" class="org.springframework.beans.TestBean" singleton="false">
  <property name="age" value="10"/>
  <property name="spouse">
    <bean class="org.springframework.beans.TestBean">
      <property name="age" value="11"/>
    </bean>
  </property>
</bean>

<bean id="testBean.age" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>[/code]


新的用法
[code]
<bean id="testBean" class="org.springframework.beans.TestBean" singleton="false">
  <property name="age" value="10"/>
  <property name="spouse">
    <bean class="org.springframework.beans.TestBean">
      <property name="age" value="11"/>
    </bean>
  </property>
</bean>

<util:property-path id="name" path="testBean.age"/>
[/code]


3,<util:properties/>
替代?jin)之前通过PropertiesFactoryBean来获取properties配制文g数据的FactoryBean!


老用?br /> [code]<bean id="jdbcConfiguration" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
  <property name="location" value="classpath:com/foo/jdbc-production.properties"/>
</bean>[/code]


新用?br /> [code]<util:properties id="jdbcConfiguration" location="classpath:com/foo/jdbc-production.properties"/>[/code]

4,<util:list/>
替代?jin)之前通过<list><value></value></list>的内|配制方式,让多个bean调用同一list成ؓ(f)可能Q?br />
老的用法
[code]<bean id="emails" class="org.springframework.beans.factory.config.ListFactoryBean">
  <property name="sourceList">
      <list>
        <value>pechorin@hero.org</value>
        <value>raskolnikov@slums.org</value>
        <value>stavrogin@gov.org</value>
        <value>porfiry@gov.org</value>
      </list>
  </property>
</bean>[/code]

新的用法
[code]<util:list id="emails" list-class="java.util.LinkedList">
    <value>pechorin@hero.org</value>
    <value>raskolnikov@slums.org</value>
    <value>stavrogin@gov.org</value>
    <value>porfiry@gov.org</value>
</util:list>[/code]

5,<util:map/>
替代?jin)之前适用<map><entry key=""><value></value></entry></map>的配|方式,让多个bean调用同一map成ؓ(f)可能Q?br />
老的用法
[code]<bean id="emails" class="org.springframework.beans.factory.config.MapFactoryBean">
  <property name="sourceMap">
      <map>
        <entry key="pechorin" value="pechorin@hero.org"/>
        <entry key="raskolnikov" value="raskolnikov@slums.org"/>
        <entry key="stavrogin" value="stavrogin@gov.org"/>
        <entry key="porfiry" value="porfiry@gov.org"/>
      </list>
  </property>
</bean>[/code]

新的用法
[code]<util:map id="emails" map-class="java.util.TreeMap">
    <entry key="pechorin" value="pechorin@hero.org"/>
    <entry key="raskolnikov" value="raskolnikov@slums.org"/>
    <entry key="stavrogin" value="stavrogin@gov.org"/>
    <entry key="porfiry" value="porfiry@gov.org"/>
</util:map>[/code]


6,<util:set/>
替代?jin)之前适用<set><value></value></set>的配|方式,
让多个bean调用同一set成ؓ(f)可能Q?br />
老的用法
[code]<bean id="emails" class="org.springframework.beans.factory.config.SetFactoryBean">
  <property name="sourceSet">
      <set>
        <value>pechorin@hero.org</value>
        <value>raskolnikov@slums.org</value>
        <value>stavrogin@gov.org</value>
        <value>porfiry@gov.org</value>
      </set>
  </property>
</bean>[/code]


新的用法
[code]<util:set id="emails" set-class="java.util.TreeSet">
    <value>pechorin@hero.org</value>
    <value>raskolnikov@slums.org</value>
    <value>stavrogin@gov.org</value>
    <value>porfiry@gov.org</value>
</util:set>[/code]

7,<jee:jndi-lookup/>
替代?jin)之前用JndiObjectFactoryBean指定配制获取容器JNDI资源的FactoryBean!

老的用法
[code]<bean id="simple" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="jdbc/MyDataSource"/>
    <property name="cache" value="true"/>
    <property name="resourceRef" value="true"/>
    <property name="lookupOnStartup" value="false"/>
    <property name="expectedType" value="com.myapp.DefaultFoo"/>
    <property name="proxyInterface" value="com.myapp.Foo"/>
</bean>
[/code]

新用?br /> [code]<jee:jndi-lookup id="simple"
             jndi-name="jdbc/MyDataSource"
             cache="true"
             resource-ref="true"
             lookup-on-startup="false"
             expected-type="com.myapp.DefaultFoo"
             proxy-interface="com.myapp.Foo"/>[/code]

8,<jee:local-slsb/>
替代?jin)之前用LocalStatelessSessionProxyFactoryBean来获取无状态会(x)话BEAN的FactoryBean!

老的用法
[code]<bean id="complexRemoteEjb"
      class="org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean">
  <property name="jndiName" value="ejb/MyRemoteBean"/>
  <property name="businessInterface" value="com.foo.service.RentalService"/>
  <property name="cacheHome" value="true"/>
  <property name="lookupHomeOnStartup" value="true"/>
  <property name="resourceRef" value="true"/>
  <property name="homeInterface" value="com.foo.service.RentalService"/>
  <property name="refreshHomeOnConnectFailure" value="true"/>
</bean>[/code]

新的用法
[code]<jee:remote-slsb id="complexRemoteEjb"
    jndi-name="ejb/MyRemoteBean"
    business-interface="com.foo.service.RentalService"
    cache-home="true"
    lookup-home-on-startup="true"
    resource-ref="true"
    home-interface="com.foo.service.RentalService"
    refresh-home-on-connect-failure="true">[/code]

 

刘铮 2008-02-14 16:09 发表评论
]]>
spring webservice 寚w|webservice的WSDL 的详?/title><link>http://www.aygfsteel.com/liuzheng/articles/172536.html</link><dc:creator>刘铮 </dc:creator><author>刘铮 </author><pubDate>Thu, 03 Jan 2008 09:55:00 GMT</pubDate><guid>http://www.aygfsteel.com/liuzheng/articles/172536.html</guid><wfw:comment>http://www.aygfsteel.com/liuzheng/comments/172536.html</wfw:comment><comments>http://www.aygfsteel.com/liuzheng/articles/172536.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/liuzheng/comments/commentRss/172536.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/liuzheng/services/trackbacks/172536.html</trackback:ping><description><![CDATA[spring webservice 可以自动生成WSDL文g, <br /> <bean id="<span style="color: red">Hr</span>"<br />   class="org.springframework.ws.wsdl.wsdl11.DynamicWsdl11Definition"><br />   <description><br />    This bean definition represents a WSDL definition that is<br />    generated at runtime, based on the builder defined below. It<br />    can be retrieved by going to /<span style="color: #00ccff">Hr</span>/<span style="color: red">Hr</span>.wsdl (i.e. the bean<br />    name corresponds to the filename).<br />   </description><br />   <property name="builder"><br />    <description><br />     The builder creates a WSDL from the 'echo.xsd' schema.<br />     It detects all elements that ends with 'Request', finds<br />     corresponding 'Response' messages, and creates an<br />     operation based on that. All operations are put in a<br />     portType with name 'Echo', and binding and service are<br />     created.<br />    </description><br />    <bean<br />     class="org.springframework.ws.wsdl.wsdl11.builder.XsdBasedSoap11Wsdl4jDefinitionBuilder"><br />     <property name="schema" value="/WEB-INF/person.xsd" /><br />     <property name="portTypeName" value="<span style="color: #339966">Info</span>" /><br />     <property name="locationUri"<br />      value="http://localhost:8080/<span style="color: #00ccff">Hr</span>/webservices" /><br />    </bean><br />   </property><br />  </bean><br /> <br /> <br /> 蓝色表示eclipse中创建的根目录也是web的根目录Q只能ؓ(f)web的根目录<br /> U色表示在根目录下的子目录中可以讉K到生成的WSDL文g的\径,可以随便?br /> l色表示portType名字Q可以随便取 <img src ="http://www.aygfsteel.com/liuzheng/aggbug/172536.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/liuzheng/" target="_blank">刘铮 </a> 2008-01-03 17:55 <a href="http://www.aygfsteel.com/liuzheng/articles/172536.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>spring的参数的注入http://www.aygfsteel.com/liuzheng/articles/170325.html刘铮 刘铮 Tue, 25 Dec 2007 07:19:00 GMThttp://www.aygfsteel.com/liuzheng/articles/170325.htmlhttp://www.aygfsteel.com/liuzheng/comments/170325.htmlhttp://www.aygfsteel.com/liuzheng/articles/170325.html#Feedback0http://www.aygfsteel.com/liuzheng/comments/commentRss/170325.htmlhttp://www.aygfsteel.com/liuzheng/services/trackbacks/170325.html<value/>元素通过字符串来指定属性或构造器参数的倹{JavaBean PropertyEditor用于把字符串从java.lang.Stringcd转化为实际的属性或参数cd?br /> 所以可以放?j)的使?lt;value/>注入int{非Stringcd

刘铮 2007-12-25 15:19 发表评论
]]>
有关spring中的factorybean的深ȝ?/title><link>http://www.aygfsteel.com/liuzheng/articles/170318.html</link><dc:creator>刘铮 </dc:creator><author>刘铮 </author><pubDate>Tue, 25 Dec 2007 07:01:00 GMT</pubDate><guid>http://www.aygfsteel.com/liuzheng/articles/170318.html</guid><wfw:comment>http://www.aygfsteel.com/liuzheng/comments/170318.html</wfw:comment><comments>http://www.aygfsteel.com/liuzheng/articles/170318.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/liuzheng/comments/commentRss/170318.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/liuzheng/services/trackbacks/170318.html</trackback:ping><description><![CDATA[<p>Interface to be implemented by objects used within a BeanFactory that are themselves factories. If a bean implements this interface, it is used as a factory, not directly as a bean. <p><strong>NB: A bean that implements this interface cannot be used as a normal bean.</strong> A FactoryBean is defined in a bean style, but the object exposed for bean references is always the object that it creates. <p>FactoryBeans can support singletons and prototypes, and can either create objects lazily on demand or eagerly on startup. <p>This interface is heavily used within the framework, for example for the AOP ProxyFactoryBean or JndiObjectFactoryBean. It can be used for application components, but this is not common outside of infrastructure code.</p> <br /> 可以自己创徏FactoryBeanQ这个时候的cd要当做工厂类来用。在spring的配|文件中<ref local="factoryBean"/>调用的是getObject()Ҏ(gu)Q返回是object对象?br /> <br /> <br /> <img src ="http://www.aygfsteel.com/liuzheng/aggbug/170318.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/liuzheng/" target="_blank">刘铮 </a> 2007-12-25 15:01 <a href="http://www.aygfsteel.com/liuzheng/articles/170318.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Spring中的重要Ҏ(gu)QBeanPostProcessorhttp://www.aygfsteel.com/liuzheng/articles/144251.html刘铮 刘铮 Tue, 11 Sep 2007 06:05:00 GMThttp://www.aygfsteel.com/liuzheng/articles/144251.htmlhttp://www.aygfsteel.com/liuzheng/comments/144251.htmlhttp://www.aygfsteel.com/liuzheng/articles/144251.html#Feedback0http://www.aygfsteel.com/liuzheng/comments/commentRss/144251.htmlhttp://www.aygfsteel.com/liuzheng/services/trackbacks/144251.html
实现BeanPostProcessor接口可以在bean被创造和被织入的时候改变它的属?br />

DefaultAdvisorAutoProxyCreator自动代理正是利用此接口完成自动代理的Q当所有的bean定义好了(jin)后,所有的advisor便会(x)利用BeanPostProcessor加蝲到对应的切入点的cM

刘铮 2007-09-11 14:05 发表评论
]]>
Spring 中的事务理学习(fn)?j)?/title><link>http://www.aygfsteel.com/liuzheng/articles/144052.html</link><dc:creator>刘铮 </dc:creator><author>刘铮 </author><pubDate>Mon, 10 Sep 2007 09:18:00 GMT</pubDate><guid>http://www.aygfsteel.com/liuzheng/articles/144052.html</guid><wfw:comment>http://www.aygfsteel.com/liuzheng/comments/144052.html</wfw:comment><comments>http://www.aygfsteel.com/liuzheng/articles/144052.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/liuzheng/comments/commentRss/144052.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/liuzheng/services/trackbacks/144052.html</trackback:ping><description><![CDATA[<p dir="ltr">Spring 中的事务理学习(fn)?j)?br /> <br /> <br /> 可以使用<bean id="autoproxy"class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"><br />    …<br /> </bean><br /> <br /> q行自动代理Q但是这里要注意的是自动代理针对的是advisorQadvisor是由advice和pointcutQinterceptor也是advice的一U)(j)所l成的,所以单独的interceptor不能使用Q也是说TransactionInterceptor不能使用?br /> 所以应该徏立advisorQ在事务理中也是TransactionAttributeSourceAdvisor?br /> <br /> TransactionAttributeSourceAdvisor中需要配|TransactionInterceptor?br /> 配置CZ如下Q?br /> <bean id="transactionAdvisor"<br /> class="org.springframework.transaction.interceptor.<br /> TransactionAttributeSourceAdvisor"><br /> <property name="transactionInterceptor"><br /> <ref bean="transactionInterceptor"/><br /> </property><br /> </bean><br /> <br /> TransactionInterceptor的配|如下:(x)<br /> <bean id="transactionInterceptor"<br /> class="org.springframework.transaction.interceptor.<br /> TransactionInterceptor"><br /> <property name="transactionManager"><br /> <ref bean="transactionManager"/><br /> </property><br /> <property name="transactionAttributeSource"><br /> <ref bean="transactionAttributeSource"/><br /> </property><br /> </bean><br /> <br /> 其中transactionManager的配|根据所使用的存储方法不同而不同:(x)<br /> <br /> 使用jdbc的配|如下:(x)<br /> <bean id="transactionManager" class="org.springframework.jdbc.<br /> datasource.DataSourceTransactionManager"><br /> <property name="dataSource"><br /> <ref bean="dataSource"/><br /> </property><br /> </bean></p> <p dir="ltr" style="margin-right: 0px"> 使用hibernate的配|如下:(x)<br /> <bean id="transactionManager" class="org.springframework.<br /> orm.hibernate.HibernateTransactionManager"><br /> <property name="sessionFactory"><br /> <ref bean="sessionFactory"/><br /> </property><br /> </bean></p> 而transactionAttributeSource是一个接口,一般用NameMatchTransactionAttributeSource实现此接?br /> <bean id="transactionAttributeSource"<br /> class="org.springframework.transaction.interceptor.<br /> NameMatchTransactionAttributeSource"><br /> <property name="properties"><br /> <props><br /> <prop key="get*">PROPAGATION_SUPPORTS</prop><br /> </props><br /> </property><br /> </bean><br /> 注意其中的properties属性是一个name/attribute 的map其中name是针寚w要进行的事务理的方法attribute是事务管理的属性由TransactionAttribute军_<br /> 而TransactionAttribute扩展的事务定义基本类TransactionDefinitionQ在q个基本cM面加上了(jin)boolean rollbackOn(Throwable ex)Ҏ(gu)<br /> 所?lt;prop key="get*">PROPAGATION_SUPPORTS</prop>的attributeq可以添加:(x)<br /> ?lt;prop key="get*">PROPAGATION_SUPPORTSQ?code>ISOLATION_SERIALIZABLE</code> Qreadonly</prop><br /> <br /> <br /> <br /> 以上是从宏观到微观的分析Q?br /> 以下是从微观到宏观的分析Q?br /> <br /> 1。设|事务管理属?br /> <bean id="transactionAttributeSource"<br /> class="org.springframework.transaction.interceptor.<br /> NameMatchTransactionAttributeSource"><br /> <property name="properties"><br /> <props><br /> <prop key="get*v>PROPAGATION_SUPPORTS</prop><br /> </props><br /> </property><br /> </bean>  <br /> 2。设|事务管理器Q根据所使用的存储方法不同而不同:(x)以hibernateZ<br /> <br /> <bean id="transactionManager" class="org.springframework.<br /> orm.hibernate.HibernateTransactionManager"><br /> <property name="sessionFactory"><br /> <ref bean="sessionFactory"/><br /> </property><br /> </bean><br /> <br /> 3。设|interceptor<br /> <bean id="transactionInterceptor"<br /> class="org.springframework.transaction.interceptor.<br /> TransactionInterceptor"><br /> <property name="transactionManager"><br /> <ref bean="transactionManager"/><br /> </property><br /> <property name="transactionAttributeSource"><br /> <ref bean="transactionAttributeSource"/><br /> </property><br /> </bean><br /> <br /> 4。最后设|a(chn)dvisorQ?br /> <bean id="transactionAdvisor"<br /> class="org.springframework.transaction.interceptor.<br /> TransactionAttributeSourceAdvisor"><br /> <property name="transactionInterceptor"><br /> <ref bean="transactionInterceptor"/><br /> </property><br /> </bean><br /> 所以就可以通过自动代理q行代理?jin)?br /> 注意q里的advisorq是有pointcut的,pointcut在事务管理中讄?jin),例如Q?br /> <props><br /> <prop key="get*">PROPAGATION_SUPPORTS</prop><br /> </props><br /> q有׃Spring本n的框架的原因Q如果在Log4j中的调试U别为debug的话Q那么设|a(chn)dvisor时就不能使用propertyҎ(gu)Q而要使用constructor-argҎ(gu)<br /> <br /> <br /> <br /> <br /> <br /> 使用MethodMapTransactionAttributeSource可以对特定的cȝҎ(gu)q行事务理<br /> 讄property------setMethodMap<br /> Set a name/attribute map, consisting of "FQCN.method" method names (e.g. "com.mycompany.mycode.MyClass.myMethod") and <a title="interface in org.springframework.transaction.interceptor" href="mk:@MSITStore:E:\学习(fn)内容\java相关官方文档\Spring_2.0.CHM::/org/springframework/transaction/interceptor/TransactionAttribute.html"><code>TransactionAttribute</code></a> instances (or Strings to be converted to <code>TransactionAttribute</code> instances). <img src ="http://www.aygfsteel.com/liuzheng/aggbug/144052.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/liuzheng/" target="_blank">刘铮 </a> 2007-09-10 17:18 <a href="http://www.aygfsteel.com/liuzheng/articles/144052.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Spring 中配|数据源http://www.aygfsteel.com/liuzheng/articles/143746.html刘铮 刘铮 Sun, 09 Sep 2007 03:54:00 GMThttp://www.aygfsteel.com/liuzheng/articles/143746.htmlhttp://www.aygfsteel.com/liuzheng/comments/143746.htmlhttp://www.aygfsteel.com/liuzheng/articles/143746.html#Feedback0http://www.aygfsteel.com/liuzheng/comments/commentRss/143746.htmlhttp://www.aygfsteel.com/liuzheng/services/trackbacks/143746.html   class="org.springframework.jndi.JndiObjectFactoryBean"
  abstract="false" singleton="true" lazy-init="default"
  autowire="default" dependency-check="default">
  <property name="jndiName">
   <value>java:comp/env/XXXX</value>
  </property>
 </bean>

刘铮 2007-09-09 11:54 发表评论
]]>
Spring 中的Ҏ(gu)advice-intruduction advicehttp://www.aygfsteel.com/liuzheng/articles/143317.html刘铮 刘铮 Fri, 07 Sep 2007 01:46:00 GMThttp://www.aygfsteel.com/liuzheng/articles/143317.htmlhttp://www.aygfsteel.com/liuzheng/comments/143317.htmlhttp://www.aygfsteel.com/liuzheng/articles/143317.html#Feedback0http://www.aygfsteel.com/liuzheng/comments/commentRss/143317.htmlhttp://www.aygfsteel.com/liuzheng/services/trackbacks/143317.html
  • intruduction adviceq里没有MethodMatcher接口,因此也就没有 Pointcut接口与引入通知相关联。这里只q行c过滤?
  • 与DefaultPointcutAdvisor不同Q由于DefaultPointcutAdvisor有PointcutQ可以在class一U和method一U上q行控制?
  • 一般用DelegatingIntroductionInterceptor 作ؓ(f)拦截器,需要编写拦截的cdȝ承DelegatingIntroductionInterceptor  ,在这个承了(jin)DelegatingIntroductionInterceptor 的类中不再用MethodInvocation的process()Ҏ(gu)Q用super.invoke(methodinvocation),q样做的原因是父cDelegatingIntroductionInterceptor 能够军_什么class负责处理Ҏ(gu)的调?
  • advisor一般用承了(jin)DefaultIntroductionAdvisor 的类Q创建的单方法就是利?code>DefaultIntroductionAdvisor(DynamicIntroductionAdvice advice, Class clazz)q个构造函数?/code>
  • 在appplicationcontext-config.xml中就只需要加?lt;bean id="" class=""></bean>可以了(jin)Q不需要进行其它配|?
  •  



    刘铮 2007-09-07 09:46 发表评论
    ]]>
    Spring api参?/title><link>http://www.aygfsteel.com/liuzheng/articles/143312.html</link><dc:creator>刘铮 </dc:creator><author>刘铮 </author><pubDate>Fri, 07 Sep 2007 01:22:00 GMT</pubDate><guid>http://www.aygfsteel.com/liuzheng/articles/143312.html</guid><wfw:comment>http://www.aygfsteel.com/liuzheng/comments/143312.html</wfw:comment><comments>http://www.aygfsteel.com/liuzheng/articles/143312.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.aygfsteel.com/liuzheng/comments/commentRss/143312.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/liuzheng/services/trackbacks/143312.html</trackback:ping><description><![CDATA[<a >http://www.redsaga.com/spring_ref/2.0/html/</a> <img src ="http://www.aygfsteel.com/liuzheng/aggbug/143312.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/liuzheng/" target="_blank">刘铮 </a> 2007-09-07 09:22 <a href="http://www.aygfsteel.com/liuzheng/articles/143312.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Spring AOP APIshttp://www.aygfsteel.com/liuzheng/articles/143311.html刘铮 刘铮 Fri, 07 Sep 2007 01:19:00 GMThttp://www.aygfsteel.com/liuzheng/articles/143311.htmlhttp://www.aygfsteel.com/liuzheng/comments/143311.htmlhttp://www.aygfsteel.com/liuzheng/articles/143311.html#Feedback0http://www.aygfsteel.com/liuzheng/comments/commentRss/143311.htmlhttp://www.aygfsteel.com/liuzheng/services/trackbacks/143311.html阅读全文

    刘铮 2007-09-07 09:19 发表评论
    ]]>
    Spring学习(fn)?j)得Q五Q?/title><link>http://www.aygfsteel.com/liuzheng/articles/142935.html</link><dc:creator>刘铮 </dc:creator><author>刘铮 </author><pubDate>Wed, 05 Sep 2007 08:50:00 GMT</pubDate><guid>http://www.aygfsteel.com/liuzheng/articles/142935.html</guid><wfw:comment>http://www.aygfsteel.com/liuzheng/comments/142935.html</wfw:comment><comments>http://www.aygfsteel.com/liuzheng/articles/142935.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/liuzheng/comments/commentRss/142935.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/liuzheng/services/trackbacks/142935.html</trackback:ping><description><![CDATA[  <p class="MsoNormal"><span lang="EN-US" style="font-size: 14pt">Spring</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">学习(fn)?j)得Q五Q?/span><span lang="EN-US" style="font-size: 14pt"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt; text-indent: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 21.0pt"><span lang="EN-US" style="font-size: 14pt; mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">1.<span style="font: 7pt 'Times New Roman'">       </span></span></span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">?/span><span lang="EN-US" style="font-size: 14pt">advice</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">l粒度的控制Q可以通过</span><span lang="EN-US" style="font-size: 14pt">pointcut</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">cL控制?/span><span lang="EN-US" style="font-size: 14pt"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt; text-indent: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 21.0pt"><span lang="EN-US" style="font-size: 14pt; mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">2.<span style="font: 7pt 'Times New Roman'">       </span></span></span><span lang="EN-US" style="font-size: 14pt">advisor</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">?/span><span lang="EN-US" style="font-size: 14pt">advice</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">?/span><span lang="EN-US" style="font-size: 14pt">pointcut</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的集合体?/span><span lang="EN-US" style="font-size: 14pt"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt; text-indent: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 21.0pt"><span lang="EN-US" style="font-size: 14pt; mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">3.<span style="font: 7pt 'Times New Roman'">       </span></span></span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">控制Ҏ(gu)如下Q?/span><span lang="EN-US" style="font-size: 14pt"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 42pt; text-indent: -21pt; mso-list: l0 level2 lfo1; tab-stops: list 42.0pt"><span lang="EN-US" style="font-size: 14pt; mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">a)<span style="font: 7pt 'Times New Roman'">       </span></span></span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">定义</span><span lang="EN-US" style="font-size: 14pt">Pointcut</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中的</span><span lang="EN-US" style="font-size: 14pt">ClassFilter</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">实现cd</span><span lang="EN-US" style="font-size: 14pt">MethodMatcher</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">实现c,完成?/span><span lang="EN-US" style="font-size: 14pt">class</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">?/span><span lang="EN-US" style="font-size: 14pt">method</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Ҏ(gu)?/span><span lang="EN-US" style="font-size: 14pt">advice</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的控Ӟ其中</span><span lang="EN-US" style="font-size: 14pt">MethodMatcher</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中的</span><span lang="EN-US" style="font-size: 14pt; mso-bidi-font-weight: bold">matches</span><span lang="EN-US" style="font-size: 14pt">(Method method, Class targetClass)</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Ҏ(gu)是对</span><span lang="EN-US" style="font-size: 14pt">class</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">?/span><span lang="EN-US" style="font-size: 14pt">method</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的双重ƈ集控?/span><span lang="EN-US" style="font-size: 14pt"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 42pt; text-indent: -21pt; mso-list: l0 level2 lfo1; tab-stops: list 42.0pt"><span lang="EN-US" style="font-size: 14pt; mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">b)<span style="font: 7pt 'Times New Roman'">      </span></span></span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">定义新的</span><span lang="EN-US" style="font-size: 14pt">Pointcut</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">实现c,q将</span><span lang="EN-US" style="font-size: 14pt">ClassFilter</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">实现cd</span><span lang="EN-US" style="font-size: 14pt">MethodMatcher</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">实现c赋?/span><span lang="EN-US" style="font-size: 14pt"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 42pt; text-indent: -21pt; mso-list: l0 level2 lfo1; tab-stops: list 42.0pt"><span lang="EN-US" style="font-size: 14pt; mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">c)<span style="font: 7pt 'Times New Roman'">       </span></span></span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">定义新的</span><span lang="EN-US" style="font-size: 14pt">advisor</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">q且实现</span><span lang="EN-US" style="font-size: 14pt">PointcutAdvisor</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口</span><span lang="EN-US" style="font-size: 14pt"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 42pt; text-indent: -21pt; mso-list: l0 level2 lfo1; tab-stops: list 42.0pt"><span lang="EN-US" style="font-size: 14pt; mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">d)<span style="font: 7pt 'Times New Roman'">      </span></span></span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在定义的</span><span lang="EN-US" style="font-size: 14pt">advisor</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中?/span><span lang="EN-US" style="font-size: 14pt">PointcutAdvisor</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口中的</span><span lang="EN-US" style="font-size: 14pt">getPointcut()</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">?/span><span lang="EN-US" style="font-size: 14pt">getAdvice()</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">?/span><span lang="EN-US" style="font-size: 14pt">Pointcut</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的实现类和需要的</span><span lang="EN-US" style="font-size: 14pt">advice</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">q行传?/span><span lang="EN-US" style="font-size: 14pt"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 42pt; text-indent: -21pt; mso-list: l0 level2 lfo1; tab-stops: list 42.0pt"><span lang="EN-US" style="font-size: 14pt; mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">e)<span style="font: 7pt 'Times New Roman'">       </span></span></span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">最后在</span><span lang="EN-US" style="font-size: 14pt">application-context.xml</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中将</span><span lang="EN-US" style="font-size: 14pt"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt; text-indent: 21pt"><span lang="EN-US" style="font-size: 14pt"><bean id="XXXX"<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt; text-indent: 21pt"><span lang="EN-US" style="font-size: 14pt">class="org.springframework.aop.framework.ProxyFactoryBean"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt; text-indent: 21pt"><span lang="EN-US" style="font-size: 14pt"><span style="mso-tab-count: 1">      </span><property name="InterceptorNames"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt; text-indent: 21pt"><span lang="EN-US" style="font-size: 14pt"><span style="mso-tab-count: 2">           </span><list><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt; text-indent: 21pt"><span lang="EN-US" style="font-size: 14pt"><span style="mso-tab-count: 3">                 </span><idref local="</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">定义新的</span><span lang="EN-US" style="font-size: 14pt">advisor</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">?/span><span lang="EN-US" style="font-size: 14pt">id"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt; text-indent: 21pt"><span lang="EN-US" style="font-size: 14pt"><span style="mso-tab-count: 2">           </span></list><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt; text-indent: 21pt"><span lang="EN-US" style="font-size: 14pt"><span style="mso-tab-count: 1">      </span><property><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt; text-indent: 21pt"><span lang="EN-US" style="font-size: 14pt"></bean><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt; text-indent: 21pt"><span lang="EN-US" style="font-size: 14pt"><bean id="</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">定义新的</span><span lang="EN-US" style="font-size: 14pt">advisor</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">?/span><span lang="EN-US" style="font-size: 14pt">id" class="</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">定义新的</span><span lang="EN-US" style="font-size: 14pt">advisor</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的类</span><span lang="EN-US" style="font-size: 14pt"><span style="mso-tab-count: 1">     </span>" ><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt; text-indent: 21pt"><span lang="EN-US" style="font-size: 14pt"></bean><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt; text-indent: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 21.0pt"><span lang="EN-US" style="font-size: 14pt; mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">4.<span style="font: 7pt 'Times New Roman'">       </span></span></span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Z(jin)使用?rn)态的</span><span lang="EN-US" style="font-size: 14pt">Pointcut</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q可以?/span><span lang="EN-US" style="font-size: 14pt">StaticMethodMatcherPointcut</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q这时?/span><span lang="EN-US" style="font-size: 14pt"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt"><span lang="EN-US" style="font-size: 14pt; mso-bidi-font-weight: bold">public</span><span lang="EN-US" style="font-size: 14pt"> <span style="mso-bidi-font-weight: bold">final</span> <span style="mso-bidi-font-weight: bold">boolean</span> isRuntime()<o:p></o:p></span></p> <p class="MsoNormal"><span lang="EN-US" style="font-size: 14pt"><span style="mso-spacerun: yes">    </span>{<o:p></o:p></span></p> <p class="MsoNormal"><span lang="EN-US" style="font-size: 14pt"><span style="mso-spacerun: yes">        </span><span style="mso-bidi-font-weight: bold">return</span> <span style="mso-bidi-font-weight: bold">false</span>;<o:p></o:p></span></p> <p class="MsoNormal" style="text-indent: 28.5pt"><span lang="EN-US" style="font-size: 14pt">}<o:p></o:p></span></p> <p class="MsoNormal" style="text-indent: 28.5pt"><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">便不能修改了(jin)。也是?rn)态的</span><span lang="EN-US" style="font-size: 14pt">Pointcut<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt; text-indent: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 21.0pt"><span lang="EN-US" style="font-size: 14pt; mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">5.<span style="font: 7pt 'Times New Roman'">       </span></span></span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">更简单的是?/span><span lang="EN-US" style="font-size: 14pt">NameMatchMethodPointcutAdvisor</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q这里一?/span><span lang="EN-US" style="font-size: 14pt">advisor</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">只有一?/span><span lang="EN-US" style="font-size: 14pt">advice<o:p></o:p></span></p> <p class="MsoNormal"><span lang="EN-US" style="font-size: 14pt"><o:p> </o:p></span></p> v <img src ="http://www.aygfsteel.com/liuzheng/aggbug/142935.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/liuzheng/" target="_blank">刘铮 </a> 2007-09-05 16:50 <a href="http://www.aygfsteel.com/liuzheng/articles/142935.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Spring学习(fn)?j)得Q四Q?/title><link>http://www.aygfsteel.com/liuzheng/articles/142823.html</link><dc:creator>刘铮 </dc:creator><author>刘铮 </author><pubDate>Wed, 05 Sep 2007 02:21:00 GMT</pubDate><guid>http://www.aygfsteel.com/liuzheng/articles/142823.html</guid><wfw:comment>http://www.aygfsteel.com/liuzheng/comments/142823.html</wfw:comment><comments>http://www.aygfsteel.com/liuzheng/articles/142823.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/liuzheng/comments/commentRss/142823.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/liuzheng/services/trackbacks/142823.html</trackback:ping><description><![CDATA[<p> </p>   <p> </p>   <p class="MsoNormal"><span lang="EN-US" style="font-size: 14pt">Spring</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">学习(fn)?j)得Q四Q?/span><span lang="EN-US" style="font-size: 14pt"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt; text-indent: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 21.0pt"><span lang="EN-US" style="font-size: 14pt; mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">1.<span style="font: 7pt 'Times New Roman'">       </span></span></span><span lang="EN-US" style="font-size: 14pt">Spring</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">?/span><span lang="EN-US" style="font-size: 14pt">Struts</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">q接Qؓ(f)?jin)?/span><span lang="EN-US" style="font-size: 14pt">Struts</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中?/span><span lang="EN-US" style="font-size: 14pt">Spring ,</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">需要在</span><span lang="EN-US" style="font-size: 14pt">Struts</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">?/span><span lang="EN-US" style="font-size: 14pt">congfig</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中加?/span><span lang="EN-US" style="font-size: 14pt"><o:p></o:p></span></p> <p class="MsoNormal"><span lang="EN-US" style="font-size: 14pt"><plug-in className="org.springframework.web.struts.ContextLoaderPlugIn"><o:p></o:p></span></p> <p class="MsoNormal"><span lang="EN-US" style="font-size: 14pt"><span style="mso-spacerun: yes">        </span><set-property property="contextConfigLocation" <o:p></o:p></span></p> <p class="MsoNormal"><span lang="EN-US" style="font-size: 14pt"><span style="mso-spacerun: yes">            </span>value="/WEB-INF/applicationContext.xml"/><o:p></o:p></span></p> <p class="MsoNormal"><span lang="EN-US" style="font-size: 14pt"><span style="mso-spacerun: yes">    </span></plug-in><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt; text-indent: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 21.0pt"><span lang="EN-US" style="font-size: 14pt; mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">2.<span style="font: 7pt 'Times New Roman'">       </span></span></span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对于</span><span lang="EN-US" style="font-size: 14pt">action</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">?/span><span lang="EN-US" style="font-size: 14pt">Spring</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的应用有两种Ҏ(gu)Q?/span><span lang="EN-US" style="font-size: 14pt"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 42pt; text-indent: -21pt; mso-list: l0 level2 lfo1; tab-stops: list 42.0pt"><span lang="EN-US" style="font-size: 14pt; mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">a)<span style="font: 7pt 'Times New Roman'">       </span></span></span><span lang="EN-US" style="font-size: 14pt">Extends ActionSupport</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q用其中的</span><span lang="EN-US" style="font-size: 14pt">getWebApplicationContext()</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">得到</span><span lang="EN-US" style="font-size: 14pt">ApplicationContext</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q在通过</span><span lang="EN-US" style="font-size: 14pt">getBean()</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Ҏ(gu)得到所需要的c,不过q样的话</span><span lang="EN-US" style="font-size: 14pt">Struts</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</span><span lang="EN-US" style="font-size: 14pt">Spring</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">耦合在一起了(jin)?/span><span lang="EN-US" style="font-size: 14pt"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 42pt; text-indent: -21pt; mso-list: l0 level2 lfo1; tab-stops: list 42.0pt"><span lang="EN-US" style="font-size: 14pt; mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">b)<span style="font: 7pt 'Times New Roman'">      </span></span></span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">重新</span><span lang="EN-US" style="font-size: 14pt">Delegating actions </span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q在</span><span lang="EN-US" style="font-size: 14pt">Struts</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">?/span><span lang="EN-US" style="font-size: 14pt">congfig</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">q行配置Q?/span><span lang="EN-US" style="font-size: 14pt"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt"><span lang="EN-US" style="font-size: 14pt"><action path="/XXXX"<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt"><span lang="EN-US" style="font-size: 14pt">type="org.springframework.web.struts.DelegatingActionProxy"/><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt"><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">然后?/span><span lang="EN-US" style="font-size: 14pt">Spring</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中进?/span><span lang="EN-US" style="font-size: 14pt">bean</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的配|:(x)</span><span lang="EN-US" style="font-size: 14pt"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt"><span lang="EN-US" style="font-size: 14pt"><bean name="/XXXX"<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt"><v:shapetype id="_x0000_t61" path="m,l0@8@12@24,0@9,,21600@6,21600@15@27@7,21600,21600,21600,21600@9@18@30,21600@8,21600,0@7,0@21@33@6,xe" adj="1350,25920" o:spt="61" coordsize="21600,21600"><v:stroke joinstyle="miter"></v:stroke><v:formulas><v:f eqn="sum 10800 0 #0"></v:f><v:f eqn="sum 10800 0 #1"></v:f><v:f eqn="sum #0 0 #1"></v:f><v:f eqn="sum @0 @1 0"></v:f><v:f eqn="sum 21600 0 #0"></v:f><v:f eqn="sum 21600 0 #1"></v:f><v:f eqn="if @0 3600 12600"></v:f><v:f eqn="if @0 9000 18000"></v:f><v:f eqn="if @1 3600 12600"></v:f><v:f eqn="if @1 9000 18000"></v:f><v:f eqn="if @2 0 #0"></v:f><v:f eqn="if @3 @10 0"></v:f><v:f eqn="if #0 0 @11"></v:f><v:f eqn="if @2 @6 #0"></v:f><v:f eqn="if @3 @6 @13"></v:f><v:f eqn="if @5 @6 @14"></v:f><v:f eqn="if @2 #0 21600"></v:f><v:f eqn="if @3 21600 @16"></v:f><v:f eqn="if @4 21600 @17"></v:f><v:f eqn="if @2 #0 @6"></v:f><v:f eqn="if @3 @19 @6"></v:f><v:f eqn="if #1 @6 @20"></v:f><v:f eqn="if @2 @8 #1"></v:f><v:f eqn="if @3 @22 @8"></v:f><v:f eqn="if #0 @8 @23"></v:f><v:f eqn="if @2 21600 #1"></v:f><v:f eqn="if @3 21600 @25"></v:f><v:f eqn="if @5 21600 @26"></v:f><v:f eqn="if @2 #1 @8"></v:f><v:f eqn="if @3 @8 @28"></v:f><v:f eqn="if @4 @8 @29"></v:f><v:f eqn="if @2 #1 0"></v:f><v:f eqn="if @3 @31 0"></v:f><v:f eqn="if #1 0 @32"></v:f><v:f eqn="val #0"></v:f><v:f eqn="val #1"></v:f></v:formulas><v:path o:connectlocs="10800,0;0,10800;10800,21600;21600,10800;@34,@35" o:connecttype="custom"></v:path><v:handles><v:h position="#0,#1"></v:h></v:handles></v:shapetype><v:shape id="_x0000_s1027" style="margin-top: 6pt; z-index: 2; left: 0px; margin-left: 201.6pt; width: 1in; position: absolute; height: 117pt; text-align: left; mso-position-horizontal: absolute; mso-position-vertical: absolute" adj="-6795,14520" type="#_x0000_t61"><v:textbox> <table cellspacing="0" cellpadding="0" width="100%"> <tbody> <tr> <td> <div> <p class="MsoNormal"><span style="font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">q里为需要用到的</span><span lang="EN-US">class</span><span style="font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q通过</span><span lang="EN-US">Ioc</span><span style="font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">来进行配|?/span> </p> </div> </td> </tr> </tbody> </table> </v:textbox></v:shape><v:rect id="_x0000_s1026" style="margin-top: 29.4pt; z-index: -2; left: 0px; margin-left: 21.6pt; width: 159pt; position: absolute; height: 101.4pt; text-align: left; mso-position-horizontal: absolute; mso-position-vertical: absolute" strokecolor="blue"></v:rect><span lang="EN-US" style="font-size: 14pt">class="XXXXXXXX"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt"><span lang="EN-US" style="font-size: 14pt"><property name="YYYY"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt"><span lang="EN-US" style="font-size: 14pt"><ref bean="YYYY"/><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt"><span lang="EN-US" style="font-size: 14pt"></property><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt"><span lang="EN-US" style="font-size: 14pt"></bean><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt"><span lang="EN-US" style="font-size: 14pt"><bean id="YYYY" class="YYYYYY"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt"><span lang="EN-US" style="font-size: 14pt"></bean><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt"><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">当然也可以在</span><span lang="EN-US" style="font-size: 14pt">struts</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中加?/span><span lang="EN-US" style="font-size: 14pt"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt"><span lang="EN-US" style="font-size: 14pt"><controller processorClass=<o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt"><span lang="EN-US" style="font-size: 14pt">"org.springframework.web.struts.DelegatingRequestProcessor"/><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt"><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">q样只需要写</span><span lang="EN-US" style="font-size: 14pt"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-left: 21pt"><span lang="EN-US" style="font-size: 14pt"><action path="/XXXX"/></span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">可以了(jin)Q?/span><span lang="EN-US" style="font-size: 14pt">DelegatingRequestProcessor</span><span style="font-size: 14pt; font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">能够自动分派</span><span lang="EN-US" style="font-size: 14pt"><o:p></o:p></span></p> <p class="MsoNormal"><span lang="EN-US" style="font-size: 14pt"><span style="mso-spacerun: yes"> </span><o:p></o:p></span></p> <img src ="http://www.aygfsteel.com/liuzheng/aggbug/142823.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/liuzheng/" target="_blank">刘铮 </a> 2007-09-05 10:21 <a href="http://www.aygfsteel.com/liuzheng/articles/142823.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Spring学习(fn)?j)得Q三Q?/title><link>http://www.aygfsteel.com/liuzheng/articles/142697.html</link><dc:creator>刘铮 </dc:creator><author>刘铮 </author><pubDate>Tue, 04 Sep 2007 09:27:00 GMT</pubDate><guid>http://www.aygfsteel.com/liuzheng/articles/142697.html</guid><wfw:comment>http://www.aygfsteel.com/liuzheng/comments/142697.html</wfw:comment><comments>http://www.aygfsteel.com/liuzheng/articles/142697.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/liuzheng/comments/commentRss/142697.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/liuzheng/services/trackbacks/142697.html</trackback:ping><description><![CDATA[在Around advice 的invokeҎ(gu)中,对象MethodInvocation很重要,getArgumentQ)(j)Ҏ(gu)可以得到拦截调用Ҏ(gu)的参敎ͼ如:(x)methodinvocation.getArgument()[]<br /> <br /> isAssignableForm可以对两个Classq行比较Q比如:(x)XXX.class.isAssignableFrom(methodinvocation.getMethod().getDeclaringClass())<br /> 在Before advice的public void before(Method m, Object[] args, Object target) throws Throwable {}中可以用以下Ҏ(gu)q行比较Qtarget instanceof XXX <img src ="http://www.aygfsteel.com/liuzheng/aggbug/142697.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/liuzheng/" target="_blank">刘铮 </a> 2007-09-04 17:27 <a href="http://www.aygfsteel.com/liuzheng/articles/142697.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Spring学习(fn)?j)得Q二Q?/title><link>http://www.aygfsteel.com/liuzheng/articles/142648.html</link><dc:creator>刘铮 </dc:creator><author>刘铮 </author><pubDate>Tue, 04 Sep 2007 07:59:00 GMT</pubDate><guid>http://www.aygfsteel.com/liuzheng/articles/142648.html</guid><wfw:comment>http://www.aygfsteel.com/liuzheng/comments/142648.html</wfw:comment><comments>http://www.aygfsteel.com/liuzheng/articles/142648.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/liuzheng/comments/commentRss/142648.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/liuzheng/services/trackbacks/142648.html</trackback:ping><description><![CDATA[  <p class="MsoNormal"><span lang="EN-US">Spring</span><span style="font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">学习(fn)?j)得Q二Q?/span></p> <p class="MsoNormal" style="margin-left: 21pt; text-indent: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 21.0pt"><span lang="EN-US" style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">1.<span style="font: 7pt 'Times New Roman'">         </span></span></span><span lang="EN-US">advice</span><span style="font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">有四U:(x)</span><span lang="EN-US">Before advice </span><span style="font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q?/span><span lang="EN-US">After advice </span><span style="font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q?/span><span lang="EN-US">Around advice ,Throws advice</span></p> <p class="MsoNormal" style="margin-left: 21pt; text-indent: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 21.0pt"><span lang="EN-US" style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">2.<span style="font: 7pt 'Times New Roman'">         </span></span></span><span style="font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">q四U?/span><span lang="EN-US">advice</span><span style="font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">分别需要承的接口?/span></p> <table class="MsoNormalTable" style="border-right: medium none; border-top: medium none; border-left: medium none; width: 100%; border-bottom: medium none; border-collapse: collapse; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext" cellspacing="0" cellpadding="0" width="100%" border="1"> <tbody> <tr style="height: 22.8pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes"> <td style="border-right: windowtext 1pt solid; padding-right: 5.4pt; border-top: windowtext 1pt solid; padding-left: 5.4pt; background: #a6a6a6; padding-bottom: 0cm; border-left: windowtext 1pt solid; width: 22.42%; padding-top: 0cm; border-bottom: windowtext 1pt solid; height: 22.8pt; mso-border-alt: solid windowtext .5pt" valign="top" width="22%"> <p class="MsoNormal" style="text-align: center" align="center"><span lang="EN-US">Advice type</span></p> </td> <td style="border-right: windowtext 1pt solid; padding-right: 5.4pt; border-top: windowtext 1pt solid; padding-left: 5.4pt; background: #a6a6a6; padding-bottom: 0cm; border-left: medium none; width: 77.58%; padding-top: 0cm; border-bottom: windowtext 1pt solid; height: 22.8pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt" valign="top" width="77%"> <p class="MsoNormal" style="text-align: center" align="center"><span lang="EN-US">Interface</span></p> </td> </tr> <tr style="height: 22.25pt; mso-yfti-irow: 1"> <td style="border-right: windowtext 1pt solid; padding-right: 5.4pt; border-top: medium none; padding-left: 5.4pt; padding-bottom: 0cm; border-left: windowtext 1pt solid; width: 22.42%; padding-top: 0cm; border-bottom: windowtext 1pt solid; height: 22.25pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" valign="top" width="22%"> <p class="MsoNormal" style="text-align: center" align="center"><span lang="EN-US">Throws advice</span></p> </td> <td style="border-right: windowtext 1pt solid; padding-right: 5.4pt; border-top: medium none; padding-left: 5.4pt; padding-bottom: 0cm; border-left: medium none; width: 77.58%; padding-top: 0cm; border-bottom: windowtext 1pt solid; height: 22.25pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" valign="top" width="77%"> <p class="MsoNormal" style="text-align: center" align="center"><span lang="EN-US">org.aopalliance.intercept.MethodInterceptor</span></p> </td> </tr> <tr style="height: 29.55pt; mso-yfti-irow: 2"> <td style="border-right: windowtext 1pt solid; padding-right: 5.4pt; border-top: medium none; padding-left: 5.4pt; padding-bottom: 0cm; border-left: windowtext 1pt solid; width: 22.42%; padding-top: 0cm; border-bottom: windowtext 1pt solid; height: 29.55pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" valign="top" width="22%"> <p class="MsoNormal" style="text-align: center" align="center"><span lang="EN-US">Before advice</span></p> </td> <td style="border-right: windowtext 1pt solid; padding-right: 5.4pt; border-top: medium none; padding-left: 5.4pt; padding-bottom: 0cm; border-left: medium none; width: 77.58%; padding-top: 0cm; border-bottom: windowtext 1pt solid; height: 29.55pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" valign="top" width="77%"> <p class="MsoNormal" style="text-align: center" align="center"><span lang="EN-US">org.springframework.aop.BeforeAdvice</span></p> </td> </tr> <tr style="height: 29.15pt; mso-yfti-irow: 3"> <td style="border-right: windowtext 1pt solid; padding-right: 5.4pt; border-top: medium none; padding-left: 5.4pt; padding-bottom: 0cm; border-left: windowtext 1pt solid; width: 22.42%; padding-top: 0cm; border-bottom: windowtext 1pt solid; height: 29.15pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" valign="top" width="22%"> <p class="MsoNormal" style="text-align: center" align="center"><span lang="EN-US">After advice</span></p> </td> <td style="border-right: windowtext 1pt solid; padding-right: 5.4pt; border-top: medium none; padding-left: 5.4pt; padding-bottom: 0cm; border-left: medium none; width: 77.58%; padding-top: 0cm; border-bottom: windowtext 1pt solid; height: 29.15pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" valign="top" width="77%"> <p class="MsoNormal" style="text-align: center" align="center"><span lang="EN-US">org.springframework.aop.AfterReturningAdvice</span></p> </td> </tr> <tr style="height: 29.4pt; mso-yfti-irow: 4; mso-yfti-lastrow: yes"> <td style="border-right: windowtext 1pt solid; padding-right: 5.4pt; border-top: medium none; padding-left: 5.4pt; padding-bottom: 0cm; border-left: windowtext 1pt solid; width: 22.42%; padding-top: 0cm; border-bottom: windowtext 1pt solid; height: 29.4pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" valign="top" width="22%"> <p class="MsoNormal" style="text-align: center" align="center"><span lang="EN-US">Throws advice</span></p> </td> <td style="border-right: windowtext 1pt solid; padding-right: 5.4pt; border-top: medium none; padding-left: 5.4pt; padding-bottom: 0cm; border-left: medium none; width: 77.58%; padding-top: 0cm; border-bottom: windowtext 1pt solid; height: 29.4pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" valign="top" width="77%"> <p class="MsoNormal" style="text-align: center" align="center"><span lang="EN-US">org.springframework.aop.ThrowsAdvice</span></p> </td> </tr> </tbody> </table> <p class="MsoNormal"><span lang="EN-US">3</span><span style="font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q?/span><span lang="EN-US">Around advice</span><span style="font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">?/span><span lang="EN-US">Before advice</span><span style="font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的区别是</span><span lang="EN-US">Before advice</span><span style="font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">是只要没有异常,目标Ҏ(gu)一定会(x)被调用,然?/span><span lang="EN-US">Around advice</span><span style="font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q只有当调用</span><span lang="EN-US">MethodInvocation.proceed()</span><span style="font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">后目标方法才能被调用。而且</span><span lang="EN-US">Around advice</span><span style="font-family: ?hu)? mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">q可以返回想q回的|(x)?/span><span lang="EN-US">Object obj=invocation.proceed();</span></p><img src ="http://www.aygfsteel.com/liuzheng/aggbug/142648.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/liuzheng/" target="_blank">刘铮 </a> 2007-09-04 15:59 <a href="http://www.aygfsteel.com/liuzheng/articles/142648.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <a href="http://www.aygfsteel.com/" title="狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频">狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频</a> </div> </footer> վ֩ģ壺 <a href="http://" target="_blank">Т</a>| <a href="http://" target="_blank">Ϻӿ</a>| <a href="http://" target="_blank">ϲ</a>| <a href="http://" target="_blank">°Ͷ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank">¡</a>| <a href="http://" target="_blank">캵</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Դ</a>| <a href="http://" target="_blank">Ϫ</a>| <a href="http://" target="_blank">崨</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ĵ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ƫ</a>| <a href="http://" target="_blank">¬</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ũ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">۩</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ֲ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">͡</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ϼ</a>| <a href="http://" target="_blank">н</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ϫ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>