<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>拈花微笑 &#187; spring</title>
	<atom:link href="http://www.jayxu.com/tags/spring/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jayxu.com</link>
	<description>晶 · 彦</description>
	<lastBuildDate>Thu, 02 Feb 2012 09:24:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<image>
<link>http://www.jayxu.com</link>
<url>http://www.jayxu.com/wp-content/cbnet-favicon/1289928181_Black_Cat.png</url>
<title>拈花微笑</title>
</image>
		<item>
		<title>解决Velocity＋Spring的中文乱码问题</title>
		<link>http://www.jayxu.com/2012/01/12/13221/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e8%25a7%25a3%25e5%2586%25b3velocity%25ef%25bc%258bspring%25e7%259a%2584%25e4%25b8%25ad%25e6%2596%2587%25e4%25b9%25b1%25e7%25a0%2581%25e9%2597%25ae%25e9%25a2%2598</link>
		<comments>http://www.jayxu.com/2012/01/12/13221/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 06:33:50 +0000</pubDate>
		<dc:creator>Jay</dc:creator>
				<category><![CDATA[技术生活]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[velocity]]></category>

		<guid isPermaLink="false">http://www.jayxu.com/?p=13221</guid>
		<description><![CDATA[将spring配置中的velocity view改为： &#60;bean id=&#34;velocityConfig&#34; class=&#34;org.springframework.web.servlet.view.velocity.VelocityConfigurer&#34;&#62; &#60;property name=&#34;resourceLoaderPath&#34; value=&#34;/WEB-INF/vm/&#34; /&#62; &#60;property name=&#34;velocityProperties&#34;&#62; &#60;props&#62; &#60;prop key=&#34;input.encoding&#34;&#62;utf-8&#60;/prop&#62; &#60;prop key=&#34;output.encoding&#34;&#62;utf-8&#60;/prop&#62; &#160; &#160; &#60;/props&#62; &#160; &#60;/property&#62; &#60;/bean&#62; &#60;bean id=&#34;velocityViewResolver&#34; class=&#34;org.springframework.web.servlet.view.velocity.VelocityViewResolver&#34;&#62; &#60;property name=&#34;cache&#34; value=&#34;true&#34; /&#62; &#60;property name=&#34;suffix&#34; value=&#34;.html&#34; /&#62; &#60;property name=&#34;contentType&#34; value=&#34;text/html;charset=UTF-8&#34; /&#62; &#60;/bean&#62; &#60;bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"&#62; &#60;property name="resourceLoaderPath" value="/WEB-INF/vm/" /&#62; &#60;property name="velocityProperties"&#62; &#60;props&#62; &#60;prop key="input.encoding"&#62;utf-8&#60;/prop&#62; &#60;prop key="output.encoding"&#62;utf-8&#60;/prop&#62; &#60;/props&#62; &#60;/property&#62; &#60;/bean&#62; <a href="http://www.jayxu.com/2012/01/12/13221/"> read more <span class="meta-nav">&#187;</span></a><table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2010%2F06%2F09%2F2342%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2012%2F01%2F12%2F13221%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Spring之Hibernate+JBoss Treecache实现Hibernate集群</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F14%2F13131%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2012%2F01%2F12%2F13221%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">使用Spring LDAP ODM操作LDAP</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2012%2F02%2F02%2F13237%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2012%2F01%2F12%2F13221%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">有关Java泛型的类型擦除（type erasing）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2010%2F07%2F18%2F2373%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2012%2F01%2F12%2F13221%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Spring之经验教训（一）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2009%2F12%2F02%2F1899%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2012%2F01%2F12%2F13221%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Apache给EJB 3.1（JSR #318）投了否决票</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>将spring配置中的velocity view改为：</p>

<div class="bwp-syntax-block clearfix">
<div class="bwp-syntax-toolbar"><div class="bwp-syntax-control"><a href="javascript:;" class="bwp-syntax-source-switch" title="View Source Code"></a></div></div>
<div class="bwp-syntax-wrapper clearfix bwp-syntax-advanced"><div class="xml"><ol><li class="li1"><div class="de1"><span class="sc3"><span class="re1">&lt;bean</span> <span class="re0">id</span>=<span class="st0">&quot;velocityConfig&quot;</span> <span class="re0">class</span>=<span class="st0">&quot;org.springframework.web.servlet.view.velocity.VelocityConfigurer&quot;</span><span class="re2">&gt;</span></span></div></li>
<li class="li2"><div class="de2"><span class="sc3"><span class="re1">&lt;property</span> <span class="re0">name</span>=<span class="st0">&quot;resourceLoaderPath&quot;</span> <span class="re0">value</span>=<span class="st0">&quot;/WEB-INF/vm/&quot;</span> <span class="re2">/&gt;</span></span></div></li>
<li class="li1"><div class="de1"><span class="sc3"><span class="re1">&lt;property</span> <span class="re0">name</span>=<span class="st0">&quot;velocityProperties&quot;</span><span class="re2">&gt;</span></span></div></li>
<li class="li2"><div class="de2"><span class="sc3"><span class="re1">&lt;props<span class="re2">&gt;</span></span></span></div></li>
<li class="li1"><div class="de1"><span class="sc3"><span class="re1">&lt;prop</span> <span class="re0">key</span>=<span class="st0">&quot;input.encoding&quot;</span><span class="re2">&gt;</span></span>utf-8<span class="sc3"><span class="re1">&lt;/prop<span class="re2">&gt;</span></span></span></div></li>
<li class="li2"><div class="de2"><span class="sc3"><span class="re1">&lt;prop</span> <span class="re0">key</span>=<span class="st0">&quot;output.encoding&quot;</span><span class="re2">&gt;</span></span>utf-8<span class="sc3"><span class="re1">&lt;/prop<span class="re2">&gt;</span></span></span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/props<span class="re2">&gt;</span></span></span></div></li>
<li class="li2"><div class="de2">&nbsp; <span class="sc3"><span class="re1">&lt;/property<span class="re2">&gt;</span></span></span></div></li>
<li class="li1"><div class="de1"><span class="sc3"><span class="re1">&lt;/bean<span class="re2">&gt;</span></span></span></div></li>
<li class="li2"><div class="de2"><span class="sc3"><span class="re1">&lt;bean</span> <span class="re0">id</span>=<span class="st0">&quot;velocityViewResolver&quot;</span> <span class="re0">class</span>=<span class="st0">&quot;org.springframework.web.servlet.view.velocity.VelocityViewResolver&quot;</span><span class="re2">&gt;</span></span></div></li>
<li class="li1"><div class="de1"><span class="sc3"><span class="re1">&lt;property</span> <span class="re0">name</span>=<span class="st0">&quot;cache&quot;</span> <span class="re0">value</span>=<span class="st0">&quot;true&quot;</span> <span class="re2">/&gt;</span></span></div></li>
<li class="li2"><div class="de2"><span class="sc3"><span class="re1">&lt;property</span> <span class="re0">name</span>=<span class="st0">&quot;suffix&quot;</span> <span class="re0">value</span>=<span class="st0">&quot;.html&quot;</span> <span class="re2">/&gt;</span></span></div></li>
<li class="li1"><div class="de1"><span class="sc3"><span class="re1">&lt;property</span> <span class="re0">name</span>=<span class="st0">&quot;contentType&quot;</span> <span class="re0">value</span>=<span class="st0">&quot;text/html;charset=UTF-8&quot;</span> <span class="re2">/&gt;</span></span></div></li>
<li class="li2"><div class="de2"><span class="sc3"><span class="re1">&lt;/bean<span class="re2">&gt;</span></span></span></div></li>
</ol></div></div>
<div class="bwp-syntax-source"><pre class="no-parse">&lt;bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"&gt;
&lt;property name="resourceLoaderPath" value="/WEB-INF/vm/" /&gt;
&lt;property name="velocityProperties"&gt;
&lt;props&gt;
&lt;prop key="input.encoding"&gt;utf-8&lt;/prop&gt;
&lt;prop key="output.encoding"&gt;utf-8&lt;/prop&gt;
    &lt;/props&gt;
  &lt;/property&gt;
&lt;/bean&gt;
&lt;bean id="velocityViewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver"&gt;
&lt;property name="cache" value="true" /&gt;
&lt;property name="suffix" value=".html" /&gt;
&lt;property name="contentType" value="text/html;charset=UTF-8" /&gt;
&lt;/bean&gt;</pre></div></div>

<div style="margin-top: 15px; font-style: italic">
<p><strong>原创内容，转载请注明：</strong> 转载自<a href="http://www.jayxu.com/">拈花微笑</a></p>
<p><strong>本文链接地址:</strong> <a href="http://www.jayxu.com/2012/01/12/13221/">解决Velocity＋Spring的中文乱码问题</a></p>
</div>
<p><a href="http://www.bshare.cn/share?url=http%3A%2F%2Fwww.jayxu.com%2F2012%2F01%2F12%2F13221%2F&title=%E8%A7%A3%E5%86%B3Velocity%EF%BC%8BSpring%E7%9A%84%E4%B8%AD%E6%96%87%E4%B9%B1%E7%A0%81%E9%97%AE%E9%A2%98" title="用bShare分享或收藏本文"><img src="http://static.bshare.cn/frame/images/button_custom1-zh.gif" alt="用bShare分享或收藏本文" /></a></p><table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2010%2F06%2F09%2F2342%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2012%2F01%2F12%2F13221%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Spring之Hibernate+JBoss Treecache实现Hibernate集群</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F14%2F13131%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2012%2F01%2F12%2F13221%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">使用Spring LDAP ODM操作LDAP</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2012%2F02%2F02%2F13237%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2012%2F01%2F12%2F13221%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">有关Java泛型的类型擦除（type erasing）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2010%2F07%2F18%2F2373%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2012%2F01%2F12%2F13221%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Spring之经验教训（一）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2009%2F12%2F02%2F1899%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2012%2F01%2F12%2F13221%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Apache给EJB 3.1（JSR #318）投了否决票</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.jayxu.com/2012/01/12/13221/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>使用Spring LDAP ODM操作LDAP</title>
		<link>http://www.jayxu.com/2011/12/14/13131/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e4%25bd%25bf%25e7%2594%25a8spring-ldap-odm%25e6%2593%258d%25e4%25bd%259cldap</link>
		<comments>http://www.jayxu.com/2011/12/14/13131/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 15:10:16 +0000</pubDate>
		<dc:creator>Jay</dc:creator>
				<category><![CDATA[技术生活]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jpa]]></category>
		<category><![CDATA[ldap]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[spring context]]></category>
		<category><![CDATA[spring ldap]]></category>
		<category><![CDATA[spring ldap odm]]></category>
		<category><![CDATA[spring mvc]]></category>
		<category><![CDATA[spring orm]]></category>
		<category><![CDATA[spring tx]]></category>
		<category><![CDATA[struts]]></category>
		<category><![CDATA[牢骚]]></category>

		<guid isPermaLink="false">http://www.jayxu.com/?p=13131</guid>
		<description><![CDATA[Spring Source真的是个很神奇的开源社区，从《J2EE without EJB》开始为大家所知晓，到把IoC、AOP大范围地带到大家的开发模型中，再到和Hibernate、Struts组成每个Java函授学校必教的“SSH”组合，从此绿遍大江南北…… 在国内，大马路上随便抓一个Java程序员，10个里有9个半知道Spring；有9个知道怎么把SSH“组装”到一起（是的，“组装”，和流水线上的蓝领熟练工没有本质区别）；有9个半知道IoC、AOP；有2个知道IoC和AOP的本质；有3个知道Spring其实分为core、context、orm、tx等不同子框架；有1个知道Spring 3之后可以用annotation取代之前版本大部分的xml配置；有2个知道Spring mvc和security；有半个知道其实Spring的子框架远不止这些……这就是我们当前Java码农们的实际情况。而造成这一局面的，我谓之三害——高校计算机系功利的培养模式、以北大青鸟为首的各种速成班的祸害和程序员们自己懒惰、人云亦云、拒绝思考的慢性自杀 牢骚发完，本文将通过介绍Spring的两个子框架：Spring LDAP和Spring LDAP ODM，来实现对LDAP的操作 项目主页：http://www.springsource.org/ldap，该框架通过提供和ORM中相似的机制对LDAP相关操作进行封装，主要包括： 类比SessionFactory的LdapContextSource 类比HibernateTemplate等的LdapTemplate 伪事务支持，能否与tx框架的TransactionManager混用未知 类比JPA的使用@Entry、@Attribute、@Id标注的ODM——Object Directory Mapping 本文（原先）目标：使用ODM将User类与LDAP中的实体进行映射，LDAP中的实体的objectClass包括inetOrgPerson，organizationalPerson，person，shadowAccount和top 相关配置文件、代码在http://static.springsource.org/spring-ldap/docs/1.3.x/reference/html/上已经很详细了，这里只是做一点旁注，全部来自于这几天和Spring LDAP的斗智斗勇 对于shadowAccount的shadowLastChange域，值是一个整形，至于具体含义网上没有找到解释，试了几次之后发现是从1970-1-1 00:00:00至今的天数，如果model里定义的是Date类型的话，需要自行实现org.springframework.ldap.odm.typeconversion.impl.Converter接口进行转换 对于@Entry标记，其中的objectClasses定义必须与objectClass完全一致。在新建和查询object时，ODM会根据此标记进行匹配，无需再指定objectClass 每个entry必须指定@Id字段，类型为javax.naming.Name，其实就是DN。但是若在LdapContextSource中指定了base，则DN将会按照base截取相对路径。比如，DN为cn=user,ou=users,dc=jayxu,dc=com，base为dc=jayxu,dc=com，则取出的user对象DN为cn=user,ou=users 如果使用Spring MVC对LDAP对象进行JSON序列化，必须注意javax.naming.Name中的某些字段无法被序列化，所以在转换成JSON之前需要将DN置null。一种方法是使用@JsonIgnoreProperties标记model类，比如：@JsonIgnoreProperties(“dn”) 对于不需要与LDAP进行映射的字段使用@Transient进行标记 考虑使用org.springframework.ldap.pool.factory.PoolingContextSource引入连接池 如果事务中需要与JDBC进行互操作，需要使用org.springframework.ldap.transaction.compensating.manager.ContextSourceAndDataSourceTransactionManager作为tx manager 原创内容，转载请注明： 转载自拈花微笑 本文链接地址: 使用Spring LDAP ODM操作LDAP<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2010%2F06%2F09%2F2342%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F14%2F13131%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Spring之Hibernate+JBoss Treecache实现Hibernate集群</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2010%2F07%2F18%2F2373%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F14%2F13131%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Spring之经验教训（一）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2012%2F01%2F12%2F13221%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F14%2F13131%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">解决Velocity＋Spring的中文乱码问题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2012%2F02%2F02%2F13237%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F14%2F13131%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">有关Java泛型的类型擦除（type erasing）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2009%2F12%2F02%2F1899%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F14%2F13131%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Apache给EJB 3.1（JSR #318）投了否决票</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>Spring Source真的是个很神奇的开源社区，从《J2EE without EJB》开始为大家所知晓，到把IoC、AOP大范围地带到大家的开发模型中，再到和Hibernate、Struts组成每个Java函授学校必教的“SSH”组合，从此绿遍大江南北……</p>
<p>在国内，大马路上随便抓一个Java程序员，10个里有9个半知道Spring；有9个知道怎么把SSH“组装”到一起（是的，“组装”，和流水线上的蓝领熟练工没有本质区别）；有9个半知道IoC、AOP；有2个知道IoC和AOP的本质；有3个知道Spring其实分为core、context、orm、tx等不同子框架；有1个知道Spring 3之后可以用annotation取代之前版本大部分的xml配置；有2个知道Spring mvc和security；有半个知道其实Spring的子框架远不止这些……这就是我们当前Java码农们的实际情况。而造成这一局面的，我谓之三害——高校计算机系功利的培养模式、以北大青鸟为首的各种速成班的祸害和程序员们自己懒惰、人云亦云、拒绝思考的慢性自杀</p>
<p>牢骚发完，本文将通过介绍Spring的两个子框架：Spring LDAP和Spring LDAP ODM，来实现对LDAP的操作</p>
<p>项目主页：<a href="http://www.springsource.org/ldap" target="_blank">http://www.springsource.org/ldap</a>，该框架通过提供和ORM中相似的机制对LDAP相关操作进行封装，主要包括：</p>
<ul>
<li>类比SessionFactory的LdapContextSource</li>
<li>类比HibernateTemplate等的LdapTemplate</li>
<li>伪事务支持，能否与tx框架的TransactionManager混用未知</li>
<li>类比JPA的使用@Entry、@Attribute、@Id标注的ODM——Object Directory Mapping</li>
</ul>
<p>本文（原先）目标：使用ODM将User类与LDAP中的实体进行映射，LDAP中的实体的objectClass包括inetOrgPerson，organizationalPerson，person，shadowAccount和top</p>
<p>相关配置文件、代码在<a href="http://static.springsource.org/spring-ldap/docs/1.3.x/reference/html/" target="_blank">http://static.springsource.org/spring-ldap/docs/1.3.x/reference/html/</a>上已经很详细了，这里只是做一点旁注，全部来自于这几天和Spring LDAP的斗智斗勇</p>
<ul>
<li>对于shadowAccount的shadowLastChange域，值是一个整形，至于具体含义网上没有找到解释，试了几次之后发现是从1970-1-1 00:00:00至今的天数，如果model里定义的是Date类型的话，需要自行实现org.springframework.ldap.odm.typeconversion.impl.Converter接口进行转换</li>
<li>对于@Entry标记，其中的objectClasses定义必须与objectClass完全一致。在新建和查询object时，ODM会根据此标记进行匹配，无需再指定objectClass</li>
<li>每个entry必须指定@Id字段，类型为javax.naming.Name，其实就是DN。但是若在LdapContextSource中指定了base，则DN将会按照base截取相对路径。比如，DN为cn=user,ou=users,dc=jayxu,dc=com，base为dc=jayxu,dc=com，则取出的user对象DN为cn=user,ou=users</li>
<li>如果使用Spring MVC对LDAP对象进行JSON序列化，必须注意javax.naming.Name中的某些字段无法被序列化，所以在转换成JSON之前需要将DN置null。一种方法是使用@JsonIgnoreProperties标记model类，比如：@JsonIgnoreProperties(“dn”)</li>
<li>对于不需要与LDAP进行映射的字段使用@Transient进行标记</li>
<li>考虑使用org.springframework.ldap.pool.factory.PoolingContextSource引入连接池</li>
<li>如果事务中需要与JDBC进行互操作，需要使用org.springframework.ldap.transaction.compensating.manager.ContextSourceAndDataSourceTransactionManager作为tx manager</li>
</ul>
<div style="margin-top: 15px; font-style: italic">
<p><strong>原创内容，转载请注明：</strong> 转载自<a href="http://www.jayxu.com/">拈花微笑</a></p>
<p><strong>本文链接地址:</strong> <a href="http://www.jayxu.com/2011/12/14/13131/">使用Spring LDAP ODM操作LDAP</a></p>
</div>
<p><a href="http://www.bshare.cn/share?url=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F14%2F13131%2F&title=%E4%BD%BF%E7%94%A8Spring+LDAP+ODM%E6%93%8D%E4%BD%9CLDAP" title="用bShare分享或收藏本文"><img src="http://static.bshare.cn/frame/images/button_custom1-zh.gif" alt="用bShare分享或收藏本文" /></a></p><table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2010%2F06%2F09%2F2342%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F14%2F13131%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Spring之Hibernate+JBoss Treecache实现Hibernate集群</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2010%2F07%2F18%2F2373%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F14%2F13131%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Spring之经验教训（一）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2012%2F01%2F12%2F13221%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F14%2F13131%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">解决Velocity＋Spring的中文乱码问题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2012%2F02%2F02%2F13237%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F14%2F13131%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">有关Java泛型的类型擦除（type erasing）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2009%2F12%2F02%2F1899%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F14%2F13131%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Apache给EJB 3.1（JSR #318）投了否决票</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.jayxu.com/2011/12/14/13131/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spring之经验教训（一）</title>
		<link>http://www.jayxu.com/2010/07/18/2373/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=spring%25e4%25b9%258b%25e7%25bb%258f%25e9%25aa%258c%25e6%2595%2599%25e8%25ae%25ad%25ef%25bc%2588%25e4%25b8%2580%25ef%25bc%2589</link>
		<comments>http://www.jayxu.com/2010/07/18/2373/#comments</comments>
		<pubDate>Sat, 17 Jul 2010 17:27:24 +0000</pubDate>
		<dc:creator>Jay</dc:creator>
				<category><![CDATA[技术生活]]></category>
		<category><![CDATA[aop]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[orm]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[struts]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[transaction]]></category>
		<category><![CDATA[依赖注入]]></category>

		<guid isPermaLink="false">http://jayxu.com/?p=2373</guid>
		<description><![CDATA[在现在的项目中我们使用了spring + hibernate + struts的架构，在享受aop, orm, ioc, di带来的种种便利的同时，我们亦遇到了很多莫名其妙或者说刻骨铭心的教训，今天先整理两点，日后继续补充 经验一：时刻牢记，spring、hibernate对对象 进行了动态代理，尽量不要试图在动态代理后的对象上进行反射，尤其是field！ 不管是hibernate的orm还是spring的声明式事务管理，都对原来的pojo、dao进行了动态代理。虽然s、h&#8220;号称&#8221;动态代理做得天衣无缝且无色无味，但是，那只是在&#8220;绝大多数情况下&#8221;，如果想对动态代理后的对象进行反射，麻烦便来了，代码片段： public static void setCreditInfoStatus&#40;CreditInfo info, CreditType type, CreditValidateStatus status&#41; &#123; &#160; &#160; ... &#160; &#160; &#160; Field&#91;&#93; fields = CreditInfo.class.getDeclaredFields&#40;&#41;; &#160; &#160; &#160; for &#40;Field f : fields&#41; &#123; &#160; &#160; &#160; &#160; if &#40;f.isAnnotationPresent&#40;Credit.class&#41; &#38;&#38; f.getAnnotation&#40;Credit.class&#41;.value&#40;&#41; == type&#41; &#123; &#160; &#160; &#160; &#160; <a href="http://www.jayxu.com/2010/07/18/2373/"> read more <span class="meta-nav">&#187;</span></a><table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F14%2F13131%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2010%2F07%2F18%2F2373%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">使用Spring LDAP ODM操作LDAP</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2010%2F06%2F09%2F2342%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2010%2F07%2F18%2F2373%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Spring之Hibernate+JBoss Treecache实现Hibernate集群</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2012%2F01%2F12%2F13221%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2010%2F07%2F18%2F2373%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">解决Velocity＋Spring的中文乱码问题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2012%2F02%2F02%2F13237%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2010%2F07%2F18%2F2373%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">有关Java泛型的类型擦除（type erasing）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2010%2F11%2F23%2F10275&from=http%3A%2F%2Fwww.jayxu.com%2F2010%2F07%2F18%2F2373%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">如何在Hibernate中让SQLServer使用nvarchar代替varchar</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>在现在的项目中我们使用了spring + hibernate + struts的架构，在享受aop, orm, ioc, di带来的种种便利的同时，我们亦遇到了很多莫名其妙或者说刻骨铭心的教训，今天先整理两点，日后继续补充</p>
<h4>经验一：时刻牢记，spring、hibernate对对象 进行了动态代理，尽量不要试图在动态代理后的对象上进行反射，尤其是field！</h4>
<p>不管是hibernate的orm还是spring的声明式事务管理，都对原来的pojo、dao进行了动态代理。虽然s、h&ldquo;号称&rdquo;动态代理做得天衣无缝且无色无味，但是，那只是在&ldquo;绝大多数情况下&rdquo;，如果想对动态代理后的对象进行反射，麻烦便来了，代码片段：</p>

<div class="bwp-syntax-block clearfix">
<div class="bwp-syntax-toolbar"><div class="bwp-syntax-control"><a href="javascript:;" class="bwp-syntax-source-switch" title="View Source Code"></a></div></div>
<div class="bwp-syntax-wrapper clearfix bwp-syntax-advanced"><div class="java"><ol><li class="li1"><div class="de1"><span class="kw1">public</span> <span class="kw1">static</span> <span class="kw4">void</span> setCreditInfoStatus<span class="br0">&#40;</span>CreditInfo info, CreditType type, CreditValidateStatus status<span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; ...</div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="kw3">Field</span><span class="br0">&#91;</span><span class="br0">&#93;</span> fields <span class="sy0">=</span> CreditInfo.<span class="kw1">class</span>.<span class="me1">getDeclaredFields</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw3">Field</span> f <span class="sy0">:</span> fields<span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>f.<span class="me1">isAnnotationPresent</span><span class="br0">&#40;</span>Credit.<span class="kw1">class</span><span class="br0">&#41;</span> <span class="sy0">&amp;&amp;</span> f.<span class="me1">getAnnotation</span><span class="br0">&#40;</span>Credit.<span class="kw1">class</span><span class="br0">&#41;</span>.<span class="me1">value</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">==</span> type<span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">PropertyDescriptor</span> pd <span class="sy0">=</span> BeanUtils.<span class="me1">getPropertyDescriptor</span><span class="br0">&#40;</span>CreditInfo.<span class="kw1">class</span>, f.<span class="me1">getName</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>pd <span class="sy0">!=</span> <span class="kw2">null</span><span class="br0">&#41;</span> &nbsp;<span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ...</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">break</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></div>
<div class="bwp-syntax-source"><pre class="no-parse">public static void setCreditInfoStatus(CreditInfo info, CreditType type, CreditValidateStatus status) {
    ...

    Field[] fields = CreditInfo.class.getDeclaredFields();

    for (Field f : fields) {
        if (f.isAnnotationPresent(Credit.class) &amp;&amp; f.getAnnotation(Credit.class).value() == type) {
            PropertyDescriptor pd = BeanUtils.getPropertyDescriptor(CreditInfo.class, f.getName());
            if (pd != null)  {
                ...
            }
            break;
        }
    }
}</pre></div></div>

<p>原先第7行写为 info.getClass()，乍一看与现有的代码功能上是一样的，但是别忘了让人又恨又爱的动态代理！上面代码返回的是真正的CreditInfo class，而左边的返回的是动态代理后的class，即意味着，第一个&ldquo;if&rdquo;永远返回的是false，除非动态代理后的对象的field上附带了原有的annotation</p>
<h4>经验二：spring的声明式事务管理确很强大，强大到可以支持多线程，但是，结合上一点，不要在线程中调用this中的事务方法</h4>
<p>声明式事务，即spring中使用aop织入或 @Transactional标记的方法注入事务容器，码农们可以完全不用操心何时begin，何时commit，何时 rollback，有没有嵌套，绝对傻瓜级的编程模型。但是，牢记，spring中的aop、annotation都是使用动态代理实现的，即，如果没有经过动态代理便也没有了事务管理，代码片段：</p>

<div class="bwp-syntax-block clearfix">
<div class="bwp-syntax-toolbar"><div class="bwp-syntax-control"><a href="javascript:;" class="bwp-syntax-source-switch" title="View Source Code"></a></div></div>
<div class="bwp-syntax-wrapper clearfix bwp-syntax-advanced"><div class="java"><ol><li class="li1"><div class="de1"><span class="kw1">public</span> <span class="kw1">class</span> AutomatedService<span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; ...</div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="me1">loanQueue</span>.<span class="me1">execute</span><span class="br0">&#40;</span><span class="kw1">new</span> <span class="kw3">Runnable</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; @Override</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">public</span> <span class="kw4">void</span> run<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Thread</span> thread <span class="sy0">=</span> &nbsp;<span class="kw3">Thread</span>.<span class="me1">currentThread</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">while</span> <span class="br0">&#40;</span><span class="sy0">!</span>thread.<span class="me1">isInterrupted</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">try</span> <span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; loanService.<span class="me1">checkNSetLoanStatus</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">Thread</span>.<span class="me1">sleep</span><span class="br0">&#40;</span>loanStatusCheckIntervalMinutes <span class="sy0">*</span> Consts.<span class="me1">ONE_MINUTE</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">catch</span> <span class="br0">&#40;</span><span class="kw3">InterruptedException</span> ex<span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; thread.<span class="me1">interrupt</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; ...</div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li>
</ol></div></div>
<div class="bwp-syntax-source"><pre class="no-parse">public class AutomatedService{
    ...

    loanQueue.execute(new Runnable() {

        @Override
        public void run() {
            Thread thread =  Thread.currentThread();

            while (!thread.isInterrupted()) {
                try {
                    loanService.checkNSetLoanStatus();

                    Thread.sleep(loanStatusCheckIntervalMinutes * Consts.ONE_MINUTE);
                } catch (InterruptedException ex) {
                    thread.interrupt();
                }
            }
        }
    });

    ...
}</pre></div></div>

<p>原先的checkNSetLoanStatus方法是定义在AutomatedService中的，且标记了@Transactional。 但是，令人发指的是，checkNSetLoanStatus中的事务没有被提交。在痛定思痛仔细回想了spring的声明式事务的本质后，豁然发现当调用this.checkNSetLoanStatus()时，并没有被织入事务管理。spring还没有霸道到或者说聪明到对this进行动态代理，于是将该方法移至其它service并注入，问题解决</p>
<div style="margin-top: 15px; font-style: italic">
<p><strong>原创内容，转载请注明：</strong> 转载自<a href="http://www.jayxu.com/">拈花微笑</a></p>
<p><strong>本文链接地址:</strong> <a href="http://www.jayxu.com/2010/07/18/2373/">Spring之经验教训（一）</a></p>
</div>
<p><a href="http://www.bshare.cn/share?url=http%3A%2F%2Fwww.jayxu.com%2F2010%2F07%2F18%2F2373%2F&title=Spring%E4%B9%8B%E7%BB%8F%E9%AA%8C%E6%95%99%E8%AE%AD%EF%BC%88%E4%B8%80%EF%BC%89" title="用bShare分享或收藏本文"><img src="http://static.bshare.cn/frame/images/button_custom1-zh.gif" alt="用bShare分享或收藏本文" /></a></p><table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F14%2F13131%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2010%2F07%2F18%2F2373%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">使用Spring LDAP ODM操作LDAP</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2010%2F06%2F09%2F2342%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2010%2F07%2F18%2F2373%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Spring之Hibernate+JBoss Treecache实现Hibernate集群</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2012%2F01%2F12%2F13221%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2010%2F07%2F18%2F2373%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">解决Velocity＋Spring的中文乱码问题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2012%2F02%2F02%2F13237%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2010%2F07%2F18%2F2373%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">有关Java泛型的类型擦除（type erasing）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2010%2F11%2F23%2F10275&from=http%3A%2F%2Fwww.jayxu.com%2F2010%2F07%2F18%2F2373%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">如何在Hibernate中让SQLServer使用nvarchar代替varchar</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.jayxu.com/2010/07/18/2373/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Spring之Hibernate+JBoss Treecache实现Hibernate集群</title>
		<link>http://www.jayxu.com/2010/06/09/2342/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=spring%25e4%25b9%258bhibernatejboss-treecache%25e9%2585%258d%25e7%25bd%25ae%25e5%25ae%259e%25e7%258e%25b0hibernate%25e9%259b%2586%25e7%25be%25a4</link>
		<comments>http://www.jayxu.com/2010/06/09/2342/#comments</comments>
		<pubDate>Wed, 09 Jun 2010 06:53:28 +0000</pubDate>
		<dc:creator>Jay</dc:creator>
				<category><![CDATA[技术生活]]></category>
		<category><![CDATA[未分类]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[treecache]]></category>

		<guid isPermaLink="false">http://jayxu.com/?p=2342</guid>
		<description><![CDATA[本文版权归本人所有，任何转载请标明出处 Hibernate作为一个ORM框架可以说已经做到了极致，但是绝大多数情况下Hibernate都被应用于单容器环境中，以至于互联网上能够找到的在集群环境中使用的参考少之又少，和Spring整合的就更别说了。实际上，Hibernate可以使用JBoss的Treecache作为二级缓存以支持分布式集群 本文将使用Spring 3.0.2框架集成Hibernate 3.5.2，并将Treecache 3.2.5作为二级缓存 Spring配置 &#60;context:annotation-config /&#62; &#160; &#60;bean id=&#34;sessionFactory&#34; class=&#34;org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean&#34;&#62; &#160; &#160; &#160; &#160; ... &#60;property name=&#34;hibernateProperties&#34;&#62; &#160; &#160; &#160; &#160; &#160; &#160; &#60;value&#62; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; hibernate.dialect=org.hibernate.dialect.MySQL5Dialect &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; hibernate.cache.use_second_level_cache=true &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; hibernate.show_sql=true &#160; <a href="http://www.jayxu.com/2010/06/09/2342/"> read more <span class="meta-nav">&#187;</span></a><table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F14%2F13131%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2010%2F06%2F09%2F2342%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">使用Spring LDAP ODM操作LDAP</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2010%2F07%2F18%2F2373%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2010%2F06%2F09%2F2342%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Spring之经验教训（一）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2012%2F01%2F12%2F13221%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2010%2F06%2F09%2F2342%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">解决Velocity＋Spring的中文乱码问题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2010%2F11%2F24%2F10280%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2010%2F06%2F09%2F2342%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">谨慎升级至Hibernate 3.6</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F15%2F13164%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2010%2F06%2F09%2F2342%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">About save/persist, update/merge in JPA/Hibernate</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p><strong><em>本文版权归本人所有，任何转载请标明出处</em></strong></p>
<p>Hibernate作为一个ORM框架可以说已经做到了极致，但是绝大多数情况下Hibernate都被应用于单容器环境中，以至于互联网上能够找到的在集群环境中使用的参考少之又少，和Spring整合的就更别说了。实际上，Hibernate可以使用JBoss的Treecache作为二级缓存以支持分布式集群</p>
<p>本文将使用Spring 3.0.2框架集成Hibernate 3.5.2，并将<a href="http://www.jboss.org/jbosscache" target="_blank">Treecache</a> 3.2.5作为二级缓存</p>
<p>Spring配置</p>

<div class="bwp-syntax-block clearfix">
<div class="bwp-syntax-toolbar"><div class="bwp-syntax-control"><a href="javascript:;" class="bwp-syntax-source-switch" title="View Source Code"></a></div></div>
<div class="bwp-syntax-wrapper clearfix bwp-syntax-advanced"><div class="xml"><ol><li class="li1"><div class="de1"><span class="sc3"><span class="re1">&lt;context:annotation-config</span> <span class="re2">/&gt;</span></span></div></li>
<li class="li2"><div class="de2">&nbsp;</div></li>
<li class="li1"><div class="de1"><span class="sc3"><span class="re1">&lt;bean</span> <span class="re0">id</span>=<span class="st0">&quot;sessionFactory&quot;</span> <span class="re0">class</span>=<span class="st0">&quot;org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean&quot;</span><span class="re2">&gt;</span></span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; ...</div></li>
<li class="li1"><div class="de1"><span class="sc3"><span class="re1">&lt;property</span> <span class="re0">name</span>=<span class="st0">&quot;hibernateProperties&quot;</span><span class="re2">&gt;</span></span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;value<span class="re2">&gt;</span></span></span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hibernate.dialect=org.hibernate.dialect.MySQL5Dialect</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hibernate.cache.use_second_level_cache=true</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hibernate.show_sql=true</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hibernate.cache.region.factory_class=org.hibernate.cache.jbc2.SharedJBossCacheRegionFactory</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hibernate.cache.use_query_cache=true</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hibernate.hbm2ddl.auto=update</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/value<span class="re2">&gt;</span></span></span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/property<span class="re2">&gt;</span></span></span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/bean<span class="re2">&gt;</span></span></span></div></li>
</ol></div></div>
<div class="bwp-syntax-source"><pre class="no-parse">&lt;context:annotation-config /&gt;

&lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"&gt;
        ...
&lt;property name="hibernateProperties"&gt;
            &lt;value&gt;
                hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
                hibernate.cache.use_second_level_cache=true
                hibernate.show_sql=true
                hibernate.cache.region.factory_class=org.hibernate.cache.jbc2.SharedJBossCacheRegionFactory
                hibernate.cache.use_query_cache=true
                hibernate.hbm2ddl.auto=update
            &lt;/value&gt;
        &lt;/property&gt;
    &lt;/bean&gt;</pre></div></div>

<p>其中第1行打开Spring的annotation支持，即使用annotation替代之前版本中的大量XML配置（貌似这个选项在Spring 2.5中就被引入，但不知道是因为大家懒还是配置文件的基本内容都是在互联网上Ctrl C+V 2.5之前的代码，反正互联网上一搜Spring的配置满眼都是XML片段）；第8行打开二级缓存；第10行选择Treecache作为缓存region工厂的实现类</p>
<p>对于需要被缓存的实体，只需要在类定义上加上@Cache注释，如：</p>

<div class="bwp-syntax-block clearfix">
<div class="bwp-syntax-toolbar"><div class="bwp-syntax-control"><a href="javascript:;" class="bwp-syntax-source-switch" title="View Source Code"></a></div></div>
<div class="bwp-syntax-wrapper clearfix bwp-syntax-advanced"><div class="java"><ol><li class="li1"><div class="de1">@Cache<span class="br0">&#40;</span>usage <span class="sy0">=</span> CacheConcurrencyStrategy.<span class="me1">TRANSACTIONAL</span><span class="br0">&#41;</span></div></li>
<li class="li2"><div class="de2"><span class="kw1">public</span> <span class="kw1">class</span> MyModel <span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; ...</div></li>
<li class="li2"><div class="de2"><span class="br0">&#125;</span></div></li>
</ol></div></div>
<div class="bwp-syntax-source"><pre class="no-parse">@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
public class MyModel {
    ...
}</pre></div></div>

<p>由于Treecache只支持只读缓存和事务缓存，因此这里usage只能设为READ_ONLY或TRANSACTIONAL，但需要注意的是设为只读缓存时不能打开Hibernate的query cache</p>
<p>最后是Treecache的配置，如果配置文件名是treecache.xml且在classpath中则无需指定，否则需要在上述Spring配置的代码段中指定。至于具体配置内容，可参考Treecache源代码中的sample，调优方式可参考Treecache文档，这里给一个sample</p>

<div class="bwp-syntax-block clearfix">
<div class="bwp-syntax-toolbar" style="right: 15px;" ><div class="bwp-syntax-control"><a href="javascript:;" class="bwp-syntax-source-switch" title="View Source Code"></a></div></div>
<div class="bwp-syntax-wrapper clearfix bwp-syntax-advanced"style=" height: 504px;"><div class="xml"><ol><li class="li1"><div class="de1"><span class="sc3"><span class="re1">&lt;?xml</span> <span class="re0">version</span>=<span class="st0">&quot;1.0&quot;</span> <span class="re0">encoding</span>=<span class="st0">&quot;UTF-8&quot;</span><span class="re2">?&gt;</span></span></div></li>
<li class="li2"><div class="de2"><span class="sc3"><span class="re1">&lt;jbosscache</span> <span class="re0">xmlns:xsi</span>=<span class="st0">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span> <span class="re0">xmlns</span>=<span class="st0">&quot;urn:jboss:jbosscache-core:config:3.2&quot;</span><span class="re2">&gt;</span></span></div></li>
<li class="li1"><div class="de1">&nbsp;</div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp;<span class="sc-1">&lt;!-- Configure the TransactionManager --&gt;</span></div></li>
<li class="li1"><div class="de1"><span class="sc3"><span class="re1">&lt;transaction</span> <span class="re0">transactionManagerLookupClass</span>=<span class="st0">&quot;org.jboss.cache.transaction.GenericTransactionManagerLookup&quot;</span><span class="re2">/&gt;</span></span></div></li>
<li class="li2"><div class="de2">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;clustering</span> <span class="re0">mode</span>=<span class="st0">&quot;replication&quot;</span><span class="re2">&gt;</span></span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; <span class="sc-1">&lt;!--</span></div></li>
<li class="li1"><div class="de1"><span class="sc-1"> &nbsp; &nbsp; &nbsp; timeout: The max amount of time (in milliseconds) we wait until the</span></div></li>
<li class="li2"><div class="de2"><span class="sc-1"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; state (i.e. the contents of the cache) are retrieved from</span></div></li>
<li class="li1"><div class="de1"><span class="sc-1"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; existing members in a clustered environment</span></div></li>
<li class="li2"><div class="de2"><span class="sc-1"> &nbsp; &nbsp; &nbsp;--&gt;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;stateRetrieval</span> <span class="re0">timeout</span>=<span class="st0">&quot;20000&quot;</span><span class="re2">/&gt;</span></span></div></li>
<li class="li2"><div class="de2">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; <span class="sc-1">&lt;!-- JGroups protocol stack properties. --&gt;</span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;jgroupsConfig<span class="re2">&gt;</span></span></span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;udp</span> <span class="re0">discard_incompatible_packets</span>=<span class="st0">&quot;true&quot;</span> <span class="re0">enable_bundling</span>=<span class="st0">&quot;true&quot;</span> <span class="re0">enable_diagnostics</span>=<span class="st0">&quot;false&quot;</span> <span class="re0">ip_ttl</span>=<span class="st0">&quot;2&quot;</span></span></div></li>
<li class="li2"><div class="de2"><span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">loopback</span>=<span class="st0">&quot;false&quot;</span> <span class="re0">max_bundle_size</span>=<span class="st0">&quot;64000&quot;</span> <span class="re0">max_bundle_timeout</span>=<span class="st0">&quot;30&quot;</span> <span class="re0">mcast_addr</span>=<span class="st0">&quot;224.12.12.12&quot;</span></span></div></li>
<li class="li1"><div class="de1"><span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">mcast_port</span>=<span class="st0">&quot;45588&quot;</span> <span class="re0">mcast_recv_buf_size</span>=<span class="st0">&quot;100000000&quot;</span> <span class="re0">mcast_send_buf_size</span>=<span class="st0">&quot;640000&quot;</span></span></div></li>
<li class="li2"><div class="de2"><span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">oob_thread_pool.enabled</span>=<span class="st0">&quot;true&quot;</span> <span class="re0">oob_thread_pool.keep_alive_time</span>=<span class="st0">&quot;10000&quot;</span> <span class="re0">oob_thread_pool.max_threads</span>=<span class="st0">&quot;20&quot;</span></span></div></li>
<li class="li1"><div class="de1"><span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">oob_thread_pool.min_threads</span>=<span class="st0">&quot;8&quot;</span> <span class="re0">oob_thread_pool.queue_enabled</span>=<span class="st0">&quot;false&quot;</span> <span class="re0">oob_thread_pool.queue_max_size</span>=<span class="st0">&quot;10&quot;</span></span></div></li>
<li class="li2"><div class="de2"><span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">oob_thread_pool.rejection_policy</span>=<span class="st0">&quot;Run&quot;</span> <span class="re0">thread_naming_pattern</span>=<span class="st0">&quot;pl&quot;</span> <span class="re0">thread_pool.enabled</span>=<span class="st0">&quot;true&quot;</span></span></div></li>
<li class="li1"><div class="de1"><span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">thread_pool.keep_alive_time</span>=<span class="st0">&quot;10000&quot;</span> <span class="re0">thread_pool.max_threads</span>=<span class="st0">&quot;15&quot;</span> <span class="re0">thread_pool.min_threads</span>=<span class="st0">&quot;8&quot;</span></span></div></li>
<li class="li2"><div class="de2"><span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">thread_pool.queue_enabled</span>=<span class="st0">&quot;true&quot;</span> <span class="re0">thread_pool.queue_max_size</span>=<span class="st0">&quot;100000&quot;</span></span></div></li>
<li class="li1"><div class="de1"><span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">thread_pool.rejection_policy</span>=<span class="st0">&quot;Discard&quot;</span></span></div></li>
<li class="li2"><div class="de2"><span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">tos</span>=<span class="st0">&quot;8&quot;</span> <span class="re0">ucast_recv_buf_size</span>=<span class="st0">&quot;20000000&quot;</span> <span class="re0">ucast_send_buf_size</span>=<span class="st0">&quot;640000&quot;</span> <span class="re0">use_concurrent_stack</span>=<span class="st0">&quot;true&quot;</span></span></div></li>
<li class="li1"><div class="de1"><span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">use_incoming_packet_handler</span>=<span class="st0">&quot;true&quot;</span><span class="re2">/&gt;</span></span></div></li>
<li class="li2"><div class="de2"><span class="sc3"><span class="re1">&lt;ping</span> <span class="re0">num_initial_members</span>=<span class="st0">&quot;3&quot;</span> <span class="re0">timeout</span>=<span class="st0">&quot;2000&quot;</span><span class="re2">/&gt;</span></span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;merge2</span> <span class="re0">max_interval</span>=<span class="st0">&quot;30000&quot;</span> <span class="re0">min_interval</span>=<span class="st0">&quot;10000&quot;</span><span class="re2">/&gt;</span></span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;fd_SOCK</span><span class="re2">/&gt;</span></span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;fd</span> <span class="re0">max_tries</span>=<span class="st0">&quot;5&quot;</span> <span class="re0">shun</span>=<span class="st0">&quot;true&quot;</span> <span class="re0">timeout</span>=<span class="st0">&quot;10000&quot;</span><span class="re2">/&gt;</span></span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;verify_SUSPECT</span> <span class="re0">timeout</span>=<span class="st0">&quot;1500&quot;</span><span class="re2">/&gt;</span></span></div></li>
<li class="li1"><div class="de1"><span class="sc3"><span class="re1">&lt;pbcast.NAKACK</span> <span class="re0">discard_delivered_msgs</span>=<span class="st0">&quot;true&quot;</span> <span class="re0">gc_lag</span>=<span class="st0">&quot;0&quot;</span> <span class="re0">retransmit_timeout</span>=<span class="st0">&quot;300,600,1200,2400,4800&quot;</span></span></div></li>
<li class="li2"><div class="de2"><span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">use_mcast_xmit</span>=<span class="st0">&quot;true&quot;</span><span class="re2">/&gt;</span></span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;unicast</span> <span class="re0">timeout</span>=<span class="st0">&quot;300,600,1200,2400,3600&quot;</span><span class="re2">/&gt;</span></span></div></li>
<li class="li2"><div class="de2"><span class="sc3"><span class="re1">&lt;pbcast.STABLE</span> <span class="re0">desired_avg_gossip</span>=<span class="st0">&quot;50000&quot;</span> <span class="re0">max_bytes</span>=<span class="st0">&quot;400000&quot;</span> <span class="re0">stability_delay</span>=<span class="st0">&quot;1000&quot;</span><span class="re2">/&gt;</span></span></div></li>
<li class="li1"><div class="de1"><span class="sc3"><span class="re1">&lt;pbcast.GMS</span> <span class="re0">join_timeout</span>=<span class="st0">&quot;5000&quot;</span> <span class="re0">print_local_addr</span>=<span class="st0">&quot;true&quot;</span> <span class="re0">shun</span>=<span class="st0">&quot;false&quot;</span> <span class="re0">view_ack_collection_timeout</span>=<span class="st0">&quot;5000&quot;</span></span></div></li>
<li class="li2"><div class="de2"><span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">view_bundling</span>=<span class="st0">&quot;true&quot;</span><span class="re2">/&gt;</span></span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;fc</span> <span class="re0">max_credits</span>=<span class="st0">&quot;500000&quot;</span> <span class="re0">min_threshold</span>=<span class="st0">&quot;0.2&quot;</span><span class="re2">/&gt;</span></span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;frag2</span> <span class="re0">frag_size</span>=<span class="st0">&quot;60000&quot;</span><span class="re2">/&gt;</span></span></div></li>
<li class="li1"><div class="de1"><span class="sc3"><span class="re1">&lt;pbcast.STREAMING_STATE_TRANSFER</span><span class="re2">/&gt;</span></span></div></li>
<li class="li2"><div class="de2"><span class="sc3"><span class="re1">&lt;pbcast.FLUSH</span> <span class="re0">timeout</span>=<span class="st0">&quot;0&quot;</span><span class="re2">/&gt;</span></span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/jgroupsConfig<span class="re2">&gt;</span></span></span></div></li>
<li class="li2"><div class="de2">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;async</span> <span class="re2">/&gt;</span></span></div></li>
<li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; <span class="sc-1">&lt;!-- Alternatively, to use sync replication, comment out the element above and uncomment the element below. &nbsp;--&gt;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; <span class="sc-1">&lt;!-- &lt;sync /&gt; --&gt;</span></div></li>
<li class="li2"><div class="de2">&nbsp;</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;/clustering<span class="re2">&gt;</span></span></span></div></li>
<li class="li2"><div class="de2"><span class="sc3"><span class="re1">&lt;/jbosscache<span class="re2">&gt;</span></span></span></div></li>
</ol></div></div>
<div class="bwp-syntax-source"><pre class="no-parse">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.2"&gt;

   &lt;!-- Configure the TransactionManager --&gt;
&lt;transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/&gt;

   &lt;clustering mode="replication"&gt;
      &lt;!--
       timeout: The max amount of time (in milliseconds) we wait until the
             state (i.e. the contents of the cache) are retrieved from
             existing members in a clustered environment
      --&gt;
      &lt;stateRetrieval timeout="20000"/&gt;

      &lt;!-- JGroups protocol stack properties. --&gt;
      &lt;jgroupsConfig&gt;
         &lt;udp discard_incompatible_packets="true" enable_bundling="true" enable_diagnostics="false" ip_ttl="2"
              loopback="false" max_bundle_size="64000" max_bundle_timeout="30" mcast_addr="224.12.12.12"
              mcast_port="45588" mcast_recv_buf_size="100000000" mcast_send_buf_size="640000"
              oob_thread_pool.enabled="true" oob_thread_pool.keep_alive_time="10000" oob_thread_pool.max_threads="20"
              oob_thread_pool.min_threads="8" oob_thread_pool.queue_enabled="false" oob_thread_pool.queue_max_size="10"
              oob_thread_pool.rejection_policy="Run" thread_naming_pattern="pl" thread_pool.enabled="true"
              thread_pool.keep_alive_time="10000" thread_pool.max_threads="15" thread_pool.min_threads="8"
              thread_pool.queue_enabled="true" thread_pool.queue_max_size="100000"
              thread_pool.rejection_policy="Discard"
              tos="8" ucast_recv_buf_size="20000000" ucast_send_buf_size="640000" use_concurrent_stack="true"
              use_incoming_packet_handler="true"/&gt;
&lt;ping num_initial_members="3" timeout="2000"/&gt;
         &lt;merge2 max_interval="30000" min_interval="10000"/&gt;
         &lt;fd_SOCK/&gt;
         &lt;fd max_tries="5" shun="true" timeout="10000"/&gt;
         &lt;verify_SUSPECT timeout="1500"/&gt;
&lt;pbcast.NAKACK discard_delivered_msgs="true" gc_lag="0" retransmit_timeout="300,600,1200,2400,4800"
                        use_mcast_xmit="true"/&gt;
         &lt;unicast timeout="300,600,1200,2400,3600"/&gt;
&lt;pbcast.STABLE desired_avg_gossip="50000" max_bytes="400000" stability_delay="1000"/&gt;
&lt;pbcast.GMS join_timeout="5000" print_local_addr="true" shun="false" view_ack_collection_timeout="5000"
                     view_bundling="true"/&gt;
         &lt;fc max_credits="500000" min_threshold="0.2"/&gt;
         &lt;frag2 frag_size="60000"/&gt;
&lt;pbcast.STREAMING_STATE_TRANSFER/&gt;
&lt;pbcast.FLUSH timeout="0"/&gt;
      &lt;/jgroupsConfig&gt;

      &lt;async /&gt;
      &lt;!-- Alternatively, to use sync replication, comment out the element above and uncomment the element below.  --&gt;
      &lt;!-- &lt;sync /&gt; --&gt;

   &lt;/clustering&gt;
&lt;/jbosscache&gt;</pre></div></div>

<p>需要注意的是第7行，集群mode。Treecache的分布式同步有两种模式：replication和invalidation。这两者的区别是：对于replication，每一个节点（缓存）中的对象改变时，该节点会将新对象通过多播的方式告知多播组中的其它节点，其它节点自行更新；而对于invalidation模式，发生改变的节点只通知其它节点某对象已发生改变，其它节点直接将自己缓存中的该对象标记为invalid，待下次需要使用时通过数据库更新该对象。这样一解释就能发现取舍的策略了：若网络比数据库金贵，选择invalidation，标记自己的对象，让数据库忙活去吧；若数据库金贵，使用replication多播对象</p>
<p>另外，由于Treecache使用了基于多播协议的jgroup库作为底层通信框架，在配置Treecache集群时不需要了解多播组中其他节点IP，只需要把第19行的多播地址（必须是D类地址）配成一个的就行了，jgroup会自行发现多播组中的其它节点</p>
<h3>世界杯大酬宾：如何使用JMX监控Treecache的状态</h3>
<p>启动容器；打开任意JMX客户端，如jconsole；在进程列表中选择容器的java进程并连接；选择“mbean”标签，找到“jboss.cache”节点，如下图</p>
<p><a href="http://www.jayxu.com/log/wp-content/uploads/2010/06/VisualVM-1.3.png"><img src="http://www.jayxu.com/log/wp-content/uploads/2010/06/VisualVM-1.3-400x235.png" alt="" title="VisualVM 1.3" width="400" height="235" /></a><br />
在这个节点下可以看到所有Treecache通过JMX暴露的属性，包括命中率、缓存对象等
<div style="margin-top: 15px; font-style: italic">
<p><strong>原创内容，转载请注明：</strong> 转载自<a href="http://www.jayxu.com/">拈花微笑</a></p>
<p><strong>本文链接地址:</strong> <a href="http://www.jayxu.com/2010/06/09/2342/">Spring之Hibernate+JBoss Treecache实现Hibernate集群</a></p>
</div>
<p><a href="http://www.bshare.cn/share?url=http%3A%2F%2Fwww.jayxu.com%2F2010%2F06%2F09%2F2342%2F&title=Spring%E4%B9%8BHibernate%2BJBoss+Treecache%E5%AE%9E%E7%8E%B0Hibernate%E9%9B%86%E7%BE%A4" title="用bShare分享或收藏本文"><img src="http://static.bshare.cn/frame/images/button_custom1-zh.gif" alt="用bShare分享或收藏本文" /></a></p><table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F14%2F13131%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2010%2F06%2F09%2F2342%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">使用Spring LDAP ODM操作LDAP</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2010%2F07%2F18%2F2373%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2010%2F06%2F09%2F2342%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Spring之经验教训（一）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2012%2F01%2F12%2F13221%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2010%2F06%2F09%2F2342%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">解决Velocity＋Spring的中文乱码问题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2010%2F11%2F24%2F10280%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2010%2F06%2F09%2F2342%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">谨慎升级至Hibernate 3.6</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2011%2F12%2F15%2F13164%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2010%2F06%2F09%2F2342%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">About save/persist, update/merge in JPA/Hibernate</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.jayxu.com/2010/06/09/2342/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache给EJB 3.1（JSR #318）投了否决票</title>
		<link>http://www.jayxu.com/2009/12/02/1899/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=apache%25e7%25bb%2599ejb-3-1%25ef%25bc%2588jsr-318%25ef%25bc%2589%25e6%258a%2595%25e4%25ba%2586%25e5%2590%25a6%25e5%2586%25b3%25e7%25a5%25a8</link>
		<comments>http://www.jayxu.com/2009/12/02/1899/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 16:49:51 +0000</pubDate>
		<dc:creator>Jay</dc:creator>
				<category><![CDATA[技术生活]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[ejb]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jsr]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[sun]]></category>

		<guid isPermaLink="false">http://ijay.net.cn/2009/12/02/1899/</guid>
		<description><![CDATA[刚才在Glassfish的Google Group上收到有关Apache在EJB 3.1 JSR表决上投了否决票的消息。过去看了一下，发现只有Apache投了否决票，Eclipse、Spring弃权，而且Apache的理由相当牛逼： On 2009-11-30 Apache Software Foundation voted No with the following comment: The Apache Software Foundation&#8217;s vote is based on the point of view that this spec lead &#8211; Sun &#8211; is in violation of the JSPA http://www.apache.org/jcp/sunopenletter.html and therefore shouldn&#8217;t be allowed to lead other JSRs until the above matter is <a href="http://www.jayxu.com/2009/12/02/1899/"> read more <span class="meta-nav">&#187;</span></a><table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2011%2F11%2F23%2F13076%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2009%2F12%2F02%2F1899%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Ubuntu下启用Apache rewrite mod</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2012%2F02%2F02%2F13237%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2009%2F12%2F02%2F1899%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">有关Java泛型的类型擦除（type erasing）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2009%2F12%2F15%2F1947%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2009%2F12%2F02%2F1899%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">java.net论坛被黑（有图有真相）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2010%2F12%2F10%2F10324%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2009%2F12%2F02%2F1899%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">有关Character.isLetter()和Character.isLetterOrDigit()</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2010%2F01%2F29%2F2032%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2009%2F12%2F02%2F1899%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">别了，sun.com</font>
                    </a>
                </td>
            </tr>
        <br/>
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">来自无觅网络的相关文章：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.dedeadmin.com%2F%3Fp%3D2379&from=http%3A%2F%2Fwww.jayxu.com%2F2009%2F12%2F02%2F1899%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Linux+Apache+PHP+MySQL服务器环境(CentOS篇) (@dedeadmin)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fdongdong.im%2F11&from=http%3A%2F%2Fwww.jayxu.com%2F2009%2F12%2F02%2F1899%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">安装apache已经成功了！ (@dongdong)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.hui-wang.info%2F2012%2F01%2F08%2Fjava-enum-and-polymorphism%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2009%2F12%2F02%2F1899%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Java的枚举和接口 (@hui-wang)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fbfya.com%2Fnginx-web-server&from=http%3A%2F%2Fwww.jayxu.com%2F2009%2F12%2F02%2F1899%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Nginx占有率超过10% 成为屈居apache之后的第二大web服务器 (@bfya)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fbfya.com%2Fimages-no-outside-link&from=http%3A%2F%2Fwww.jayxu.com%2F2009%2F12%2F02%2F1899%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">利用.htaccess 实现apache服务器下 图片 音乐 防盗链 (@bfya)</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>刚才在Glassfish的Google Group上收到有关Apache在EJB 3.1 JSR表决上投了否决票的消息。<a target="_blank" href="http://www.jcp.org/en/jsr/results?id=5029">过去</a>看了一下，发现只有Apache投了否决票，Eclipse、Spring弃权，而且Apache的理由相当牛逼：</p>
<blockquote><p>
On 2009-11-30 Apache Software Foundation voted No with the following comment:<br />
The Apache Software Foundation&#8217;s vote is based on the point of view that this spec lead &#8211; Sun &#8211; is in violation of the JSPA</p>
<p>http://www.apache.org/jcp/sunopenletter.html</p>
<p>and therefore shouldn&#8217;t be allowed to lead other JSRs until the above matter is resolved.</p>
<p>This vote is not a comment on the technical merits of the JSR.  If not for the issue of the spec lead, the ASF would have otherwise voted “yes”.
</p></blockquote>
<p>于是又围观了一下<a target="_blank" href="http://www.apache.org/jcp/sunopenletter.html">那封</a>公开信，不亏是Apache，邮件的口气都不一样，比如开头：</p>
<blockquote><p>My name is Geir Magnusson Jr, and I&#8217;m the officer of the Apache Software Foundation (ASF), a 501(c)3 public charity, charged with matters relating to our participation in the Java Community Process (JCP).  I am also the VP of the Apache Harmony project. In this matter I represent the ASF.
</p></blockquote>
<p>还有结尾：</p>
<blockquote><p>We expect you to offer an acceptable, JSPA-compliant license to us within 30 days, or provide a public explanation of why you cannot do so.
</p></blockquote>
<p>继续关注EJB 3.1的相关发展……
<div style="margin-top: 15px; font-style: italic">
<p><strong>原创内容，转载请注明：</strong> 转载自<a href="http://www.jayxu.com/">拈花微笑</a></p>
<p><strong>本文链接地址:</strong> <a href="http://www.jayxu.com/2009/12/02/1899/">Apache给EJB 3.1（JSR #318）投了否决票</a></p>
</div>
<p><a href="http://www.bshare.cn/share?url=http%3A%2F%2Fwww.jayxu.com%2F2009%2F12%2F02%2F1899%2F&title=Apache%E7%BB%99EJB+3.1%EF%BC%88JSR+%23318%EF%BC%89%E6%8A%95%E4%BA%86%E5%90%A6%E5%86%B3%E7%A5%A8" title="用bShare分享或收藏本文"><img src="http://static.bshare.cn/frame/images/button_custom1-zh.gif" alt="用bShare分享或收藏本文" /></a></p><table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2011%2F11%2F23%2F13076%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2009%2F12%2F02%2F1899%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Ubuntu下启用Apache rewrite mod</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2012%2F02%2F02%2F13237%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2009%2F12%2F02%2F1899%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">有关Java泛型的类型擦除（type erasing）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2009%2F12%2F15%2F1947%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2009%2F12%2F02%2F1899%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">java.net论坛被黑（有图有真相）</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2010%2F12%2F10%2F10324%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2009%2F12%2F02%2F1899%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">有关Character.isLetter()和Character.isLetterOrDigit()</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.jayxu.com%2F2010%2F01%2F29%2F2032%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2009%2F12%2F02%2F1899%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">别了，sun.com</font>
                    </a>
                </td>
            </tr>
        <br/>
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">来自无觅网络的相关文章：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.dedeadmin.com%2F%3Fp%3D2379&from=http%3A%2F%2Fwww.jayxu.com%2F2009%2F12%2F02%2F1899%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Linux+Apache+PHP+MySQL服务器环境(CentOS篇) (@dedeadmin)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fdongdong.im%2F11&from=http%3A%2F%2Fwww.jayxu.com%2F2009%2F12%2F02%2F1899%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">安装apache已经成功了！ (@dongdong)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.hui-wang.info%2F2012%2F01%2F08%2Fjava-enum-and-polymorphism%2F&from=http%3A%2F%2Fwww.jayxu.com%2F2009%2F12%2F02%2F1899%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Java的枚举和接口 (@hui-wang)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fbfya.com%2Fnginx-web-server&from=http%3A%2F%2Fwww.jayxu.com%2F2009%2F12%2F02%2F1899%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">Nginx占有率超过10% 成为屈居apache之后的第二大web服务器 (@bfya)</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fbfya.com%2Fimages-no-outside-link&from=http%3A%2F%2Fwww.jayxu.com%2F2009%2F12%2F02%2F1899%2F">
                        <font size="-1"  style="line-height: 1.65em; font-size: 12px !important;">利用.htaccess 实现apache服务器下 图片 音乐 防盗链 (@bfya)</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.jayxu.com/2009/12/02/1899/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

