??xml version="1.0" encoding="utf-8" standalone="yes"?>国产精品91xxx,亚洲国产一区二区三区高清,亚洲毛片avhttp://www.aygfsteel.com/alexwan/category/32011.htmlLet life be beautiful like summer flowers and death like autumn leaves.zh-cnWed, 26 Aug 2009 04:01:19 GMTWed, 26 Aug 2009 04:01:19 GMT60[j2ee]linux下Activemq的部|和使用http://www.aygfsteel.com/alexwan/archive/2009/05/06/269182.htmlAlexwanAlexwanWed, 06 May 2009 02:57:00 GMThttp://www.aygfsteel.com/alexwan/archive/2009/05/06/269182.htmlhttp://www.aygfsteel.com/alexwan/comments/269182.htmlhttp://www.aygfsteel.com/alexwan/archive/2009/05/06/269182.html#Feedback0http://www.aygfsteel.com/alexwan/comments/commentRss/269182.htmlhttp://www.aygfsteel.com/alexwan/services/trackbacks/269182.html http://activemq.apache.org/getting-started.html#GettingStarted-StartingActiveMQ

1.下蝲
http://activemq.apache.org/download.html

2.解压
下载下来的apache-activemq-5.2.0-bin.tar.gz攄?usr/local
cd /usr/local/
tar xvfz apache-activemq-5.2.0-bin.tar.gz
则ActiveMQ的安装目录ؓQ?usr/local/apache-activemq-5.2.0

3.修改activemqq行文g的权?br /> cd /usr/local/apache-activemq-5.2.0/bin
chmod 755 activemq

4.q行
(1).普通启?br /> bin/activemq
(2).指定日志文g的启动方?br /> bin/activemq >/tmp/smlog 2>&1 &
(3)后台启动方式
nohup bin/activemq >/tmp/smlog 2>&1 &

q里需要注意:前两U启动方式在linix命o行或者通过ssh客户端启动时在关闭对应的H口时activemq会关闭,甚至直接ctrl+c也会Dactivemq退出;W三U则不会出现q种情况?br />
5.验证服务端是否开启,有几U方?br /> (1).查看控制台输出或者日志文?br /> (2).直接讉Kactivemq的管理页面:http://localhost:8161/admin/

6.关闭activemq
如果开启方式是使用(1)?2)Q则直接ctrl+c或者关闭对应的l端卛_
如果开启方式是(3),则稍微麻烦一点:
先查扑ֈactivemq对应的进E:
ps -ef | grep activemq
然后把对应的q程杀掉,假设扑ֈ的进E编号ؓ 168168
kill 168168





Alexwan 2009-05-06 10:57 发表评论
]]>
关闭MyEclipse6.0.1的Quick Update的方?/title><link>http://www.aygfsteel.com/alexwan/archive/2009/03/16/259964.html</link><dc:creator>Alexwan</dc:creator><author>Alexwan</author><pubDate>Mon, 16 Mar 2009 03:13:00 GMT</pubDate><guid>http://www.aygfsteel.com/alexwan/archive/2009/03/16/259964.html</guid><wfw:comment>http://www.aygfsteel.com/alexwan/comments/259964.html</wfw:comment><comments>http://www.aygfsteel.com/alexwan/archive/2009/03/16/259964.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/alexwan/comments/commentRss/259964.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/alexwan/services/trackbacks/259964.html</trackback:ping><description><![CDATA[Windows > Preferences > MyEclipse > Community Essentials, <br /> 把选项 "Search for new features on startup"的前勑֎掉即? <br /> <img src ="http://www.aygfsteel.com/alexwan/aggbug/259964.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/alexwan/" target="_blank">Alexwan</a> 2009-03-16 11:13 <a href="http://www.aygfsteel.com/alexwan/archive/2009/03/16/259964.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[cxf]CXF客户端配|文件之包含文ghttp://www.aygfsteel.com/alexwan/archive/2009/02/18/255275.htmlAlexwanAlexwanWed, 18 Feb 2009 07:03:00 GMThttp://www.aygfsteel.com/alexwan/archive/2009/02/18/255275.htmlhttp://www.aygfsteel.com/alexwan/comments/255275.htmlhttp://www.aygfsteel.com/alexwan/archive/2009/02/18/255275.html#Feedback0http://www.aygfsteel.com/alexwan/comments/commentRss/255275.htmlhttp://www.aygfsteel.com/alexwan/services/trackbacks/255275.htmlLQ?/font>

在CXF服务端配|WEB SERVICEӞ通常会包含一些来此cxf.jar里面的XML文gQ用于自动配|需要用到的BEAN

例如Q?/p>

1<import resource="classpath:META-INF/cxf/cxf.xml" />   
2<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />   
3<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />   

但是在客L配置的时候这些文件是不需要的Q甚至配|会引发错误Q详l的l过见下文?/p>

l过Q?/font>

今天在配|客L的时候,步骤和内定w是和往怸LQ但?/p>

出现一个NullPointerException 的错误,只知道这个错误是在创建客Lservice的时候出的错Q但是原因找不到?/p>

错误堆栈Q?/p>

Caused by: java.lang.NullPointerException    
    at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpointInfo(AbstractWSDLBasedEndpointFactory.java:
160)    
    at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:
102)    
    at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:
51)    
    at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:
97)    
    at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:
89)    
    at com.itravel.cxf.client.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:
25)    
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)    
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)    
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)    
    at java.lang.reflect.Method.invoke(Method.java:
585)    
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:
115)   

直到后来我单独加载了创徏客户端service的applicationContextӞ初始化是正常的,所以就怀疑配|文件出了问题;

当上面提到的几个被包含进来的文g的配|被删除后,一切就正常了?/p>

Alexwan 2009-02-18 15:03 发表评论
]]>
【Web Harvest】Web harvest获取XML出现q的解军_?http://www.aygfsteel.com/alexwan/archive/2009/02/17/255102.htmlAlexwanAlexwanTue, 17 Feb 2009 07:13:00 GMThttp://www.aygfsteel.com/alexwan/archive/2009/02/17/255102.htmlhttp://www.aygfsteel.com/alexwan/comments/255102.htmlhttp://www.aygfsteel.com/alexwan/archive/2009/02/17/255102.html#Feedback0http://www.aygfsteel.com/alexwan/comments/commentRss/255102.htmlhttp://www.aygfsteel.com/alexwan/services/trackbacks/255102.htmlWeb harvest获取XML出现q的解军_法:

现象Q?/p>

在Web harvest中用httph去获取某个远E的XMLQ此XML的特征是无文件头(x有编码描q等关键信息)Q采用了多种办法去获取,出现qQ无法解析成我们需要的数据?/p>

办法Q?/p>

(1)最原始办法Q?/font>使用Java中的URLConnectionQInputStream{类d字节,构造字W串Q?/p>

Java代码
  1. /**  
  2.              * 通过URL获取XML,因ؓ在Web harvest获取XML时无法获取正常编码的XML  
  3.              */  
  4.             URL url=new URL(link);   
  5.             URLConnection connection=url.openConnection();   
  6.             InputStream in=connection.getInputStream();   
  7.             ListbyteList=new ArrayList();   
  8.             byte b=-1;   
  9.             while((b=(byte)in.read())!=-1)   
  10.             {   
  11.                 byteList.add(b);   
  12.             }   
  13.             byte[]bytes=new byte[byteList.size()];   
  14.             for(int i=0;i
  15.             {   
  16.                 bytes[i]=byteList.get(i);   
  17.             }   
  18.             /**  
  19.              * 输出日志认其编? 
  20.              */  
  21.             logger.debug(new String(bytes));   
  22.             logger.debug(new String(bytes,"utf-8"));   
  23.             logger.debug(new String(bytes,"gbk"));   
  24.             logger.debug(new String(bytes,"gb2312"));  

 

 (2)最好的办法Q?/font>直接使用dom4j中的SAXReader

Java代码
  1. /**  
  2.              * 通过URL获取XML,因ؓ在Web harvest获取XML时无法获取正常编码的XML  
  3.              */  
  4.             URL url=new URL(link);   
  5.             SAXReader xmlReader = new SAXReader();   
  6.             Document doc=xmlReader.read(url);  

非常单,q编码都不用!

 

 其中Qlink为需要获取XML的地址



Alexwan 2009-02-17 15:13 发表评论
]]>
[CXF]CXF下的保护暴露在外的web service的方法及注意事项http://www.aygfsteel.com/alexwan/archive/2009/02/17/255049.htmlAlexwanAlexwanTue, 17 Feb 2009 03:31:00 GMThttp://www.aygfsteel.com/alexwan/archive/2009/02/17/255049.htmlhttp://www.aygfsteel.com/alexwan/comments/255049.htmlhttp://www.aygfsteel.com/alexwan/archive/2009/02/17/255049.html#Feedback3http://www.aygfsteel.com/alexwan/comments/commentRss/255049.htmlhttp://www.aygfsteel.com/alexwan/services/trackbacks/255049.htmlCXF下的保护暴露在外的web service的方法及注意事项

最q这几天都在使用CXF作ؓwebservice的组Ӟ试图公开的webservice加入C护的范围内?/p>

dC护的Ҏ(gu)有三U:

(1)指定地址讉KQ即指定一些IP地址Q只有这些地址的请求我们的接口才处理?/font>

q种Ҏ(gu)我在开发中有用到Q可以通过WEB容器中的FiltercL实现Q?/p>

只需要检查请求的地址是否在我们指定的地址列表中就可以了?/p>

优点:处于h响应铄前端Q响应非常迅速,所以消耗的资源很少?/p>

~端Q?/font>使用q种Ҏ(gu)只能查指定地址的请求,通常只能应用的小范围内,如局域网?/p>

另外使用q种验证Ҏ(gu)Q无法进行权限的查,一旦通过验证可以执行所有公开的接口?/p>

(2)用户?密码寚w证,使用指定的用户名密码q行验证

q种Ҏ(gu)适合于具体用L查,q而可以检查其是否有权限执行其h的操?

优点Q?/span>可以只准地查用P甚至验证权限?/p>

~点Q?/span>q种方式不能和WEB应用的登录一P只需要验证一ơ就可以了;必须

每个h都检查,如果需要用这U方法去做,q需要处理好cMd/退出机制?/p>

(3)使用HTTPSq行验证Q这U方法应该也可以具体的验证证书来自哪个用Pq而检查其权限?/font>

优点Q?/font>安全更有保证

~点Q?/font>配置复杂Q对客户端程序员要求很比较高?/p>

 

注意事项Q?/font>

使用CXFq行WEBService交互Ӟ特别是进行客L工作Ӟ最好将服务端和客户端的环境剥离开来?/p>

q几天的工作教会了我q个事情(今天上午在测试客L代码时出现莫名其妙的错,最后发现是JAR包冲H,

在服务器的环境中q行客户端程序时Q程序加载了q时的JAR)?/p>

Alexwan 2009-02-17 11:31 发表评论
]]>
[爬虫]|页分析的媄响因素之专业化程?/title><link>http://www.aygfsteel.com/alexwan/archive/2009/02/17/255038.html</link><dc:creator>Alexwan</dc:creator><author>Alexwan</author><pubDate>Tue, 17 Feb 2009 03:01:00 GMT</pubDate><guid>http://www.aygfsteel.com/alexwan/archive/2009/02/17/255038.html</guid><wfw:comment>http://www.aygfsteel.com/alexwan/comments/255038.html</wfw:comment><comments>http://www.aygfsteel.com/alexwan/archive/2009/02/17/255038.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/alexwan/comments/commentRss/255038.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/alexwan/services/trackbacks/255038.html</trackback:ping><description><![CDATA[<p>在爬虫领域的|页分析的过E中Q爬虫程序的复杂度很大程度上受目标网站的专业化程度媄响?/p> <p>其媄响主要表现在两方面:</p> <p>(1)Ҏ(gu)E确定过E的影响</p> <p>在通过分析|站地图的方式去定程Q对专业化程度不是那么高的网站而言Q其|站分类、列表方式基本基本都采用链接的方式,q样在流E实现是很容易就可获取需要的链接Q而对专业化程度较高的|站而言Q在分类下往往通过搜烦、javascript(包括AJAX)页的方式来陈列同类记录Q这在流E实现的时候,需要程序员d析一些javascript函数所做的操作Q去猜度相关列表方式的URL(如搜索的表单如何提交、翻函数如何处理翻늭)?/p> <p>(2)对获取详l信息过E的影响</p> <p>在获取详l信息的时候,基本都是通过分心详细信息面的结构出发的?/p> <p>对专业化E度高的|站而言Q详l信息页面的的制作也是投入了一些精力的Q通常都规定和面特定的位|显C特定的信息Q这样就便于在分析过E中获取指定的数据?/p> <p>而对专业化程度稍低的|站而言Q详l页面的内容很多都是用HTML~辑器直接编辑出来的内容Q在同一频道的不同分cȝ详细信息面中存在着很大的差异,q得获取详l信息部分的分析E序复杂度倍增?/p> <p> </p> <p>个h的美好愿望:宁愿分析的是专业化程度高一点的站点Q因为流E的定及具体实现L可以惛_办法解决的;详细信息的分析存在太多页面结构的话,在获取详细信息付出太大代h(hun)Q?/p> <img src ="http://www.aygfsteel.com/alexwan/aggbug/255038.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/alexwan/" target="_blank">Alexwan</a> 2009-02-17 11:01 <a href="http://www.aygfsteel.com/alexwan/archive/2009/02/17/255038.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[linux]linux下的脚本与java中的相对路径http://www.aygfsteel.com/alexwan/archive/2008/12/12/246000.htmlAlexwanAlexwanFri, 12 Dec 2008 09:31:00 GMThttp://www.aygfsteel.com/alexwan/archive/2008/12/12/246000.htmlhttp://www.aygfsteel.com/alexwan/comments/246000.htmlhttp://www.aygfsteel.com/alexwan/archive/2008/12/12/246000.html#Feedback0http://www.aygfsteel.com/alexwan/comments/commentRss/246000.htmlhttp://www.aygfsteel.com/alexwan/services/trackbacks/246000.html背景Q?/strong>
linux使用ANT~译javacdƈ部v到Tomcat下,然后使用脚本(deploy.sh)开启Tomcat,脚本如下:
deploy.sh(其绝对\径ؓQ?usr/local/myapp/deploy.sh)

