﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-jinfeng_wang-随笔分类-spring</title><link>http://www.blogjava.net/jinfeng_wang/category/480.html</link><description>G-G-S,D-D-U!</description><language>zh-cn</language><lastBuildDate>Thu, 20 Mar 2008 10:19:20 GMT</lastBuildDate><pubDate>Thu, 20 Mar 2008 10:19:20 GMT</pubDate><ttl>60</ttl><item><title>XDoclet的build.xml写法 zz</title><link>http://www.blogjava.net/jinfeng_wang/archive/2008/03/20/187409.html</link><dc:creator>jinfeng_wang</dc:creator><author>jinfeng_wang</author><pubDate>Thu, 20 Mar 2008 01:52:00 GMT</pubDate><guid>http://www.blogjava.net/jinfeng_wang/archive/2008/03/20/187409.html</guid><wfw:comment>http://www.blogjava.net/jinfeng_wang/comments/187409.html</wfw:comment><comments>http://www.blogjava.net/jinfeng_wang/archive/2008/03/20/187409.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/jinfeng_wang/comments/commentRss/187409.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/jinfeng_wang/services/trackbacks/187409.html</trackback:ping><description><![CDATA[http://gocom.primeton.com/showblogarticle.php?cat_id=all&amp;articleId=&amp;blogId=14478&amp;?PHPSESSID=0d485ace30025757c7b9a22da013c1a0&amp;page=4&amp;PHPSESSID=1370043e8b6d902ac0f6fdc3fe7776a8<br />
<br />
<br />
&nbsp;XDoclet的build.xml写法
<p><br />
</p>
<div>
<ol>
    <li>&lt;?xml version="1.0" encoding="utf-8"?&gt; </li>
    <li>&lt;project name="appgen" default="web-demo" basedir="."&gt; </li>
    <li>&nbsp;</li>
    <li>&lt;property file="build.properties" /&gt; </li>
    <li>&nbsp;</li>
    <li>&lt;path id="xdoclet.classpath"&gt; </li>
    <li>&lt;fileset dir="${lib}"&gt; </li>
    <li>&lt;include name="**/*.jar" /&gt; </li>
    <li>&lt;/fileset&gt; </li>
    <li>&lt;path location="${classes}" /&gt; </li>
    <li>&lt;/path&gt; </li>
    <li>&nbsp;</li>
    <li>&lt;target name="clean"&gt; </li>
    <li>&lt;delete&gt; </li>
    <li>&lt;fileset dir="${gen}"&gt; </li>
    <li>&lt;include name="*.xml" /&gt; </li>
    <li>&lt;/fileset&gt; </li>
    <li>&lt;/delete&gt; </li>
    <li>&lt;/target&gt; </li>
    <li>&nbsp;</li>
    <li>&lt;!-- 这个target可以生成，strutsconfigxml , strutsvalidationxml ,web.xml--&gt; </li>
    <li>&nbsp;</li>
    <li>&lt;target name="web-demo" depends="clean,Spring-service-beans,Spring-action-beans,Spring-dao-beans"&gt; </li>
    <li>&lt;taskdef name="webdoclet" classname="xdoclet.modules.web.WebDocletTask" classpathref="xdoclet.classpath" /&gt; </li>
    <li>&lt;webdoclet destDir="${gen}" mergeDir="${merge}" force="false"&gt; </li>
    <li>&lt;fileset dir="${src}"&gt; </li>
    <li>&lt;include name="**/*Action.java" /&gt; </li>
    <li>&lt;include name="**/*Form.java" /&gt; </li>
    <li>&lt;/fileset&gt; </li>
    <li>&nbsp;</li>
    <li>&lt;strutsconfigxml Version="1.2" destDir="${gen}" validateXML="true"/&gt; </li>
    <li>&lt;strutsvalidationxml destDir="${gen}" /&gt; </li>
    <li>&lt;deploymentdescriptor Servletspec="2.4" destDir="${gen}" /&gt; </li>
    <li>&nbsp;</li>
    <li>&lt;/webdoclet&gt; </li>
    <li>&lt;/target&gt; </li>
    <li>&nbsp;</li>
    <li>&lt;target name="ReplaceConfigFile" depends="web-demo"&gt; </li>
    <li>&lt;copy todir="${webinf}"&gt; </li>
    <li>&lt;fileset dir="${gen}"&gt; </li>
    <li>&lt;include name="struts-config.xml"/&gt; </li>
    <li>&lt;include name="validation.xml"/&gt; </li>
    <li>&lt;include name="action-beans.xml"/&gt; </li>
    <li>&lt;include name="dao-beans.xml"/&gt; </li>
    <li>&lt;include name="service-beans.xml"/&gt; </li>
    <li>&lt;/fileset&gt; </li>
    <li>&lt;/copy&gt; </li>
    <li>&lt;/target&gt; </li>
    <li>&lt;!-- 生成spring的xml文件 --&gt; </li>
    <li>&lt;target name="Spring-service-beans" description="Spring-application-beans"&gt; </li>
    <li>&lt;taskdef name="springdoclet" classname="xdoclet.modules.spring.SpringDocletTask" classpathref="xdoclet.classpath" /&gt; </li>
    <li><span>&lt;springdoclet
    excludedTags="@version,@author,@todo" destDir="gen" verbose="true"
    addedTags="@xdoclet-generated at ${TODAY},@copyright The XDoclet
    Team,@author XDoclet,@version ${version}"&gt; </span></li>
    <li>&lt;fileset dir="src" includes="**/*ServiceImpl.java"/&gt; </li>
    <li>&lt;springxml destinationFile="service-beans.xml" destDir="gen"/&gt; </li>
    <li>&lt;/springdoclet&gt; </li>
    <li>&lt;/target&gt; </li>
    <li>&nbsp;</li>
    <li>&nbsp;</li>
    <li>&lt;!-- 生成spring的xml文件 --&gt; </li>
    <li>&lt;target name="Spring-action-beans" description="Spring-servlet-beans"&gt; </li>
    <li>&lt;taskdef name="springdoclet" classname="xdoclet.modules.spring.SpringDocletTask" classpathref="xdoclet.classpath" /&gt; </li>
    <li><span>&lt;springdoclet
    excludedTags="@version,@author,@todo" destDir="gen" verbose="true"
    addedTags="@xdoclet-generated at ${TODAY},@copyright The XDoclet
    Team,@author XDoclet,@version ${version}"&gt; </span></li>
    <li>&lt;springxml destinationFile="action-beans.xml" destDir="gen"/&gt; </li>
    <li>&lt;fileset dir="src" includes="**/*Action.java"/&gt; </li>
    <li>&lt;/springdoclet&gt; </li>
    <li>&lt;/target&gt; </li>
    <li>&nbsp;</li>
    <li>&nbsp;</li>
    <li>&lt;!-- 生成spring的xml文件 --&gt; </li>
    <li>&lt;target name="Spring-dao-beans" description="Spring-servlet-beans"&gt; </li>
    <li>&lt;taskdef name="springdoclet" classname="xdoclet.modules.spring.SpringDocletTask" classpathref="xdoclet.classpath" /&gt; </li>
    <li><span>&lt;springdoclet
    excludedTags="@version,@author,@todo" destDir="gen" verbose="true"
    addedTags="@xdoclet-generated at ${TODAY},@copyright The XDoclet
    Team,@author XDoclet,@version ${version}"&gt; </span></li>
    <li>&lt;springxml destinationFile="dao-beans.xml" destDir="gen"/&gt; </li>
    <li>&lt;fileset dir="src" includes="**/*DAOIbatis.java"/&gt; </li>
    <li>&lt;/springdoclet&gt; </li>
    <li>&lt;/target&gt; </li>
    <li>&nbsp;</li>
    <li>&lt;/project&gt; </li>
    <li>&nbsp;</li>
</ol>
</div>
<p><br />
＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝</p>
<p><br />
</p>
<div>
<ol>
    <li>/** </li>
    <li>* @spring.bean id="UserDAO" </li>
    <li>* @spring.property name="dataSource" ref="dataSource" </li>
    <li>* @spring.property name="sqlMapClient" ref="sqlMapClient" </li>
    <li>* </li>
    <li>* @author Conan </li>
    <li>* </li>
    <li>*/ </li>
    <li>public class UserDAOIbatis extends BaseDAOIBatis implements UserDAO {....} </li>