1/usr/local/apache-tomcat-5.5.20/bin/shutdown.sh
2ant
3/usr/local/apache-tomcat-5.5.20/bin/startup.sh
4
其中各行的意义:
(1)关闭tomcat
(2)~译javacdƈ部v到tomcat
(3)开启tomcat
q里使用的命令都是绝对\径运行的?br />
问题来了Q?/strong>
(1)在项目中安排了log4j的日志输出到myapp.log,其\径写法:../log/myapp.log;启动服务器的时候在catalina.out中输出错误信息,?./log/myapp.log没有扑ֈ?br /> (2)在程序中使用了output/files/Q程序完成后很难才找到文Ӟ因ؓ其位|ƈ不像在window下调试时一P最后?find   -name   output -type   d命o才找刎ͼ发现原来q个文gҎ(gu)在的位置是在:/usr/local/myapp/下面?br />
倪端初现Q?/strong>
可见Q用脚本开启tomcat时如果以l对路径的方式去开启的话,那么在程序中的相对\径就会以脚本的当前目录作\径的起始炏V这样就D了在文g的位|上出现变化Q得文件管理出现困隄臛_已有的文仉成破坏?br />
问题解决Q?br /> 解决路径的问题有很多Q在q里主要说一下以下两个思\Q?br /> (1)使用可配|的l对路径Q在ANT部v的时候,可以Window下的路径替换成Linux下的l对路径Q这样就很方便管理,此ؓ上策?br /> (2)使用相对路径Ӟ开启Tomcat时一定要切换到tomcat的bin文g夹开启,q样相对路径指向的位|就和Window下的一致了Q此Z{也?br /> 使用相对路径的脚本如下:
1/usr/local/apache-tomcat-5.5.20/bin/shutdown.sh
2ant
3cd /usr/local/apache-tomcat-5.5.20/bin/
4./startup.sh
其中各行的作用:
(1)关闭tomcat
(2)~译javacdƈ部v文g
(3)切换目录到tomcat的bin文g?br /> (4)开启tomcat


估计其他应用服务器下使用脚本和相对\径也时也会遇CL问题Q方法估计也是类似的?br />


Alexwan 2008-12-12 17:31 发表评论
]]>
[freemarcker]Expression JspTaglibs is undefined的解军_?/title><link>http://www.aygfsteel.com/alexwan/archive/2008/10/23/236194.html</link><dc:creator>Alexwan</dc:creator><author>Alexwan</author><pubDate>Thu, 23 Oct 2008 08:02:00 GMT</pubDate><guid>http://www.aygfsteel.com/alexwan/archive/2008/10/23/236194.html</guid><wfw:comment>http://www.aygfsteel.com/alexwan/comments/236194.html</wfw:comment><comments>http://www.aygfsteel.com/alexwan/archive/2008/10/23/236194.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/alexwan/comments/commentRss/236194.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/alexwan/services/trackbacks/236194.html</trackback:ping><description><![CDATA[     摘要: Expression JspTaglibs is undefined的解军_?nbsp; <a href='http://www.aygfsteel.com/alexwan/archive/2008/10/23/236194.html'>阅读全文</a><img src ="http://www.aygfsteel.com/alexwan/aggbug/236194.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/alexwan/" target="_blank">Alexwan</a> 2008-10-23 16:02 <a href="http://www.aygfsteel.com/alexwan/archive/2008/10/23/236194.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[eclipse]eclipse svn更换帐号的方?/title><link>http://www.aygfsteel.com/alexwan/archive/2008/10/16/234721.html</link><dc:creator>Alexwan</dc:creator><author>Alexwan</author><pubDate>Thu, 16 Oct 2008 08:53:00 GMT</pubDate><guid>http://www.aygfsteel.com/alexwan/archive/2008/10/16/234721.html</guid><wfw:comment>http://www.aygfsteel.com/alexwan/comments/234721.html</wfw:comment><comments>http://www.aygfsteel.com/alexwan/archive/2008/10/16/234721.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.aygfsteel.com/alexwan/comments/commentRss/234721.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/alexwan/services/trackbacks/234721.html</trackback:ping><description><![CDATA[     摘要: ׃在svn的界面中q没有ؓ我们提供直接更换用户名密码的地方Q所以一旦我们需要更换用户名的就需要自己想一些办法?<br>  <a href='http://www.aygfsteel.com/alexwan/archive/2008/10/16/234721.html'>阅读全文</a><img src ="http://www.aygfsteel.com/alexwan/aggbug/234721.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/alexwan/" target="_blank">Alexwan</a> 2008-10-16 16:53 <a href="http://www.aygfsteel.com/alexwan/archive/2008/10/16/234721.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[linux]linux下集成apache和tomcat时可能用到的命ohttp://www.aygfsteel.com/alexwan/archive/2008/10/05/232423.htmlAlexwanAlexwanSat, 04 Oct 2008 16:10:00 GMThttp://www.aygfsteel.com/alexwan/archive/2008/10/05/232423.htmlhttp://www.aygfsteel.com/alexwan/comments/232423.htmlhttp://www.aygfsteel.com/alexwan/archive/2008/10/05/232423.html#Feedback0http://www.aygfsteel.com/alexwan/comments/commentRss/232423.htmlhttp://www.aygfsteel.com/alexwan/services/trackbacks/232423.html         在apache2和tomcat5集成的环境下Q通常会把静态文Ӟ如shtml文gQ存攑֜apache的目录下Q而动态文件则存在在tomcat的管辖范围内Q因为开发过E中q没有将q两cL件分开Q所以在讉K静态文件是需要做个映?br />
        假设集成环境中,装有apache2的机器在局域网中的地址?92.168.1.55Q下面简U?5Q装有tomcat5的机器的地址?92.168.1.66Q后面简U?6
那么?5中需要提供的是NFS服务Q?br />
?etc/exports中添加如下语句:

{apache2_home}/htdocs     192.168.1.*(ro,no_root_squash)

其中
{apache2_home}/是指apache2的安装目录;
192.168.1.*是指可访问的?br /> ro选项是指讉K的权?br /> no_root_squash选项是指55的root在这个文件夹下没有写的权?br />


开启NFS服务的命令:

service nfs start

然后?6中运行另外一个命令:

mount -o nolock 192.168.1.55:{apache2_home}/htdocs {tomcat_home}/webapps/ROOT


PS:如果修改?etc/exports的话需要重新开启nfs服务Q那么关闭的命o是:service nfs stop?br />

Alexwan 2008-10-05 00:10 发表评论
]]>
[Tomcat]linux下改变tomcat5.5的内存设|?/title><link>http://www.aygfsteel.com/alexwan/archive/2008/09/12/228537.html</link><dc:creator>Alexwan</dc:creator><author>Alexwan</author><pubDate>Fri, 12 Sep 2008 02:58:00 GMT</pubDate><guid>http://www.aygfsteel.com/alexwan/archive/2008/09/12/228537.html</guid><wfw:comment>http://www.aygfsteel.com/alexwan/comments/228537.html</wfw:comment><comments>http://www.aygfsteel.com/alexwan/archive/2008/09/12/228537.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/alexwan/comments/commentRss/228537.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/alexwan/services/trackbacks/228537.html</trackback:ping><description><![CDATA[打开在Tomcat的安装目录的bin文g的catalina.sh文g,q入~辑状?<br /> 在注释后面加上如下脚?<br /> JAVA_OPTS='-Xms512m -Xmx1024m'<br /> JAVA_OPTS="$JAVA_OPTS -server -XX:PermSize=64M -XX:MaxPermSize=256m"<br /> <br /> 其中 JAVA_OPTS='-Xms512m -Xmx1024m' 是设|Tomcat使用的内存的大小.<br /> <br /> -XX:PermSize=64M -XX:MaxPermSize=256m 指定cȝ?用于加蝲c?的内存大? <img src ="http://www.aygfsteel.com/alexwan/aggbug/228537.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/alexwan/" target="_blank">Alexwan</a> 2008-09-12 10:58 <a href="http://www.aygfsteel.com/alexwan/archive/2008/09/12/228537.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[CXF]Spring下设|CXF的WebService客户端超时时?/title><link>http://www.aygfsteel.com/alexwan/archive/2008/09/04/227009.html</link><dc:creator>Alexwan</dc:creator><author>Alexwan</author><pubDate>Thu, 04 Sep 2008 08:45:00 GMT</pubDate><guid>http://www.aygfsteel.com/alexwan/archive/2008/09/04/227009.html</guid><wfw:comment>http://www.aygfsteel.com/alexwan/comments/227009.html</wfw:comment><comments>http://www.aygfsteel.com/alexwan/archive/2008/09/04/227009.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/alexwan/comments/commentRss/227009.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/alexwan/services/trackbacks/227009.html</trackback:ping><description><![CDATA[<strong>背景</strong>:<br /> 在用WebService的时?我们可能需要一个备份的WebService服务?一旦主服务器down?我们可以使用备䆾的服务器.那么q里需要对客服端连接服务器的时间做一个修?<br /> <br /> 在Spring+CXF的WebService环境?客户端有两个旉属性是可配|的,分别是ConnectionTimeout和ReceiveTimeout.<br /> ConnectionTimeout--WebService以TCPq接为基,q个属性可以理解ؓtcp的握手时的时间设|?过讄的时间长则认为是q接时.以毫Uؓ单位,默认?0000毫秒,?0U?<br /> <br /> ReceiveTimeout -- q个属性是发送WebService的请求后{待响应的时?过讄的时长就认ؓ是响应超?以毫Uؓ单位,默认?0000毫秒,?0U?<br /> <br /> <br /> <strong>讄的例?/strong>:<br /> <br /> <div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><span style="color: #008080"> 1</span><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><span style="color: #0000ff"><?</span><span style="color: #ff00ff">xml version="1.0" encoding="UTF-8"</span><span style="color: #0000ff">?></span><span style="color: #000000"><br /> </span><span style="color: #008080"> 2</span><span style="color: #000000"><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff"><</span><span style="color: #800000">beans </span><span style="color: #ff0000">xmlns</span><span style="color: #0000ff">="http://www.springframework.org/schema/beans"</span><span style="color: #ff0000"><br /> </span><span style="color: #008080"> 3</span><span style="color: #ff0000"><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />    xmlns:xsi</span><span style="color: #0000ff">="http://www.w3.org/2001/XMLSchema-instance"</span><span style="color: #ff0000"><br /> </span><span style="color: #008080"> 4</span><span style="color: #ff0000"><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />    xmlns:jee</span><span style="color: #0000ff">="http://www.springframework.org/schema/jee"</span><span style="color: #ff0000"><br /> </span><span style="color: #008080"> 5</span><span style="color: #ff0000"><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />    xmlns:jaxws</span><span style="color: #0000ff">="http://cxf.apache.org/jaxws"</span><span style="color: #ff0000"><br /> </span><span style="color: #008080"> 6</span><span style="color: #ff0000"><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />    xmlns:http-conf</span><span style="color: #0000ff">="http://cxf.apache.org/transports/http/configuration"</span><span style="color: #ff0000"> <br /> </span><span style="color: #008080"> 7</span><span style="color: #ff0000"><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />    xsi:schemaLocation</span><span style="color: #0000ff">="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd<br /> </span><span style="color: #008080"> 8</span><span style="color: #0000ff"><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />           http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd<br /> </span><span style="color: #008080"> 9</span><span style="color: #0000ff"><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />           http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd<br /> </span><span style="color: #008080">10</span><span style="color: #0000ff"><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />           http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd "</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> </span><span style="color: #008080">11</span><span style="color: #000000"><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        </span><span style="color: #0000ff"><</span><span style="color: #800000">http-conf:conduit </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="{http://impl.service.product.super.com/}ProjectService.http-conduit"</span><span style="color: #0000ff">></span><span style="color: #000000"> <br /> </span><span style="color: #008080">12</span><span style="color: #000000"><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        </span><span style="color: #0000ff"><</span><span style="color: #800000">http-conf:client </span><span style="color: #ff0000">ConnectionTimeout</span><span style="color: #0000ff">="10000"</span><span style="color: #ff0000"> ReceiveTimeout</span><span style="color: #0000ff">="20000"</span><span style="color: #0000ff">/></span><span style="color: #000000"><br /> </span><span style="color: #008080">13</span><span style="color: #000000"><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />    </span><span style="color: #0000ff"></</span><span style="color: #800000">http-conf:conduit</span><span style="color: #0000ff">></span><span style="color: #000000"> <br /> </span><span style="color: #008080">14</span><span style="color: #000000"><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff"></</span><span style="color: #800000">beans</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> </span><span style="color: #008080">15</span><span style="color: #000000"><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span></div> <p> </p> <p><strong>q里需要注意的有几个地?/strong>:<br /> 1:需要指定http-conf名称I间 xmlns:http-conf=<a >http://cxf.apache.org/transports/http/configuration</a><br /> 2:指定模式位置: http://cxf.apache.org/transports/http/configuration <a >http://cxf.apache.org/schemas/configuration/http-conf.xsd</a><br /> 3:http-conf:conduit中的name属?指定讄生效的服?如例子中,只对服务名ؓ{http://impl.service.product.sww.com/}ProjectService的服务生?<br /> 使用下面的设|则会对所有服务生?br /> </p> <div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><span style="color: #0000ff"><</span><span style="color: #800000">http-conf:conduit </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="*.http-conduit"</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />      <img alt="" src="http://www.aygfsteel.com/Images/dot.gif" /><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff"></</span><span style="color: #800000">http-conf:conduit</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span></div> <p><br /> 更详l的配置请参考CXF官方文档:<br /> <br /> <a title="http://cwiki.apache.org/CXF20DOC/client-http-transport-including-ssl-support.html" >http://cwiki.apache.org/CXF20DOC/client-http-transport-including-ssl-support.html</a><br /> </p> <p> </p> <img src ="http://www.aygfsteel.com/alexwan/aggbug/227009.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/alexwan/" target="_blank">Alexwan</a> 2008-09-04 16:45 <a href="http://www.aygfsteel.com/alexwan/archive/2008/09/04/227009.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[J2EE]一些不错的文章http://www.aygfsteel.com/alexwan/archive/2008/09/03/226602.htmlAlexwanAlexwanWed, 03 Sep 2008 03:12:00 GMThttp://www.aygfsteel.com/alexwan/archive/2008/09/03/226602.htmlhttp://www.aygfsteel.com/alexwan/comments/226602.htmlhttp://www.aygfsteel.com/alexwan/archive/2008/09/03/226602.html#Feedback0http://www.aygfsteel.com/alexwan/comments/commentRss/226602.htmlhttp://www.aygfsteel.com/alexwan/services/trackbacks/226602.html 攉一些好文章的链?Z方便而已.

最后更新时?:2008-09-03



配置c?

L实现Apache,Tomcat集群和负载均?/a>

java中的路径问题

数据库类:

oracle 分区表的建立Ҏ(gu)

励志c?



Alexwan 2008-09-03 11:12 发表评论
]]>
[hibernate]hibernate中自定义主键生成?/title><link>http://www.aygfsteel.com/alexwan/archive/2008/09/02/226316.html</link><dc:creator>Alexwan</dc:creator><author>Alexwan</author><pubDate>Tue, 02 Sep 2008 03:59:00 GMT</pubDate><guid>http://www.aygfsteel.com/alexwan/archive/2008/09/02/226316.html</guid><wfw:comment>http://www.aygfsteel.com/alexwan/comments/226316.html</wfw:comment><comments>http://www.aygfsteel.com/alexwan/archive/2008/09/02/226316.html#Feedback</comments><slash:comments>8</slash:comments><wfw:commentRss>http://www.aygfsteel.com/alexwan/comments/commentRss/226316.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/alexwan/services/trackbacks/226316.html</trackback:ping><description><![CDATA[<strong>背景</strong>:<br /> Hibernate(目前使用的版本是3.2)中提供了多种生成主键的方?在下面的文章中有列出?br /> <a title="[hibernate]Hibernate主键生成方式 Key Generator " href="http://www.aygfsteel.com/alexwan/archive/2008/09/02/226299.html">[hibernate]Hibernate主键生成方式 Key Generator </a><br /> <br /> 然而当前的q么多种生成方式未必能满x们的要求.<br /> 比如<strong>increment</strong>,可以在一个hibernate实例的应用上很方便的时?但是在集的时候就不行?<br /> 再如<strong> identity</strong> ,<strong>sequence</strong> ,<strong>native</strong> 是数据局提供的主键生成方?往往也不是我们需?而且在程序跨数据库方面也体现Z?<br /> q有Z法的生成方式生成出来的主键基本都是字符串的.<br /> <br /> 我们现在需要一U生成方?使用Long作ؓ主键cd,自动?支持集群.<br /> 那么我们需要自定义一个我们的主键生成器才能实C.<br /> <br /> <strong>实现代码</strong>:<br /> <div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /><span style="color: #0000ff">package</span><span style="color: #000000"> hibernate;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> java.io.Serializable;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> java.sql.Connection;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> java.sql.PreparedStatement;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> java.sql.ResultSet;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> java.sql.SQLException;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> java.util.Properties;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> org.apache.commons.logging.Log;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> org.apache.commons.logging.LogFactory;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> org.hibernate.HibernateException;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> org.hibernate.MappingException;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> org.hibernate.dialect.Dialect;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> org.hibernate.engine.SessionImplementor;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> org.hibernate.id.Configurable;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> org.hibernate.id.IdentifierGenerator;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> org.hibernate.id.PersistentIdentifierGenerator;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> org.hibernate.type.Type;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /><br /> <img id="Codehighlighter1_699_2226_Open_Image" onclick="this.style.display='none'; Codehighlighter1_699_2226_Open_Text.style.display='none'; Codehighlighter1_699_2226_Closed_Image.style.display='inline'; Codehighlighter1_699_2226_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_699_2226_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_699_2226_Closed_Text.style.display='none'; Codehighlighter1_699_2226_Open_Image.style.display='inline'; Codehighlighter1_699_2226_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align="top" alt="" /></span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">class</span><span style="color: #000000"> IncrementGenerator </span><span style="color: #0000ff">implements</span><span style="color: #000000"> IdentifierGenerator, Configurable </span><span id="Codehighlighter1_699_2226_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_699_2226_Open_Text"><span style="color: #000000">{<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />    </span><span style="color: #0000ff">private</span><span style="color: #000000"> </span><span style="color: #0000ff">static</span><span style="color: #000000"> </span><span style="color: #0000ff">final</span><span style="color: #000000"> Log log </span><span style="color: #000000">=</span><span style="color: #000000"> LogFactory.getLog(IncrementGenerator.</span><span style="color: #0000ff">class</span><span style="color: #000000">);<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />    </span><span style="color: #0000ff">private</span><span style="color: #000000"> Long next;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />    </span><span style="color: #0000ff">private</span><span style="color: #000000"> String sql;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />    </span><span style="color: #0000ff">public</span><span style="color: #000000"> Serializable generate(SessionImplementor session, Object object)<br /> <img id="Codehighlighter1_927_1025_Open_Image" onclick="this.style.display='none'; Codehighlighter1_927_1025_Open_Text.style.display='none'; Codehighlighter1_927_1025_Closed_Image.style.display='inline'; Codehighlighter1_927_1025_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_927_1025_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_927_1025_Closed_Text.style.display='none'; Codehighlighter1_927_1025_Open_Image.style.display='inline'; Codehighlighter1_927_1025_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />            </span><span style="color: #0000ff">throws</span><span style="color: #000000"> HibernateException </span><span id="Codehighlighter1_927_1025_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_927_1025_Open_Text"><span style="color: #000000">{<br /> <img id="Codehighlighter1_946_1001_Open_Image" onclick="this.style.display='none'; Codehighlighter1_946_1001_Open_Text.style.display='none'; Codehighlighter1_946_1001_Closed_Image.style.display='inline'; Codehighlighter1_946_1001_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_946_1001_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_946_1001_Closed_Text.style.display='none'; Codehighlighter1_946_1001_Open_Image.style.display='inline'; Codehighlighter1_946_1001_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">if</span><span style="color: #000000"> (sql</span><span style="color: #000000">!=</span><span style="color: #0000ff">null</span><span style="color: #000000">) </span><span id="Codehighlighter1_946_1001_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_946_1001_Open_Text"><span style="color: #000000">{<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />            getNext( session.connection() );<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />        }</span></span><span style="color: #000000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />       </span><span style="color: #0000ff">return</span><span style="color: #000000"> next;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" /><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />    }</span></span><span style="color: #000000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />    <br /> <img id="Codehighlighter1_1117_1607_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1117_1607_Open_Text.style.display='none'; Codehighlighter1_1117_1607_Closed_Image.style.display='inline'; Codehighlighter1_1117_1607_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_1117_1607_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_1117_1607_Closed_Text.style.display='none'; Codehighlighter1_1117_1607_Open_Image.style.display='inline'; Codehighlighter1_1117_1607_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />    </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">void</span><span style="color: #000000"> configure(Type type, Properties params, Dialect d) </span><span style="color: #0000ff">throws</span><span style="color: #000000"> MappingException </span><span id="Codehighlighter1_1117_1607_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_1117_1607_Open_Text"><span style="color: #000000">{<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        String table </span><span style="color: #000000">=</span><span style="color: #000000"> params.getProperty(</span><span style="color: #000000">"</span><span style="color: #000000">table</span><span style="color: #000000">"</span><span style="color: #000000">);<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">if</span><span style="color: #000000"> (table</span><span style="color: #000000">==</span><span style="color: #0000ff">null</span><span style="color: #000000">) table </span><span style="color: #000000">=</span><span style="color: #000000"> params.getProperty(PersistentIdentifierGenerator.TABLE);<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        String column </span><span style="color: #000000">=</span><span style="color: #000000"> params.getProperty(</span><span style="color: #000000">"</span><span style="color: #000000">column</span><span style="color: #000000">"</span><span style="color: #000000">);<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">if</span><span style="color: #000000"> (column</span><span style="color: #000000">==</span><span style="color: #0000ff">null</span><span style="color: #000000">) column </span><span style="color: #000000">=</span><span style="color: #000000"> params.getProperty(PersistentIdentifierGenerator.PK);<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        String schema </span><span style="color: #000000">=</span><span style="color: #000000"> params.getProperty(PersistentIdentifierGenerator.SCHEMA);<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        sql </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">"</span><span style="color: #000000">select max(</span><span style="color: #000000">"</span><span style="color: #000000">+</span><span style="color: #000000">column </span><span style="color: #000000">+</span><span style="color: #000000">"</span><span style="color: #000000">) from </span><span style="color: #000000">"</span><span style="color: #000000"> </span><span style="color: #000000">+</span><span style="color: #000000"> ( schema</span><span style="color: #000000">==</span><span style="color: #0000ff">null</span><span style="color: #000000"> </span><span style="color: #000000">?</span><span style="color: #000000"> table : schema </span><span style="color: #000000">+</span><span style="color: #000000"> </span><span style="color: #000000">'</span><span style="color: #000000">.</span><span style="color: #000000">'</span><span style="color: #000000"> </span><span style="color: #000000">+</span><span style="color: #000000"> table );<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        log.info(sql);<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />    }</span></span><span style="color: #000000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />    <br /> <img id="Codehighlighter1_1677_2224_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1677_2224_Open_Text.style.display='none'; Codehighlighter1_1677_2224_Closed_Image.style.display='inline'; Codehighlighter1_1677_2224_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_1677_2224_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_1677_2224_Closed_Text.style.display='none'; Codehighlighter1_1677_2224_Open_Image.style.display='inline'; Codehighlighter1_1677_2224_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />     </span><span style="color: #0000ff">private</span><span style="color: #000000"> </span><span style="color: #0000ff">void</span><span style="color: #000000"> getNext(Connection conn) </span><span style="color: #0000ff">throws</span><span style="color: #000000"> HibernateException </span><span id="Codehighlighter1_1677_2224_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_1677_2224_Open_Text"><span style="color: #000000">{<br /> <img id="Codehighlighter1_1692_1961_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1692_1961_Open_Text.style.display='none'; Codehighlighter1_1692_1961_Closed_Image.style.display='inline'; Codehighlighter1_1692_1961_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_1692_1961_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_1692_1961_Closed_Text.style.display='none'; Codehighlighter1_1692_1961_Open_Image.style.display='inline'; Codehighlighter1_1692_1961_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />            </span><span style="color: #0000ff">try</span><span style="color: #000000"> </span><span id="Codehighlighter1_1692_1961_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_1692_1961_Open_Text"><span style="color: #000000">{<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                PreparedStatement st </span><span style="color: #000000">=</span><span style="color: #000000"> conn.prepareStatement(sql);<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                ResultSet rs </span><span style="color: #000000">=</span><span style="color: #000000"> st.executeQuery();<br /> <img id="Codehighlighter1_1829_1887_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1829_1887_Open_Text.style.display='none'; Codehighlighter1_1829_1887_Closed_Image.style.display='inline'; Codehighlighter1_1829_1887_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_1829_1887_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_1829_1887_Closed_Text.style.display='none'; Codehighlighter1_1829_1887_Open_Image.style.display='inline'; Codehighlighter1_1829_1887_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />                </span><span style="color: #0000ff">if</span><span style="color: #000000"> ( rs.next() ) </span><span id="Codehighlighter1_1829_1887_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_1829_1887_Open_Text"><span style="color: #000000">{<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                    next </span><span style="color: #000000">=</span><span style="color: #000000"> rs.getLong(</span><span style="color: #000000">1</span><span style="color: #000000">) </span><span style="color: #000000">+</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000">;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />                }</span></span><span style="color: #000000"><br /> <img id="Codehighlighter1_1907_1950_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1907_1950_Open_Text.style.display='none'; Codehighlighter1_1907_1950_Closed_Image.style.display='inline'; Codehighlighter1_1907_1950_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_1907_1950_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_1907_1950_Closed_Text.style.display='none'; Codehighlighter1_1907_1950_Open_Image.style.display='inline'; Codehighlighter1_1907_1950_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />                </span><span style="color: #0000ff">else</span><span style="color: #000000"> </span><span id="Codehighlighter1_1907_1950_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_1907_1950_Open_Text"><span style="color: #000000">{<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                    next </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">1l</span><span style="color: #000000">;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />                }</span></span><span style="color: #000000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />            }</span></span><span style="color: #0000ff">catch</span><span style="color: #000000">(SQLException e)<br /> <img id="Codehighlighter1_1993_2047_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1993_2047_Open_Text.style.display='none'; Codehighlighter1_1993_2047_Closed_Image.style.display='inline'; Codehighlighter1_1993_2047_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_1993_2047_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_1993_2047_Closed_Text.style.display='none'; Codehighlighter1_1993_2047_Open_Image.style.display='inline'; Codehighlighter1_1993_2047_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />            </span><span id="Codehighlighter1_1993_2047_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_1993_2047_Open_Text"><span style="color: #000000">{<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                </span><span style="color: #0000ff">throw</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> HibernateException(e);<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />            }</span></span><span style="color: #000000"><br /> <img id="Codehighlighter1_2066_2217_Open_Image" onclick="this.style.display='none'; Codehighlighter1_2066_2217_Open_Text.style.display='none'; Codehighlighter1_2066_2217_Closed_Image.style.display='inline'; Codehighlighter1_2066_2217_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_2066_2217_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_2066_2217_Closed_Text.style.display='none'; Codehighlighter1_2066_2217_Open_Image.style.display='inline'; Codehighlighter1_2066_2217_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />            </span><span style="color: #0000ff">finally</span><span style="color: #000000"> </span><span id="Codehighlighter1_2066_2217_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_2066_2217_Open_Text"><span style="color: #000000">{<br /> <img id="Codehighlighter1_2081_2117_Open_Image" onclick="this.style.display='none'; Codehighlighter1_2081_2117_Open_Text.style.display='none'; Codehighlighter1_2081_2117_Closed_Image.style.display='inline'; Codehighlighter1_2081_2117_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_2081_2117_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_2081_2117_Closed_Text.style.display='none'; Codehighlighter1_2081_2117_Open_Image.style.display='inline'; Codehighlighter1_2081_2117_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />                </span><span style="color: #0000ff">try</span><span id="Codehighlighter1_2081_2117_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_2081_2117_Open_Text"><span style="color: #000000">{<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                conn.close();<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />                }</span></span><span style="color: #0000ff">catch</span><span style="color: #000000">(SQLException e)<br /> <img id="Codehighlighter1_2150_2206_Open_Image" onclick="this.style.display='none'; Codehighlighter1_2150_2206_Open_Text.style.display='none'; Codehighlighter1_2150_2206_Closed_Image.style.display='inline'; Codehighlighter1_2150_2206_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_2150_2206_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_2150_2206_Closed_Text.style.display='none'; Codehighlighter1_2150_2206_Open_Image.style.display='inline'; Codehighlighter1_2150_2206_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />                </span><span id="Codehighlighter1_2150_2206_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_2150_2206_Open_Text"><span style="color: #000000">{<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                    </span><span style="color: #0000ff">throw</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> HibernateException(e);<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />                }</span></span><span style="color: #000000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />            }</span></span><span style="color: #000000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />        }</span></span><span style="color: #000000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" alt="" />}</span></span><span style="color: #000000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span></div> <br /> <br /> 配置:<br /> 在对应的hbm文g里面id的配|如?<br /> <div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /><span style="color: #000000">        </span><span style="color: #0000ff"><</span><span style="color: #800000">id </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="id"</span><span style="color: #ff0000"> type</span><span style="color: #0000ff">="long"</span><span style="color: #ff0000"> column</span><span style="color: #0000ff">="id"</span><span style="color: #ff0000"> </span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" />            </span><span style="color: #0000ff"><</span><span style="color: #800000">generator </span><span style="color: #ff0000">class</span><span style="color: #0000ff">="hibernate.IncrementGenerator"</span><span style="color: #ff0000"> </span><span style="color: #0000ff">/></span><span style="color: #000000"> <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" />        </span><span style="color: #0000ff"></</span><span style="color: #800000">id</span><span style="color: #0000ff">></span></div> <br /> ps:此生成方式仅通过两个hibernate实例试,如发现有问题,La.<br /> <img src ="http://www.aygfsteel.com/alexwan/aggbug/226316.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/alexwan/" target="_blank">Alexwan</a> 2008-09-02 11:59 <a href="http://www.aygfsteel.com/alexwan/archive/2008/09/02/226316.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[hibernate]Hibernate主键生成方式 Key Generatorhttp://www.aygfsteel.com/alexwan/archive/2008/09/02/226299.htmlAlexwanAlexwanTue, 02 Sep 2008 03:24:00 GMThttp://www.aygfsteel.com/alexwan/archive/2008/09/02/226299.htmlhttp://www.aygfsteel.com/alexwan/comments/226299.htmlhttp://www.aygfsteel.com/alexwan/archive/2008/09/02/226299.html#Feedback0http://www.aygfsteel.com/alexwan/comments/commentRss/226299.htmlhttp://www.aygfsteel.com/alexwan/services/trackbacks/226299.html   主键产生? 
  可选项说明Q? 
  1)   assigned  
  主键由外部程序负责生成,无需Hibernate参与? 
   
  2)   hilo  
  通过hi/lo   法实现的主键生成机Ӟ需要额外的数据库表保存? 
  键生成历史状态? 
   
  3)   seqhilo  
  与hilo   cMQ通过hi/lo   法实现的主键生成机Ӟ只是主键历史  
  状态保存在Sequence中,适用于支持Sequence的数据库Q如Oracle? 
   
  4)   increment  
  主键按数值顺序递增。此方式的实现机制ؓ在当前应用实例中l持  
  一个变量,以保存着当前的最大|之后每次需要生成主键的时? 
  此值加1作ؓ主键? 
  q种方式可能产生的问题是Q如果当前有多个实例讉K同一个数? 
  库,那么׃各个实例各自l护主键状态,不同实例可能生成同样  
  的主键,从而造成主键重复异常。因此,如果同一数据库有多个? 
  例访问,此方式必避免用? 
   
  5)   identity  
  采用数据库提供的主键生成机制。如DB2、SQL   Server、MySQL  
  中的主键生成机制? 
   
  6)   sequence  
  采用数据库提供的sequence   机制生成主键。如Oralce   中的  
  Sequence? 
   
  7)   native  
  由HibernateҎ(gu)底层数据库自行判断采用identity、hilo、sequence  
  其中一U作Z键生成方式? 
   
  8)   uuid.hex  
  由HibernateZ128   位唯一g生算法生?6   q制数|~码? 
  以长?2   的字W串表示Q作Z键? 
   
  9)   uuid.string  
  与uuid.hex   cMQ只是生成的主键未进行编码(长度16Q。在某些  
  数据库中可能出现问题Q如PostgreSQLQ? 
   
  10)   foreign  
  使用外部表的字段作ؓ主键? 
  一般而言Q利用uuid.hex方式生成主键提供最好的性能和数据库q_? 
  应性? 
   
  另外׃常用的数据库Q如Oracle、DB2、SQLServer、MySql   {,都提  
  供了易用的主键生成机ӞAuto-Increase   字段或者SequenceQ。我们可以在? 
  据库提供的主键生成机制上Q采用generator-class=native的主键生成方式? 
  不过值得注意的是Q一些数据库提供的主键生成机制在效率上未必最佻I  
  大量q发insert数据时可能会引v表之间的互锁? 
  数据库提供的主键生成机制Q往往是通过在一个内部表中保存当前主键状  
  态(如对于自增型主键而言Q此内部表中q护着当前的最大值和递增量)Q? 
  之后每次插入数据会读取这个最大|然后加上递增量作为新记录的主键,? 
  后再把这个新的最大值更新回内部表中Q这P一ơInsert操作可能D数据  
  库内部多ơ表d操作Q同时伴随的q有数据的加锁解锁操作,q对性能产生  
  了较大媄响? 
  因此Q对于ƈ发Insert要求较高的系l,推荐采用uuid.hex   作ؓ主键生成  
  机制?nbsp;   


Alexwan 2008-09-02 11:24 发表评论
]]>
吃力不讨好的旧系l数据导入到新系l?/title><link>http://www.aygfsteel.com/alexwan/archive/2008/08/15/222131.html</link><dc:creator>Alexwan</dc:creator><author>Alexwan</author><pubDate>Thu, 14 Aug 2008 18:39:00 GMT</pubDate><guid>http://www.aygfsteel.com/alexwan/archive/2008/08/15/222131.html</guid><wfw:comment>http://www.aygfsteel.com/alexwan/comments/222131.html</wfw:comment><comments>http://www.aygfsteel.com/alexwan/archive/2008/08/15/222131.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.aygfsteel.com/alexwan/comments/commentRss/222131.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/alexwan/services/trackbacks/222131.html</trackback:ping><description><![CDATA[         Ҏ(gu)的系l进行改造后,在新的系l里面数据的l构和关p都和以前有了比较大的变?q种情况?我们没有办法借助数据的导入导出工具去直接地将两个pȝ的数据融合v?那么唯一的办法就是通过写程序的来实C!<br />         可是事实?q种导数据的工作q不是想象中的那么简?首先需要清楚两个系l中各自内部的数据的关系是怎么L,否则Ҏ(gu)׃知道如何d关系的处?q样的事情不是普通的E序员能处理?甚至p有经验的E序员也没有一个行之有效的Ҏ(gu)去迅速的完成d!那怎么办呢?只好动用较有l验,Ҏ(gu)旧系l都有相当了解的E序员去做了!L有h认ؓq些个问题到了他?前面指的有经验的E序?,可以迎刃而解?D不?无论对谁都会造成很大的损?也很能了解的这些Q务需要耗费多少旉和精力去?<br />         q有一点也是最重要的一?是程序员所不能接受?是q个导数据的E序,在导完数据之后就失去了存在意义了.对程序员而言,不异于要抛弃自己的孩子一L?同时也是对程序员力_的不重!<br />         可是现实往往不是E序员能左右?数据q是要导,_֊和时间还是要耗费q些一ơ性的代码里面!<br />         对于q样的需?个h深恶痛绝?同时q处境感觉很无?<br />         希望q是最后一ơ这么做! <img src ="http://www.aygfsteel.com/alexwan/aggbug/222131.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/alexwan/" target="_blank">Alexwan</a> 2008-08-15 02:39 <a href="http://www.aygfsteel.com/alexwan/archive/2008/08/15/222131.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[Extjs]输出JSON时图片及文g需要单独处?/title><link>http://www.aygfsteel.com/alexwan/archive/2008/07/18/215900.html</link><dc:creator>Alexwan</dc:creator><author>Alexwan</author><pubDate>Fri, 18 Jul 2008 13:41:00 GMT</pubDate><guid>http://www.aygfsteel.com/alexwan/archive/2008/07/18/215900.html</guid><wfw:comment>http://www.aygfsteel.com/alexwan/comments/215900.html</wfw:comment><comments>http://www.aygfsteel.com/alexwan/archive/2008/07/18/215900.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/alexwan/comments/commentRss/215900.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/alexwan/services/trackbacks/215900.html</trackback:ping><description><![CDATA[[Extjs]输出JSON是图片及文g需要单独处?br /> 今天在用Extjs开发的后台pȝ中碰C个很奇怪的错误,从一个只有很记录的数据表中查数据出来竟然用?U多;<br /> 而且会在firefox中可以显C出?在IE中却没有昄出来(通过grid来显C?,最?我通过在服务端打印响应中的内容,<br /> 竟然让我的eclipse都卡住了,{缓q来查看输出的时候发?原来是服务端输出json的时候把囄的字节g一h印出来了,<br /> 所以才会导致eclipse卡住q且即能输Z是相当得?而且几条数据的图片的输出值就让IE处理不了!!<br /> 所?如果要在数据表内存储囄(文g)?不能图片的字节g当作JSON输出到客L,如果需要显C是单独处理ؓ? <img src ="http://www.aygfsteel.com/alexwan/aggbug/215900.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/alexwan/" target="_blank">Alexwan</a> 2008-07-18 21:41 <a href="http://www.aygfsteel.com/alexwan/archive/2008/07/18/215900.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>单实现MD5加密字符?/title><link>http://www.aygfsteel.com/alexwan/archive/2008/06/30/211786.html</link><dc:creator>Alexwan</dc:creator><author>Alexwan</author><pubDate>Mon, 30 Jun 2008 15:34:00 GMT</pubDate><guid>http://www.aygfsteel.com/alexwan/archive/2008/06/30/211786.html</guid><wfw:comment>http://www.aygfsteel.com/alexwan/comments/211786.html</wfw:comment><comments>http://www.aygfsteel.com/alexwan/archive/2008/06/30/211786.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/alexwan/comments/commentRss/211786.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/alexwan/services/trackbacks/211786.html</trackback:ping><description><![CDATA[<div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><span style="color: #008080"> 1</span><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /><span style="color: #0000ff">package</span><span style="color: #000000"> util;<br /> </span><span style="color: #008080"> 2</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /><br /> </span><span style="color: #008080"> 3</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> java.security.MessageDigest;<br /> </span><span style="color: #008080"> 4</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /><br /> </span><span style="color: #008080"> 5</span><span style="color: #000000"><img id="Codehighlighter1_76_1718_Open_Image" onclick="this.style.display='none'; Codehighlighter1_76_1718_Open_Text.style.display='none'; Codehighlighter1_76_1718_Closed_Image.style.display='inline'; Codehighlighter1_76_1718_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_76_1718_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_76_1718_Closed_Text.style.display='none'; Codehighlighter1_76_1718_Open_Image.style.display='inline'; Codehighlighter1_76_1718_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align="top" alt="" /></span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">class</span><span style="color: #000000"> StringUtil </span><span id="Codehighlighter1_76_1718_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_76_1718_Open_Text"><span style="color: #000000">{<br /> </span><span style="color: #008080"> 6</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        <br /> </span><span style="color: #008080"> 7</span><span style="color: #000000"><img id="Codehighlighter1_124_220_Open_Image" onclick="this.style.display='none'; Codehighlighter1_124_220_Open_Text.style.display='none'; Codehighlighter1_124_220_Closed_Image.style.display='inline'; Codehighlighter1_124_220_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_124_220_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_124_220_Closed_Text.style.display='none'; Codehighlighter1_124_220_Open_Image.style.display='inline'; Codehighlighter1_124_220_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />    </span><span style="color: #0000ff">private</span><span style="color: #000000"> </span><span style="color: #0000ff">final</span><span style="color: #000000"> </span><span style="color: #0000ff">static</span><span style="color: #000000"> String[] hexDigits </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span id="Codehighlighter1_124_220_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_124_220_Open_Text"><span style="color: #000000">{ <br /> </span><span style="color: #008080"> 8</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />          </span><span style="color: #000000">"</span><span style="color: #000000">0</span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">"</span><span style="color: #000000">1</span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">"</span><span style="color: #000000">2</span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">"</span><span style="color: #000000">3</span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">"</span><span style="color: #000000">4</span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">"</span><span style="color: #000000">5</span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">"</span><span style="color: #000000">6</span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">"</span><span style="color: #000000">7</span><span style="color: #000000">"</span><span style="color: #000000">, <br /> </span><span style="color: #008080"> 9</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />          </span><span style="color: #000000">"</span><span style="color: #000000">8</span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">"</span><span style="color: #000000">9</span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">"</span><span style="color: #000000">a</span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">"</span><span style="color: #000000">b</span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">"</span><span style="color: #000000">c</span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">"</span><span style="color: #000000">d</span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">"</span><span style="color: #000000">e</span><span style="color: #000000">"</span><span style="color: #000000">, </span><span style="color: #000000">"</span><span style="color: #000000">f</span><span style="color: #000000">"</span><span style="color: #000000">}</span></span><span style="color: #000000">; <br /> </span><span style="color: #008080">10</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" /><br /> </span><span style="color: #008080">11</span><span style="color: #000000"><img id="Codehighlighter1_228_302_Open_Image" onclick="this.style.display='none'; Codehighlighter1_228_302_Open_Text.style.display='none'; Codehighlighter1_228_302_Closed_Image.style.display='inline'; Codehighlighter1_228_302_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_228_302_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_228_302_Closed_Text.style.display='none'; Codehighlighter1_228_302_Open_Image.style.display='inline'; Codehighlighter1_228_302_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />      </span><span id="Codehighlighter1_228_302_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff">/** */</span><span id="Codehighlighter1_228_302_Open_Text"><span style="color: #008000">/**</span><span style="color: #008000"> <br /> </span><span style="color: #008080">12</span><span style="color: #008000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />       * 转换字节数组?6q制字串 <br /> </span><span style="color: #008080">13</span><span style="color: #008000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />       * </span><span style="color: #808080">@param</span><span style="color: #008000"> b 字节数组 <br /> </span><span style="color: #008080">14</span><span style="color: #008000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />       * </span><span style="color: #808080">@return</span><span style="color: #008000"> 16q制字串 <br /> </span><span style="color: #008080">15</span><span style="color: #008000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />       </span><span style="color: #008000">*/</span></span><span style="color: #000000"> <br /> </span><span style="color: #008080">16</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" /><br /> </span><span style="color: #008080">17</span><span style="color: #000000"><img id="Codehighlighter1_361_550_Open_Image" onclick="this.style.display='none'; Codehighlighter1_361_550_Open_Text.style.display='none'; Codehighlighter1_361_550_Closed_Image.style.display='inline'; Codehighlighter1_361_550_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_361_550_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_361_550_Closed_Text.style.display='none'; Codehighlighter1_361_550_Open_Image.style.display='inline'; Codehighlighter1_361_550_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />      </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">static</span><span style="color: #000000"> String byteArrayToHexString(</span><span style="color: #0000ff">byte</span><span style="color: #000000">[] b) </span><span id="Codehighlighter1_361_550_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_361_550_Open_Text"><span style="color: #000000">{ <br /> </span><span style="color: #008080">18</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        StringBuffer resultSb </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> StringBuffer(); <br /> </span><span style="color: #008080">19</span><span style="color: #000000"><img id="Codehighlighter1_454_510_Open_Image" onclick="this.style.display='none'; Codehighlighter1_454_510_Open_Text.style.display='none'; Codehighlighter1_454_510_Closed_Image.style.display='inline'; Codehighlighter1_454_510_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_454_510_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_454_510_Closed_Text.style.display='none'; Codehighlighter1_454_510_Open_Image.style.display='inline'; Codehighlighter1_454_510_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">for</span><span style="color: #000000"> (</span><span style="color: #0000ff">int</span><span style="color: #000000"> i </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">0</span><span style="color: #000000">; i </span><span style="color: #000000"><</span><span style="color: #000000"> b.length; i</span><span style="color: #000000">++</span><span style="color: #000000">) </span><span id="Codehighlighter1_454_510_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_454_510_Open_Text"><span style="color: #000000">{ <br /> </span><span style="color: #008080">20</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />          resultSb.append(byteToHexString(b[i])); <br /> </span><span style="color: #008080">21</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />        }</span></span><span style="color: #000000"> <br /> </span><span style="color: #008080">22</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">return</span><span style="color: #000000"> resultSb.toString(); <br /> </span><span style="color: #008080">23</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />      }</span></span><span style="color: #000000"> <br /> </span><span style="color: #008080">24</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" /><br /> </span><span style="color: #008080">25</span><span style="color: #000000"><img id="Codehighlighter1_603_754_Open_Image" onclick="this.style.display='none'; Codehighlighter1_603_754_Open_Text.style.display='none'; Codehighlighter1_603_754_Closed_Image.style.display='inline'; Codehighlighter1_603_754_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_603_754_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_603_754_Closed_Text.style.display='none'; Codehighlighter1_603_754_Open_Image.style.display='inline'; Codehighlighter1_603_754_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />      </span><span style="color: #0000ff">private</span><span style="color: #000000"> </span><span style="color: #0000ff">static</span><span style="color: #000000"> String byteToHexString(</span><span style="color: #0000ff">byte</span><span style="color: #000000"> b) </span><span id="Codehighlighter1_603_754_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_603_754_Open_Text"><span style="color: #000000">{ <br /> </span><span style="color: #008080">26</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">int</span><span style="color: #000000"> n </span><span style="color: #000000">=</span><span style="color: #000000"> b; <br /> </span><span style="color: #008080">27</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">if</span><span style="color: #000000"> (n </span><span style="color: #000000"><</span><span style="color: #000000"> </span><span style="color: #000000">0</span><span style="color: #000000">) <br /> </span><span style="color: #008080">28</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />          n </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">256</span><span style="color: #000000"> </span><span style="color: #000000">+</span><span style="color: #000000"> n; <br /> </span><span style="color: #008080">29</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">int</span><span style="color: #000000"> d1 </span><span style="color: #000000">=</span><span style="color: #000000"> n </span><span style="color: #000000">/</span><span style="color: #000000"> </span><span style="color: #000000">16</span><span style="color: #000000">; <br /> </span><span style="color: #008080">30</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">int</span><span style="color: #000000"> d2 </span><span style="color: #000000">=</span><span style="color: #000000"> n </span><span style="color: #000000">%</span><span style="color: #000000"> </span><span style="color: #000000">16</span><span style="color: #000000">; <br /> </span><span style="color: #008080">31</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">return</span><span style="color: #000000"> hexDigits[d1] </span><span style="color: #000000">+</span><span style="color: #000000"> hexDigits[d2]; <br /> </span><span style="color: #008080">32</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />      }</span></span><span style="color: #000000"> <br /> </span><span style="color: #008080">33</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" /><br /> </span><span style="color: #008080">34</span><span style="color: #000000"><img id="Codehighlighter1_807_1114_Open_Image" onclick="this.style.display='none'; Codehighlighter1_807_1114_Open_Text.style.display='none'; Codehighlighter1_807_1114_Closed_Image.style.display='inline'; Codehighlighter1_807_1114_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_807_1114_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_807_1114_Closed_Text.style.display='none'; Codehighlighter1_807_1114_Open_Image.style.display='inline'; Codehighlighter1_807_1114_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />      </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">static</span><span style="color: #000000"> String MD5Encode(String origin) </span><span id="Codehighlighter1_807_1114_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_807_1114_Open_Text"><span style="color: #000000">{ <br /> </span><span style="color: #008080">35</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        String resultString </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">null</span><span style="color: #000000">; <br /> </span><span style="color: #008080">36</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" /><br /> </span><span style="color: #008080">37</span><span style="color: #000000"><img id="Codehighlighter1_854_1043_Open_Image" onclick="this.style.display='none'; Codehighlighter1_854_1043_Open_Text.style.display='none'; Codehighlighter1_854_1043_Closed_Image.style.display='inline'; Codehighlighter1_854_1043_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_854_1043_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_854_1043_Closed_Text.style.display='none'; Codehighlighter1_854_1043_Open_Image.style.display='inline'; Codehighlighter1_854_1043_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">try</span><span style="color: #000000"> </span><span id="Codehighlighter1_854_1043_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_854_1043_Open_Text"><span style="color: #000000">{ <br /> </span><span style="color: #008080">38</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />          resultString</span><span style="color: #000000">=</span><span style="color: #0000ff">new</span><span style="color: #000000"> String(origin); <br /> </span><span style="color: #008080">39</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />          MessageDigest md </span><span style="color: #000000">=</span><span style="color: #000000"> MessageDigest.getInstance(</span><span style="color: #000000">"</span><span style="color: #000000">MD5</span><span style="color: #000000">"</span><span style="color: #000000">); <br /> </span><span style="color: #008080">40</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />          resultString</span><span style="color: #000000">=</span><span style="color: #000000">byteArrayToHexString(md.digest(resultString.getBytes())); <br /> </span><span style="color: #008080">41</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />        }</span></span><span style="color: #000000"> <br /> </span><span style="color: #008080">42</span><span style="color: #000000"><img id="Codehighlighter1_1072_1081_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1072_1081_Open_Text.style.display='none'; Codehighlighter1_1072_1081_Closed_Image.style.display='inline'; Codehighlighter1_1072_1081_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_1072_1081_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_1072_1081_Closed_Text.style.display='none'; Codehighlighter1_1072_1081_Open_Image.style.display='inline'; Codehighlighter1_1072_1081_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">catch</span><span style="color: #000000"> (Exception ex) </span><span id="Codehighlighter1_1072_1081_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_1072_1081_Open_Text"><span style="color: #000000">{ <br /> </span><span style="color: #008080">43</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" /><br /> </span><span style="color: #008080">44</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />        }</span></span><span style="color: #000000"> <br /> </span><span style="color: #008080">45</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">return</span><span style="color: #000000"> resultString; <br /> </span><span style="color: #008080">46</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />      }</span></span><span style="color: #000000"> <br /> </span><span style="color: #008080">47</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" /><br /> </span><span style="color: #008080">48</span><span style="color: #000000"><img id="Codehighlighter1_1159_1415_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1159_1415_Open_Text.style.display='none'; Codehighlighter1_1159_1415_Closed_Image.style.display='inline'; Codehighlighter1_1159_1415_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_1159_1415_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_1159_1415_Closed_Text.style.display='none'; Codehighlighter1_1159_1415_Open_Image.style.display='inline'; Codehighlighter1_1159_1415_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />      </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">static</span><span style="color: #000000"> </span><span style="color: #0000ff">void</span><span style="color: #000000"> main(String[] args)</span><span id="Codehighlighter1_1159_1415_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_1159_1415_Open_Text"><span style="color: #000000">{ <br /> </span><span style="color: #008080">49</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />          System.err.println(MD5Encode(</span><span style="color: #000000">""</span><span style="color: #000000">)); <br /> </span><span style="color: #008080">50</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />          System.err.println(MD5Encode(</span><span style="color: #000000">"</span><span style="color: #000000">a</span><span style="color: #000000">"</span><span style="color: #000000">)); <br /> </span><span style="color: #008080">51</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />          System.err.println(MD5Encode(</span><span style="color: #000000">"</span><span style="color: #000000">abc</span><span style="color: #000000">"</span><span style="color: #000000">)); <br /> </span><span style="color: #008080">52</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />          System.err.println(MD5Encode(</span><span style="color: #000000">"</span><span style="color: #000000">message digest</span><span style="color: #000000">"</span><span style="color: #000000">)); <br /> </span><span style="color: #008080">53</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />          System.err.println(MD5Encode(</span><span style="color: #000000">"</span><span style="color: #000000">abcdefghijklmnopqrstuvwxyz</span><span style="color: #000000">"</span><span style="color: #000000">)); <br /> </span><span style="color: #008080">54</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        <br /> </span><span style="color: #008080">55</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />      }</span></span><span style="color: #000000"> <br /> </span><span style="color: #008080">56</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />      <br /> </span><span style="color: #008080">57</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />      </span><span style="color: #008000">//</span><span style="color: #008000">MD5 ("") = d41d8cd98f00b204e9800998ecf8427e<br /> </span><span style="color: #008080">58</span><span style="color: #008000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />      </span><span style="color: #008000">//</span><span style="color: #008000">MD5 ("a") = 0cc175b9c0f1b6a831c399e269772661<br /> </span><span style="color: #008080">59</span><span style="color: #008000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />      </span><span style="color: #008000">//</span><span style="color: #008000">MD5 ("abc") = 900150983cd24fb0d6963f7d28e17f72<br /> </span><span style="color: #008080">60</span><span style="color: #008000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />      </span><span style="color: #008000">//</span><span style="color: #008000">MD5 ("message digest") = f96b697d7cb7938d525a2f31aaf161d0<br /> </span><span style="color: #008080">61</span><span style="color: #008000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />      </span><span style="color: #008000">//</span><span style="color: #008000">MD5 ("abcdefghijklmnopqrstuvwxyz") = c3fcd3d76192e4007dfb496cca67e13b</span><span style="color: #008000"><br /> </span><span style="color: #008080">62</span><span style="color: #008000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" /></span><span style="color: #000000">       <br /> </span><span style="color: #008080">63</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" /><br /> </span><span style="color: #008080">64</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" /><br /> </span><span style="color: #008080">65</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" alt="" />}</span></span><span style="color: #000000"><br /> </span><span style="color: #008080">66</span><span style="color: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span></div> <img src ="http://www.aygfsteel.com/alexwan/aggbug/211786.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/alexwan/" target="_blank">Alexwan</a> 2008-06-30 23:34 <a href="http://www.aygfsteel.com/alexwan/archive/2008/06/30/211786.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Top Ten Errors Java Programmers Makehttp://www.aygfsteel.com/alexwan/archive/2008/06/24/210332.htmlAlexwanAlexwanTue, 24 Jun 2008 08:17:00 GMThttp://www.aygfsteel.com/alexwan/archive/2008/06/24/210332.htmlhttp://www.aygfsteel.com/alexwan/comments/210332.htmlhttp://www.aygfsteel.com/alexwan/archive/2008/06/24/210332.html#Feedback0http://www.aygfsteel.com/alexwan/comments/commentRss/210332.htmlhttp://www.aygfsteel.com/alexwan/services/trackbacks/210332.html http://www.javacoffeebreak.com/articles/toptenerrors.html