</ol>
</div>
<p><br />
</p>
<p>-------------------------------------------</p>
<p><br />
</p>
<div>
<ol>
    <li>/** </li>
    <li>* @spring.bean id="UserService" </li>
    <li>* @spring.property name="userDao" ref="UserDAO" </li>
    <li>* </li>
    <li>* @author Conan </li>
    <li>* </li>
    <li>*/ </li>
    <li>public class UserServiceImpl extends BaseManager implements UserService {...} </li>
</ol>
</div>
<p><br />
<br />
&nbsp;---------------------------------------------</p>
<p><br />
</p>
<div>
<ol>
    <li>/** </li>
    <li>* </li>
    <li>* @struts.action path="/add" name="UserForm" input="/add.jsp" </li>
    <li>* type="org.springframework.web.struts.DelegatingActionProxy" </li>
    <li>* validate="true" scope="request" </li>
    <li>* </li>
    <li>* @struts.action-forward name="success" path="/success.jsp" redirect="true" </li>
    <li>* @struts.action-forward name="failure" path="/failure.jsp" redirect="true" </li>
    <li>* </li>
    <li>* @struts.action-form name="UserForm" </li>
    <li>* </li>
    <li>* @spring.bean </li>
    <li>* name="/add" </li>
    <li>* @spring.property </li>
    <li>* name="userService" </li>
    <li>* ref="UserService" </li>
    <li>* </li>
    <li>*/ </li>
    <li>public final class AddAction extends BaseAction {...} </li>
</ol>
</div>
<p><br />
</p>
<p>------------------------------------------</p>
<p><br />
</p>
<div>
<ol>
    <li>/** </li>
    <li>* @struts.form name="UserForm" </li>
    <li>*/ </li>
    <li>public class UserForm extends BaseForm{ </li>
    <li>&nbsp;</li>
    <li>/** </li>
    <li>* @struts.validator type="required" </li>
    <li>* @struts.validator type="mask" msgkey="error.age" </li>
    <li>* @struts.validator-var name="mask" value="^[0-9]*$" </li>
    <li>*/ </li>
    <li>public void setAge(Integer age) { </li>
    <li>this.age = age; </li>
    <li>} </li>
    <li>&nbsp;</li>
    <li>} </li>