Whether you program regularly in Java, and know it like the back of your hand, or whether you're new to the language or a casual programmer, you'll make mistakes. It's natural, it's human, and guess what? You'll more than likely make the same mistakes that others do, over and over again. Here's my top ten list of errors that we all seem to make at one time or another,  how to spot them, and how to fix them.

10. Accessing non-static member variables from static methods (such as main)

Many programmers, particularly when first introduced to Java, have problems with accessing member variables from their main method. The method signature for main is marked static - meaning that we don't need to create an instance of the class to invoke the main method. For example, a Java Virtual Machine (JVM) could call the class MyApplication like this :-

MyApplication.main ( command_line_args );

This means, however, that there isn't an instance of MyApplication - it doesn't have any member variables to access! Take for example the following application, which will generate a compiler error message.

public class StaticDemo
{
public String my_member_variable = "somedata";
        public static void main (String args[])
{
// Access a non-static member from static method
System.out.println ("This generates a compiler error" +
my_member_variable );
}
}

If you want to access its member variables from a non-static method (like main), you must create an instance of the object. Here's a simple example of how to correctly write code to access non-static member variables, by first creating an instance of the object.

public class NonStaticDemo
{
public String my_member_variable = "somedata";
public static void main (String args[])
{
NonStaticDemo demo = new NonStaticDemo();
// Access member variable of demo
System.out.println ("This WON'T generate an error" +
demo.my_member_variable );
}
}

9. Mistyping the name of a method when overriding

Overriding allows programmers to replace a method's implementation with new code. Overriding is a handy feature, and most OO programmers make heavy use of it. If you use the AWT 1.1 event handling model, you'll often override listener implementations to provide custom functionality. One easy trap to fall into with overriding, is to mistype the method name. If you mistype the name, you're no longer overriding a method - you're creating an entirely new method, but with the same parameter and return type.

public class MyWindowListener extends WindowAdapter {
// This should be WindowClosed
public void WindowClose(WindowEvent e) {
// Exit when user closes window
System.exit(0);
}
});

Compilers won't pick up on this one, and the problem can be quite frustrating to detect. In the past, I've looked at a method, believed that it was being called, and taken ages to spot the problem. The symptom of this error will be that your code isn't being called, or you think the method has skipped over its code. The only way to ever be certain is to add a println statement, to record a message in a log file, or to use good trace debugger (like Visual J++ or Borland JBuilder) and step through line by line. If your method still isn't being called, then it's likely you've mistyped the name.

8. Comparison assignment (  = rather than == )

This is an easy error to make. If you're used other languages before, such as Pascal, you'll realize just how poor a choice this was by the language's designers. In Pascal, for example, we use the := operator for assignment, and leave = for comparison. This looks like a throwback to C/C++, from which Java draws its roots.