</ol>
</div>
<p><br />
</p>
<p><br />
</p>
<br />
<img src ="http://www.blogjava.net/jinfeng_wang/aggbug/187409.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/jinfeng_wang/" target="_blank">jinfeng_wang</a> 2008-03-20 09:52 <a href="http://www.blogjava.net/jinfeng_wang/archive/2008/03/20/187409.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>XDoclet Spring+Struts HowTo zz</title><link>http://www.blogjava.net/jinfeng_wang/archive/2008/03/20/187406.html</link><dc:creator>jinfeng_wang</dc:creator><author>jinfeng_wang</author><pubDate>Thu, 20 Mar 2008 01:42:00 GMT</pubDate><guid>http://www.blogjava.net/jinfeng_wang/archive/2008/03/20/187406.html</guid><wfw:comment>http://www.blogjava.net/jinfeng_wang/comments/187406.html</wfw:comment><comments>http://www.blogjava.net/jinfeng_wang/archive/2008/03/20/187406.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/jinfeng_wang/comments/commentRss/187406.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/jinfeng_wang/services/trackbacks/187406.html</trackback:ping><description><![CDATA[http://www.logemann.org/day/archives/000148.html<br />
<br />
<br />
<p>For all those out there using Spring together with Struts, i created
a small howTo regarding automatic generation of relevant files,
especially the boring action-servlet-xml file which must be in synch
with your struts-config.xml, at least for all Struts actions which
should be injected by Spring.</p>
<p>Lets start with the Action class:</p>
<table border="1">
    <tbody>
        <tr>
            <td>
            <pre>/**<br />
            * Action to delete a Client<br />
            * Date: 09.02.2005<br />
            * Time: 15:29:15<br />
            *<br />
            * @author Logemann - Logentis e.K. (ml@logentis.de)<br />
            * @version $Id$<br />
            * @struts.action path="clientDelete" validate="false"<br />
            *            type="org.springframework.web.struts.DelegatingActionProxy"<br />
            *            name="emptyform"<br />
            * @struts.action-forward name="back" <br />
            *             path="/clientManager.html" redirect="true"<br />
            * @spring.bean name="clientDelete"<br />
            */<br />
            public class ClientDeleteAction extends Action {<br />
            <br />
            <p>    ClientManager clientManagerService;</p>
            <br />
            <br />
            <p>    /**<br />
            <br />
            * Spring injection<br />
            <br />
            *<br />
            <br />
            * @param clientManagerService clientManagerService<br />
            <br />
            * @spring.property ref="clientManagerService"<br />
            <br />
            */<br />
            <br />
            public void setClientManagerService(ClientManager clientManagerService) {<br />
            <br />
            this.clientManagerService = clientManagerService;<br />
            <br />
            }<br />
            <br />
            [..]<br />
            <br />
            </p>
            </pre>
            <br />
            </td>
        </tr>
    </tbody>
</table>
<p>With this tags, the ant build target outlined below will create a
struts-config.xml and the necessary action-servlet.xml needed by
Spring. Lets see how the target looks:</p>
<table border="1">
    <tbody>
        <tr>
            <td>
            &lt;path id="classpath"&gt;
            <p>        &lt;fileset dir="c:/xdoclet-1.2.2" includes="*.jar"/&gt;<br />
            &lt;fileset dir="c:/j2sdkee1.3.1/lib" includes="*.jar"/&gt;<br />
            &lt;fileset dir="c:/struts/lib" includes="struts.jar"/&gt;<br />
            &lt;/path&gt;</p>
            <p>    &lt;taskdef name="springdoclet" <br />
            classname="xdoclet.modules.spring.SpringDocletTask"<br />
            classpathref="classpath"/&gt;<br />
            <br />
            &lt;taskdef name="webdoclet" <br />
            classname="xdoclet.modules.web.WebDocletTask"<br />
            classpathref="classpath"/&gt;</p>
            <p>   &lt;target name="myTest"&gt;<br />
            &lt;webdoclet destDir="c:\" force="true" verbose="true"&gt;<br />
            &lt;fileset dir="${src.dir}"&gt;<br />
            &lt;include name="**/*Form.java" /&gt;<br />
            &lt;include name="**/*Action.java" /&gt;<br />
            &lt;include name="**/*Servlet.java" /&gt;<br />
            &lt;/fileset&gt;<br />
            &lt;strutsconfigxml version="1.1" validateXml="true"/&gt;<br />
            &lt;/webdoclet&gt;</p>
            <p>        &lt;springdoclet destDir="c:\" verbose="true"&gt;<br />
            &lt;fileset dir="${src.dir}"&gt;<br />
            &lt;include name="**/*Action.java" /&gt;<br />
            &lt;/fileset&gt;<br />
            &lt;springxml destinationFile="action-servlet.xml"/&gt;<br />
            &lt;/springdoclet&gt;<br />
            &lt;/target&gt;<br />
            </p>
            </td>
        </tr>
    </tbody>
</table>
<p>Be sure to modify the classpath definition and the destDir values of
springdoclet and webdoclet to suit your needs. Right now the Spring
task only searches for Actions in order to create action-servlet.xml,
if you also want to create your normal service beans like
ClientManagerService, you should create another springdoclet task and
output things to applicationContext.xml if you like. </p>
<p>But this is mostly users choice, as you know, Spring supports from
one to many bean definition files and its up to you how you want to
have your spring xml world.</p>
<p>This will be created when you run the mentioned target:</p>
<p>(action-servlet.xml)<br />
</p>
<table border="1">
    <tbody>
        <tr>
            <td><br />
            &lt;?xml version="1.0" encoding="UTF-8"?&gt;<br />
            &lt;!DOCTYPE beans PUBLIC<br />
            "-//SPRING//DTD BEAN//EN"<br />
            "http://www.springframework.org/dtd/spring-beans.dtd"&gt;
            <p>&lt;beans<br />
            default-autowire="no"<br />
            default-lazy-init="false"<br />
            default-dependency-check="none"<br />
            &gt;</p>
            <p>  &lt;bean<br />
            name="clientDelete"<br />
            class="de.logentis.versysng.action.clientmanager.ClientDeleteAction"<br />
            &gt;</p>
            <p>    &lt;property name="clientManagerService"&gt;</p>
            <p>      &lt;ref bean="clientManagerService"/&gt;<br />
            &lt;/property&gt;</p>
            <p>  &lt;/bean&gt;</p>
            <p>  &lt;!--<br />
            To include additional bean definitions for Spring in the generated<br />
            application context file, add a file to your XDoclet merge directory<br />
            called spring-beans.xml that contains the &lt;bean&gt;&lt;/bean&gt; markup.<br />
            --&gt;<br />
            &lt;/beans&gt;<br />
            </p>
            </td>
        </tr>
    </tbody>
</table>
<p><br />
(struts-config.xml)<br />
</p>
<br />
&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
<p>&lt;!DOCTYPE struts-config PUBLIC "-//Apache Software
Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"&gt;</p>
<p>&lt;struts-config&gt;</p>
<p>  &lt;!-- ========== Data Sources Definitions =================================== --&gt;<br />
&lt;!--<br />
Define your Struts data sources in a file called struts-data-sources.xml and place<br />
it in your merge directory.<br />
--&gt;</p>
<p>  &lt;!-- ========== Form Bean Definitions =================================== --&gt;<br />
&lt;form-beans&gt;</p>
<p>    &lt;!--<br />
If you have non XDoclet forms, define them in a file called struts-forms.xml and<br />
place it in your merge directory.<br />
--&gt;<br />
&lt;/form-beans&gt;</p>
<p>  &lt;!-- ========== Global Exceptions Definitions =================================== --&gt;<br />
&lt;!--<br />
Define your exceptions in a file called global-exceptions.xml and place<br />
it in your merge directory.<br />
--&gt;</p>
<p>  &lt;!-- ========== Global Forward Definitions =================================== --&gt;<br />
&lt;!--<br />
Define your forwards in a file called global-forwards.xml and place<br />
it in your merge directory.<br />
--&gt;</p>
<p>  &lt;!-- ========== Action Mapping Definitions =================================== --&gt;<br />
&lt;action-mappings&gt;<br />
&lt;action<br />
path="clientDelete"<br />
type="org.springframework.web.struts.DelegatingActionProxy"<br />
name="emptyform"<br />
scope="request"<br />
unknown="false"<br />
validate="false"<br />
&gt;<br />
&lt;forward<br />
name="back"<br />
path="/clientManager.html"<br />
redirect="true"<br />
/&gt;<br />
&lt;/action&gt;</p>
<p> &lt;!-- If you have non XDoclet actions, define them in a file
called struts-actions.xml and place it in your merge directory. --&gt;<br />
&lt;/action-mappings&gt;</p>
<p>   &lt;!-- Define your Struts controller in a file called struts-controller.xml and place it in your merge directory. --&gt;</p>
<p> &lt;!-- Define your Struts message-resources in a file called
struts-message-resources.xml and place it in your merge directory.
--&gt;</p>
<p>   &lt;!-- Define your Struts plugins in a file called struts-plugins.xml and place it in your merge directory. --&gt;</p>
&lt;/struts-config&gt;<br />
<br />
<img src ="http://www.blogjava.net/jinfeng_wang/aggbug/187406.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/jinfeng_wang/" target="_blank">jinfeng_wang</a> 2008-03-20 09:42 <a href="http://www.blogjava.net/jinfeng_wang/archive/2008/03/20/187406.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Pro Spring: Spring and EJB (zz)</title><link>http://www.blogjava.net/jinfeng_wang/archive/2005/03/18/2192.html</link><dc:creator>jinfeng_wang</dc:creator><author>jinfeng_wang</author><pubDate>Fri, 18 Mar 2005 06:35:00 GMT</pubDate><guid>http://www.blogjava.net/jinfeng_wang/archive/2005/03/18/2192.html</guid><wfw:comment>http://www.blogjava.net/jinfeng_wang/comments/2192.html</wfw:comment><comments>http://www.blogjava.net/jinfeng_wang/archive/2005/03/18/2192.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/jinfeng_wang/comments/commentRss/2192.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/jinfeng_wang/services/trackbacks/2192.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Pro Spring: Spring and EJBLearn how to use Spring with EJB applictionsSummary-->SummaryIn traditional J2EE applications, Enterprise JavaBeans (EJB) often forms the cornerstone of an application'...&nbsp;&nbsp;<a href='http://www.blogjava.net/jinfeng_wang/archive/2005/03/18/2192.html'>阅读全文</a><img src ="http://www.blogjava.net/jinfeng_wang/aggbug/2192.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/jinfeng_wang/" target="_blank">jinfeng_wang</a> 2005-03-18 14:35 <a href="http://www.blogjava.net/jinfeng_wang/archive/2005/03/18/2192.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Pro Spring的目录</title><link>http://www.blogjava.net/jinfeng_wang/archive/2005/03/06/1768.html</link><dc:creator>jinfeng_wang</dc:creator><author>jinfeng_wang</author><pubDate>Sun, 06 Mar 2005 06:46:00 GMT</pubDate><guid>http://www.blogjava.net/jinfeng_wang/archive/2005/03/06/1768.html</guid><wfw:comment>http://www.blogjava.net/jinfeng_wang/comments/1768.html</wfw:comment><comments>http://www.blogjava.net/jinfeng_wang/archive/2005/03/06/1768.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/jinfeng_wang/comments/commentRss/1768.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/jinfeng_wang/services/trackbacks/1768.html</trackback:ping><description><![CDATA[PART 1 ■ ■ ■ Getting Started with Spring<BR>CHAPTER 1 Introducing Spring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3<BR>CHAPTER 2 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15<BR>CHAPTER 3 The Sample Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35<BR>PART 2 ■ ■ ■ Spring Basics<BR>CHAPTER 4 Introducing Inversion of Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49<BR>CHAPTER 5 Beyond the Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93<BR>PART 3 ■ ■ ■ Aspect Oriented Programming<BR>with Spring<BR>CHAPTER 6 Introducing Spring AOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157<BR>CHAPTER 7 More on Spring AOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205<BR>PART 4 ■ ■ ■ Data Access with Spring<BR>CHAPTER 8 Spring JDBC Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249<BR>CHAPTER 9 Using Hibernate in Spring Applications . . . . . . . . . . . . . . . . . . . . . . . 279<BR>CHAPTER 10 iBATIS Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311<BR>vi ■CONTENTS AT A GLANCE<BR>PART 5 ■ ■ ■ Spring in the Middle Tier<BR>CHAPTER 11 Designing and Implementing Spring-Based Applications . . . . . . 353<BR>CHAPTER 12 Transaction Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395<BR>CHAPTER 13 Spring and J2EE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439<BR>CHAPTER 14 Job Scheduling with Spring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487<BR>CHAPTER 15 Mail Support in Spring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517<BR>CHAPTER 16 Using Spring Remoting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 549<BR>PART 6 ■ ■ ■ Web Applications with Spring<BR>CHAPTER 17 Web Applications with Spring MVC . . . . . . . . . . . . . . . . . . . . . . . . . . 599<BR>CHAPTER 18 Beyond JSP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 645<BR>CHAPTER 19 Spring and Struts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 679<BR>PART 7 ■ ■ ■ Appendixes<BR>APPENDIX A Testing with Spring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 697<BR>APPENDIX B The Spring Rich Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 711<BR>APPENDIX C Spring IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 729<BR>APPENDIX D The Future of Spring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 743<img src ="http://www.blogjava.net/jinfeng_wang/aggbug/1768.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/jinfeng_wang/" target="_blank">jinfeng_wang</a> 2005-03-06 14:46 <a href="http://www.blogjava.net/jinfeng_wang/archive/2005/03/06/1768.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Spring Transaction</title><link>http://www.blogjava.net/jinfeng_wang/archive/2005/03/04/1683.html</link><dc:creator>jinfeng_wang</dc:creator><author>jinfeng_wang</author><pubDate>Fri, 04 Mar 2005 06:15:00 GMT</pubDate><guid>http://www.blogjava.net/jinfeng_wang/archive/2005/03/04/1683.html</guid><wfw:comment>http://www.blogjava.net/jinfeng_wang/comments/1683.html</wfw:comment><comments>http://www.blogjava.net/jinfeng_wang/archive/2005/03/04/1683.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/jinfeng_wang/comments/commentRss/1683.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/jinfeng_wang/services/trackbacks/1683.html</trackback:ping><description><![CDATA[<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>Spring Transaction</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">：通过</SPAN><SPAN lang=EN-US>Template+Callback</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">机制，实现对各种事务的统一封装。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>&nbsp;<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>&lt;bean id="transactionManager" //</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对</SPAN><SPAN lang=EN-US>JDBC Transaction</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的封装</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>class="<SPAN style="COLOR: red">org.springframework.jdbc.datasource.DataSourceTransactionManager</SPAN>"&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;property name="<SPAN style="COLOR: red">dataSource</SPAN>"&gt; <o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;ref bean="dataSource"/&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;/property&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>&lt;/bean&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>&lt;bean id="transactionManager" //</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对</SPAN><SPAN lang=EN-US>Hibernate</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">事务的封装</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>class="<SPAN style="COLOR: red">org.springframework.orm.hibernate.HibernateTransactionManager</SPAN>"&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;property name="<SPAN style="COLOR: red">sessionFactory</SPAN>"&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;ref bean="sessionFactory"/&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;/property&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>&lt;/bean&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>&lt;bean id="transactionManager"//</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对</SPAN><SPAN lang=EN-US>JDO</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">事务的封装</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>class="<SPAN style="COLOR: red">org.springframework.orm.jdo.JdoTransactionManager</SPAN>"&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;property name="<SPAN style="COLOR: red">persistenceManagerFactory</SPAN>"&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;ref bean="persistenceManagerFactory"/&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;/property&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>&lt;/bean&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>&lt;bean id="transactionManager" //</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对</SPAN><SPAN lang=EN-US>JTA </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">事务的封装</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>class="<SPAN style="COLOR: red">org.springframework.transaction.jta.JtaTransactionManager</SPAN>"&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;property name="<SPAN style="COLOR: red">transactionManagerName</SPAN>"&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;value&gt;java:/TransactionManager&lt;/value&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;/property&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>&lt;/bean&gt;</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>&lt;bean id="courseService"//</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">利用</SPAN><SPAN lang=EN-US>AOP</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，将</SPAN><SPAN lang=EN-US>TransactionManager</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和普通的</SPAN><SPAN lang=EN-US>Service</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">编织起来，实现事务。</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>class="<SPAN style="COLOR: red">org.springframework.transaction.interceptor.TransactionProxyFactoryBean</SPAN>"&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;property name="<SPAN style="COLOR: red">proxyInterfaces</SPAN>"&gt;//</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">编织后对外的接口</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;list&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;value&gt;com.springinaction.training.service.<SPAN style="COLOR: red">CourseService</SPAN>&lt;/value&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;/list&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;/property&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;property name="<SPAN style="COLOR: red">target</SPAN>"&gt;//</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">目标</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;ref bean="<SPAN style="COLOR: red">courseServiceTarget</SPAN>"/&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;/property&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;property name="<SPAN style="COLOR: red">transactionManager</SPAN>"&gt;//</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">植入的事务管理者</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;ref bean="<SPAN style="COLOR: red">transactionManager</SPAN>"/&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;/property&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;property name="transactionAttributeSource"&gt;//</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">事务的参数（隔离度，方法名等）</SPAN><SPAN lang=EN-US><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;ref bean="attributeSource"/&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;/property&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>&lt;/bean&gt;</SPAN></P><img src ="http://www.blogjava.net/jinfeng_wang/aggbug/1683.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/jinfeng_wang/" target="_blank">jinfeng_wang</a> 2005-03-04 14:15 <a href="http://www.blogjava.net/jinfeng_wang/archive/2005/03/04/1683.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Spring封装Hibernate</title><link>http://www.blogjava.net/jinfeng_wang/archive/2005/03/03/1654.html</link><dc:creator>jinfeng_wang</dc:creator><author>jinfeng_wang</author><pubDate>Thu, 03 Mar 2005 08:58:00 GMT</pubDate><guid>http://www.blogjava.net/jinfeng_wang/archive/2005/03/03/1654.html</guid><wfw:comment>http://www.blogjava.net/jinfeng_wang/comments/1654.html</wfw:comment><comments>http://www.blogjava.net/jinfeng_wang/archive/2005/03/03/1654.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/jinfeng_wang/comments/commentRss/1654.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/jinfeng_wang/services/trackbacks/1654.html</trackback:ping><description><![CDATA[<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><SPAN lang=EN-US>Spring</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">封装</SPAN><SPAN lang=EN-US>Hibernate</SPAN>：</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">有两种手段：</SPAN><SPAN lang=EN-US>1</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、使用</SPAN><SPAN lang=EN-US>HibernateTemplate</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">；</SPAN><SPAN lang=EN-US>2</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、继承</SPAN><SPAN lang=EN-US>HibernateDaoSupport</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">（实际上，</SPAN><SPAN lang=EN-US>HibernateDaoSupport</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">本身就是对</SPAN><SPAN lang=EN-US>HibernateTemplate</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的一个封装）</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">一切尽在代码中，查看</SPAN><SPAN lang=EN-US>API</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">唉！<BR></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>注意：hibernate 2.X和hibernate3.X的区别，我用的是2.X&nbsp;。&nbsp;&nbsp;<IMG height=20 src="http://www.blogjava.net/Emoticons/QQ/45.gif" width=20 border=0><BR>&nbsp;<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>package com.company.example.dao;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>import java.util.List;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>import com.company.example.model.Student;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>public interface StudentDao {<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>public abstract Student getStudent(final Integer id);<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>public abstract void updateStudent(Student student);<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>public abstract List findStudentsByLastName(String lastName);<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>}</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>==================</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>package com.company.example.dao.hibernateImpl;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>import java.util.List;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>import net.sf.hibernate.Hibernate;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>import net.sf.hibernate.HibernateException;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>import net.sf.hibernate.Session;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>import org.springframework.orm.hibernate.HibernateCallback;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>import org.springframework.orm.hibernate.HibernateTemplate;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>import com.company.example.dao.StudentDao;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>import com.company.example.model.Student;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>public class StudentDaoHibernate implements StudentDao {<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>HibernateTemplate hibernateTemplate;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>public static void main(String[] args) {<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>public HibernateTemplate getHibernateTemplate() {<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>return hibernateTemplate;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>this.hibernateTemplate = hibernateTemplate;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>public Student getStudent(final Integer id) {<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>return (Student) hibernateTemplate.execute(new HibernateCallback() {<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>public Object doInHibernate(Session session)<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>throws HibernateException {<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>return session.load(Student.class, id);<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>});<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>public Student getStudent2(Integer id) {<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>return (Student) hibernateTemplate.load(Student.class, id);<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>public void updateStudent(Student student) {<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>hibernateTemplate.update(student);<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>public List findStudentsByLastName(String lastName) {<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>return hibernateTemplate.find("from Student student "<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>+ "where student.lastName = ?", lastName, Hibernate.STRING);<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<DIV style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0cm; BORDER-TOP: medium none; PADDING-LEFT: 0cm; PADDING-BOTTOM: 1pt; BORDER-LEFT: medium none; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 2.25pt double">
<P class=MsoNormal style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0cm; BORDER-TOP: medium none; PADDING-LEFT: 0cm; PADDING-BOTTOM: 0cm; MARGIN: 0cm 0cm 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0cm; BORDER-BOTTOM: medium none; TEXT-ALIGN: left; mso-layout-grid-align: none; mso-padding-alt: 0cm 0cm 1.0pt 0cm; mso-border-bottom-alt: double windowtext 2.25pt" align=left><SPAN lang=EN-US>}</SPAN></P></DIV>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-font-kerning: 0pt">public class StudentDaoHibernate extends HibernateDaoSupport<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-font-kerning: 0pt">implements StudentDao {<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-font-kerning: 0pt">&nbsp;...........</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-font-kerning: 0pt">}<BR>======The Spring XML Configuration===========<BR>&lt;?xml version="1.0" encoding="UTF-8"?&gt;<BR>&lt;!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"<BR>"<A href="http://www.springframework.org/dtd/spring-beans.dtd">http://www.springframework.org/dtd/spring-beans.dtd</A>"&gt;<BR>&lt;beans&gt;<BR>&nbsp;&lt;bean id="dataSource"<BR>&nbsp;&nbsp;class="org.springframework.jndi.JndiObjectFactoryBean"&gt;<BR>&nbsp;&nbsp;&lt;property name="jndiName"&gt;<BR>&nbsp;&nbsp;&nbsp;&lt;value&gt;java:comp/env/jdbc/trainingDatasource&lt;/value&gt;<BR>&nbsp;&nbsp;&lt;/property&gt;<BR>&nbsp;&lt;/bean&gt;<BR>&nbsp;<BR>&nbsp;&lt;bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean"&gt;<BR>&nbsp;&nbsp;&lt;property name="dataSource"&gt;<BR>&nbsp;&nbsp;&nbsp;&lt;ref bean="dataSource"/&gt;<BR>&nbsp;&nbsp;&lt;/property&gt;<BR>&nbsp;&nbsp;&lt;property name="hibernateProperties"&gt;<BR>&nbsp;&nbsp;&nbsp;&lt;props&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&lt;prop key="hibernate.dialect"&gt;net.sf.hibernate.dialect.MySQLDialect&lt;/prop&gt;<BR>&nbsp;&nbsp;&nbsp;&lt;/props&gt;<BR>&nbsp;&nbsp;&lt;/property&gt;<BR>&nbsp;&nbsp;&lt;property name="mappingResources"&gt;<BR>&nbsp;&nbsp;&nbsp;&lt;list&gt; &lt;!--list of each hbm.xml--&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&lt;value&gt;Student.hbm.xml&lt;/value&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&lt;value&gt;Course.hbm.xml&lt;/value&gt;<BR>&nbsp;&nbsp;&nbsp;&lt;/list&gt;<BR>&nbsp;&nbsp;&lt;/property&gt;<BR>&nbsp;&nbsp;&lt;property name="mappingDirectoryLocations"&gt;<BR>&nbsp;&nbsp;&nbsp;&lt;list&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&lt;!--list the directory of the hbm.xml, including each xml file in the dir--&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&lt;value&gt;classpath:/com/springinaction/training/model&lt;/value&gt;<BR>&nbsp;&nbsp;&nbsp;&lt;/list&gt;<BR>&nbsp;&nbsp;&lt;/property&gt;<BR>&nbsp;&lt;/bean&gt;<BR>&nbsp;<BR>&nbsp;&lt;bean id="hibernateTemplate"<BR>&nbsp;&nbsp;class="org.springframework.orm.hibernate.HibernateTemplate"&gt;<BR>&nbsp;&nbsp;&lt;property name="sessionFactory"&gt;<BR>&nbsp;&nbsp;&nbsp;&lt;ref bean="sessionFactory"/&gt;<BR>&nbsp;&nbsp;&lt;/property&gt;<BR>&nbsp;&lt;/bean&gt;</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-font-kerning: 0pt">&nbsp;&lt;bean id="studentDao" class="com.company.example.dao.hibernateImpl.StudentDaoHibernate"&gt;<BR>&nbsp;&nbsp;&lt;property name="hibernateTemplate"&gt;<BR>&nbsp;&nbsp;&nbsp;&lt;ref bean="hibernateTemplate"/&gt;<BR>&nbsp;&nbsp;&lt;/property&gt;<BR>&nbsp;&lt;/bean&gt;</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-font-kerning: 0pt">&nbsp;&lt;bean id="courseDao" class="com.company.example.dao.hibernateImpl.CourseDaoHibernate"&gt;<BR>&nbsp;&nbsp;&lt;property name="hibernateTemplate"&gt;<BR>&nbsp;&nbsp;&nbsp;&lt;ref bean="hibernateTemplate"/&gt;<BR>&nbsp;&nbsp;&lt;/property&gt;<BR>&nbsp;&lt;/bean&gt;<BR>&lt;/beans&gt;</SPAN></P><img src ="http://www.blogjava.net/jinfeng_wang/aggbug/1654.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/jinfeng_wang/" target="_blank">jinfeng_wang</a> 2005-03-03 16:58 <a href="http://www.blogjava.net/jinfeng_wang/archive/2005/03/03/1654.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Spring JDBC DAO的两个example</title><link>http://www.blogjava.net/jinfeng_wang/archive/2005/03/03/1647.html</link><dc:creator>jinfeng_wang</dc:creator><author>jinfeng_wang</author><pubDate>Thu, 03 Mar 2005 06:40:00 GMT</pubDate><guid>http://www.blogjava.net/jinfeng_wang/archive/2005/03/03/1647.html</guid><wfw:comment>http://www.blogjava.net/jinfeng_wang/comments/1647.html</wfw:comment><comments>http://www.blogjava.net/jinfeng_wang/archive/2005/03/03/1647.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.blogjava.net/jinfeng_wang/comments/commentRss/1647.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/jinfeng_wang/services/trackbacks/1647.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &nbsp;import&nbsp;java.sql.CallableStatement;import&nbsp;java.sql.PreparedStatement;import&nbsp;java.sql.ResultSet;import&nbsp;java.sql.SQLException;import&nbsp;java.sql.Types;import&nbsp;java.uti...&nbsp;&nbsp;<a href='http://www.blogjava.net/jinfeng_wang/archive/2005/03/03/1647.html'>阅读全文</a><img src ="http://www.blogjava.net/jinfeng_wang/aggbug/1647.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/jinfeng_wang/" target="_blank">jinfeng_wang</a> 2005-03-03 14:40 <a href="http://www.blogjava.net/jinfeng_wang/archive/2005/03/03/1647.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Spring DAO的哲学</title><link>http://www.blogjava.net/jinfeng_wang/archive/2005/03/03/1644.html</link><dc:creator>jinfeng_wang</dc:creator><author>jinfeng_wang</author><pubDate>Thu, 03 Mar 2005 05:04:00 GMT</pubDate><guid>http://www.blogjava.net/jinfeng_wang/archive/2005/03/03/1644.html</guid><wfw:comment>http://www.blogjava.net/jinfeng_wang/comments/1644.html</wfw:comment><comments>http://www.blogjava.net/jinfeng_wang/archive/2005/03/03/1644.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.blogjava.net/jinfeng_wang/comments/commentRss/1644.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/jinfeng_wang/services/trackbacks/1644.html</trackback:ping><description><![CDATA[<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt" align=left><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">Spring DAO</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: NewBaskervilleITCbyBT-Roman; mso-hansi-font-family: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">的哲学：</SPAN><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt" align=left><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: NewBaskervilleITCbyBT-Roman; mso-hansi-font-family: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">封装所有的数据库访问实现，包括</SPAN><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">JDBC,JDO,Hibernate</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: NewBaskervilleITCbyBT-Roman; mso-hansi-font-family: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">等。</SPAN><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">Spring</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: NewBaskervilleITCbyBT-Roman; mso-hansi-font-family: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">的异常一般都是</SPAN><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">RuntimeException</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: NewBaskervilleITCbyBT-Roman; mso-hansi-font-family: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">，数据访问的根异常是</SPAN><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">DataAccessException</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: NewBaskervilleITCbyBT-Roman; mso-hansi-font-family: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">，所有的</SPAN><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">Spring</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: NewBaskervilleITCbyBT-Roman; mso-hansi-font-family: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">的数据访问异常都继承</SPAN><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">DataAccessException</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: NewBaskervilleITCbyBT-Roman; mso-hansi-font-family: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">。此外</SPAN><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">DataAccessException</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: NewBaskervilleITCbyBT-Roman; mso-hansi-font-family: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">的</SPAN><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">nestedRuntimeException</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: NewBaskervilleITCbyBT-Roman; mso-hansi-font-family: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">子类中，已经将所有的异常栈都进行了记录。</SPAN><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">Spring</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: NewBaskervilleITCbyBT-Roman; mso-hansi-font-family: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">的</SPAN><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">DAO</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: NewBaskervilleITCbyBT-Roman; mso-hansi-font-family: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">异常对所有底层的</SPAN><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">DAO</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: NewBaskervilleITCbyBT-Roman; mso-hansi-font-family: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">访问实现层的异常进行了统一的封装，并给出了更为有意义的异常。</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Courier; mso-font-kerning: 0pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">CleanupFailureDataAccessException</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: NewBaskervilleITCbyBT-Roman; mso-hansi-font-family: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">：清除失败异常</SPAN><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">DataAccessResourceFailureException</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: NewBaskervilleITCbyBT-Roman; mso-hansi-font-family: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">：资源访问异常</SPAN><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">DataIntegrityViolationException</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: NewBaskervilleITCbyBT-Roman; mso-hansi-font-family: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">：完整性约束异常</SPAN><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">DataRetrievalFailureException</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: NewBaskervilleITCbyBT-Roman; mso-hansi-font-family: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">：数据获取异常</SPAN><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">DeadlockLoserDataAccessException</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: NewBaskervilleITCbyBT-Roman; mso-hansi-font-family: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">：死锁访问异常</SPAN><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">IncorrectUpdateSemanticsDataAccessException</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: NewBaskervilleITCbyBT-Roman; mso-hansi-font-family: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">：更新出错异常</SPAN><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">InvalidDataAccessApiUsageException</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: NewBaskervilleITCbyBT-Roman; mso-hansi-font-family: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">：无效数据访问</SPAN><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">API</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: NewBaskervilleITCbyBT-Roman; mso-hansi-font-family: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">使用异常</SPAN><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">InvalidDataAccessResourceUsageException</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: NewBaskervilleITCbyBT-Roman; mso-hansi-font-family: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">：无效数据访问资源使用异常</SPAN><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">OptimisticLockingFailureException</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: NewBaskervilleITCbyBT-Roman; mso-hansi-font-family: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">：乐观锁失败异常</SPAN><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">TypeMismatchDataAccessException</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: NewBaskervilleITCbyBT-Roman; mso-hansi-font-family: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">：类型匹配失败异常</SPAN><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">UncategorizedDataAccessException</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: NewBaskervilleITCbyBT-Roman; mso-hansi-font-family: NewBaskervilleITCbyBT-Roman; mso-bidi-font-size: 10.5pt">：其他原因异常<BR></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Courier; mso-font-kerning: 0pt"><o:p><BR><BR><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Courier; mso-ansi-language: EN-US; mso-bidi-font-family: 'Times New Roman'; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-fareast-font-family: 宋体">Spring</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-ascii-font-family: Courier; mso-hansi-font-family: Courier; mso-ansi-language: EN-US; mso-bidi-font-family: 'Times New Roman'; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">使用</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Courier; mso-ansi-language: EN-US; mso-bidi-font-family: 'Times New Roman'; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-fareast-font-family: 宋体">Template</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-ascii-font-family: Courier; mso-hansi-font-family: Courier; mso-ansi-language: EN-US; mso-bidi-font-family: 'Times New Roman'; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">和</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Courier; mso-ansi-language: EN-US; mso-bidi-font-family: 'Times New Roman'; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-fareast-font-family: 宋体">Callback</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-ascii-font-family: Courier; mso-hansi-font-family: Courier; mso-ansi-language: EN-US; mso-bidi-font-family: 'Times New Roman'; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">模式完成了对底层实现的统一封装，其中</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Courier; mso-ansi-language: EN-US; mso-bidi-font-family: 'Times New Roman'; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-fareast-font-family: 宋体">Template</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-ascii-font-family: Courier; mso-hansi-font-family: Courier; mso-ansi-language: EN-US; mso-bidi-font-family: 'Times New Roman'; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">负责完成那些通用的功能（处理事务、管理资源、处理异常），</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Courier; mso-ansi-language: EN-US; mso-bidi-font-family: 'Times New Roman'; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-fareast-font-family: 宋体">Callback</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-ascii-font-family: Courier; mso-hansi-font-family: Courier; mso-ansi-language: EN-US; mso-bidi-font-family: 'Times New Roman'; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">则完成变化的那部分内容（创建</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Courier; mso-ansi-language: EN-US; mso-bidi-font-family: 'Times New Roman'; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-fareast-font-family: 宋体">statement</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-ascii-font-family: Courier; mso-hansi-font-family: Courier; mso-ansi-language: EN-US; mso-bidi-font-family: 'Times New Roman'; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">、设定参数</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Courier; mso-ansi-language: EN-US; mso-bidi-font-family: 'Times New Roman'; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-fareast-font-family: 宋体">parameter</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-ascii-font-family: Courier; mso-hansi-font-family: Courier; mso-ansi-language: EN-US; mso-bidi-font-family: 'Times New Roman'; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">、生成数据集</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Courier; mso-ansi-language: EN-US; mso-bidi-font-family: 'Times New Roman'; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-fareast-font-family: 宋体">result</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-ascii-font-family: Courier; mso-hansi-font-family: Courier; mso-ansi-language: EN-US; mso-bidi-font-family: 'Times New Roman'; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">）。参考图</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Courier; mso-ansi-language: EN-US; mso-bidi-font-family: 'Times New Roman'; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-fareast-font-family: 宋体">4.2</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-ascii-font-family: Courier; mso-hansi-font-family: Courier; mso-ansi-language: EN-US; mso-bidi-font-family: 'Times New Roman'; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">、</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Courier; mso-ansi-language: EN-US; mso-bidi-font-family: 'Times New Roman'; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-fareast-font-family: 宋体">4.3</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-ascii-font-family: Courier; mso-hansi-font-family: Courier; mso-ansi-language: EN-US; mso-bidi-font-family: 'Times New Roman'; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">太重要了。</SPAN></o:p></SPAN></P><img src ="http://www.blogjava.net/jinfeng_wang/aggbug/1644.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/jinfeng_wang/" target="_blank">jinfeng_wang</a> 2005-03-03 13:04 <a href="http://www.blogjava.net/jinfeng_wang/archive/2005/03/03/1644.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Spring AOP中的Introduction</title><link>http://www.blogjava.net/jinfeng_wang/archive/2005/03/03/1637.html</link><dc:creator>jinfeng_wang</dc:creator><author>jinfeng_wang</author><pubDate>Thu, 03 Mar 2005 02:49:00 GMT</pubDate><guid>http://www.blogjava.net/jinfeng_wang/archive/2005/03/03/1637.html</guid><wfw:comment>http://www.blogjava.net/jinfeng_wang/comments/1637.html</wfw:comment><comments>http://www.blogjava.net/jinfeng_wang/archive/2005/03/03/1637.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/jinfeng_wang/comments/commentRss/1637.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/jinfeng_wang/services/trackbacks/1637.html</trackback:ping><description><![CDATA[<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt" align=left><SPAN lang=EN-US>Spring AOP</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中的</SPAN><SPAN lang=EN-US>Introduction</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">：</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt" align=left><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">正如前面已经提到的，</SPAN><SPAN lang=EN-US>Introduction</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和前面的四个</SPAN><SPAN lang=EN-US>advice</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">是有很大的区别的，</SPAN><SPAN lang=EN-US>introduction</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">用于给</SPAN><SPAN lang=EN-US>target</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">引入新的接口（例如锁，状态等功能），生成一个</SPAN><SPAN lang=EN-US>mix-in</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的接口。而普通的</SPAN><SPAN lang=EN-US>advice</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">只是在原有接口基础上增加附加内容。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 19pt; TEXT-ALIGN: left; mso-layout-grid-align: none; mso-char-indent-count: 2.0; mso-char-indent-size: 9.5pt" align=left><SPAN style="FONT-SIZE: 9.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: Courier; mso-hansi-font-family: Courier; mso-font-kerning: 0pt">在</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9.5pt; FONT-FAMILY: Courier; mso-font-kerning: 0pt">Spring</SPAN><SPAN style="FONT-SIZE: 9.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: Courier; mso-hansi-font-family: Courier; mso-font-kerning: 0pt">中，完成一个</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9.5pt; FONT-FAMILY: Courier; mso-font-kerning: 0pt">introduction</SPAN><SPAN style="FONT-SIZE: 9.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: Courier; mso-hansi-font-family: Courier; mso-font-kerning: 0pt">需要三个内容：</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9.5pt; FONT-FAMILY: Courier; mso-font-kerning: 0pt">1</SPAN><SPAN style="FONT-SIZE: 9.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: Courier; mso-hansi-font-family: Courier; mso-font-kerning: 0pt">、将要添加的新接口的定义，</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9.5pt; FONT-FAMILY: Courier; mso-font-kerning: 0pt">2</SPAN><SPAN style="FONT-SIZE: 9.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: Courier; mso-hansi-font-family: Courier; mso-font-kerning: 0pt">、该新接口的实现，在实现的</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9.5pt; FONT-FAMILY: Courier; mso-font-kerning: 0pt">class</SPAN><SPAN style="FONT-SIZE: 9.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: Courier; mso-hansi-font-family: Courier; mso-font-kerning: 0pt">中，必须实现</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9.5pt; FONT-FAMILY: Courier; mso-font-kerning: 0pt">Spring</SPAN><SPAN style="FONT-SIZE: 9.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: Courier; mso-hansi-font-family: Courier; mso-font-kerning: 0pt">的</SPAN><TT><SPAN lang=EN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN">IntroductionInterceptor</SPAN></TT><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: NewBaskervilleITCbyBT-Roman; mso-hansi-font-family: NewBaskervilleITCbyBT-Roman; mso-font-kerning: 0pt; mso-bidi-font-size: 10.5pt">接口（</SPAN><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-font-kerning: 0pt; mso-bidi-font-size: 10.5pt">Spring in action</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: NewBaskervilleITCbyBT-Roman; mso-hansi-font-family: NewBaskervilleITCbyBT-Roman; mso-font-kerning: 0pt; mso-bidi-font-size: 10.5pt">原文有误），</SPAN><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-font-kerning: 0pt; mso-bidi-font-size: 10.5pt">3</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: NewBaskervilleITCbyBT-Roman; mso-hansi-font-family: NewBaskervilleITCbyBT-Roman; mso-font-kerning: 0pt; mso-bidi-font-size: 10.5pt">、</SPAN><TT><SPAN lang=EN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-ansi-language: EN">IntroductionAdvisor</SPAN></TT><TT><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 黑体; mso-ascii-font-family: 'Courier New'; mso-ansi-language: EN">接口的实现</SPAN></TT><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: NewBaskervilleITCbyBT-Roman; mso-hansi-font-family: NewBaskervilleITCbyBT-Roman; mso-font-kerning: 0pt; mso-bidi-font-size: 10.5pt">。</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Courier; mso-font-kerning: 0pt"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt" align=left><SPAN lang=EN-US>public interface IntroductionInterceptor extends MethodInterceptor {</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>boolean implementsInterface(Class intf); </SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 31.5pt; TEXT-ALIGN: left; mso-layout-grid-align: none; mso-char-indent-count: 3.0; mso-char-indent-size: 10.5pt" align=left><SPAN lang=EN-US>java.lang.Object invoke(MethodInvocation invocation) //</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">此方法来源于</SPAN><SPAN lang=EN-US>MethodInterceptor</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt" align=left><SPAN lang=EN-US>}</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt" align=left><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">其中</SPAN><SPAN lang=EN-US>implementsInterface</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">方法返回一个</SPAN><SPAN lang=EN-US>boolean</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">值，此方法用于判断该</SPAN><SPAN lang=EN-US>introduction</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">实现是否实现了某个接口――</SPAN><SPAN lang=EN-US>intf</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">参数。所有对</SPAN><SPAN lang=EN-US>intf</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口的调用都会转发给</SPAN><SPAN lang=EN-US>invoke</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">方法，由</SPAN><SPAN lang=EN-US>invoke</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">方法完成相应的任务。下面给出例子（给某个类添加是否</SPAN><SPAN lang=EN-US>auditable</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">功能）：</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-font-kerning: 0pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; </SPAN>public interface Auditable {//1</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、</SPAN><SPAN lang=EN-US>auditable</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口的定义</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>void setLastModifiedDate(Date date);</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>Date getLastModifiedDate();</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>}</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>public class AuditableMixin</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>implements <SPAN style="COLOR: red">IntroductionInterceptor</SPAN>, <SPAN style="COLOR: red">Auditable</SPAN> {//2</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、</SPAN><SPAN lang=EN-US>auditable</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口的实现，同时要实现</SPAN><SPAN lang=EN-US>IntroductionInterceptor</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="COLOR: red">public boolean implementsInterface(Class intf) {<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 63pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="COLOR: red">return intf.isAssignableFrom(Auditable.class);<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>// AuditableMixin</SPAN><SPAN style="COLOR: red; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">实现了</SPAN><SPAN lang=EN-US style="COLOR: red">Auditable</SPAN><SPAN style="COLOR: red; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">类的功能</SPAN><SPAN lang=EN-US style="COLOR: red"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="COLOR: red">}<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="COLOR: red">public Object invoke(MethodInvocation m) throws Throwable {<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 63pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="COLOR: red">if (implementsInterface(m.getMethod().getDeclaringClass())) {<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 63pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="COLOR: red">//</SPAN><SPAN style="COLOR: red; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对</SPAN><SPAN lang=EN-US style="COLOR: red">invoke</SPAN><SPAN style="COLOR: red; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的参数</SPAN><SPAN lang=EN-US style="COLOR: red">m</SPAN><SPAN style="COLOR: red; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">进行判断，当前的调用是否在</SPAN><SPAN lang=EN-US style="COLOR: red">implementsInterface</SPAN><SPAN style="COLOR: red; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">范围内，即，当前的调用是否是</SPAN><SPAN lang=EN-US style="COLOR: red">auditable</SPAN><SPAN style="COLOR: red; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口中的方法？</SPAN><SPAN lang=EN-US style="COLOR: red"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 84pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="COLOR: red">return m.getMethod().invoke(this, m.getArguments());<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 84pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="COLOR: red">//</SPAN><SPAN style="COLOR: red; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">这里的</SPAN><SPAN lang=EN-US style="COLOR: red">this</SPAN><SPAN style="COLOR: red; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">就是自己，调用引入的方法（属于</SPAN><SPAN lang=EN-US style="COLOR: red">auditable</SPAN><SPAN style="COLOR: red; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口的方法），这样也就给</SPAN><SPAN lang=EN-US style="COLOR: red">target</SPAN><SPAN style="COLOR: red; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">添加了新的</SPAN><SPAN lang=EN-US style="COLOR: red">auditable</SPAN><SPAN style="COLOR: red; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口。</SPAN><SPAN lang=EN-US style="COLOR: red"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 63pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="COLOR: red">} else {<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 84pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="COLOR: red">return m.proceed();//</SPAN><SPAN style="COLOR: red; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">其他方法的调用。</SPAN><SPAN lang=EN-US style="COLOR: red"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 63pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="COLOR: red">}<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="COLOR: red">}<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>private Date lastModifiedDate; //</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">实现</SPAN><SPAN lang=EN-US>auditable</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>public Date getLastModifiedDate() {</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 63pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>return lastModifiedDate;</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>}</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>public void setLastModifiedDate(Date lastModifiedDate) {</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 63pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>this.lastModifiedDate = lastModifiedDate;</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 63pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>}</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>}</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Courier; mso-font-kerning: 0pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt" align=left><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在</SPAN><SPAN lang=EN-US>Spring</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中，除了上面直接实现</SPAN><SPAN lang=EN-US>IntroductionInterceptor</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口之外，还可以通过继承</SPAN><SPAN lang=EN-US>DelegatingIntroductionInterceptor</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">类实现。其中</SPAN><SPAN lang=EN-US>DelegatingIntroductionInterceptor</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">给出了</SPAN><SPAN lang=EN-US>IntroductionInterceptor</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口中的两个方法（</SPAN><SPAN lang=EN-US>implementsInterface</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，</SPAN><SPAN lang=EN-US>invoke</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）的默认实现，你仅需要实现</SPAN><SPAN lang=EN-US>auditable</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口即可。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt" align=left><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">通过跟踪</SPAN><SPAN lang=EN-US>Spring</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">源代码可以发现：</SPAN><SPAN lang=EN-US>DelegatingIntroductionInterceptor</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</SPAN><SPAN lang=EN-US>implementsInterface </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">（在</SPAN><SPAN lang=EN-US>IntroductionInfoSupport</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">类中）和</SPAN><SPAN lang=EN-US>invoke</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">方法与上面的代码的形式基本一致。下面是利用</SPAN><SPAN lang=EN-US>DelegatingIntroductionInterceptor</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">写出的</SPAN><SPAN lang=EN-US>AuditableMixin</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">：</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 42pt; TEXT-ALIGN: left; mso-layout-grid-align: none; mso-char-indent-count: 4.0; mso-char-indent-size: 10.5pt" align=left><SPAN lang=EN-US>public class AuditableMixin</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>extends <SPAN style="COLOR: red">DelegatingIntroductionInterceptor</SPAN> implements Auditable {</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 63pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>private Date lastModifiedDate;</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>public Date getLastModifiedDate() {</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 63pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>return lastModifiedDate;</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>}</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>public void setLastModifiedDate(Date lastModifiedDate) {</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 63pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>this.lastModifiedDate = lastModifiedDate;</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>}<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 8pt; FONT-FAMILY: Courier; mso-font-kerning: 0pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>}</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Courier; mso-font-kerning: 0pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt" align=left><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">注意到一点：上面的两个</SPAN><SPAN lang=EN-US>AuditableMixin</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的实现都仅仅是给</SPAN><SPAN lang=EN-US>Target</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">添加行为，但是未曾改变</SPAN><SPAN lang=EN-US>Target</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的原有行为（因为在</SPAN><SPAN lang=EN-US>invoke</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">方法的实现中，还是会转发给</SPAN><SPAN lang=EN-US>Target</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）。如果需要改变</SPAN><SPAN lang=EN-US>Target</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的行为<SPAN style="COLOR: red">（例如给</SPAN></SPAN><SPAN lang=EN-US style="COLOR: red">Target</SPAN><SPAN style="COLOR: red; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">增加</SPAN><SPAN lang=EN-US style="COLOR: red">lock</SPAN><SPAN style="COLOR: red; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口，一旦处于</SPAN><SPAN lang=EN-US style="COLOR: red">locked</SPAN><SPAN style="COLOR: red; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">状态，那么再调用</SPAN><SPAN lang=EN-US style="COLOR: red">Target</SPAN><SPAN style="COLOR: red; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的方法就会出现异常）</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，这就需要自己写代码修改</SPAN><SPAN lang=EN-US>invoke</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">方法。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>public class ImmutableMixin</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>extends DelegatingIntroductionInterceptor implements Immutable {</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>private boolean immutable;</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>public void setImmutable(boolean immutable) {</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 63pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>this.immutable = immutable;</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>}</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="COLOR: red">public Object invoke(MethodInvocation mi) throws Throwable {<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 63pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="COLOR: red">String name = mi.getMethod().getName();<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 63pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="COLOR: red">if (immutable &amp;&amp; name.indexOf("set") == 0) { //这里一旦已经是immutable了，那么就不可以调用setXXX方法了，这也就改变了Target的行为，而不是前面的仅增加接口。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 84pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="COLOR: red">throw new IllegalModificationException();<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 63pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="COLOR: red">}<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 63pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="COLOR: red">return super.invoke(mi);<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="COLOR: red">}</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>}</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Courier; mso-font-kerning: 0pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt" align=left><SPAN lang=EN-US>&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US>Spring</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中的</SPAN><SPAN lang=EN-US>Introduction</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">需要有自己的</SPAN><SPAN lang=EN-US>advisor:</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9.5pt; FONT-FAMILY: Courier; mso-font-kerning: 0pt"> IntroductionAdvisor</SPAN><SPAN lang=EN-US style="FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-font-kerning: 0pt; mso-bidi-font-size: 10.5pt"><o:p></o:p></SPAN></P><SPAN style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: NewBaskervilleITCbyBT-Roman; mso-hansi-font-family: NewBaskervilleITCbyBT-Roman; mso-ansi-language: EN-US; mso-bidi-font-family: 'Times New Roman'; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">剩下的也就是和前面一样的</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: NewBaskervilleITCbyBT-Roman; mso-ansi-language: EN-US; mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><FONT face="宋体, MS Song">xml</FONT></SPAN><SPAN style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: NewBaskervilleITCbyBT-Roman; mso-hansi-font-family: NewBaskervilleITCbyBT-Roman; mso-ansi-language: EN-US; mso-bidi-font-family: 'Times New Roman'; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">文件的编写了。<BR><BR><BR>Spring中使用Introduction需要注意的问题：<BR>&nbsp;&nbsp;&nbsp; 由于Spring使用的是动态AOP,并没有象AspectJ使用静态的代码预编译的方式生成AOP代码，因此只有你从Spring的BeanFactory中得到的Introduction Bean才会已经被introducted，而直接在代码中new出来的target对象则不具有Intorduction功能。 你可以使用一个Factory，封装对Introduction的创建。</SPAN><img src ="http://www.blogjava.net/jinfeng_wang/aggbug/1637.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/jinfeng_wang/" target="_blank">jinfeng_wang</a> 2005-03-03 10:49 <a href="http://www.blogjava.net/jinfeng_wang/archive/2005/03/03/1637.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Spring AOP中的pointcut</title><link>http://www.blogjava.net/jinfeng_wang/archive/2005/03/02/1615.html</link><dc:creator>jinfeng_wang</dc:creator><author>jinfeng_wang</author><pubDate>Wed, 02 Mar 2005 09:33:00 GMT</pubDate><guid>http://www.blogjava.net/jinfeng_wang/archive/2005/03/02/1615.html</guid><wfw:comment>http://www.blogjava.net/jinfeng_wang/comments/1615.html</wfw:comment><comments>http://www.blogjava.net/jinfeng_wang/archive/2005/03/02/1615.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/jinfeng_wang/comments/commentRss/1615.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/jinfeng_wang/services/trackbacks/1615.html</trackback:ping><description><![CDATA[<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none"><SPAN lang=EN-US>Spring AOP</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中的</SPAN><SPAN lang=EN-US>pointcut</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">：</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-layout-grid-align: none; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><SPAN lang=EN-US>PointCuts</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">用于定义所需要“拦截”的</SPAN><SPAN lang=EN-US>class</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">及其</SPAN><SPAN lang=EN-US>method</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。分为静态、动态两种</SPAN><SPAN lang=EN-US>pointcut</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。其中静态</SPAN><SPAN lang=EN-US>pointcuts</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">仅和</SPAN><SPAN lang=EN-US>class name, method name</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">相关，可以在配置文件中通过正则表达式进行部署，因此它们都可以在运行前进行确认。而动态</SPAN><SPAN lang=EN-US>pointcuts</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">则需要考虑到方法的参数，在运行时动态的确认</SPAN><SPAN lang=EN-US>pointcuts</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。一般来说，都是根据</SPAN><SPAN lang=EN-US>method</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</SPAN><SPAN lang=EN-US>class</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的名字来进行。其涉及到的接口如下定义：</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-pagination: widow-orphan" align=left><SPAN lang=EN-US>public interface Pointcut {</SPAN><SPAN lang=EN-US style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>ClassFilter getClassFilter();</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>MethodMatcher getMethodMatcher();</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt"><SPAN lang=EN-US>}</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt"><SPAN lang=EN-US>public interface ClassFilter {</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>boolean matches(Class clazz);</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt"><SPAN lang=EN-US>}</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt"><SPAN lang=EN-US>public interface MethodMatcher {</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>boolean matches(Method m, Class targetClass);</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>boolean isRuntime();</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>boolean matches(Method m, Class targetClass, Object[] args);</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt"><SPAN lang=EN-US>}</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt" align=left><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">两种静态</SPAN><SPAN lang=EN-US>pointcut</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的实现：</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt" align=left><SPAN lang=EN-US><FONT color=#008000>NameMatchMethodPointcut</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">：只能对方法名进行判别。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt" align=left><SPAN lang=EN-US><FONT color=#008000>RegexpMethodPointcut</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">：可以对类名、方法名使用正则表达式判别。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: FranklinGothicITCbyBT-DemiItal; mso-font-kerning: 0pt">&lt;beans&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: FranklinGothicITCbyBT-DemiItal; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;bean id="maidServiceTarget"<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: FranklinGothicITCbyBT-DemiItal; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>class="com.springinaction.chapter03.cleaning.MaidService"/&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: FranklinGothicITCbyBT-DemiItal; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: FranklinGothicITCbyBT-DemiItal; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;bean id="queryInterceptor" class="com.springinaction.chapter03.cleaning.QueryInterceptor"/&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: FranklinGothicITCbyBT-DemiItal; mso-font-kerning: 0pt">&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: FranklinGothicITCbyBT-DemiItal; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;bean id="queryPointcutAdvisor"<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: FranklinGothicITCbyBT-DemiItal; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>class="org.springframework.aop.support.RegExpPointcutAdvisor"&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: FranklinGothicITCbyBT-DemiItal; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;property name="pattern"&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: FranklinGothicITCbyBT-DemiItal; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;value&gt;.*get.+By.+&lt;/value&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: FranklinGothicITCbyBT-DemiItal; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;/property&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: FranklinGothicITCbyBT-DemiItal; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;property name="advice"&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: FranklinGothicITCbyBT-DemiItal; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;ref bean="queryInterceptor"/&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: FranklinGothicITCbyBT-DemiItal; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;/property&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: FranklinGothicITCbyBT-DemiItal; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;/bean&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: FranklinGothicITCbyBT-DemiItal; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: FranklinGothicITCbyBT-DemiItal; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;bean id="maidService"<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: FranklinGothicITCbyBT-DemiItal; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>class="org.springframework.aop.framework.ProxyFactoryBean"&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: FranklinGothicITCbyBT-DemiItal; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;property name="proxyInterfaces"&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: FranklinGothicITCbyBT-DemiItal; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;value&gt;com.springinaction.chapter03.cleaning.MaidService&lt;/value&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: FranklinGothicITCbyBT-DemiItal; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;/property&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: FranklinGothicITCbyBT-DemiItal; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;property name="interceptorNames"&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: FranklinGothicITCbyBT-DemiItal; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;list&gt;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: FranklinGothicITCbyBT-DemiItal; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;value&gt;queryPointcutAdvisor&lt;/value&gt;<o:p><