Fortunately, even if you don't spot this one by looking at code on the screen, your compiler will. Most commonly, it will report an error message like this : "Can't convert xxx to boolean", where xxx is a Java type that you're assigning instead of comparing.

7. Comparing two objects ( == instead of .equals)

When we use the == operator, we are actually comparing two object references, to see if they point to the same object. We cannot compare, for example, two strings for equality, using the == operator. We must instead use the .equals method, which is a method inherited by all classes from java.lang.Object.

Here's the correct way to compare two strings.

String abc = "abc"; String def = "def";
// Bad way
if ( (abc + def) == "abcdef" )
{
    ......
}
// Good way
if ( (abc + def).equals("abcdef") )
{
   .....
}

6. Confusion over passing by value, and passing by reference

This can be a frustrating problem to diagnose, because when you look at the code, you might be sure that its passing by reference, but find that its actually being passed by value. Java uses both, so you need to understand when you're passing by value, and when you're passing by reference.

When you pass a primitive data type, such as a char, int, float, or double, to a function then you are passing by value. That means that a copy of the data type is duplicated, and passed to the function. If the function chooses to modify that value, it will be modifying the copy only. Once the function finishes, and control is returned to the returning function, the "real" variable will be untouched, and no changes will have been saved. If you need to modify a primitive data type, make it a return value for a function, or wrap it inside an object.

When you pass a Java object, such as an array, a vector, or a string, to a function then you are passing by reference. Yes - a String is actually an object, not a primitive data type.  So that means that if you pass an object to a function, you are passing a reference to it, not a duplicate. Any changes you make to the object's member variables will be permanent - which can be either good or bad, depending on whether this was what you intended.

On a side note, since String contains no methods to modify its contents, you might as well be passing by value.

5. Writing blank exception handlers

I know it's very tempting to write blank exception handlers, and to just ignore errors. But if you run into problems, and haven't written any error messages, it becomes almost impossible to find out the cause of the error. Even the simplest exception handler can be of benefit. For example, put a try { .. } catch Exception around your code, to catch ANY type of exception, and print out the message. You don't need to write a custom handler for every exception (though this is still good programming practice). Don't ever leave it blank, or you won't know what's happening.

For example

public static void main(String args[])
{
    try {
// Your code goes here..
    }
    catch (Exception e)
    {
System.out.println ("Err - " + e );
    }
}

4. Forgetting that Java is zero-indexed

If you've come from a C/C++ background, you may not find this quite as much a problem as those who have used other languages. In Java, arrays are zero-indexed, meaning that the first element's index is actually 0. Confused? Let's look at a quick example.

// Create an array of three strings
String[] strArray = new String[3];
// First element's index is actually 0
strArray[0] = "First string";
// Second element's index is actually 1
strArray[1] = "Second string";
// Final element's index is actually 2
strArray[2] = "Third and final string";

In this example, we have an array of three strings, but to access elements of the array we actually subtract one. Now, if we were to try and access strArray[3], we'd be accessing the fourth element. This will case an ArrayOutOfBoundsException to be thrown - the most obvious sign of forgetting the zero-indexing rule.

Other areas where zero-indexing can get you into trouble is with strings. Suppose you wanted to get a character at a particular offset within a string. Using the String.charAt(int) function you can look this information up - but under Java, the String class is also zero-indexed. That means than the first character is at offset 0, and second at offset 1. You can run into some very frustrating problems unless you are aware of this - particularly if you write applications with heavy string processing. You can be working on the wrong character, and also throw exceptions at run-time. Just like the ArrayOutOfBoundsException, there is a string equivalent. Accessing beyond the bounds of a String will cause a StringIndexOutOfBoundsException to be thrown, as demonstrated by this example.

public class StrDemo
{
public static void main (String args[])
{
String abc = "abc";
System.out.println ("Char at offset 0 : " + abc.charAt(0) );
System.out.println ("Char at offset 1 : " + abc.charAt(1) );
System.out.println ("Char at offset 2 : " + abc.charAt(2) );
// This line should throw a StringIndexOutOfBoundsException
System.out.println ("Char at offset 3 : " + abc.charAt(3) );
}
}

Note too, that zero-indexing doesn't just apply to arrays, or to Strings. Other parts of Java are also indexed, but not always consistently. The java.util.Date, and java.util.Calendar classes start their months with 0, but days start normally with 1. This problem is demonstrated by the following application.

import java.util.Date;
import java.util.Calendar;
public class ZeroIndexedDate
{
public static void main (String args[])
{
// Get today's date
Date today = new Date();
// Print return value of getMonth
System.out.println ("Date.getMonth() returns : " +
today.getMonth());
// Get today's date using a Calendar
Calendar rightNow = Calendar.getInstance();
// Print return value of get ( Calendar.MONTH )
System.out.println ("Calendar.get (month) returns : " +
rightNow.get ( Calendar.MONTH ));
        }
}

Zero-indexing is only a problem if you don't realize that its occurring. If you think you're running into a problem, always consult your API documentation.

3. Preventing concurrent access to shared variables by threads

When writing multi-threaded applications, many programmers (myself included) often cut corners, and leave their applications and applets vulnerable to thread conflicts. When two or more threads access the same data concurrently, there exists the possibility (and Murphy's law holding, the probability) that two threads will access or modify the same data at the same time. Don't be fooled into thinking that such problems won't occur on single-threaded processors. While accessing some data (performing a read), your thread may be suspended, and another thread scheduled. It writes its data, which is then overwritten when the first thread makes its changes.

Such problems are not just limited to multi-threaded applications or applets. If you write Java APIs, or JavaBeans, then your code may not be thread-safe. Even if you never write a single application that uses threads, people that use your code WILL. For the sanity of others, if not yourself, you should always take precautions to prevent concurrent access to shared data.

How can this problem be solved? The simplest method is to make your variables private (but you do that already,  right?) and to use synchronized accessor methods. Accessor methods allow access to private member variables, but in a controlled manner. Take the following accessor methods, which provide a safe way to change the value of a counter.

public class MyCounter
{
private int count = 0; // count starts at zero
public synchronized void setCount(int amount)
{
count = amount;
}
public synchronized int getCount()
{
return count;
}
}

2. Capitalization errors

This is one of the most frequent errors that we all make. It's so simple to do, and sometimes one can look at an uncapitalized variable or method and still not spot the problem. I myself have often been puzzled by these errors, because I recognize that the method or variable does exist, but don't spot the lack of capitalization.

While there's no silver bullet for detecting this error, you can easily train yourself to make less of them. There's a very simple trick you can learn :-

  • all methods and member variables in the Java API begin with lowercase letters
  • all methods and member variables use capitalization where a new word begins e.g - getDoubleValue()

If you use this pattern for all of your member variables and classes, and then make a conscious effort to get it right, you can gradually reduce the number of mistakes you'll make. It may take a while, but it can save some serious head scratching in the future.

(drum roll)

And the number one error that Java programmers make !!!!!

 

1. Null pointers!

Null pointers are one of the most common errors that Java programmers make. Compilers can't check this one for you - it will only surface at runtime, and if you don't discover it, your users certainly will.

When an attempt to access an object is made, and the reference to that object is null, a NullPointerException will be thrown. The cause of null pointers can be varied, but generally it means that either you haven't initialized an object, or you haven't checked the return value of a function.

Many functions return null to indicate an error condition - but unless you check your return values, you'll never know what's happening. Since the cause is an error condition, normal testing may not pick it up - which means that your users will end up discovering the problem for you. If the API function indicates that null may be returned, be sure to check this before using the object reference!

Another cause is where your initialization has been sloppy, or where it is conditional. For example, examine the following code, and see if you can spot the problem.

public static void main(String args[])
{
// Accept up to 3 parameters
String[] list = new String[3];
int index = 0;
while ( (index < args.length) && ( index < 3 ) )
{
list[index++] = args[index];
}
// Check all the parameters
for (int i = 0; i < list.length; i++)
{
if (list[i].equals "-help")
{
// .........
}
else
if (list[i].equals "-cp")
{
// .........
}
// else .....
}
}

This code (while a contrived example), shows a common mistake. Under some circumstances, where the user enters three or more parameters, the code will run fine. If no parameters are entered, you'll get a NullPointerException at runtime. Sometimes your variables (the array of strings) will be initialized, and other times they won't. One easy solution is to check BEFORE you attempt to access a variable in an array that it is not equal to null.

Summary

These errors represent but some of the many that we all make. Though it is impossible to completely eliminate errors from the coding process, with care and practice you can avoid repeating the same ones. Rest assured, however, that all Java programmers encounter the same sorts of problems. It's comforting to know, that while you work late into the night tracking down an error, someone, somewhere, sometime, will make the same mistake!

We'd like to thank the readers of the comp.lang.java.programmer newsgroup for their suggestions for the top ten. Regrettably, due to the number of submissions, not every error could be featured - but we think this "Top Ten" list represents the most popular and frequent errors people make.


Alexwan 2008-06-24 16:17 发表评论
]]>
spring框架使用d调度quartz的例?TriggerListener ?/title><link>http://www.aygfsteel.com/alexwan/archive/2008/06/12/207273.html</link><dc:creator>Alexwan</dc:creator><author>Alexwan</author><pubDate>Thu, 12 Jun 2008 00:42:00 GMT</pubDate><guid>http://www.aygfsteel.com/alexwan/archive/2008/06/12/207273.html</guid><wfw:comment>http://www.aygfsteel.com/alexwan/comments/207273.html</wfw:comment><comments>http://www.aygfsteel.com/alexwan/archive/2008/06/12/207273.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/alexwan/comments/commentRss/207273.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/alexwan/services/trackbacks/207273.html</trackback:ping><description><![CDATA[     摘要:         有时候我们的d(Job)需要再某些d完成之后才能q行Q例如从旧的数据库批量导数据的时候;需要现被其他数据依赖的数据导入新的数据库Q然后再q行关系的导?。在q种情况下我们就可以使用Quartz的listener来做文章了?       ...  <a href='http://www.aygfsteel.com/alexwan/archive/2008/06/12/207273.html'>阅读全文</a><img src ="http://www.aygfsteel.com/alexwan/aggbug/207273.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/alexwan/" target="_blank">Alexwan</a> 2008-06-12 08:42 <a href="http://www.aygfsteel.com/alexwan/archive/2008/06/12/207273.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>spring框架使用d调度quartz的例?Job and Trigger ?/title><link>http://www.aygfsteel.com/alexwan/archive/2008/06/11/207241.html</link><dc:creator>Alexwan</dc:creator><author>Alexwan</author><pubDate>Wed, 11 Jun 2008 15:21:00 GMT</pubDate><guid>http://www.aygfsteel.com/alexwan/archive/2008/06/11/207241.html</guid><wfw:comment>http://www.aygfsteel.com/alexwan/comments/207241.html</wfw:comment><comments>http://www.aygfsteel.com/alexwan/archive/2008/06/11/207241.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/alexwan/comments/commentRss/207241.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/alexwan/services/trackbacks/207241.html</trackback:ping><description><![CDATA[MainJob.java<br /> <div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><span style="color: #008080"> 1</span><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><span style="color: #0000ff">package</span><span style="color: #000000"> jobs;<br /> </span><span style="color: #008080"> 2</span><span style="color: #000000"><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /> </span><span style="color: #008080"> 3</span><span style="color: #000000"><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> org.apache.log4j.Logger;<br /> </span><span style="color: #008080"> 4</span><span style="color: #000000"><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> org.quartz.JobExecutionContext;<br /> </span><span style="color: #008080"> 5</span><span style="color: #000000"><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> org.quartz.JobExecutionException;<br /> </span><span style="color: #008080"> 6</span><span style="color: #000000"><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> org.springframework.scheduling.quartz.QuartzJobBean;<br /> </span><span style="color: #008080"> 7</span><span style="color: #000000"><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /> </span><span style="color: #008080"> 8</span><span style="color: #000000"><img id="Codehighlighter1_231_468_Open_Image" onclick="this.style.display='none'; Codehighlighter1_231_468_Open_Text.style.display='none'; Codehighlighter1_231_468_Closed_Image.style.display='inline'; Codehighlighter1_231_468_Closed_Text.style.display='inline';" alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_231_468_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_231_468_Closed_Text.style.display='none'; Codehighlighter1_231_468_Open_Image.style.display='inline'; Codehighlighter1_231_468_Open_Text.style.display='inline';" alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">class</span><span style="color: #000000"> MainJob </span><span style="color: #0000ff">extends</span><span style="color: #000000"> QuartzJobBean </span><span id="Codehighlighter1_231_468_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img alt="" src="http://www.aygfsteel.com/Images/dot.gif" /></span><span id="Codehighlighter1_231_468_Open_Text"><span style="color: #000000">{<br /> </span><span style="color: #008080"> 9</span><span style="color: #000000"><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="color: #0000ff">private</span><span style="color: #000000">  Logger logger </span><span style="color: #000000">=</span><span style="color: #000000"> Logger.getLogger(getClass());<br /> </span><span style="color: #008080">10</span><span style="color: #000000"><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />    @Override<br /> </span><span style="color: #008080">11</span><span style="color: #000000"><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="color: #0000ff">protected</span><span style="color: #000000"> </span><span style="color: #0000ff">void</span><span style="color: #000000"> executeInternal(JobExecutionContext context)<br /> </span><span style="color: #008080">12</span><span style="color: #000000"><img id="Codehighlighter1_393_465_Open_Image" onclick="this.style.display='none'; Codehighlighter1_393_465_Open_Text.style.display='none'; Codehighlighter1_393_465_Closed_Image.style.display='inline'; Codehighlighter1_393_465_Closed_Text.style.display='inline';" alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_393_465_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_393_465_Closed_Text.style.display='none'; Codehighlighter1_393_465_Open_Image.style.display='inline'; Codehighlighter1_393_465_Open_Text.style.display='inline';" alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span><span style="color: #0000ff">throws</span><span style="color: #000000"> JobExecutionException </span><span id="Codehighlighter1_393_465_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img alt="" src="http://www.aygfsteel.com/Images/dot.gif" /></span><span id="Codehighlighter1_393_465_Open_Text"><span style="color: #000000">{<br /> </span><span style="color: #008080">13</span><span style="color: #000000"><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="color: #008000">//</span><span style="color: #008000"> TODO Auto-generated method stub</span><span style="color: #008000"><br /> </span><span style="color: #008080">14</span><span style="color: #008000"><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="color: #000000">        logger.debug(</span><span style="color: #000000">"</span><span style="color: #000000">Just say hi.</span><span style="color: #000000">"</span><span style="color: #000000">);<br /> </span><span style="color: #008080">15</span><span style="color: #000000"><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="color: #000000"><br /> </span><span style="color: #008080">16</span><span style="color: #000000"><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /> </span><span style="color: #008080">17</span><span style="color: #000000"><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="color: #000000"><br /> </span><span style="color: #008080">18</span><span style="color: #000000"><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span></div> application.xml<br /> <div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><span style="color: #0000ff"><?</span><span style="color: #ff00ff">xml version="1.0" encoding="UTF-8"</span><span style="color: #0000ff">?></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff"><</span><span style="color: #800000">beans </span><span style="color: #ff0000">xmlns</span><span style="color: #0000ff">="http://www.springframework.org/schema/beans"</span><span style="color: #ff0000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />    xmlns:xsi</span><span style="color: #0000ff">="http://www.w3.org/2001/XMLSchema-instance"</span><span style="color: #ff0000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />    xmlns:jee</span><span style="color: #0000ff">="http://www.springframework.org/schema/jee"</span><span style="color: #ff0000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />    xsi:schemaLocation</span><span style="color: #0000ff">="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd<br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />           http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd"</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />    </span><span style="color: #008000"><!--</span><span style="color: #008000"> d调度对象 </span><span style="color: #008000">--></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />    </span><span style="color: #0000ff"><</span><span style="color: #800000">bean </span><span style="color: #ff0000">id</span><span style="color: #0000ff">="mainJob"</span><span style="color: #ff0000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        class</span><span style="color: #0000ff">="org.springframework.scheduling.quartz.JobDetailBean"</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        </span><span style="color: #008000"><!--</span><span style="color: #008000"> q行的类 </span><span style="color: #008000">--></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        </span><span style="color: #0000ff"><</span><span style="color: #800000">property </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="jobClass"</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            </span><span style="color: #0000ff"><</span><span style="color: #800000">value</span><span style="color: #0000ff">></span><span style="color: #000000">jobs.MainJob</span><span style="color: #0000ff"></</span><span style="color: #800000">value</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        </span><span style="color: #0000ff"></</span><span style="color: #800000">property</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        </span><span style="color: #008000"><!--</span><span style="color: #008000"> 需要用到的对象 </span><span style="color: #008000">--></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        </span><span style="color: #0000ff"><</span><span style="color: #800000">property </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="jobDataAsMap"</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            </span><span style="color: #0000ff"><</span><span style="color: #800000">map</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />                </span><span style="color: #0000ff"><</span><span style="color: #800000">entry </span><span style="color: #ff0000">key</span><span style="color: #0000ff">="data"</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />                    </span><span style="color: #0000ff"><</span><span style="color: #800000">value</span><span style="color: #0000ff">></span><span style="color: #000000">data</span><span style="color: #0000ff"></</span><span style="color: #800000">value</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />                </span><span style="color: #0000ff"></</span><span style="color: #800000">entry</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            </span><span style="color: #0000ff"></</span><span style="color: #800000">map</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        </span><span style="color: #0000ff"></</span><span style="color: #800000">property</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />    </span><span style="color: #0000ff"></</span><span style="color: #800000">bean</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />    </span><span style="color: #008000"><!--</span><span style="color: #008000"> 单的触发?nbsp;</span><span style="color: #008000">--></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />    </span><span style="color: #0000ff"><</span><span style="color: #800000">bean </span><span style="color: #ff0000">id</span><span style="color: #0000ff">="mainTrigger"</span><span style="color: #ff0000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        class</span><span style="color: #0000ff">="org.springframework.scheduling.quartz.SimpleTriggerBean"</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        </span><span style="color: #0000ff"><</span><span style="color: #800000">property </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="jobDetail"</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            </span><span style="color: #008000"><!--</span><span style="color: #008000"> 上面创徏的Q务调度对?nbsp;</span><span style="color: #008000">--></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            </span><span style="color: #0000ff"><</span><span style="color: #800000">ref </span><span style="color: #ff0000">bean</span><span style="color: #0000ff">="mainJob"</span><span style="color: #ff0000"> </span><span style="color: #0000ff">/></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        </span><span style="color: #0000ff"></</span><span style="color: #800000">property</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        </span><span style="color: #008000"><!--</span><span style="color: #008000"> 启动60U后执行d调度的excuteҎ(gu) </span><span style="color: #008000">--></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        </span><span style="color: #0000ff"><</span><span style="color: #800000">property </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="startDelay"</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            </span><span style="color: #0000ff"><</span><span style="color: #800000">value</span><span style="color: #0000ff">></span><span style="color: #000000">6000</span><span style="color: #0000ff"></</span><span style="color: #800000">value</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        </span><span style="color: #0000ff"></</span><span style="color: #800000">property</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        </span><span style="color: #008000"><!--</span><span style="color: #008000"> q行ơ数 </span><span style="color: #008000">--></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        </span><span style="color: #0000ff"><</span><span style="color: #800000">property </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="repeatCount"</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            </span><span style="color: #0000ff"><</span><span style="color: #800000">value</span><span style="color: #0000ff">></span><span style="color: #000000">0</span><span style="color: #0000ff"></</span><span style="color: #800000">value</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        </span><span style="color: #0000ff"></</span><span style="color: #800000">property</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        </span><span style="color: #008000"><!--</span><span style="color: #008000"> 隔一个小时运行一?貌似多余,不写会报? </span><span style="color: #008000">--></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        </span><span style="color: #0000ff"><</span><span style="color: #800000">property </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="repeatInterval"</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            </span><span style="color: #0000ff"><</span><span style="color: #800000">value</span><span style="color: #0000ff">></span><span style="color: #000000">3600000</span><span style="color: #0000ff"></</span><span style="color: #800000">value</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        </span><span style="color: #0000ff"></</span><span style="color: #800000">property</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />    </span><span style="color: #0000ff"></</span><span style="color: #800000">bean</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />    <br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        <br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />    <br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />    </span><span style="color: #008000"><!--</span><span style="color: #008000"> d调度工厂c?nbsp;</span><span style="color: #008000">--></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />    </span><span style="color: #0000ff"><</span><span style="color: #800000">bean<br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        </span><span style="color: #ff0000">class</span><span style="color: #0000ff">="org.springframework.scheduling.quartz.SchedulerFactoryBean"</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        </span><span style="color: #008000"><!--</span><span style="color: #008000"> q一部分的配|不用管 </span><span style="color: #008000">--></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        </span><span style="color: #0000ff"><</span><span style="color: #800000">property </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="quartzProperties"</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            </span><span style="color: #0000ff"><</span><span style="color: #800000">props</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />                </span><span style="color: #0000ff"><</span><span style="color: #800000">prop </span><span style="color: #ff0000">key</span><span style="color: #0000ff">="org.quartz.threadPool.class"</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />                    org.quartz.simpl.SimpleThreadPool<br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />                </span><span style="color: #0000ff"></</span><span style="color: #800000">prop</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />                </span><span style="color: #0000ff"><</span><span style="color: #800000">prop </span><span style="color: #ff0000">key</span><span style="color: #0000ff">="org.quartz.threadPool.threadCount"</span><span style="color: #0000ff">></span><span style="color: #000000">10</span><span style="color: #0000ff"></</span><span style="color: #800000">prop</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />                </span><span style="color: #0000ff"><</span><span style="color: #800000">prop </span><span style="color: #ff0000">key</span><span style="color: #0000ff">="org.quartz.threadPool.threadPriority"</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />                    5<br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />                </span><span style="color: #0000ff"></</span><span style="color: #800000">prop</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />                </span><span style="color: #0000ff"><</span><span style="color: #800000">prop<br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />                    </span><span style="color: #ff0000">key</span><span style="color: #0000ff">="org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread"</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />                    true<br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />                </span><span style="color: #0000ff"></</span><span style="color: #800000">prop</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            </span><span style="color: #0000ff"></</span><span style="color: #800000">props</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        </span><span style="color: #0000ff"></</span><span style="color: #800000">property</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        </span><span style="color: #008000"><!--</span><span style="color: #008000"> 触发?可以放一大堆触发?nbsp;</span><span style="color: #008000">--></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        </span><span style="color: #0000ff"><</span><span style="color: #800000">property </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="triggers"</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            </span><span style="color: #0000ff"><</span><span style="color: #800000">list</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />                </span><span style="color: #008000"><!--</span><span style="color: #008000"> 在这里加 </span><span style="color: #008000">--></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />                 </span><span style="color: #0000ff"><</span><span style="color: #800000">ref </span><span style="color: #ff0000">bean</span><span style="color: #0000ff">="mainTrigger"</span><span style="color: #0000ff">/></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            </span><span style="color: #0000ff"></</span><span style="color: #800000">list</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        </span><span style="color: #0000ff"></</span><span style="color: #800000">property</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />    </span><span style="color: #0000ff"></</span><span style="color: #800000">bean</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff"></</span><span style="color: #800000">beans</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span></div> <img src ="http://www.aygfsteel.com/alexwan/aggbug/207241.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/alexwan/" target="_blank">Alexwan</a> 2008-06-11 23:21 <a href="http://www.aygfsteel.com/alexwan/archive/2008/06/11/207241.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用eclipse生成文档QjavadocQ?http://www.aygfsteel.com/alexwan/archive/2008/06/07/206478.htmlAlexwanAlexwanSat, 07 Jun 2008 02:26:00 GMThttp://www.aygfsteel.com/alexwan/archive/2008/06/07/206478.htmlhttp://www.aygfsteel.com/alexwan/comments/206478.htmlhttp://www.aygfsteel.com/alexwan/archive/2008/06/07/206478.html#Feedback0http://www.aygfsteel.com/alexwan/comments/commentRss/206478.htmlhttp://www.aygfsteel.com/alexwan/services/trackbacks/206478.html 1Q在目列表中按右键Q选择ExportQ导出)Q然后在Export(导出)对话框中选择java下的javadocQ提交到下一步?br /> 在Javadoc Generation对话框中有两个地方要注意的:
javadoc command:应该选择jdk的bin/javadoc.exe
destination:为生成文档的保存路径Q可自由选择?br /> 按finish(完成)提交卛_开始生成文档?br /> 2Q用菜单选择QFile->Export(文gQ?gt;导出)Q?br /> 剩下的步骤和W一U方法是一L?br /> 3Q选中要生成文档的目Q然后用菜单选择Q?br /> Project->Generate Javadoc直接q入Javadoc Generation对话框,剩余的步骤就和第一U方法在Javadoc Generation对话框开始是一L?nbsp;

Alexwan 2008-06-07 10:26 发表评论
]]>
Velocity语法 http://www.aygfsteel.com/alexwan/archive/2008/06/07/206473.htmlAlexwanAlexwanSat, 07 Jun 2008 02:18:00 GMThttp://www.aygfsteel.com/alexwan/archive/2008/06/07/206473.htmlhttp://www.aygfsteel.com/alexwan/comments/206473.htmlhttp://www.aygfsteel.com/alexwan/archive/2008/06/07/206473.html#Feedback1http://www.aygfsteel.com/alexwan/comments/commentRss/206473.htmlhttp://www.aygfsteel.com/alexwan/services/trackbacks/206473.html阅读全文

Alexwan 2008-06-07 10:18 发表评论
]]>
velocity开发插?http://www.aygfsteel.com/alexwan/archive/2008/06/07/206472.htmlAlexwanAlexwanSat, 07 Jun 2008 02:16:00 GMThttp://www.aygfsteel.com/alexwan/archive/2008/06/07/206472.htmlhttp://www.aygfsteel.com/alexwan/comments/206472.htmlhttp://www.aygfsteel.com/alexwan/archive/2008/06/07/206472.html#Feedback0http://www.aygfsteel.com/alexwan/comments/commentRss/206472.htmlhttp://www.aygfsteel.com/alexwan/services/trackbacks/206472.htmlveloeclipse
http://propsorter.sourceforge.net/veloeclipse

Properties Editor

http://propedit.sourceforge.jp/eclipse/updates/ 



Alexwan 2008-06-07 10:16 发表评论
]]>
关于cas原理 http://www.aygfsteel.com/alexwan/archive/2008/06/07/206461.htmlAlexwanAlexwanSat, 07 Jun 2008 01:19:00 GMThttp://www.aygfsteel.com/alexwan/archive/2008/06/07/206461.htmlhttp://www.aygfsteel.com/alexwan/comments/206461.htmlhttp://www.aygfsteel.com/alexwan/archive/2008/06/07/206461.html#Feedback0http://www.aygfsteel.com/alexwan/comments/commentRss/206461.htmlhttp://www.aygfsteel.com/alexwan/services/trackbacks/206461.htmlfrom:http://www.javaeye.com/topic/21770?page=3

CAS用来标志用户的token是存在它自己的域名下?不是存在web应用的域名下?CAS判断用户d由agent军_,agent验证用户信息有两U处?
1.如果q个用户是以前没dq的,也就是说q个web应用的域名下没有一个agent颁发的sessionid(在cookie?的话,那么它会跌{到CAS server的登录界?q里由CAS server军_是否昄d界面,q是直接p转回?也就是不是每ơ都要求输入密码d?.
2.CAS的登录界面会有两U处?如果以前没登录过,也就是在CAS server自己的域名下,没有用户的token的话,p求登?如果有token的话,p回一个ticket(也就是不昄d界面直接重定向返回了).
然后接第一步里?agent收到ticket以后提交给CAS server验证,q取得返回信?是个xml,cas的协议规定的,也可以用saml之类?q个地方可以取得除了用户姓名以外的信?q样可以做同步?权限的问题可以这么解?.然后agent׃存此时的session,把sessionid攑ֈ该web应用域名下的cookie?
以上逻辑说明?标志用户w䆾的token在CAS server的域名下,每个web应用不保存用戯n?因此跨域是绝Ҏ(gu)问题?只是single sign off需要CAS server的配合了,要把那个token删掉.
不过如果标志w䆾的token不存?而sessionid存在,那还是被认ؓ是登录的,只不q是在等待那个session timeout而已.



Alexwan 2008-06-07 09:19 发表评论
]]>
cas登陆验证程?/title><link>http://www.aygfsteel.com/alexwan/archive/2008/06/07/206460.html</link><dc:creator>Alexwan</dc:creator><author>Alexwan</author><pubDate>Sat, 07 Jun 2008 01:18:00 GMT</pubDate><guid>http://www.aygfsteel.com/alexwan/archive/2008/06/07/206460.html</guid><wfw:comment>http://www.aygfsteel.com/alexwan/comments/206460.html</wfw:comment><comments>http://www.aygfsteel.com/alexwan/archive/2008/06/07/206460.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/alexwan/comments/commentRss/206460.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/alexwan/services/trackbacks/206460.html</trackback:ping><description><![CDATA[<img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/alexwan/cas服务端流E_gif_1.gif" /><br /> <p>囄中的字体E微了?呵呵,使用visio我还是个新? </p> <p>ps:q个程图是Ҏ(gu)cas服务端的webflow的配|画出来,如有本h有理解错误的!Ƣ迎指正!</p> <img src ="http://www.aygfsteel.com/alexwan/aggbug/206460.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/alexwan/" target="_blank">Alexwan</a> 2008-06-07 09:18 <a href="http://www.aygfsteel.com/alexwan/archive/2008/06/07/206460.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>PATTERN FORMATS GLOSSARY for log4j http://www.aygfsteel.com/alexwan/archive/2008/06/07/206458.htmlAlexwanAlexwanSat, 07 Jun 2008 01:10:00 GMThttp://www.aygfsteel.com/alexwan/archive/2008/06/07/206458.htmlhttp://www.aygfsteel.com/alexwan/comments/206458.htmlhttp://www.aygfsteel.com/alexwan/archive/2008/06/07/206458.html#Feedback0http://www.aygfsteel.com/alexwan/comments/commentRss/206458.htmlhttp://www.aygfsteel.com/alexwan/services/trackbacks/206458.htmlFrom :http://topic.csdn.net/t/20040706/20/3151154.html

!-----------------------------------------------------------------------------!  
  !                                                     PATTERN   FORMATS   GLOSSARY                                                       !  
  !-----------------------------------------------------------------------------!  
  !   %n   -   newline                                                                                                                                 !  
  !   %m   -   your   log   message                                                                                                               !  
  !   %p   -   message   priority   (FATAL,   ERROR,   WARN,   INFO,   DEBUG   or   custom)                       !  
  !   %r   -   millisecs   since   program   started   running                                                                 !  
  !    %%  -   percent   sign   in   output                                                                                                   !  
  !                                                                                                                                                           !  
  !-----------------------SOME   MORE   CLUTTER   IN   YOUR   LOG-------------------------!  
  !   %c   -   name   of   your   category   (logger),   %c{2}   will   outputs   last   two   components   !  
  !   %t   -   name   of   current   thread                                                                                                   !  
  !   %x   -   Nested   Diagnostic   Context   (NDC)   (you   supply   it!)                                               !  
  !                                                                                                                                                           !  
  !-------------------------SLOW   PERFORMANCE   FORMATS----------------------------!  
  !   %d   -   date   and   time,   also   %d{ISO8601},   %d{DATE},   %d{ABSOLUTE},                               !  
  !                 %d{HH:mm:ss,SSS},   %d{dd   MMM   yyyy   HH:mm:ss,SSS}   and   so   on                           !  
  !   %l   -   Shortcut   for   %F%L%C%M                                                                                                     !  
  !   %F   -   Java   source   file   name                                                                                                     !  
  !   %L   -   Java   source   line   number                                                                                                 !  
  !   %C   -   Java   class   name,   %C{1}   will   output   the   last   one   component                             !  
  !   %M   -   Java   method   name                                                                                                               !  
  !                                                                                                                                                           !  
  !------------------------------FORMAT   MODIFIERS-------------------------------!  
  !   %-any_letter_above   -   Left-justify   in   min.   width   (default   is   right-justify)     !  
  !   %20any_letter_above   -   20   char.   min.   width   (pad   with   spaces   if   reqd.)                 !  
  !   %.30any_letter_above   -   30   char.   max.   width   (truncate   beginning   if   reqd.)         !  
  !   %-10.10r   -   Example.     Left-justify   time   elapsed   within   10-wide   field.                 !  
  !                             Truncate   from   beginning   if   wider   than   10   characters.                       !  
  !-----------------------------------------------------------------------------!  



Alexwan 2008-06-07 09:10 发表评论
]]>
վ֩ģ壺 | | | ˱| | | | ʦ| ƽ| | ˻| ۲| | Ҷ| ij| ƽ| | | ƽ| ף| | | | | ͼ| | ʯ| ϰ| | | Դ| ̫| | | | | | | ʷ| | |