<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-12718556</id><updated>2011-11-23T10:35:19.948+01:00</updated><title type='text'>Even vampire can also be cool</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default?start-index=101&amp;max-results=100'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>124</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-12718556.post-115495133797853903</id><published>2006-08-07T13:47:00.000+02:00</published><updated>2006-08-07T13:48:58.156+02:00</updated><title type='text'>C - "extern"</title><content type='html'>&lt;span style="font-size:78%;"&gt;&lt;p:colorscheme colors="#FFFFFF,#000000,#FFB800,#FF0000,#FFEF66,#000000,#00B200,#703DFF"&gt;  &lt;/p:colorscheme&gt;&lt;/span&gt; &lt;div shape="_x0000_s1026" class="O"&gt;  &lt;div style=""&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="font-family: 宋体; font-size: 24pt;"&gt;&lt;b&gt;（&lt;/b&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Comic Sans MS&amp;quot;; font-size: 24pt;" lang="EN-US"&gt;&lt;b&gt;1&lt;/b&gt;&lt;/span&gt;&lt;span style="font-family: 宋体; font-size: 24pt;"&gt;&lt;b&gt;）设全局变量的作用是增加了函数间数据联系，可以从函数得&lt;/b&gt;&lt;/span&gt;&lt;span style="font-family: 宋体; font-size: 24pt;"&gt;&lt;b&gt;到一个以上的返值，是&lt;/b&gt;&lt;/span&gt;&lt;span style="font-family: Arial; font-size: 24pt;"&gt;&lt;b&gt;“&lt;/b&gt;&lt;/span&gt;&lt;span style="font-family: 宋体; font-size: 24pt;"&gt;&lt;b&gt;双向传递的&lt;/b&gt;&lt;/span&gt;&lt;span style="font-family: Arial; font-size: 24pt;"&gt;&lt;b&gt;”&lt;/b&gt;&lt;/span&gt;&lt;span style="font-family: 宋体; font-size: 24pt;"&gt;&lt;b&gt;。 &lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;  &lt;div style=""&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="font-family: 宋体; font-size: 24pt;"&gt;&lt;b&gt;（&lt;/b&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Comic Sans MS&amp;quot;; font-size: 24pt;" lang="EN-US"&gt;&lt;b&gt;2&lt;/b&gt;&lt;/span&gt;&lt;span style="font-family: 宋体; font-size: 24pt;"&gt;&lt;b&gt;）不要轻易使用全局变量 &lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;  &lt;div style=""&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="font-family: 宋体; font-size: 24pt;"&gt;&lt;b&gt;　　　在程序执行过程中都占用存贮单元；通用性降低；不清&lt;/b&gt;&lt;/span&gt;&lt;span style="font-family: 宋体; font-size: 24pt;"&gt;&lt;b&gt;晰。 &lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;  &lt;div style=""&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="font-family: 宋体; font-size: 24pt;"&gt;&lt;b&gt;（&lt;/b&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Comic Sans MS&amp;quot;; font-size: 24pt;" lang="EN-US"&gt;&lt;b&gt;3&lt;/b&gt;&lt;/span&gt;&lt;span style="font-family: 宋体; font-size: 24pt;"&gt;&lt;b&gt;）在定义点之前引用外部变量要用关键字&lt;/b&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Comic Sans MS&amp;quot;; font-size: 24pt;" lang="EN-US"&gt;&lt;b&gt;extern&lt;/b&gt;&lt;/span&gt;&lt;span style="font-family: 宋体; font-size: 24pt;"&gt;&lt;b&gt;作&lt;/b&gt;&lt;/span&gt;&lt;span style="font-family: Arial; font-size: 24pt;"&gt;&lt;b&gt;“&lt;/b&gt;&lt;/span&gt;&lt;span style="font-family: 宋体; font-size: 24pt;"&gt;&lt;b&gt;外部变量&lt;/b&gt;&lt;/span&gt;&lt;span style="font-family: 宋体; font-size: 24pt;"&gt;&lt;b&gt;说明&lt;/b&gt;&lt;/span&gt;&lt;span style="font-family: Arial; font-size: 24pt;"&gt;&lt;b&gt;”&lt;/b&gt;&lt;/span&gt;&lt;span style="font-family: 宋体; font-size: 24pt;"&gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;  &lt;div style=""&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="font-family: 宋体; font-size: 24pt;"&gt;&lt;b&gt;（&lt;/b&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Comic Sans MS&amp;quot;; font-size: 24pt;" lang="EN-US"&gt;&lt;b&gt;4&lt;/b&gt;&lt;/span&gt;&lt;span style="font-family: 宋体; font-size: 24pt;"&gt;&lt;b&gt;）在同一源文件中，外部变量与局部变量同名，则在局部变量&lt;/b&gt;&lt;/span&gt;&lt;span style="font-family: 宋体; font-size: 24pt;"&gt;&lt;b&gt;的作用范围内，外部变量不起作用。&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;  &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-115495133797853903?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/115495133797853903/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=115495133797853903&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/115495133797853903'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/115495133797853903'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2006/08/c-extern.html' title='C - &quot;extern&quot;'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-115495079969900482</id><published>2006-08-07T13:39:00.000+02:00</published><updated>2006-08-07T13:40:00.916+02:00</updated><title type='text'>C</title><content type='html'>【1】为了防止头文件被重复引用，应当用ifndef/define/endif结构产生预处理块。&lt;br /&gt;【2】用 #include &lt;filename.h&gt; 格式来引用标准库的头文件（编译器将从标准库目录开始搜索）。&lt;br /&gt;【3】用 #include “filename.h” 格式来引用非标准库的头文件（编译器将从用户的工作目录开始搜索）。&lt;br /&gt;【4】头文件中只存放“声明”而不存放“定义”&lt;br /&gt;【5】不提倡使用全局变量，尽量不要在头文件中出现象extern int value 这类声明。&lt;/filename.h&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-115495079969900482?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/115495079969900482/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=115495079969900482&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/115495079969900482'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/115495079969900482'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2006/08/c.html' title='C'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-115228810155531665</id><published>2006-07-07T17:54:00.000+02:00</published><updated>2006-07-07T18:08:04.023+02:00</updated><title type='text'>GPRS</title><content type='html'>General Packet Radio Service&lt;br /&gt;&lt;br /&gt;中文为通用无线分组业务，是一种基于GSM系统的无线分组交换技术，提供端到 端的、广域的无线IP连接。相对原来GSM的拨号方式的电路交换数据传送方 式，GPRS是分组交换技术，具有“实时在线”、“按量计费”、“快捷登录”、“高速传输”、“自如切换”的优点。通俗地讲，GPRS是一项高速数据处理 的技术，方法是以“分组”的形式传送资料到用户手上。虽然GPRS是作为现有GSM网络向第三代移动通信过渡的过渡技术，但是它在许多方面都具有显著的优 势&lt;br /&gt;&lt;br /&gt;由于使用了“分组”技术，用户上网相对稳定，避免了不必要的短线带来的困扰。此外，使用GPRS上网的方法与WAP并不同，用WAP上 网就如在家中上网， 先“拨号连接”，而上网后便不能同时使用该电话线，但GPRS就较为优越，下载资料和通话是可以同时进行。从技术上来说，声音的传送(即通话)继续使用 GSM，而数据的传送便可使用GPRS，这样的话，就把移动电话的应用提升到一个更高的层次。而且发展GPRS技术也十分“经济”，因为只须沿用现有的 GSM网络来发展即可。GPRS的用途十分广泛，包括通过手机发送及接收电子邮件，在互联网上浏览等。&lt;br /&gt;&lt;br /&gt;GPRS是在GSM基础上发展 起来的一种分组交换的数据承载和传输方式，与原有的GSM比较，GPRS在数据业务的承载和支持上具有非常明显的优势： GPRS可以更有效的利用无线网络信道资源，特别适合突发性、频繁的小流量数据传输；GPRS支持的数据传输的速率更高，理论峰值达115kbps； GPRS计费方式更加灵活，可以支持按数据流量来进行计费；GPRS还能支持用户在进行数据传输的同时进行语音通话等等。&lt;br /&gt;&lt;br /&gt;  GPRS 是通用分组无线业务 (General Packet Radio Service) 的英文简称，是在现有的 GSM 系统上发展出来的一种新的分组数据承载业务。 GPRS 与现有的 GSM 语音系统最根本的区别是， GSM 是一种电路交换系统，而 GPRS 是一种分组交换系统，因此， GPRS 特别适用于间断的、突发性的或频繁的、少量的数据传输，也适用于偶尔的大数据量传输。  &lt;p&gt;GPRS 与原有的 GSM 相比，具有时尚前卫，令人耳目一新的优势：&lt;br /&gt;1、 永远在线：只要激活 GPRS 应用后，将永远保持在线，不存在掉线问题；类似于一种无线专线网络。&lt;br /&gt;2、 按量计费：虽然可以保持永远在线，但不必担心费用问题；因为只有产生通信流量时才计费。她是一种面向使用的计费，计费方式更加科学合理。&lt;br /&gt;3、 快速登录：全新的分组服务，无需以往长时间的拨号建立连接过程。&lt;br /&gt;4、 自如切换：话音和数据业务可以切换使用，电话上网两不误。&lt;br /&gt;5、 高速传输： GPRS 最高理论传输速度为 171.2kbps ，目前使用 GPRS 可以支持 40Kbps 左右的传输速率。&lt;/p&gt;  GPRS 可提供的如下服务:&lt;br /&gt;1、 GPRS 承载 WAP&lt;br /&gt;2、 电子邮件 E-Mail &lt;span class="style2"&gt;&lt;/span&gt;&lt;br /&gt;3、 GPRS 手机 + 笔记本，无线方式接入因特网&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-115228810155531665?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/115228810155531665/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=115228810155531665&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/115228810155531665'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/115228810155531665'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2006/07/gprs.html' title='GPRS'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-115228758082521850</id><published>2006-07-07T17:42:00.000+02:00</published><updated>2006-07-07T17:53:01.196+02:00</updated><title type='text'>UMTS</title><content type='html'>Universal Mobile Telecommunication System&lt;br /&gt;&lt;br /&gt;分组数据速率在静止时可达2Mbps，步行时为384kbps，车载时为144kbps。在QoS方面也有很大改进，它可以支持多媒体等新业务。&lt;br /&gt;&lt;br /&gt;欧洲电信标准协会（ETSI）负责UMTS的标准化工作，并与国际电联负责的第三代移动通信系统IMT-2000标准化工作协调一致&lt;br /&gt;&lt;br /&gt;通过升级GSM／GPRS网络中的MSC和GSN，使之提供 UMTS网络所需要的IU接口，并增加UMTS协议处理能力，即可使GSM／GPRS的核心网络节点设备具有UMTS核心网功能，在保证与原有的 GSM／GPRS BSS兼容的前提下，实现UMTS接入。在升级MSC／SGSN的同时，还需要对GMSC／GGSN进行软件升级，如果升级后网络容量不能满足新的要求， 可以在升级的同时对核心网设备进行扩容。对于UMTS用户来说，升级后的核心网支持UMTS协议要求的所有功能和业务。&lt;br /&gt;&lt;br /&gt;UMTS通信具有下面的特点:&lt;br /&gt;&lt;br /&gt;1. 它能直接与GSM的基础设施相连。&lt;br /&gt;2. 提供点对点无连接型网络业务，该业务中的各个数据分组彼此互相独立，用户之间的信息传输不需要端到端的呼叫建立程序。&lt;br /&gt;3. 抗衰弱能力强。UMTS技术具有更大的抗衰弱能力，这就意味着在相同的输出功率下能提供范围更广泛的性能, 或者在同样的覆盖范围下可降低功率要求。&lt;br /&gt;4. 业务处理能力增强。UMTS克服了传统通信系统的容量不足、语音失真度大、易掉线串线、功率辐射强、数据传输慢等问题，它的业务能力和性能大大增加。&lt;br /&gt;5. 应用范围广泛。&lt;br /&gt;6. 通话质量及数据通信速度大大提高。与传统的通信技术相比，UMTS通信技术的优势在于通话质量及数据通信速度。另外，由于技术的先进性确保了成本投资的减少，UMTS通信费用也要比目前的通信费低。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-115228758082521850?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/115228758082521850/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=115228758082521850&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/115228758082521850'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/115228758082521850'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2006/07/umts.html' title='UMTS'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-115228673641196958</id><published>2006-07-07T17:37:00.000+02:00</published><updated>2006-07-07T17:38:57.043+02:00</updated><title type='text'>TETRA</title><content type='html'>&lt;span style="font-size: 11pt; line-height: 16pt;"&gt;TETRA在全世界的成功不像它所要应对的突发 事件那样的偶然，而是主要得益于其自身的优良性能。&lt;br /&gt;&lt;br /&gt;TETRA系统的呼叫建立时间实际小于0.3秒，远远少于GSM呼叫建立的10秒时间，在紧急情况下， 这种快速反应能力最能力挽狂澜。&lt;br /&gt;&lt;br /&gt;TETRA具有多种指挥调度功能，如动态重组、多种优先级配置方案，可以单呼、组呼和广播，并可多个单位组成共同的通话组 以实施联合指挥，便于应付突发事件。&lt;br /&gt;&lt;br /&gt;此外，TETRA还具备多种加密方式、安全抗毁性高、可脱网直通的特性，在嘈杂的环境下话音质量比GSM手机还略胜一 筹，在高速环境中仍能保持清晰通话，并且组网灵活。 &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-115228673641196958?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/115228673641196958/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=115228673641196958&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/115228673641196958'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/115228673641196958'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2006/07/tetra.html' title='TETRA'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-115209815731193803</id><published>2006-07-05T13:15:00.000+02:00</published><updated>2006-07-05T13:18:00.253+02:00</updated><title type='text'>菜鸟终究是飞不高的</title><content type='html'>&lt;span style="color: rgb(51, 51, 255);font-family:georgia;font-size:130%;"  &gt;菜鸟终究是飞不高的 &lt;/span&gt;&lt;span style=";font-family:georgia;font-size:130%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);font-family:georgia;font-size:130%;"  &gt;/大漠凌鹰 &lt;/span&gt;&lt;span style=";font-family:georgia;font-size:130%;"  &gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);font-family:georgia;font-size:130%;"  &gt;当刘建宏老师喋喋不休的絮叨德国队点球的伟大战绩时，伟大的意大利左后卫格罗索狠狠地扇了克林斯曼率领的菜鸟们一记响亮的耳光。告诉他们，足球不仅仅是凭借点球赢得冠军，比赛的任何一分钟都可以成为绝杀。 &lt;/span&gt;&lt;span style=";font-family:georgia;font-size:130%;"  &gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);font-family:georgia;font-size:130%;"  &gt;在淘汰了阿根廷后，德国队便开始憧憬着冠军，向往着柏林。并且世界杯前，就早有预谋的选择了他们自以为是的福地――多特蒙德体育场。可圆圆的足球 终归是不信邪的，因为他们与生俱来就是颠覆的代名词。更何况这次的驾驭者意大利，无论从内涵还是到外在，都是那种底蕴、素养登峰造极的球队。 &lt;/span&gt;&lt;span style=";font-family:georgia;font-size:130%;"  &gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);font-family:georgia;font-size:130%;"  &gt;许是家门口作战的缘故，在防守反击了上半场后，下半场的德国队开始蠢蠢欲动，而后大肆的进攻。这细微的一点便将克林斯曼的菜鸟本质展现的一览无 余。虽然他曾经是德国的伟大射手，虽然他曾经在欧洲各大联赛取得不错的成绩，虽然在前面的比赛他取得了一叶障目的成绩，但教练终究是个脑力劳动者。和将防 守反击玩弄的游刃有余的意大利比进攻，不是搬起石头砸自己的脚？更何况德国队队高进攻也仅仅是在弱队身上灵验。 &lt;/span&gt;&lt;span style=";font-family:georgia;font-size:130%;"  &gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);font-family:georgia;font-size:130%;"  &gt;加时赛的一次门柱、一次横梁已经为埋葬菜鸟们铺好了序幕，只是菜鸟们天真的以为这是上帝在帮助他们。非但不稳固自己的防线，还是一如既往的进攻。 这个时候，伟大的意大利左后卫格罗索已经是杀红眼的斗士，对于拔剑绝杀这事早已迫不及待。于是，在接到皮尔洛的传球后，一柄锋利的匕首深深的刺向了苟延残 喘了１００多分种的德国菜鸟的心脏。紧接着血喷涌而出，德国菜鸟慢慢倒下…… &lt;/span&gt;&lt;span style=";font-family:georgia;font-size:130%;"  &gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);font-family:georgia;font-size:130%;"  &gt;克林斯曼在安慰他的队员，与其说是安慰队员，还不如说是安慰自己的失误。换句话说，德国队能取得这样的成绩完全可以心安理得了，因为他仅仅是一个 菜鸟，即便波多尔斯基挥舞着他苍劲而有力的手臂证明着什么。看看里皮的换人，吉拉吉诺、皮耶罗、亚昆塔，再反观克林斯曼，还把赌注押到诺伊维尔身上，这样 不失败的话只能说明上帝再帮助德国。只可惜上帝不会每一次都怜悯菜鸟。 &lt;/span&gt;&lt;span style=";font-family:georgia;font-size:130%;"  &gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);font-family:georgia;font-size:130%;"  &gt;突然记得我们的前辈陈涉有句话“燕雀安知鸿鹄之志”，德国这菜鸟焉知意大利人的坚韧不屈？菜鸟终究是菜鸟，只适合在小场子折腾，终究是飞不高的。 &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-115209815731193803?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/115209815731193803/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=115209815731193803&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/115209815731193803'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/115209815731193803'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2006/07/blog-post.html' title='菜鸟终究是飞不高的'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-115150203971857507</id><published>2006-06-28T15:29:00.000+02:00</published><updated>2006-06-28T15:45:58.076+02:00</updated><title type='text'>Time to say good bye ...</title><content type='html'>&lt;span style="color: rgb(255, 0, 0); font-weight: bold;"&gt;&lt;br /&gt;Auch ich muss gehen...  &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Liebe ISST-Crew,&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;leider ist es nun auch bei mir soweit, Abschied zu nehmen. Ich wünsche &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Euch/ Ihnen alles Gute und vor allem sehr viele lukrative Projekte.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Für den Bereich Personal wird meine nette Nachfolgerin Frau Cammin &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;zuständigen sein.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Möchtet ihr auch nach meiner ISST Zeit Kontakt aufnehmen, dann kommt &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;hier noch meine E-Mail Adresse: alexandramueller1@... :-)   .&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Alles Liebe&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Alexandra Müller&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;P.S. Einige wenige Brötchen liegen noch in der 6. Etage in der Küche!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;--  Alexandra Büge   Wed, 08 Feb 2006 13:59:39 +0100&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0); font-weight: bold;"&gt;Abschied&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Liebe Kolleginnen und Kollegen,&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;an meinem letzten Arbeitstag im Fraunhofer ISST Berlin möchte ich mich &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;recht herzlich für die außergewöhnlich gute fachliche Zusammenarbeit und &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;die motivierende und freundliche Arbeitsatmosphäre in den vergangenen &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;4414 Tagen bedanken. Ich wünsche Euch allen persönlich und beruflich &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;alles Gute!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Mit freundlichen Grüßen&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;                     -- Jan Pyttel Fri, 03 Mar 2006 13:30:55 +0100&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0); font-weight: bold;"&gt;Abschied&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Liebe Kollegen,&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;und heute ist es bei mir soweit. Heute ist nicht nur mein letzter &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Arbeitstag, sondern auch der Beginn des Aufbruchs zu neuen Ufern. Ostern &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;werde ich Deutschland verlassen und bei den Nordlichtern mit meiner &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Familie einen neuen Lebensabschnitt geniessen. Ich möchte mich bei euch &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;allen für die ereignisreiche und spannende Zeit bedanken. Dies gilt &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;insbesondere für die Abteilung VTS!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;In diesem Sinne: Heydå, och tack så mycket för fisken! :)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;                           -- Wolfram Webers   Fri, 31 Mar 2006 11:41:07 +0200&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0); font-weight: bold;"&gt;Auch weg&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Liebe Kollegen,&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;auch für mich endet heute eine interessante und schöne Zeit hier im Institut.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Ich möchte mich hiermit vor allem bei all denen verabschieden, die ich jetzt&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;nicht mehr persönlich getroffen habe oder noch treffen werde. Vielen Dank an&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;alle, die zu der schönen Zeit hier beigetragen haben.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Mit dem Wunsch, dass meine Einsparung dem Institut wieder auf die Beine helfe&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;;-)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;verbleibe ich mit besten Grüßen&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;PS: Wer mich mal privat kontaktieren möchte, kann dies über ... &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;                          -- bodo.sievers Fri, 31 Mar 2006 12:57:11 +0200&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0); font-weight: bold;"&gt;Abschied&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Hallo ISSTler,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;nun ist auch für mich die Zeit gekommen, weiterzuziehen. So möchte ich&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;mich auf diesem Wege noch einmal für die tolle Zusammenarbeit und die&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;schöne und lehrreiche Zeit am ISST bedanken.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Gruss,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;                          -- Sebastian Wed, 21 Jun 2006 12:02:43 +0200&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0); font-weight: bold;"&gt;Time to say goodbye&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Soon is the time to say goodbye to all, always work with an appreciate heart in the past many days, saddened &amp; anyway, it should be a nice page memories in my life.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Greetinx, &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;                          -- Dongsheng Zheng Mon, 26 Jun 2006 15:32:43 +0200 &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-115150203971857507?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/115150203971857507/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=115150203971857507&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/115150203971857507'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/115150203971857507'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2006/06/time-to-say-good-bye.html' title='Time to say good bye ...'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-115150125534303688</id><published>2006-06-28T15:25:00.000+02:00</published><updated>2006-06-28T15:28:58.836+02:00</updated><title type='text'>Specially delivery this song to all Argentina supporters~!</title><content type='html'>It won't be easy to face Germany, you'll think it strange&lt;br /&gt;When I try to explain how I feel&lt;br /&gt;That I still need you after all that I've done&lt;br /&gt;You won't believe me&lt;br /&gt;All you will see is a Blue and White strip everyone knew&lt;br /&gt;Although they dressed up to face the eleven&lt;br /&gt;Im always be with you&lt;br /&gt;&lt;br /&gt;I had to let it happen, I had to change&lt;br /&gt;Couldn't stay all my life down at heel&lt;br /&gt;Looking out of the stadium, staying out of the sun&lt;br /&gt;So I chose U&lt;br /&gt;Running around, trying everything possible&lt;br /&gt;But nothing impressed me at all&lt;br /&gt;I never expected it to lose this game&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Don't cry for me Argentina&lt;br /&gt;The truth is I never left you&lt;br /&gt;All through Germany are wild&lt;br /&gt;My mad existence&lt;br /&gt;I kept my promise&lt;br /&gt;Don't keep your distance&lt;br /&gt;&lt;br /&gt;Have I said too much?&lt;br /&gt;There's nothing more I can think of to say to you&lt;br /&gt;But all you have to do is look toward the trophy&lt;br /&gt;To know that every dream is true&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/1662/1091/1600/3151095720.jpg"&gt;&lt;img style="float:center; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://photos1.blogger.com/blogger/1662/1091/320/3151095720.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-115150125534303688?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/115150125534303688/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=115150125534303688&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/115150125534303688'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/115150125534303688'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2006/06/specially-delivery-this-song-to-all.html' title='Specially delivery this song to all Argentina supporters~!'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-115072353040826166</id><published>2006-06-19T15:25:00.000+02:00</published><updated>2006-06-19T15:29:31.580+02:00</updated><title type='text'>a complex javadoc example</title><content type='html'>&lt;span style="color:#3366ff;"&gt;&lt;span style="color:#33ccff;"&gt;/*&lt;br /&gt;* @pre subroutes != null&lt;br /&gt;* @pre forall Object o in subroutes | o != null&lt;br /&gt;* @pre forall Object o in subroutes |&lt;br /&gt;*     o instanceof de.***.PtRoute&lt;br /&gt;*  || o instanceof de.***.ItRoute&lt;br /&gt;*  || o instanceof de.***.ImRoute&lt;br /&gt;*/&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#cc33cc;"&gt;public ImRoute( Route[] subroutes ) { }&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-115072353040826166?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/115072353040826166/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=115072353040826166&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/115072353040826166'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/115072353040826166'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2006/06/complex-javadoc-example.html' title='a complex javadoc example'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-115059509996440600</id><published>2006-06-18T03:11:00.000+02:00</published><updated>2006-06-18T03:52:34.970+02:00</updated><title type='text'>CET 23:00 14.06 Unten den Linden POLAN-GERMANY</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/1662/1091/1600/DSCN1674.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://photos1.blogger.com/blogger/1662/1091/320/DSCN1674.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;The first picture of us after USEDOM, it's one year ago, time went by, and we are older.&lt;br /&gt;still remember the details of WC2002, as an amateur punter, won some money, 4 years is long for the life, short for the memory, another world cup comes, we're laughing, as a pure soccer fan, as a past experienced punter, at the lousy performace of both sides and this new created one page memories. yes, we're laughing :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-115059509996440600?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/115059509996440600/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=115059509996440600&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/115059509996440600'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/115059509996440600'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2006/06/cet-2300-1406-unten-den-linden-polan.html' title='CET 23:00 14.06 Unten den Linden POLAN-GERMANY'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-114962101675897002</id><published>2006-06-06T21:07:00.000+02:00</published><updated>2006-06-06T21:12:51.416+02:00</updated><title type='text'>natürlich ist Fußballzeit keine Arbeitszeit</title><content type='html'>&lt;pre style="font-family: times new roman;"&gt;&lt;span style="font-size:85%;"&gt;Hallo alle,&lt;br /&gt;&lt;br /&gt;wer an Fußball nicht interessiert ist, kann schon aufhören zu lesen ;)&lt;br /&gt;&lt;br /&gt;Für alle anderen: am Freitag beginnt die Fußball-WM in Deutschland, da&lt;br /&gt;stellt sich die Frage: schauen oder nicht? Oft ist man ja auf Arbeit,&lt;br /&gt;wenn ein Spiel läuft (ist beim letzten Gruppenspiel Deutschlands so),&lt;br /&gt;auch andere Mannschaften können durchaus interessant sein.&lt;br /&gt;&lt;br /&gt;In Abstimmung mit der Institutsleitung ist das Fußballschauen im&lt;br /&gt;Institut erlaubt, folgende Bedingungen sollten beachtet werden:&lt;br /&gt;- - keine Internetvideostreams (würde auch eher eine Diashow werden)&lt;br /&gt;- - keine Nutzung des Demoraums, Ausweichen in die Versammlungsräume der&lt;br /&gt;3. und 4. Etage, dort ist das Ganze auch sichtgeschützt&lt;br /&gt;- - natürlich ist Fußballzeit keine Arbeitszeit&lt;br /&gt;- - die technische Ausstattung muß selbst organisiert werden, Beamer des&lt;br /&gt;Instituts dürfen genutzt werden&lt;br /&gt;- - insgesamt den laufenden Betrieb nicht stören&lt;br /&gt;&lt;br /&gt;Wie das Ganze technisch funktioniert, habe ich schon mal überlegt, am&lt;br /&gt;besten, jemand bringt einen DVB-T-Receiver mit, der dann kunstreich&lt;br /&gt;angeschlossen wird, ich hoffe, in einem Systemtechnik-Institut ist das&lt;br /&gt;zu schaffen.&lt;br /&gt;&lt;br /&gt;In diesem Sinne fröhliches Fußballen,&lt;br /&gt;&lt;br /&gt;Ekkart.&lt;br /&gt;- --&lt;br /&gt;* FhG - Institut fuer Software- und Systemtechnik       *&lt;br /&gt;* Ekkart Kleinod &lt;/span&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-114962101675897002?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/114962101675897002/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=114962101675897002&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/114962101675897002'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/114962101675897002'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2006/06/natrlich-ist-fuballzeit-keine.html' title='natürlich ist Fußballzeit keine Arbeitszeit'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-114803340830047829</id><published>2006-05-19T12:09:00.000+02:00</published><updated>2006-05-19T12:10:08.420+02:00</updated><title type='text'>资源需求决定汇率形成  -- 薛兆丰</title><content type='html'>两个礼拜前我到杜克大学（Duke University）拜访朋友。席间有人问：为什么国与国之间会有汇率？人民币与美元之间1:8.2的汇率是怎样定出来的？两个国家之间的汇率为什么会变动？两个国家之间汇率的变动会否波及其他国家之间的汇率？ 　　说来话长，我只顾低头吃饭。 读财务专业的朋友回答：“汇率基本上是由所谓‘购买力平价’决定的。简单地说，一只鸡蛋的价值，在中国和美国两地应该是一样的，人民币兑美元的汇率，就是为了保持人民币在中国的购买力与美元在美国的购买力相等而确定的。” 　　他补充说：“当然不仅仅是鸡蛋一种商品。国家的汇率管理部门，确定了一揽子社会最基本的商品。他们从这些商品的市场价格取样，通过汇总和计算，再根据世界各国银行和金融机构公布的宏观数据，综合确定该国货币的汇率。” 　　我听了拍案而起：“错！错！完全是错的。汇率不是这么定的。所有经济学和金融学的教科书，说的都跟你说的一样，但那些教科书都只是说说而已。我一万比一跟你赌，你找不到任何一本印刷物，上面印有你说的‘一揽子社会最基本商品清单’和加权汇总公式。到底谁在做你所说的采样工作呢？实际上有做这事儿的人吗？” 　　“有！当然有！我就认识一个。”朋友肯定地回答：“你别管我对不对，我们只管汇率是不是这样决定的。我们把这作为评判标准，好吧？我这就给熟人打电话，看他是怎么参与决定汇率的，他以前就是从事这类工作，我们来问他。” 　　电话打通，那头的汇率专家一板一眼回答：“汇率由四个因素决定，一是购买力平价，二是各国的通货膨胀，三是国际贸易平衡，四是金融投机。每个国家的政府，还有中央银行、商业银行和投资银行，都会定期发布各种经济数据，我们是根据这些数据确定汇率的。” 　　我哈哈大笑：“我不管那些专家是如何确定汇率的，我要问的是，他们的预测对了吗？如果汇率是由一群专家根据既定的数据来源和公式确定的，那为什么不同的专家对汇率会有不同的预测，为什么还会有人在汇率市场上倾家荡产？” 　　我进一步解释：“气象专家可以用这样或那样的历史统计数据来预测明天的天气，但他们的预测对了吗？或许对，或许错，但不管对错，都绝不能说天气是由这些气象专家决定的。一开始的问题是‘汇率是如何决定的’，而你谈的是‘汇率是如何预测的’，两者南辕北辙。” 　　两百年前，还没有中央银行，更没有什么宏观统计数据，那时候的汇率是怎么决定的？不要以为没有金融专家就没有汇率，没有中央银行就无法形成汇率形成机制。即便取消货币，回到物物交换的年代，部落之间也仍然存在汇率：一块羊肉兑一杆标枪就是汇率。 　　我的答案：汇率是由甲国人民对乙国资源的需求，以及乙国人民对甲国资源的需求共同决定的。如果一国人民对另一国资源完全没有需求，那么两国就不存在汇率；如果甲国人民对乙国资源的需求增加，在其他条件不变的情况下，甲国的货币就会相对乙国货币贬值。 　　正是一国对异国资源的需求，决定了汇率。这是最初始的需求，它无需涉及货币，与统计数据无关，也非金融专家所能预测。汇率只由每个国家每个消费者的每笔消费共同决定。正是每个消费者在购买商品时的钞票投票，表达了他们对商品中所包含的外国资源（自然资源和人力资源）的需求程度，从而通过这种不可抗拒的经济力量，决定了国与国之间的汇率。 　　过去美元强，对其他货币有升值趋势，简而言之，就是因为其他国家对“美国制造”的商品需求大。今天人民币强，对美元升值，其根本原因也是世界人民对“中国制造”的商品需求增大的缘故。要指出的是，所谓“中国制造”，是一般化的概念，既包括了自然资源，也包含了人力资源，更包含了制度因素。 　　杜克的朋友也终于分清了“预测”与“决定”的差别。我的感慨是：以为汇率是由金融机构根据经济理论、统计数据和数学公式来制定的人太多，包括许多著书立说的专家，而我只能跟其中个别人吃饭。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-114803340830047829?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/114803340830047829/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=114803340830047829&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/114803340830047829'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/114803340830047829'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2006/05/blog-post_19.html' title='资源需求决定汇率形成  -- 薛兆丰'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-114790107773311437</id><published>2006-05-17T23:22:00.000+02:00</published><updated>2006-05-17T23:26:41.380+02:00</updated><title type='text'>★ BITTER AFTER TASTE © ★</title><content type='html'>&lt;span style=";font-family:Arial;font-size:100%;color:black;"   &gt;&lt;strong&gt;&lt;span style="color: rgb(255, 0, 0);font-family:Tahoma;" &gt;Saddened. Not because the tip flopped.&lt;br /&gt;Saddened because Arsenal lost.&lt;br /&gt;Saddened because the referee rigged it.&lt;br /&gt;The referee capped off his pathetic display by WASTING TIME to yellow card Larsson for WASTING TIME. What was the logic in that? And for all the injuries and time-wasting in the game, only 3 minutes added on.&lt;br /&gt;Yes, I am saddened.&lt;br /&gt;Deeply, as an Arsenal fan.&lt;br /&gt;Deeply, as a fan of football.&lt;br /&gt;Deeply, by the worst refereeing performance I have ever seen - the full 90 minutes.&lt;br /&gt;&lt;br /&gt;As for Henry, I don't really care if he stays or leaves. Any player who doesn't feel proud putting on the reds of Arsenal should leave.&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-114790107773311437?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/114790107773311437/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=114790107773311437&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/114790107773311437'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/114790107773311437'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2006/05/bitter-after-taste.html' title='★ BITTER AFTER TASTE © ★'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-114709267438502513</id><published>2006-05-08T14:43:00.000+02:00</published><updated>2006-05-08T14:51:14.466+02:00</updated><title type='text'>Modern Englisch</title><content type='html'>u had me a row 一见钟情&lt;br /&gt;plenty of other fish in the sea 海里的鱼多得很（天涯何处无芳草）&lt;br /&gt;rob the cradle 劫摇篮（老牛吃嫩草）&lt;br /&gt;make finger to sb 针对sb&lt;br /&gt;he's not going to talk down to me 他没资格以高人一等的姿态跟我说话&lt;br /&gt;tear it up 破旧立新&lt;br /&gt;manpower resource 劳动资源&lt;br /&gt;play favorities 偏心&lt;br /&gt;around corner 迫在眉睫&lt;br /&gt;out of this world 独一无二&lt;br /&gt;pale in comparison 相形失色&lt;br /&gt;play it by ear 随机应变&lt;br /&gt;poker face 扑克面孔（喜怒不形于色）&lt;br /&gt;put all of one's eggs in one basket 鸡蛋都放在一个篮子里（孤注一掷）&lt;br /&gt;put one's foot in one's mouth 把脚丫放进嘴里（说错话了）&lt;br /&gt;put up the white flag 竖白旗（投降，放弃）&lt;br /&gt;read sb like a book 对sb一目了然&lt;br /&gt;sleep on it 睡在上面（考虑一晚上）&lt;br /&gt;small talk 寒喧，闲聊&lt;br /&gt;toe the line 循规蹈矩，沿着线走&lt;br /&gt;walk in someone's shoes 穿他的鞋走走看（设身处地，经历相同）&lt;br /&gt;one step ahead of you 领先你一步&lt;br /&gt;let the cat out of the bag 放出袋中猫（泄密，说漏嘴）&lt;br /&gt;let sleeping dogs lie 别惊动睡着的狗（别无事生非，过去的事不要再提）&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-114709267438502513?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/114709267438502513/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=114709267438502513&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/114709267438502513'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/114709267438502513'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2006/05/modern-englisch.html' title='Modern Englisch'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-114709132177670141</id><published>2006-05-08T14:28:00.000+02:00</published><updated>2006-05-08T14:28:41.846+02:00</updated><title type='text'>好好想想</title><content type='html'>Think it over&lt;br /&gt;好好想想&lt;br /&gt;&lt;br /&gt;today we have higher buildings and wider highways,&lt;br /&gt;今天我们拥有了更高层的楼宇以及更宽阔的公路，&lt;br /&gt;but shorter temperaments and narrower points of view;&lt;br /&gt;但是我们的性情却更为急躁，眼光也更加狭隘；&lt;br /&gt;we spend more,&lt;br /&gt;我们消耗得更多，&lt;br /&gt;but enjoy less;&lt;br /&gt;但享受到的却更少；&lt;br /&gt;we have bigger houses,&lt;br /&gt;我们的住房更大了，&lt;br /&gt;but smaller families;&lt;br /&gt;但我们的家庭却更小了；&lt;br /&gt;we have more compromises,&lt;br /&gt;我们妥协更多，&lt;br /&gt;but less time;&lt;br /&gt;但时间却更少；&lt;br /&gt;we have more knowledge,&lt;br /&gt;我们拥有了更多的知识，&lt;br /&gt;but less judgment;&lt;br /&gt;可判断力却更差了；&lt;br /&gt;we have more medicines,&lt;br /&gt;我们有了更多的药品，&lt;br /&gt;but less health;&lt;br /&gt;但健康状况却更不如意；&lt;br /&gt;we have multiplied out possessions,&lt;br /&gt;我们拥有的财富倍增，&lt;br /&gt;but reduced out values;&lt;br /&gt;但其价值却减少了；&lt;br /&gt;we talk much,&lt;br /&gt;我们的交谈多了，&lt;br /&gt;we love only a little,&lt;br /&gt;我们的爱却只有一丁点，&lt;br /&gt;and we hate too much;&lt;br /&gt;而我们的仇恨却更多了；&lt;br /&gt;we reached the moon and came back,&lt;br /&gt;我们可以往返月球，&lt;br /&gt;but we find it troublesome to cross our own street and meet our neighbors;&lt;br /&gt;但却难以迈出一步去亲近我们的左邻右舍；&lt;br /&gt;we have conquered the outer space,&lt;br /&gt;我们可以征服外太空，&lt;br /&gt;but not our inner space;&lt;br /&gt;却征服不了我们的内心；&lt;br /&gt;we have higher income,&lt;br /&gt;我们的收入增加了，&lt;br /&gt;but less morals;&lt;br /&gt;但我们的道德却弱化了；&lt;br /&gt;these are times with more liberty,&lt;br /&gt;我们的时代更加自由了，&lt;br /&gt;but less joy;&lt;br /&gt;但我们拥有的快乐时光却越来越少；&lt;br /&gt;we have much more food,&lt;br /&gt;我们有了更多的食物，&lt;br /&gt;but less nutrition;&lt;br /&gt;但所能得到的营养却越来越少了；&lt;br /&gt;these are the days in which it takes two salaries for each home,&lt;br /&gt;现在每个家庭都可以有双份收入，&lt;br /&gt;but divorces increase;&lt;br /&gt;但离婚的现象却越来越多了；&lt;br /&gt;these are times of finer houses,&lt;br /&gt;现在的住房越来越精致，&lt;br /&gt;but more broken homes;&lt;br /&gt;但破碎的家庭却更多了；&lt;br /&gt;that's why I propose,&lt;br /&gt;这就是我为什么要说，&lt;br /&gt;that as of today;&lt;br /&gt;今天的这些；&lt;br /&gt;you do not keep anything for a special occasion,&lt;br /&gt;不要将你的东西为了某一个特别的时刻而预留着，&lt;br /&gt;because every day that you live is a special occasion;&lt;br /&gt;因为你生活的每一天都是那么特别；&lt;br /&gt;search for knowledge,&lt;br /&gt;寻找更多的知识，&lt;br /&gt;read more ,&lt;br /&gt;多读一些书，&lt;br /&gt;sit on your porch and admire the view without paying attention to your needs;&lt;br /&gt;坐在你家的前廊里，以赞美的眼光去享受眼前的风景，不要带上任何功利的想法；&lt;br /&gt;spend more time with your family and friends,&lt;br /&gt;花多点时间和朋友与家人在一起，&lt;br /&gt;eat your favorite foods,&lt;br /&gt;吃你爱吃的食物，&lt;br /&gt;visit the places you love;&lt;br /&gt;去你想去的地方；&lt;br /&gt;life is a chain of moments of enjoyment;&lt;br /&gt;生活是一串串的快乐时光；&lt;br /&gt;not only about survival;&lt;br /&gt;我们不仅仅是为了生存而生存；&lt;br /&gt;use your crystal goblets.&lt;br /&gt;举起你的水晶酒杯吧。&lt;br /&gt;do not save your best perfume,&lt;br /&gt;不要吝啬洒上你最好的香水，&lt;br /&gt;and use it every time you feel you want it.&lt;br /&gt;你想用的时候就享用吧！&lt;br /&gt;remove from your vocabulary phrases like"one of these days"or "someday";&lt;br /&gt;从你的词汇库中移去所谓的“有那么一天”或者“某一天”；&lt;br /&gt;let's write that letter we thought of writing "one of these days"!&lt;br /&gt;曾打算“有那么一天”去写的信，就在今天吧！&lt;br /&gt;let's tell our families and friends how much we love them;&lt;br /&gt;告诉家人和朋友，我们是多么地爱他们；&lt;br /&gt;do not delay anything that adds laughter and joy to your life;&lt;br /&gt;不要延迟任何可以给你的生活带来欢笑与快乐的事情；&lt;br /&gt;every day,&lt;br /&gt;每一天、&lt;br /&gt;every hour,&lt;br /&gt;每一小时、&lt;br /&gt;and every minute is special;&lt;br /&gt;每一分钟都是那么特别；&lt;br /&gt;and you don't know if it will be your last. 你无从知道这是否是最后刻。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-114709132177670141?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/114709132177670141/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=114709132177670141&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/114709132177670141'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/114709132177670141'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2006/05/blog-post_114709132177670141.html' title='好好想想'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-114709089395147073</id><published>2006-05-08T14:20:00.000+02:00</published><updated>2006-05-08T14:21:34.080+02:00</updated><title type='text'>关于生活</title><content type='html'>About life&lt;br /&gt;关于生活&lt;br /&gt;&lt;br /&gt;Maybe it is true that we do not know what we have got until we lost it,&lt;br /&gt;也许这是真的,直到我们失去自己所拥有的东西时，才会认识到它的珍贵；&lt;br /&gt;but it is also true that we do not know what we have been missing until it arrives .&lt;br /&gt;但这也是真的,直到我们失去的东西失而复得时，才会了解到它可能才是真正我们所想要的。&lt;br /&gt;Giving someone all your love is never an assurance that they will love you back.&lt;br /&gt;即使你把所有的爱都给予别人，也不要指望别人会把所有的爱都给你。&lt;br /&gt;Do not expect love in return;&lt;br /&gt;不要指望爱的回报，&lt;br /&gt;but if it does not,&lt;br /&gt;但如果爱没有回报，&lt;br /&gt;be content it grew in yours.&lt;br /&gt;也不要放弃不断加大你的爱心。&lt;br /&gt;It takes an hour to like someone,&lt;br /&gt;喜欢某个人只需要一小时，&lt;br /&gt;and a day to love someone,&lt;br /&gt;爱上某个人只需要一天，&lt;br /&gt;but it takes a lifetime to forget someone .&lt;br /&gt;而忘却某个人却需要用你的一生。&lt;br /&gt;Do not rely on one’s appearance;&lt;br /&gt;不要相信人的外表，&lt;br /&gt;it can deceive.&lt;br /&gt;那会蒙人;&lt;br /&gt;Do not rely on wealth;&lt;br /&gt;不要依赖财富，&lt;br /&gt;even that fades away.&lt;br /&gt;那会消失。&lt;br /&gt;Rely on someone who makes you smile,&lt;br /&gt;依靠使你欢笑的人，&lt;br /&gt;because it takes only a smile to make a dark day seem bright.&lt;br /&gt;因为仅仅是那一笑，就可以使黑暗的一天变得灿烂。&lt;br /&gt;There are moments in life when you miss someone so much that you just want to pick them from your dreams and hug them.&lt;br /&gt;生活中总会有这样的时刻：当你想念某些人时，你便会在梦中念叨他们，拥抱他们。&lt;br /&gt;Dream what you want to dream;&lt;br /&gt;做你想做的梦，&lt;br /&gt;go where you want to go;&lt;br /&gt;去你想去的地方，&lt;br /&gt;be what you want to be ,&lt;br /&gt;做你想做的人，&lt;br /&gt;because you have only one life and one chance to do all the things you wan t to do.&lt;br /&gt;因为你只有一次生命和一次机会做所有你想做的事。&lt;br /&gt;May you have enough happiness to make you sweet,&lt;br /&gt;也许有足够的幸福令你开心，&lt;br /&gt;enough trials to make you strong,&lt;br /&gt;有足够的磨练使你坚强，&lt;br /&gt;enough sorrow to keep you human,&lt;br /&gt;有足够的悲伤保持你的人性，&lt;br /&gt;enough hope to make you happy.&lt;br /&gt;有足够的希望让你欢欣鼓舞。&lt;br /&gt;Always put yourself others’ shoes.&lt;br /&gt;常常站在别人的立场上想一想，&lt;br /&gt;If you feel that it hurts you,&lt;br /&gt;如果你觉得那会使你难受，&lt;br /&gt;it probably hurts the other person, too.&lt;br /&gt;那也可能同样会使他人难受。&lt;br /&gt;The happiest of people do not necessarily have the best of everything;&lt;br /&gt;人生的最大幸福未必是拥有一切最好的东西，&lt;br /&gt;they just make the most of everything that comes along their way.&lt;br /&gt;真正需要的是物尽其用。&lt;br /&gt;Happiness waits for those who cry,&lt;br /&gt;幸福期待的是那些哭过，&lt;br /&gt;those who have been hurt,&lt;br /&gt;被伤害过，&lt;br /&gt;those who have searched,&lt;br /&gt;追求过，&lt;br /&gt;and those who have been hurt,&lt;br /&gt;以及努力过的人，&lt;br /&gt;for only they can appreciate the importance of people who have touched their lives.&lt;br /&gt;因为只有他们才能够领悟到那些曾经触动过他们生命的人的重要性。&lt;br /&gt;The brightest future will always be based on a forgotten past.&lt;br /&gt;最灿烂的未来总是建立在忘掉过去的基础上。&lt;br /&gt;You cannot go on well in life until you let your past failures and heartaches go off.&lt;br /&gt;只有摆脱过去的失败和痛楚，你才能够继续走好人生的道路。&lt;br /&gt;When you were born,&lt;br /&gt;当你诞生的时候，&lt;br /&gt;you were crying and everyone around you was smiling.&lt;br /&gt;只有你自己在哭，而你周围的人则都在微笑。&lt;br /&gt;Live your life so that when you die,&lt;br /&gt;好好地活着，以至于当你去世的时候，&lt;br /&gt;you are the one who is smiling and everyone around you is crying.&lt;br /&gt;你带着微笑，而你周围的人则都在哭泣。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-114709089395147073?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/114709089395147073/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=114709089395147073&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/114709089395147073'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/114709089395147073'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2006/05/blog-post_114709089395147073.html' title='关于生活'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-114709077709518160</id><published>2006-05-08T14:18:00.000+02:00</published><updated>2006-05-08T14:19:37.156+02:00</updated><title type='text'>你的生命是我的责任</title><content type='html'>your life is my responsibility你的生命是我的责任&lt;br /&gt;"Life consists not in holding good cards but in playing those you hold well."&lt;br /&gt;生命不是你拿了一副好牌而是将你拿的牌打好。&lt;br /&gt;A girl and a boy were on a motorcycle, speeding through the night. 一个女孩和一个男孩骑着一辆摩托车，飞快地穿越黑夜。&lt;br /&gt;They loved each other a lot.. 他们彼此深深得相爱。&lt;br /&gt;Girl: "slow down a little.. I'm scared.." 女孩：“开慢点，我害怕”。&lt;br /&gt;Boy: "No, it's so fun.." 男孩：“不，这多好玩啊”。&lt;br /&gt;Girl: "please..it's so scary.." 女孩：“求你了，这太可怕”。&lt;br /&gt;Boy: "Then say that you love me.." 男孩：“先说你爱我”。&lt;br /&gt;Girl: "Fine..I love you..can you slow down now?" 女孩：“好啊，我爱你，现在你能开慢了吗？”&lt;br /&gt;Boy: "Give me a big hug.." 男孩：“抱紧我”。&lt;br /&gt;The girl gave him a big hug. 女孩紧紧得抱住了男孩。&lt;br /&gt;Girl: "Now can you slow down?" 女孩：“现在你能开慢了吗？”&lt;br /&gt;Boy: "Can you take off my helmet and put it on? 男孩：“你能取下我的头盔自己戴上吗？”&lt;br /&gt;It's uncomfortable and its bothering me while i drive." 它很不舒服，也影响我开车。&lt;br /&gt;“The next day, there was a story in the newspaper. 第二天，报纸上有一条新闻。&lt;br /&gt;A motorcycle had crashed into a building because its brakes were broken.&lt;br /&gt;一辆摩托车因为刹车失灵撞进了一栋建筑。&lt;br /&gt;There were two people on the motorcycle, of which one died, and the other had survived....&lt;br /&gt;摩托上的两个人，一死一活....&lt;br /&gt;The guy knew that the brakes were broken. 男孩知道刹车失灵了,&lt;br /&gt;He didn't want to let the girl know, 他不想让女孩知道，&lt;br /&gt;because he knew that the girl would have gotten scared. 因为他知道女孩会害怕。&lt;br /&gt;Instead, 相反，&lt;br /&gt;he was told the last time that she loved him, 他最后一听到她爱他，&lt;br /&gt;got a hug from her,并得到她的拥抱，&lt;br /&gt;put his helmet on her so that she can live, 以及将他的头盔给她戴上以至于她能够活着，&lt;br /&gt;and died himself...而自己却牺牲了...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-114709077709518160?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/114709077709518160/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=114709077709518160&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/114709077709518160'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/114709077709518160'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2006/05/blog-post_114709077709518160.html' title='你的生命是我的责任'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-114709065728265892</id><published>2006-05-08T14:15:00.000+02:00</published><updated>2006-05-08T14:17:37.456+02:00</updated><title type='text'>从起床到出门</title><content type='html'>Good morning.&lt;br /&gt;早晨好，约翰。&lt;br /&gt;Good morning, John.&lt;br /&gt;早晨好，妈妈。&lt;br /&gt; Good morning, mom.&lt;br /&gt;闹钟响了吗?&lt;br /&gt;Did the alarm clock go off?&lt;br /&gt;*go off是闹钟“响”的意思。&lt;br /&gt;Did the alarm clock buzz?&lt;br /&gt;Did the alarm clock ring?&lt;br /&gt;该起床了!&lt;br /&gt;It's time to get up!&lt;br /&gt;It's time to wake up!&lt;br /&gt;It's time to get out of bed.&lt;br /&gt;It's time to get ready.&lt;br /&gt;我真不想起。&lt;br /&gt;I don't wanna get up.&lt;br /&gt;快点儿起床!&lt;br /&gt;Get up soon.&lt;br /&gt;我真不想起。&lt;br /&gt;I don't want to.&lt;br /&gt;你醒了吗?&lt;br /&gt;Are you awake?&lt;br /&gt;*get up是动词，表示“起床”、“起”的动作。&lt;br /&gt;awake是形容词，表示“醒了”、“没睡”的状态。&lt;br /&gt;我刚醒。&lt;br /&gt;I am now.&lt;br /&gt;你不舒服吗?&lt;br /&gt;Are you feeling sick?&lt;br /&gt;没有，只是有点儿累。&lt;br /&gt;No, I'm just tired.&lt;br /&gt;睡得好吗?&lt;br /&gt;Did you sleep well?&lt;br /&gt;嗯，睡得挺好。&lt;br /&gt;Yes, I slept very well.&lt;br /&gt;哪儿啊，几乎没睡着。&lt;br /&gt;No, I couldn't fall asleep.&lt;br /&gt;能帮我关掉闹钟吗?&lt;br /&gt;Would you turn off the alarm clock?&lt;br /&gt; *turn off的原意是“关”，多用于收音机、电视、照明等类的东西。&lt;br /&gt;虽然现在有许多东西无需用按钮开关，但一般也用turn off表示。&lt;br /&gt;请把闹钟关了。&lt;br /&gt;Please turn off the alarm clock.&lt;br /&gt;你终于起来了。&lt;br /&gt;You finally got up.&lt;br /&gt;我还困着呢!&lt;br /&gt;I'm still sleepy.&lt;br /&gt;今天是个好天!&lt;br /&gt;It's a nice day!&lt;br /&gt;是不错啊。&lt;br /&gt;It sure is.&lt;br /&gt;It's a beautiful day!&lt;br /&gt;It's a wonderful day!&lt;br /&gt;It's a great day!&lt;br /&gt;昨晚你熬夜了?&lt;br /&gt;Did you stay up late last night?&lt;br /&gt; *stay up late“睡得晚”、“熬夜”。&lt;br /&gt;把被子叠好。&lt;br /&gt;Let's fold up the futon.&lt;br /&gt;*fold意为“折叠”，&lt;br /&gt;fold up意为“叠好”、“叠整齐”；&lt;br /&gt;futon原本是日文，现在英文中也逐渐使用，意为“被子”。&lt;br /&gt;把被子收起来吧。&lt;br /&gt;Let's put the futon away.&lt;br /&gt;昨天晚上你打呼噜了。&lt;br /&gt;You were snoring last night.&lt;br /&gt;*snore“打呼噜”。&lt;br /&gt;影响你睡觉了吗?&lt;br /&gt;Did I keep you up?&lt;br /&gt;You were sawing logs last night.&lt;br /&gt;*saw logs原意为“锯木头”，在此用来表示“打呼噜”。&lt;br /&gt;我做了个可怕的梦。&lt;br /&gt;I had a nightmare.&lt;br /&gt;现在没事了。&lt;br /&gt;It's all right now.&lt;br /&gt;你一直没关灯啊。&lt;br /&gt;You left the light on.&lt;br /&gt;*left (leave)是“保持某种样子”、“保持某种状态”的意思，表达“电灯一直开着”、“发动机一直开着”、“窗户一直开着”也可以用这种句型。&lt;br /&gt;你忘了关灯了。&lt;br /&gt;You forgot to turn off the light.&lt;br /&gt;我得洗脸了。&lt;br /&gt;I have to go wash my face.&lt;br /&gt; *go wash是go和wash两个动词连用，口语中常用。&lt;br /&gt;可以把它看作是go and wash的缩略形式。&lt;br /&gt;该吃早饭了。&lt;br /&gt;It's time to eat breakfast.&lt;br /&gt;It's time to have breakfast.&lt;br /&gt;我还困着呢。&lt;br /&gt;I'm still sleepy.&lt;br /&gt;I'm still drowsy.&lt;br /&gt;我还打哈欠呢。&lt;br /&gt;I'm still yawning.&lt;br /&gt;昨天的酒还没醒呢。&lt;br /&gt;I have a hangover.&lt;br /&gt;我是个夜猫子。&lt;br /&gt;I'm a night person.&lt;br /&gt;*“早上起不来”的意思。&lt;br /&gt;我可不是。&lt;br /&gt;I'm not.&lt;br /&gt;我喜欢早起。&lt;br /&gt;I'm a morning person.&lt;br /&gt;我是用咖啡来提神的。&lt;br /&gt;Coffee wakes me up.&lt;br /&gt;Coffee gets me going.&lt;br /&gt;刷牙了吗?&lt;br /&gt;Did you brush your teeth?&lt;br /&gt;Have you brushed your teeth?&lt;br /&gt;我得梳梳头了。&lt;br /&gt;I have to comb my hair.&lt;br /&gt;穿什么好呢?&lt;br /&gt;What should I wear?&lt;br /&gt;穿红的吧!&lt;br /&gt;The red one.&lt;br /&gt;Which dress should I wear?&lt;br /&gt;Which one should I wear?&lt;br /&gt;What should I put on?&lt;br /&gt;快换衣服。&lt;br /&gt;Hurry up and get dressed.&lt;br /&gt;干嘛?&lt;br /&gt;Why?&lt;br /&gt;把睡衣收好。&lt;br /&gt;Put those pajamas away!&lt;br /&gt;啊，我正要洗呢。&lt;br /&gt;Oh, I'm washing those.&lt;br /&gt;我走了，妈妈。&lt;br /&gt;I'm leaving. Bye mom!&lt;br /&gt;好好学习啊!&lt;br /&gt;Study hard.&lt;br /&gt;I'll see you when I get back.&lt;br /&gt;I'm taking off now.&lt;br /&gt;See you.&lt;br /&gt;See you later.&lt;br /&gt;今天我们逃学吧。&lt;br /&gt;Let's play hooky today!&lt;br /&gt;*play hooky为俚语“逃学”。&lt;br /&gt;好哇，走吧!&lt;br /&gt;Yeah, let's.&lt;br /&gt;你毛衣穿反了。&lt;br /&gt;You're wearing your sweater inside out.&lt;br /&gt;You have your sweater on inside out.&lt;br /&gt;上下颠倒了。&lt;br /&gt;It's upside down.&lt;br /&gt;别忘了扔垃圾呀。&lt;br /&gt;Don't forget to take out the garbage.&lt;br /&gt;忘不了!&lt;br /&gt;I won't. 今天该你扔垃圾了。&lt;br /&gt;It's your turn to take out the garbage.&lt;br /&gt; *garbage也可以用trash和rubbish替代。&lt;br /&gt;今天你干什么?&lt;br /&gt;What are you doing today?&lt;br /&gt;今天我们开运动会。&lt;br /&gt;We're having a track and field meet.&lt;br /&gt;你快点儿，我们该迟到了。If you don't hurry, we'll be late.&lt;br /&gt;知道了，知道了。&lt;br /&gt;Okay, Okay.&lt;br /&gt;快点儿，上学该迟到了。&lt;br /&gt;Hurry up or we'll be late.&lt;br /&gt;Hurry or you'll be late for school.&lt;br /&gt;现在几点?&lt;br /&gt;What time is it?&lt;br /&gt;你锁门了吗?&lt;br /&gt;Did you lock the door?&lt;br /&gt;Have you locked the door?&lt;br /&gt;没忘了什么东西吧?&lt;br /&gt;Aren't you forgetting something?&lt;br /&gt;我想没有。&lt;br /&gt;I don't think so.&lt;br /&gt;都已经8点了!&lt;br /&gt;It's already 8:00.&lt;br /&gt;It's 8:00 already.&lt;br /&gt;我晚了!&lt;br /&gt;I'm late!&lt;br /&gt;快点儿吧!&lt;br /&gt;Hurry up!&lt;br /&gt;我得赶紧走!&lt;br /&gt;I have to rush!&lt;br /&gt;I have to hurry (up)!&lt;br /&gt;I have to get going!&lt;br /&gt;I have to get moving.&lt;br /&gt;你今天会回来得晚吗?&lt;br /&gt;Are you gonna be late today?&lt;br /&gt;不，和平常一样。&lt;br /&gt;No, I'll be home at the usual time.&lt;br /&gt;几点回来?&lt;br /&gt;What time are you coming home?&lt;br /&gt;大概7点左右吧。&lt;br /&gt;Around seven o'clock.&lt;br /&gt;饭盒带了吗?&lt;br /&gt;Have you got your lunch box?&lt;br /&gt;嗯，带了。&lt;br /&gt;Yes, right here.&lt;br /&gt;今天好像要下雨。 It might rain today.&lt;br /&gt;带上伞吧!&lt;br /&gt;Take your umbrella with you.&lt;br /&gt;出门的时候，可别忘了锁门。&lt;br /&gt;Don't forget to lock the door when you leave.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-114709065728265892?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/114709065728265892/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=114709065728265892&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/114709065728265892'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/114709065728265892'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2006/05/blog-post_08.html' title='从起床到出门'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-114691358870185875</id><published>2006-05-06T12:59:00.000+02:00</published><updated>2006-05-07T18:18:43.513+02:00</updated><title type='text'>数据库索引</title><content type='html'>索引是一个单独的、物理的数据库结构，它是某个表中一列或若干列值的集合和相应 的指向表中物理标识这些值的数据页的逻辑指针清单。&lt;br /&gt;&lt;br /&gt;一个 表的存储是由两部分组成的，一部分用来存放表 的数据页面，另一部分存放索引页面。索引就存放在索引页面上，通常，索引页面相对于 数据页面来说小得多。当进行数据检索时，系统先搜索索引页面，从中找到所需数据的指 针，再直接通过指针从数据页面中读取数据。从某种程度上，可以把数据库看作一本书， 把索引看作书的目录，通过目录查找书中的信息，显然较没有目录的书方便、快捷。&lt;br /&gt;&lt;br /&gt;&lt;span class="style2"&gt;&lt;/span&gt;索 引的B-树结构, B-树是一个多层次、 自维护的结构。一个B-树包括一个顶层，称为根节点（Root Node）；0 到多个中间层 （Intermediate）；一个底层（Level 0），底层中包括若干叶子节点（Leaf Node）。在图 8-1 中，每个方框代表一个索引页，索引列的宽度越大，B-树的深度越深，即层次越多，读取记录所要访问的索引页就越多。也就是说，数据查询的性能将随索引列层 次数目的增加而降低。&lt;br /&gt;&lt;br /&gt;索引的B-树结构&lt;br /&gt;在SQL Server 的数据库中按存储结构的不同将索引分为两类：簇索引（Clustered Index）和非簇索引（Nonclustered Index）。&lt;br /&gt;&lt;br /&gt;簇索引 簇索引对表的物理数据页中的数据按列进行排序，然后再重新存储到磁盘上，即簇索 引与数据是混为一体，的它的叶节点中存储的是实际的数据。由于簇索引对表中的数据一 一进行了排序，因此用簇索引查找数据很快。但由于簇索引将表的所有数据完全重新排列 了，它所需要的空间也就特别大，大概相当于表中数据所占空间的120% 。表的数据行只 能以一种排序方式存储在磁盘上，所以一个表只能有一个簇索引。&lt;br /&gt;&lt;br /&gt;非簇索引 非簇索引具有与表的数据完全分离的结构，使用非簇索引不用将物理数据页中的数据 按列排序。非簇索引的叶节点中存储了组成非簇索引的关键字的值和行定位器。行定位器 的结构和存储内容取决于数据的存储方式。如果数据是以簇索引方式存储的，则行定位器 中存储的是簇索引的索引键；如果数据不是以簇索引方式存储的，这种方式又称为堆存储 方式（Heap Structure），则行定位器存储的是指向数据行的指针。非簇索引将行定位器 按关键字的值用一定的方式排序，这个顺序与表的行在数据页中的排序是不匹配的。 由于非簇索引使用索引页存储因此它比簇索引需要更多的存储空间且检索效率较 低但一个表只能建一个簇索引，当用户需要建立多个索引时就需要使用非簇索引了。 从理论上讲，一个表最多可以建249 个非簇索引。&lt;br /&gt;&lt;br /&gt;&lt;p class="MsoNormal" style="text-indent: 17.1pt; line-height: 12pt;"&gt;&lt;span style="font-size: 9pt; font-family: 宋体;"&gt;由于非&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: 宋体;"&gt;聚&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: 宋体;"&gt;簇索引&lt;/span&gt;&lt;span class="unnamed31"&gt;&lt;span style="font-size: 9pt; font-family: 宋体; letter-spacing: 0pt;"&gt;的叶级点不包含实际的数据&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: 宋体;"&gt;，因此它检索效率较低，但一个表只能建一个&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: 宋体;"&gt;聚&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: 宋体;"&gt;簇索引，当用户需要建立多个索引时就需要使用非&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: 宋体;"&gt;聚&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: 宋体;"&gt;簇索引了&lt;/span&gt;&lt;span class="txt"&gt;&lt;span style="font-size: 9pt; font-family: 宋体;"&gt;。在建立非聚簇索引时，要权衡索引对查询速度的加快与降低修改速度之间的利弊。&lt;span lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p class="MsoNormal" style="text-indent: 17.1pt; line-height: 12pt;"&gt;&lt;span class="txt"&gt;&lt;span style="font-size: 9pt; font-family: 宋体;"&gt;在下面情况中使用非聚簇索引：&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: Arial;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p class="MsoNormal" style="margin-left: 63pt; text-indent: -21pt; line-height: 12pt;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 9pt; font-family: Wingdings;" lang="EN-US"&gt;u&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;        &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span class="txt"&gt;&lt;span style="font-size: 9pt; font-family: 宋体;"&gt;常用于集合函数&lt;span lang="EN-US"&gt;(如Sum,....)的列；&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: 宋体;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p class="MsoNormal" style="margin-left: 63pt; text-indent: -21pt; line-height: 12pt;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 9pt; font-family: Wingdings;" lang="EN-US"&gt;u&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;        &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span class="txt"&gt;&lt;span style="font-size: 9pt; font-family: 宋体;"&gt;常用于&lt;span lang="EN-US"&gt;join, order by, group by的列；&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: 宋体;" lang="EN-US"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;!--[if !supportLists]--&gt;&lt;span class="txt"&gt;&lt;span style="font-size: 9pt; font-family: Wingdings;" lang="EN-US"&gt;u&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;        &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span class="txt"&gt;&lt;span style="font-size: 9pt; font-family: 宋体;"&gt;查寻出的数据不超过表中数据量的&lt;span lang="EN-US"&gt;20%。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-114691358870185875?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/114691358870185875/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=114691358870185875&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/114691358870185875'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/114691358870185875'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2006/05/blog-post.html' title='数据库索引'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-114597061500040756</id><published>2006-04-25T13:56:00.000+02:00</published><updated>2006-04-25T15:16:57.330+02:00</updated><title type='text'>Das Gedanken nach dem Lesen des Junit Sourcecodes</title><content type='html'>&lt;span style="color: rgb(255, 0, 0); font-weight: bold;"&gt;&gt;&gt; Prozess:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;           &lt;/span&gt;&lt;span style="color: rgb(51, 0, 51); font-weight: bold;"&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;TestRunner.run( ToTest.class ) &lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;    &lt;/span&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;new TestSuite(testClass) &lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;// die eigentliche Klasse zerlegt und in einem TestSuite gekapselt.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;TestRunner.run(new TestSuite(testClass)) &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;// TestResult Instanz erzeugt, die existiert immer als Singleton innerhalb des ganzen Test Prozesses, die Singleton Eigenschaft wird nicht im Code hard-codiert, sondern mit dem IOC Pattern als Parameter transportiert. Gleichzeitig wird noch einen ResultPrinter erzeugt, z.B. System.out, später schließt die noch mit dem Result an.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;result.addListener(fPrinter)&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;suite.run(result)&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;            &lt;/span&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;public void run(TestResult result) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;                for (Test each : fTests) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;                      if (result.shouldStop() )&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;                          break;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;                     runTest(each, result);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;                }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;           }&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;// Die Aufgabe von TestRunner bisher schon fertig.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;TestCase.run(result)&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;Result.run(test);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;Result.runProtected( test, protected )&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;   &lt;/span&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt; public void runProtected(final Test test, Protectable p) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;        try {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;            p.protect();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;        } &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;        catch (AssertionFailedError e) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;            addFailure(test, e);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;        catch (ThreadDeath e) { // don't catch ThreadDeath by accident&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;            throw e;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;        catch (Throwable e) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;            addError(test, e);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;    }&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;// mit obengenannten Catch Block wird alle Failures und Error von TestResult gesammelt.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;TestCase.runBare(); &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;// Result wird hier nicht mehr als Parameter transportiert&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;   &lt;/span&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt; public void runBare() throws Throwable {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;        Throwable exception= null;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;        setUp(); // Fixture&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;        try {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;            runTest();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;        } catch (Throwable running) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;            exception= running;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;        finally {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;            try {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;                tearDown(); // Fixture&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;            } catch (Throwable tearingDown) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt; ...&lt;/span&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;TestCase.runTest()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;     runMethod.invoke(this);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&gt;&gt; Fixture Pattern&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Methoden, die immer davor &amp; dahinten was machen sollen, z.B Menschen, vor dem Leben ist Geboren und hinten Sterben, dann schreiben wir eine solche Klasse für den Menschen:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;public interface Menschen {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;    void runBare();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;public abstract class AbstractMenschen implements Menschen{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;    @to be overrided, na ja, jeder hat eigenen geboren Still&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;    protected abstract void geboren();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;    @to be overrided&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;    protected abstract void sterben();   &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255); font-weight: bold;"&gt;    @to be overrided&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;    protected abstract void leben();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;    // das volles Leben, implementiert die runBare Methode vom interface Menschen&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;    public void runBare() {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;        geboren();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;        leben();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;        sterben();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Die Geboren, Sterben und Leben Methoden müssen von untere Methoden weiter implementiert werden, zu 'personisieren',  dadurch haben  wir  den Contract,  hier die Sequenz schon festgelegt, das ist sogennante Fixture pattern.  &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt; public void runBare() throws Throwable {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;        Throwable exception= null;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;        setUp(); &lt;span style="color: rgb(51, 204, 0);"&gt;// Fixture&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;        try {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;            runTest();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;        } catch (Throwable running) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;            exception= running;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;        finally {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;            try {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;                tearDown(); &lt;span style="color: rgb(51, 204, 0);"&gt;// Fixture&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;            } catch (Throwable tearingDown) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;                if (exception == null) exception= tearingDown;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;        if (exception != null) throw exception;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&gt;&gt; Composite Pattern&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;interface Test, Klasse TestSuite &amp; TestCase beiden implementieren Test, d.h. die einen gemeinsame Methode &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;   &lt;span style="color: rgb(51, 102, 255);"&gt; public abstract void run(TestResult result);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;hat. &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;TestSuite enthält mehrere TestCase.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;oh... ok,&lt;span style="color: rgb(51, 51, 255);"&gt; Result.run(Test); -&gt; Test.run(result);&lt;/span&gt; mit dem Polymorphie Prinzip, wenn die instanceof TestCase, dann einfach &lt;span style="color: rgb(51, 51, 255);"&gt;TestCase.run(result)&lt;/span&gt;, sondern &lt;span style="color: rgb(51, 51, 255);"&gt;TestSuite.run(result),&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;   &lt;span style="color: rgb(51, 51, 255);"&gt; public void run(TestResult result) {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;        for (Test each : fTests) { &lt;span style="color: rgb(0, 0, 0);"&gt;// FTests ist ein Collection, der enthält TestCases.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;              if (result.shouldStop() )&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;                  break;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;            runTest(each, result); &lt;span style="color: rgb(0, 0, 0);"&gt;// endlich auch TestCase.run(Result).&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&gt;&gt; OberserverPattern&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Result existiert wie ein Teufel immer mit Test,  der enthält mehrere TestListeners,  mit dem folgenden Methoden&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;    &lt;span style="color: rgb(51, 102, 255);"&gt;public void runProtected(final Test test, Protectable p) {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;        try {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;            p.protect();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;        } &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;        catch (AssertionFailedError e) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;            addFailure(test, e);&lt;/span&gt;&lt;br /&gt;...&lt;span style="color: rgb(51, 102, 255);"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;irgend ein Fehler passiert, wird dann z.B. die Methode addFailure(*,*) aufgerufen,&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;    &lt;span style="color: rgb(51, 102, 255);"&gt;public synchronized void addFailure(Test test, AssertionFailedError t) {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;        fFailures.add(new TestFailure(test, t)); &lt;span style="color: rgb(0, 0, 0);"&gt;// fFailures ist ein List, der sammelt Failures&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;        for (TestListener each : cloneListeners())&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;            each.addFailure(test, t); &lt;span style="color: rgb(0, 0, 0);"&gt;// iterate jeden Listener, die bei dem Result registriert hat, reagiert der Listener mit dem gleichen Namen Methode addFailure.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&gt;&gt; Test eine Methode, die ein Exception auswerfen&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;jede zu testete Methode wird gekapselt bei junit Framwork, z.B. assertTrue(*), wenn die Bedingung &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0); font-weight: bold;"&gt;nicht &lt;/span&gt;&lt;span style="color: rgb(51, 102, 255); font-weight: bold;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;passt, AssertionFailedError wird ausgewurfen, dannach wird die Error bei Result gesammelt, und endlich ausgedrucken, soweit &amp; sofort, wenn ein Exception ausgewurfen werden muss, z.B. 3 / 0, dann schreiben wir nach dem Assert Satz ein fail();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;    static public void fail(String message) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;        throw new AssertionFailedError(message);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;wie folgendes &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;try {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;    assertTrue( ""+ 3/ 0, true  ); &lt;span style="color: rgb(0, 0, 0);"&gt;// ein Exception thrown muss&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;    fail(); &lt;span style="color: rgb(0, 0, 0);"&gt;// if reach here, it says no Exception ausgewurfen, error instead then, won't be caught&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;} catch( Exception e) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;    // everything's fine&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-114597061500040756?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/114597061500040756/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=114597061500040756&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/114597061500040756'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/114597061500040756'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2006/04/das-gedanken-nach-dem-lesen-des-junit.html' title='Das Gedanken nach dem Lesen des Junit Sourcecodes'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-114563208790466033</id><published>2006-04-21T16:44:00.000+02:00</published><updated>2006-04-21T17:08:08.500+02:00</updated><title type='text'>Transfer Database from MS into POSTGRES</title><content type='html'>Somehow we want to move our complete Database from MS into  Postgres. As concerned&lt;br /&gt;to save $ := )&lt;br /&gt;1.  We need following packages:&lt;br /&gt;        postgresql-8.1-404.jdbc2.jar (or any other version from Postgres)&lt;br /&gt;         msbase.jar(from Microsoft)&lt;br /&gt;         mssqlserver.jar(from Microsoft)&lt;br /&gt;         msutil.jar(from Microsoft)&lt;br /&gt;&lt;br /&gt;2. create connection to MS server:&lt;br /&gt;       String m_driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";&lt;br /&gt;       String m_url     = "jdbc:microsoft:sqlserver://fakeserver:port;&lt;br /&gt;                                         DatabaseName=nameOfDB";&lt;br /&gt;       String m_user     = "UID";&lt;br /&gt;       String m_pass     = "PWD";&lt;br /&gt;&lt;br /&gt;3. create connection to Postgres server:&lt;br /&gt;       String p_driver = "org.postgresql.Driver";&lt;br /&gt;       String p_url     = "jdbc:postgresql://fakeserver:port(usually 5432)/nameOfDB";&lt;br /&gt;       String p_user     = "UID";&lt;br /&gt;       String p_pass     = "PWD";&lt;br /&gt; &lt;br /&gt;4. Iterates every tables and copy it.&lt;br /&gt;    Needed to be concerned is the type of data. for example:  some should be surrounded&lt;br /&gt;    with " ' " and some not. I have used to build sql-string in such a way:&lt;br /&gt;          we can get metadata information of each table. Type informations were alse stored&lt;br /&gt;            in metadata. Iterate the metadata of every table and build sql-string for&lt;br /&gt;            inserting data.&lt;br /&gt;&lt;br /&gt;     three important methods: DBConnector works similiar with Connection Class.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;     /**&lt;br /&gt;      * TODO: more situations should be done&lt;br /&gt;      * @param value&lt;br /&gt;      * @param type&lt;br /&gt;      * @return&lt;br /&gt;      */&lt;br /&gt;     private String dataType( String value , int type ){&lt;br /&gt;         if(type == java.sql.Types.INTEGER ){&lt;br /&gt;             return value;&lt;br /&gt;         }&lt;br /&gt;         if( value != null ){&lt;br /&gt;             value = value.trim();&lt;br /&gt;         }&lt;br /&gt;         return value = "'" + value + "'";&lt;br /&gt;        &lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     /**&lt;br /&gt;      * Read MetaData of a table&lt;br /&gt;      * @param database&lt;br /&gt;      * @param table&lt;br /&gt;      * @throws SQLException&lt;br /&gt;      */&lt;br /&gt;     public void readTableMetaData( DBConnector database , String table )&lt;br /&gt;     throws SQLException {&lt;br /&gt;         String sql = "SELECT * FROM " + table;&lt;br /&gt;         ResultSetMetaData rsmd = database.executeQuery( sql ).getMetaData();&lt;br /&gt;         int numberOfColumns = rsmd.getColumnCount();&lt;br /&gt;        &lt;br /&gt;         typeArray = new int[ numberOfColumns ];&lt;br /&gt;         nameArray = new String[ numberOfColumns ];&lt;br /&gt;         int count = 1;&lt;br /&gt;        &lt;br /&gt;         while( count &lt;= numberOfColumns ){&lt;br /&gt;             nameArray[ count - 1  ] = rsmd.getColumnName( count );&lt;br /&gt;             typeArray[ count - 1 ] = rsmd.getColumnType( count );&lt;br /&gt;             count++;&lt;br /&gt;         }&lt;br /&gt;     }        &lt;br /&gt;&lt;br /&gt;   /**&lt;br /&gt;     * Transfers all lines of a table from srcDatabase to desDatabase&lt;br /&gt;     * @param table&lt;br /&gt;     * @throws SQLException&lt;br /&gt;     */&lt;br /&gt;    public void transferTable( String table ) throws SQLException{&lt;br /&gt;        String init = "INSERT INTO " + table + " VALUES ( ";&lt;br /&gt;        String sql = init;&lt;br /&gt;        String select = "SELECT * FROM " + table;       &lt;br /&gt;       &lt;br /&gt;        readTableMetaData( src , table );&lt;br /&gt;        rs = src.executeQuery( select );&lt;br /&gt;       &lt;br /&gt;        //iterates ResultSet&lt;br /&gt;        while( rs.next() ){&lt;br /&gt;            //get a line from ResultSet and parse it&lt;br /&gt;            for( int i = 1; i &lt;= typeArray.length ; i++){               &lt;br /&gt;                //find out the real type of a string with the help typeArray&lt;br /&gt;                if(i==1){&lt;br /&gt;                    sql = sql + dataType(rs.getString( i ) , typeArray[i-1] );&lt;br /&gt;                }&lt;br /&gt;                else{&lt;br /&gt;                    sql = sql + " ," + dataType(rs.getString( i ) , typeArray[i-1] );&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;            sql = sql + " ); ";&lt;br /&gt;            //excute a insert query&lt;br /&gt;            des.executeQuery( sql );&lt;br /&gt;            //set sql to init value&lt;br /&gt;            sql = init;&lt;br /&gt;        }                       &lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;5. to the end: fast every SQL server has their own almeighty tools, but no two of them&lt;br /&gt;    has comfortable communications interface with each other.&lt;br /&gt;    Let java do it, one of the best way!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-114563208790466033?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/114563208790466033/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=114563208790466033&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/114563208790466033'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/114563208790466033'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2006/04/transfer-database-from-ms-into.html' title='Transfer Database from MS into POSTGRES'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-114314180717835826</id><published>2006-03-23T20:11:00.000+01:00</published><updated>2006-03-23T20:23:27.766+01:00</updated><title type='text'>TCP会话详析</title><content type='html'>&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;    TCP是一个可靠的，连接定向的发送服务，数据分段传送。连接定向意味着在主机交换数据之前必须建立会话。&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　可靠性是通过给传送的段分配序号来实现的。如果一个TCP段被分裂为小片，对于每一个发送的段，接收主机必须返回带有特定时间段内接收到的字节数的答复（ACK）。&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　如果没接收到ACK，数据将重新发送。&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　如果段在接收到的时候已经损坏，接收主机将废弃它。因为没有发回ACK，所以发送者将重新发送这段。&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　TCP Three-Way Handshake&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　一次TCP会话通过Three-Way Handshake实行初始化。Three-Way Handshake的目的在于：&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　1，合成发送和接收段。&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　2，同意另一主机能一次接受的数据量（窗口尺寸与段大小）。&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　3，建立虚拟连接。&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　下列步骤概括叙述了过程：&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　1，源主机通过发送带有置为on的SYN标志的段要求会话。&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　2，接受主机通过发回具有以下特点的段表示同意接收：&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　　.SYN标志置为on。&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　　.有一个指示可能发送的段的开始字节序列号。&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　　.带有它等待接收的下一个段的字节序列号的许可。&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　3，请求的饿主机返回带有许可的序列号和许可号码的段。&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　TCP使用类似的握手过程结束连接。这保证两台主机都结束传送并且所有的数据收到了。&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　TCP滑动窗口&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　TCP使用滑动窗口为两台主机间传送缓冲数据。每台TCP/IP主机支持两个滑动窗口：一个用于接收数据，另一个用于发送数据。敞口尺寸表示计算机可以缓冲的数据量的大小。&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;滑动窗口的工作。&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　1，当TCP发送数据时，数据位于send窗口。TCP将一个带有序列号的报头加入数据包并将其交给IP，由IP将它发送到目标主机。&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　2，当每一个数据包传送时，客户机设置重传计时器，描述在重新发送数据包之前将等待ACK多久。在SEND窗口中有每一个数据包的备分，直到收到ACK。&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　3，当数据包到达服务器RECEIVE窗口，它们按照序列号放置。当接收到连续的段时间就向用户机发送一个关于数据的认可，其中带有当前窗口尺寸。&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　4，一旦客户机接收到认可，SEND窗口将由已获得认可的数据滑动到等待发送的数据。如果在重发计时器设定的时间内，客户机没有接收到对现存数据的认可，数据将重新发送。重发数据包将加重网络和客户机的负担。&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　5，如果数据包接收到时顺序错乱，那么将强制延迟ACK计时器发送认可。&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　TCP数据包结构&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　所有TCP段有两部分：数据和报头。下面域被加在TCP报头。&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　 域　　　　　　 功能&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;-------------------------------------------------------------------------&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　源端口　　　　　发送主机的TCP端口&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　目标端口　　　　目标主机的TCP端口，给通信提供终止点&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　序列号　　　　　在一个段中发送字节的顺序。&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　数据长度　　　　TCP数据段的长度&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　保留的　　　　　保留供以后使用&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　标志　　　　　　用于表示段的内容&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　窗口　　　　　　在TCP窗口中还有多少空间可用&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　校验和　　　　　验证报头是否损坏&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153); font-family: verdana;"&gt;　　紧急指针　　　　当发送紧急数据时，指针将指向紧急数据的结尾 &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-114314180717835826?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/114314180717835826/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=114314180717835826&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/114314180717835826'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/114314180717835826'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2006/03/tcp.html' title='TCP会话详析'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-113682860314138335</id><published>2006-01-09T18:31:00.000+01:00</published><updated>2006-01-09T18:43:23.940+01:00</updated><title type='text'>iNetMess 代码:</title><content type='html'>Client:&lt;br /&gt;&lt;a href="http://www.inf.fu-berlin.de/%7Eding/forblog/inet/Client.zip"&gt;下载&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Server:&lt;br /&gt;&lt;a href="http://www.inf.fu-berlin.de/%7Eding/forblog/inet/Server.zip"&gt;下载&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;使用简易manuel:&lt;br /&gt;1. start rmiregistry&lt;br /&gt;2. start Server&lt;br /&gt;3. start Client 1&lt;br /&gt;4.start Client 2&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/1662/1091/1600/jianyi.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://photos1.blogger.com/blogger/1662/1091/400/jianyi.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-113682860314138335?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/113682860314138335/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=113682860314138335&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/113682860314138335'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/113682860314138335'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2006/01/inetmess.html' title='iNetMess 代码:'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-113680395885396255</id><published>2006-01-09T11:51:00.000+01:00</published><updated>2006-01-09T11:52:39.490+01:00</updated><title type='text'>过度思维</title><content type='html'>我记得几年前,长江大桥的桥墩上, 准备建两个艺术雕像.雕像的内容是两个裸体女人.消息一发布,马上招来一片反对的声音. 有人都说,如果长江大桥的桥墩上有两个裸体女人雕像,司机的车开到那里,会掉到长江里去的.大概貌有很多中国人,看到裸体女人雕像,就马上想到了女.人.的.,生,.殖,.器. 就马上联想到了动物世界一样的,.交,.配.这还得了,这简直是色.,情.当然这个工程只有下马了. 裸体女人雕像,本生没什么可怕,但是在有些人的眼睛里,已经完全变成另外一样邪恶的东西.产生的根源,就是过度思维,过度的发挥了大脑的想像力. 所以,扫黄,扫来扫去,常常把艺术画,艺术像片也扫进去了,这不是扫黄的人的负任.怪只怪有的人太过于富于想像了. 富于想像,虽然带有"富"的字样,其实并不是真正的"富",而是缺陷. 就以JAVAEYE为例, 很多人讨论问题,学术气氛很好,讨论热火朝天.很多回贴却对前面的发言,要么断章取义,要么经回贴者想像一下,构想出一个东西出来,他的回贴,痛批他构想出来的东西,就像痛批长江大桥的桥墩上两个裸体女人艺术雕像,竟敢把色.,情的东西公开出来? 其实这不是JAVAEYE论坛上程序员们的问题,很多中国人过度思维是普遍现象,JAVAEYE论坛上域名就带了org.cn,自然也就是马克思主义原理的,共性存于个性之中的普遍原理了.相比之下,JAVA的程序员们算是好的了,在很多论坛上你能看到之样的贴子:"大陆三天收复台湾的作战过程",写的会声会色,好像是真的发生了一样. 从心理学上来说,发贴的人有了些妄想狂的心理. 从医学上来说,这叫精神分裂症的症状. 当然,有症状了,和已经生病了,还相差很远距离,不是一回事. 由于人经常有过度思维这样的情况发生,有时就造成人与人沟通成了问题,有些人处朋友,常常想,这家伙在暗中搞什么呀,他话里有话呀,这就不利于团结.想一想,人与人对面交流,都会沟通有问题,所以古人才给我们发明了"误会"这个词.何况你去猜想别人的想法呢,我认为十之八九是错的. 所以我很相信一句话: 沟通,是一种能力. 沟通就意味着实事求事,不要过度思维,不在把自已想像的东西加要别人的话里面. 求学问如此,做人更是如此!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-113680395885396255?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/113680395885396255/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=113680395885396255&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/113680395885396255'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/113680395885396255'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2006/01/blog-post.html' title='过度思维'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-113649813353937911</id><published>2006-01-05T22:51:00.000+01:00</published><updated>2006-01-05T22:55:33.876+01:00</updated><title type='text'>find a new gramatik of java</title><content type='html'>final Thread t2 = new Thread(){&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt; {start();} &lt;/span&gt;&lt;br /&gt; public void run(){&lt;br /&gt;  synchronized(mutex2){&lt;br /&gt;   t1.interrupt();&lt;br /&gt;   synchronized(mutex1){}&lt;br /&gt;}}};&lt;br /&gt;&lt;br /&gt;Diese verdammte rote Zeile ist bestimmt keine Methode, war nur einfach initialisieren, wie Konstruktor, d.h. bei dem Erzeugen des neuen Threads wird wird es gleichzeitig starten. war nur Vermuten von mir, Ergänzung wäre super.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-113649813353937911?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/113649813353937911/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=113649813353937911&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/113649813353937911'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/113649813353937911'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2006/01/find-new-gramatik-of-java.html' title='find a new gramatik of java'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-113473800309905197</id><published>2005-12-16T13:58:00.000+01:00</published><updated>2005-12-16T14:00:03.556+01:00</updated><title type='text'>3 - 30 Minutes to control c++ ( if you allready know c )</title><content type='html'>&lt;a href="http://www.topcoder.com/pl/?module=Static&amp;d1=gccj05&amp;amp;d2=ZH_cpp"&gt;http://www.topcoder.com/pl/?module=Static&amp;d1=gccj05&amp;amp;d2=ZH_cpp&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-113473800309905197?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/113473800309905197/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=113473800309905197&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/113473800309905197'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/113473800309905197'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/12/3-30-minutes-to-control-c-if-you.html' title='3 - 30 Minutes to control c++ ( if you allready know c )'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-113325914865882155</id><published>2005-11-29T11:07:00.000+01:00</published><updated>2005-11-29T11:12:28.853+01:00</updated><title type='text'>Triky Constants</title><content type='html'>interface InterfaceA{&lt;br /&gt;    public static final int A = 2 * InterfaceB.B;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;interface InterfaceB{&lt;br /&gt;    public static final int B = InterfaceC.C + 1;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;interface InterfaceC extends InterfaceA{&lt;br /&gt;    public static final int C = A + 1;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public class Main implements InterfaceA,&lt;br /&gt;    InterfaceB, InterfaceC {&lt;br /&gt;    public static void main (String [] args){&lt;br /&gt;        System.out.println (C + B + A);  // &gt;&gt; 6&lt;br /&gt;         System.out.println (A + B + C);  // &gt;&gt; 7&lt;br /&gt;        System.out.println (B + A + C);  // &gt;&gt; 3&lt;br /&gt;        System.out.println (C + A + B);  // &gt;&gt; ?&lt;br /&gt;    }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-113325914865882155?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/113325914865882155/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=113325914865882155&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/113325914865882155'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/113325914865882155'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/11/triky-constants.html' title='Triky Constants'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-113275569927841056</id><published>2005-11-23T15:19:00.000+01:00</published><updated>2005-11-23T15:21:41.733+01:00</updated><title type='text'>在网上看到一种突破收费网站的搜索方法</title><content type='html'>&gt;/首先打开Google，在关键词输入框中输入"index&lt;br /&gt;&gt;of/"inurl:lib(双引号为英文状态下），选择 &lt;div id="mb_4"&gt;&lt;wbr&gt;"搜索简体中文网页"选项，回车搜&lt;br /&gt;&gt;索，得到了一些网页，不要以为这是一些普通的页面&lt;wbr&gt;，其实它们是一些图­书网站&lt;br /&gt;&gt;的资源列表，点击打开它来看看，怎么样？是不是所有资源一收眼&lt;wbr&gt;底了？&lt;br /&gt;&gt;&lt;br /&gt;&gt;&lt;br /&gt;&gt;使用其他关键字可能得到更多的资源：&lt;br /&gt;&gt;在搜索框上输入："index of /"cnki&lt;br /&gt;&gt;再按搜索你就可以找到许多图书馆的CNKI、VIP&lt;wbr&gt;、超星等入口！&lt;br /&gt;&gt;&lt;br /&gt;&gt;&lt;br /&gt;&gt;在搜索框上输入："index of /" ppt&lt;br /&gt;&gt;再按搜索你就可以突破网站入口下载powerpint作品！&lt;br /&gt;&gt;在搜索框上输入："index of /"mp3&lt;br /&gt;&gt;再按搜索你就可以突破网站入口下载mp3、rm等影视作品！&lt;br /&gt;&gt;&lt;br /&gt;&gt;&lt;br /&gt;&gt;在搜索框上输入："index of /"swf&lt;br /&gt;&gt;再按搜索你就可以突破网站入口下载flash作品！&lt;br /&gt;&gt;在搜索框上输入："index of /"加上要下载的软件名&lt;br /&gt;&gt;再按搜索你就可以突破网站入口下载软件！&lt;br /&gt;&gt;在搜索框上输入："index of /"AVI&lt;br /&gt;&gt;再按搜索你就可以突破网站入口下载AVI视频&lt;br /&gt;&gt;你会找到什么呢？同理，把AVI换为MPEG看看又会找到什么&lt;wbr&gt;呢？呵呵！接下来不用&lt;br /&gt;&gt;我再教了吧？那就试一下你的手气吧！&lt;br /&gt;&gt;&lt;br /&gt;&gt;呵呵，我在网上查到的，没有试过，不知道效果如何。&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-113275569927841056?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/113275569927841056/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=113275569927841056&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/113275569927841056'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/113275569927841056'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/11/blog-post.html' title='在网上看到一种突破收费网站的搜索方法'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-113234542098712692</id><published>2005-11-18T21:22:00.000+01:00</published><updated>2005-11-18T21:23:41.110+01:00</updated><title type='text'>Java中的测不准原理</title><content type='html'>测不准原理&lt;br /&gt;     想做一个物理实验，看看某物质的导电情形，于是接上电压，并串联上一个安培计来观察电流，但是你知道吗？安培计本身也带有电阻，造成你的实验准确度受到影响。诸如此类的问题在科学界很常见，所以有了「测不准原理」之说。不只是物理，测不准的现象在计算机上也有可能发生。比方说，你想写一个观察程序，观察 CPU 在执行某程序之下的使用率， 但是你的观察程序本身也会占用一部份的 CPU 效能，造成测出来的数据不精确。&lt;br /&gt;&lt;br /&gt;　　 再想象下面的情况：如果你想写一个 Java 程序，观察某对象什么时候会被垃圾收集的执行绪清除，所以你必须要用 一个 reference 记住此对象，以便随时观察，但是却因此造成此对象的 reference 数目一直无法为零， 使得对象无法被清除。...... 又是「测不准」。&lt;br /&gt;&lt;br /&gt;　　 java.lang.ref.WeakReference&lt;br /&gt;&lt;br /&gt;　　 不过，现在有了 Weak Reference 之后，这就可以迎刃而解了。如果你希望能随时取得某对象的信息，但又不想影响此 对象的垃圾收集，那么你应该用 Weak Reference 来记住此对象，而不是用一般的 reference。请看下面的例子：&lt;br /&gt;&lt;br /&gt;　　 ...&lt;br /&gt;&lt;br /&gt;　　 WeakReference wr = new WeakReference(obj);&lt;br /&gt;&lt;br /&gt;　　 ...&lt;br /&gt;&lt;br /&gt;　　 if (wr.get()==null) {&lt;br /&gt;&lt;br /&gt;　　 System.out.println("obj 已经被清除了 ");&lt;br /&gt;&lt;br /&gt;　　 } else {&lt;br /&gt;&lt;br /&gt;　　 System.out.println("obj&lt;br /&gt;　　 尚未被清除，其信息是 "+obj.toString());&lt;br /&gt;&lt;br /&gt;　　 }&lt;br /&gt;&lt;br /&gt;　　 ...&lt;br /&gt;&lt;br /&gt;　　 在此例中，透过 get() 可以取得此 Reference 的所指到的对象，如果传出值为 null 的话，代表此对象已经被清除。&lt;br /&gt;&lt;br /&gt;　　 这类的技巧，在设计 Optimizer 或 Debugger 这类的程序时常会用到，因为这类程序需要取得某对象的信息，但是不可以 影响此对象的垃圾收集。&lt;br /&gt;&lt;br /&gt;　　 java.lang.ref.SoftReference&lt;br /&gt;&lt;br /&gt;　　 Soft Reference 虽然和 Weak Reference 很类似，但是用途却不同。SoftReference 是用来设计 object-cache 之用的。 被 Soft Reference 指到的对象，即使没有任何 Direct Reference，也不会被清除。一直要到 JVM 内存不足时且 没有 Direct Reference 时才会清除，如此一来 SoftReference 不但可以把对象 cache 起来，也不会造成内存不足的错误 （OutOfMemoryError）。我觉得 Soft Reference 也适合拿来实作 pooling 的技巧。&lt;br /&gt;&lt;br /&gt;　　 java.lang.ref.PhantomReference&lt;br /&gt;&lt;br /&gt;　　 Phantom Reference 主要是用来取代对象的 finalize()。程序员利用 finalize() 来进行释放资源的同时，有可能不小心 让此对象再度拥有 Direct Reference。但是使用 Phantom Reference 则不会有此情形发生。和 Weak Reference 以 及 SoftReference 最大的不同是：Phantom Reference 一订要搭配着 ReferenceQueue 使用，因为 Phantom Reference 的 get() 传 出值一定是 null（以避免此对象不小心再度拥有 Direct Reference）。通常我们会设计一个 class 继承 PhantomReference，然 后 override 其 clear() 来定义释放资源等收尾的动作。当然，我宁可小心一点地使用 finalize()，也不愿意自找麻烦地使用 Phantom Reference。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-113234542098712692?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/113234542098712692/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=113234542098712692&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/113234542098712692'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/113234542098712692'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/11/java.html' title='Java中的测不准原理'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-113234506675338515</id><published>2005-11-18T21:02:00.000+01:00</published><updated>2005-11-18T21:17:54.366+01:00</updated><title type='text'>The java.lang.ref package</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/1662/1091/1600/references.gif"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://photos1.blogger.com/blogger/1662/1091/320/references.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;Letzte Woche geschiet der JAVA Expert Kurs über den Thema 'References', Im Prinzip haben wir beide den Verdammten nicht umgefasst, jetzt kommt die Zusammenfassungen, hoffe die hilft.&lt;br /&gt;&lt;br /&gt;&gt;&gt; strong reference, normale reference, überall, z.B Object obj = new Object(); An dieser Stelle ist obj eine Strong Reference, die zeigt einen Object, der im Heap liegt, &lt;br /&gt;solange 'obj == null || obj == woanderes' nicht gibt, der System.gc() wurde nie den Speicer Platz, wo der Object liegt, zurücksammeln.&lt;br /&gt;&lt;br /&gt;&gt;&gt; SoftReference, public class SoftReference&lt;T&gt; extends Reference&lt;T&gt;, &lt;br /&gt;&lt;br /&gt;SoftReference 类的一个典型用途就是用于内存敏感的高速缓存。SoftReference 的原理是：在保持对对象的引用时保证在 JVM 报告内存不足情况之前将清除所有的软引用。关键之处在于，垃圾收集器在运行时可能会（也可能不会）释放软可及对象。对象是否被释放取决于垃圾收集器的算法以及垃圾收集器运行时可用的内存数量。&lt;br /&gt;&lt;br /&gt;&gt;&gt; WeakReference, &lt;br /&gt;&lt;br /&gt;WeakReference 类的一个典型用途就是规范化映射（canonicalized mapping）。另外，对于那些生存期相对较长而且重新创建的开销也不高的对象来说，弱引用也比较有用。关键之处在于，垃圾收集器运行时如果碰到了弱可及对象，将释放 WeakReference 引用的对象。然而，请注意，垃圾收集器可能要运行多次才能找到并释放弱可及对象&lt;br /&gt;&lt;br /&gt;&gt;&gt; PhantomReference,&lt;br /&gt;&lt;br /&gt;PhantomReference 类只能用于跟踪对被引用对象即将进行的收集。同样，它还能用于执行 pre-mortem 清除操作。PhantomReference 必须与 ReferenceQueue 类一起使用。需要 ReferenceQueue 是因为它能够充当通知机制。当垃圾收集器确定了某个对象是虚可及对象时，PhantomReference 对象就被放在它的 ReferenceQueue 上。将 PhantomReference 对象放在 ReferenceQueue 上也就是一个通知，表明 PhantomReference 对象引用的对象已经结束，可供收集了。这使您能够刚好在对象占用的内存被回收之前采取行动。&lt;br /&gt;&lt;br /&gt;&gt;&gt; 垃圾收集器和引用交互,&lt;br /&gt;&lt;br /&gt;垃圾收集器每次运行时都可以随意地释放不再是强可及的对象占用的内存。如果垃圾收集器发现了软可及对象，就会出现下列情况：&lt;br /&gt;　　&lt;br /&gt;　　SoftReference 对象的 referent 域被设置为 null，从而使该对象不再引用 heap 对象。&lt;br /&gt;　　&lt;br /&gt;　　SoftReference 引用过的 heap 对象被声明为 finalizable。&lt;br /&gt;　　&lt;br /&gt;　　当 heap 对象的 finalize() 方法被运行而且该对象占用的内存被释放，SoftReference 对象就被添加到它的 ReferenceQueue（如果后者存在的话）。&lt;br /&gt;&lt;br /&gt;&gt;&gt; Create a strong reference to an object, MyObject obj = new MyObject();&lt;br /&gt;&gt;&gt; Create a reference queue, ReferenceQueue rq = new ReferenceQueue();&lt;br /&gt;&gt;&gt; Create a weakReference to obj and associate our reference queue, &lt;br /&gt;WeakReference wr = new WeakReference(obj, rq);　&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-113234506675338515?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/113234506675338515/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=113234506675338515&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/113234506675338515'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/113234506675338515'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/11/javalangref-package.html' title='The java.lang.ref package'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-113145125152013195</id><published>2005-11-08T12:59:00.000+01:00</published><updated>2005-11-08T13:00:51.583+01:00</updated><title type='text'>a useful frage</title><content type='html'>Text:&lt;br /&gt;Hallo&lt;br /&gt;&lt;br /&gt;Ich habe folgendes Problem. Ich arbeite an einer Client Server Software und möchte RMI nutzen. Nun habe ich RMI an einem Beispiel getestet und es lief. Wenn ich es aber in meiner Software integriere entsteht folgender Fehler.&lt;br /&gt;&lt;br /&gt;Hello Server failed: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:&lt;br /&gt;    java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:&lt;br /&gt;    java.lang.ClassNotFoundException: com.ch.rmiex.Hello_Stub&lt;br /&gt;&lt;br /&gt;Die Klassen sind exakt wie im Test wo es funktioniert hat. Und die Stub-Klasse liegt im selben Package wie der Server.&lt;br /&gt;&lt;br /&gt;Was kann da falsch sein?&lt;br /&gt;&lt;br /&gt;&lt;font color=red&gt;Ant:es könnt sein das die RMIREGISTRY die klassen des severs nicht findet. start die registry mal im verzeichnis wo deine klassen liegen&lt;/font&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-113145125152013195?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/113145125152013195/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=113145125152013195&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/113145125152013195'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/113145125152013195'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/11/useful-frage.html' title='a useful frage'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-113144456831071338</id><published>2005-11-08T11:08:00.000+01:00</published><updated>2005-11-08T11:09:28.326+01:00</updated><title type='text'>RMI classic Tutorial</title><content type='html'>&lt;a href="http://www.ccs.neu.edu/home/kenb/com3337/rmi_tut.html"&gt;HIER&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-113144456831071338?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/113144456831071338/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=113144456831071338&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/113144456831071338'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/113144456831071338'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/11/rmi-classic-tutorial.html' title='RMI classic Tutorial'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-113070368216781413</id><published>2005-10-30T21:20:00.000+01:00</published><updated>2005-10-30T22:38:52.163+01:00</updated><title type='text'></title><content type='html'>&lt;a href="http://page.mi.fu-berlin.de/~yang/links/eaa_1.rar"&gt;eaa_1&lt;/a&gt;&lt;br /&gt;&lt;a href="http://page.mi.fu-berlin.de/~yang/links/sysi_1.rar"&gt;sysi_1&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-113070368216781413?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/113070368216781413/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=113070368216781413&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/113070368216781413'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/113070368216781413'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/10/eaa1-sysi1.html' title=''/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-113049682796176115</id><published>2005-10-28T12:53:00.000+02:00</published><updated>2005-10-28T12:53:47.976+02:00</updated><title type='text'>robbin的HttpSession总结</title><content type='html'>HttpSession不是Java独有的概念，JSP，PHP，ASP都支持HttpSession。偶对，PHP还比较清楚，JSP也比较清楚，ASP没有研究过这个问题，但估计和JSP一样。 &lt;br /&gt;&lt;br /&gt;apache httpd server本身不支持session，更多的作为一个web server，仅支持少量的SSI，CGI功能。我猜想你说的apache session大概是安装了PHP的Apache。php的session确实是每次都要在apache的临时目录建了session文件。这有一定的缘故。由于不像JSP有一个JVM专门开辟了一个内存区，同时传统的apache在unix是进程模型，进程间通讯比较困难，对于进程间共享session的问题，就是采取保存在硬盘上的办法。只不过unix上的apache的IO效率特别高，基本上不会有多少性能损失。这就是你看到apache临时目录里面有很多session文件的原因。 &lt;br /&gt;&lt;br /&gt;对于JSP来说，在非集群环境下，session是保存在JVM开辟的内存里面的，那么究竟是否会使用某些算法，例如LRU算法将不常用的session钝化在硬盘上呢？由于每个App Server实现不同，我也不敢下断言，但是就普遍情况而言，是不会钝化在硬盘上的。不论是Tomcat，还是Weblogic都是如此。其实这个问题很容易就可以想清楚，session对象如果能够钝化在硬盘上，必须实现序列化接口，如果App Server没有要求你必须把所有session对象实现序列化接口的化就意味着肯定不会钝化到硬盘上，否则App Server一钝化就很有可能报无法序列化的错误。 &lt;br /&gt;&lt;br /&gt;因此session绝对不应该设为永远不过期，实际上App Server也不会允许你这么做，就是你在程序里面这么设也不起作用。 &lt;br /&gt;&lt;br /&gt;由于大量session占用过多JVM内存，导致JVM报告OutOfMemory的错误，这是一个很常见的现象，不管是多牛的App Server一样会中招！绝不会有例外。也许某些人说这么容易中招的App Server还能在市场上混下去吗？ &lt;br /&gt;&lt;br /&gt;嘿嘿，拿weblogic来说吧，你写一个JSP，就一句话 System.exit(0);，你运行一下，Weblogic Server马上关闭，换了任何App Server都得中招，只有一个例外，就是Resin。因为resin很狡猾，用一个脚本不断监视，一旦发现App Server down掉立刻重起。所以Resin也不是不中招，而是中招以后立刻重起罢了。 &lt;br /&gt;&lt;br /&gt;因此程序带来的性能问题不管多好的App Server都架不住，你说JRun可以钝化到硬盘上，我相信肯定有一个前提，就是所有的session对象都必须可序列化，否则也根本无法钝化。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-113049682796176115?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/113049682796176115/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=113049682796176115&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/113049682796176115'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/113049682796176115'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/10/robbinhttpsession.html' title='robbin的HttpSession总结'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112941410264341038</id><published>2005-10-16T00:01:00.000+02:00</published><updated>2005-10-16T00:08:25.300+02:00</updated><title type='text'>Themen für Mobile DB</title><content type='html'>&lt;h3&gt;Vorstellung der Themen&lt;br /&gt;              17.10.2005 um 16:00 SR006&lt;/h3&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Entwicklung einer persistenten Message Queue für mobile ad-hoc Netze&lt;br /&gt;&lt;/h3&gt;  Nachrichten orientierte Middleware (Message Oriented Middleware (MOM)) unterstützt die Kommunikation zwischen verteilten Komponenten durch Nachrichtenvermittlung: Clients senden Nachrichten mit einem Serviceaufruf and zugehörigen Parametern an andere Komponenten durch das Netz. Empfänger führen den angeforderten Dienst aus und schicken asynchron eine Nachricht mit dem Ergebnis des Dienstes an den Sender zurück. Nachrichten orientierte Middleware ermöglicht eine Entkopplung von Client und Server, da der Client bereits in seinem Workflow weiterverfahren kann, sobald die Middleware seine Nachricht akzeptiert hat. Die eventuelle Antwort kann sich der Client zu einer beliebigen Zeit später abholen.&lt;br /&gt; Die Kommunikationsmetapher von MOM passt relativ gut zu den Anforderungen in mobilen ad-hoc Netzen (MANETs), entsprechend soll in diesem Projekt eine persistente Nachrichten Queue für MANETs entwickelt werden. Da in MANETs nicht von einem zentralen Server ausgegangen werden kann, auf dem eine solche Message Queue persistent abgelegt werden kann, soll die Message Queue auf Basis eines verteilen  virtuellen Speichers entwickelt werden.&lt;br /&gt; &lt;ul&gt; &lt;li&gt;Betreuer: Joos-Hendrik Böse (boese[at]mi.fu-berlin.de)&lt;/li&gt; &lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112941410264341038?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112941410264341038/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112941410264341038&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112941410264341038'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112941410264341038'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/10/themen-fr-mobile-db.html' title='Themen für Mobile DB'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112818229382785878</id><published>2005-10-01T17:45:00.000+02:00</published><updated>2005-10-01T18:32:20.040+02:00</updated><title type='text'>TDD</title><content type='html'>8月份曾被chef要求写一个对csv Datei进行读入然后加以字符串分析并生成对应Object的类，而这些被读入的字符串又拥有好几种不同的组合方式(Pattern)。 当时我们是这样做的， 先由chef写一个测试类， 考虑到所有的Pattern和一些极端情况， 然后由我来写这个具体类， 目的是让这个测试类通过。 真是好具体的Aufgabe啊, 感觉上是在做作业. 其实当时已经在不知不觉地使用了当今最为热门的敏捷开发方法之一 'TDD', Test Driven Developing, 即以测试来驱动开发.&lt;br /&gt;&lt;br /&gt;Kent Beck用了两页纸的篇幅，演示了一次完全以测试驱动的方式，开发计算斐波纳契数列。&lt;br /&gt;&lt;br /&gt;&gt;&gt; 第一个测试与第一次的代码&lt;br /&gt;&lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;public&lt;/span&gt; &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;void&lt;/span&gt; testFibonacci&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;    assertEquals&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;,fib&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;int&lt;/span&gt; fib&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;int&lt;/span&gt; n&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;/span&gt;&gt;&gt; 第二个测试与第二次的代码&lt;br /&gt;&lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;public&lt;/span&gt; &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;void&lt;/span&gt; testFibonacci&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;    assertEquals&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;,fib&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;;&lt;br /&gt;    assertEquals&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;,fib&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;int&lt;/span&gt; fib&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;int&lt;/span&gt; n&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;if&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;n==&lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;;&lt;br /&gt;    &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;/span&gt;&gt;&gt; 对测试代码进行改进，使之更为通用&lt;br /&gt;&lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;public&lt;/span&gt; &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;void&lt;/span&gt; testFibonacci&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;int&lt;/span&gt; cases&lt;span style="color: rgb(0, 0, 0);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;]&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;]&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;,&lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;/span&gt;,&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;,&lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;/span&gt;;&lt;br /&gt;    &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;for&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;int&lt;/span&gt; i=&lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;;i&lt;cases.&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;length&lt;/span&gt;;i++&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;        assertEquals&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;cases&lt;span style="color: rgb(0, 0, 0);"&gt;[&lt;/span&gt;i&lt;span style="color: rgb(0, 0, 0);"&gt;]&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;]&lt;/span&gt;,fib&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;cases&lt;span style="color: rgb(0, 0, 0);"&gt;[&lt;/span&gt;i&lt;span style="color: rgb(0, 0, 0);"&gt;]&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;]&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="postbody"&gt;&gt;&gt; 再增加n=2的测试&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;public&lt;/span&gt; &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;void&lt;/span&gt; testFibonacci&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;int&lt;/span&gt; cases&lt;span style="color: rgb(0, 0, 0);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;]&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;]&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;,&lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;/span&gt;,&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;,&lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;/span&gt;,&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;2&lt;/span&gt;,&lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;/span&gt;;&lt;br /&gt;    &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;for&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;int&lt;/span&gt; i=&lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;;i&lt;cases.&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;length&lt;/span&gt;;i++&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;        assertEquals&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;cases&lt;span style="color: rgb(0, 0, 0);"&gt;[&lt;/span&gt;i&lt;span style="color: rgb(0, 0, 0);"&gt;]&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;]&lt;/span&gt;,fib&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;cases&lt;span style="color: rgb(0, 0, 0);"&gt;[&lt;/span&gt;i&lt;span style="color: rgb(0, 0, 0);"&gt;]&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;]&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;cases.length 再增加n="2的测试" public="" void="" testfibonacci="" cases="{{0,0},{1,1},{2,1}};" int="" i="" 0="" 不=""&gt;&lt;/cases.length&gt;&lt;span class="postbody"&gt; 不需要修改代码，测试就通过了。 &lt;/span&gt;&lt;br /&gt;&lt;cases.length 再增加n="2的测试" public="" void="" testfibonacci="" cases="{{0,0},{1,1},{2,1}};" int="" i="" 0="" 不=""&gt;&lt;br /&gt;&gt;&gt; 再增加n=3的测试&lt;br /&gt;&lt;/cases.length&gt;&lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;public&lt;/span&gt; &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;void&lt;/span&gt; testFibonacci&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;int&lt;/span&gt; cases&lt;span style="color: rgb(0, 0, 0);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;]&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;]&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;,&lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;/span&gt;,&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;,&lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;/span&gt;,&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;2&lt;/span&gt;,&lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;/span&gt;,&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;3&lt;/span&gt;,&lt;span style="color: rgb(0, 0, 0);"&gt;2&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;/span&gt;;&lt;br /&gt;    &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;for&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;int&lt;/span&gt; i=&lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;;i&lt;cases.&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;length&lt;/span&gt;;i++&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;        assertEquals&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;cases&lt;span style="color: rgb(0, 0, 0);"&gt;[&lt;/span&gt;i&lt;span style="color: rgb(0, 0, 0);"&gt;]&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;]&lt;/span&gt;,fib&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;cases&lt;span style="color: rgb(0, 0, 0);"&gt;[&lt;/span&gt;i&lt;span style="color: rgb(0, 0, 0);"&gt;]&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;]&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="postbody"&gt;&gt;&gt; 测试失败，于是修改代码，还是如法炮制&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;int&lt;/span&gt; fib&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;int&lt;/span&gt; n&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;if&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;n==&lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;;&lt;br /&gt;    &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;if&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;n&lt;=&lt;span style="color: rgb(0, 0, 0);"&gt;2&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;;&lt;br /&gt;    &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;2&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;cases.length 再增加n="2的测试" public="" void="" testfibonacci="" cases="{{0,0},{1,1},{2,1}};" int="" i="" 0="" 不=""&gt;&lt;cases.length i="" 测="" int="" return="" 0="" n=""&gt;然后，最为神奇的部分在下面的四次修改：&lt;br /&gt;&lt;br /&gt;&gt;&gt;&gt;&gt; &lt;/cases.length&gt;&lt;/cases.length&gt;&lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;int&lt;/span&gt; fib&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;int&lt;/span&gt; n&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;if&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;n==&lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;;&lt;br /&gt;    &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;if&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;n&lt;=&lt;span style="color: rgb(0, 0, 0);"&gt;2&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;;&lt;br /&gt;    &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;+&lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;;&lt;span style="color: rgb(102, 102, 255);"&gt;//注意这里&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;br /&gt;&lt;br /&gt;&gt;&gt;&gt;&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;int&lt;/span&gt; fib&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;int&lt;/span&gt; n&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;if&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;n==&lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;;&lt;br /&gt;    &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;if&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;n&lt;=&lt;span style="color: rgb(0, 0, 0);"&gt;2&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;;&lt;br /&gt;    &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;return&lt;/span&gt; fib&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;n-&lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;+&lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;;&lt;span style="color: rgb(102, 102, 255);"&gt;//注意这里&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;br /&gt;&lt;br /&gt;&gt;&gt;&gt;&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;int&lt;/span&gt; fib&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;int&lt;/span&gt; n&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;if&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;n==&lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;;&lt;br /&gt;    &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;if&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;n&lt;=&lt;span style="color: rgb(0, 0, 0);"&gt;2&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;;&lt;br /&gt;    &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;return&lt;/span&gt; fib&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;n-&lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;+fib&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;n-&lt;span style="color: rgb(0, 0, 0);"&gt;2&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;;&lt;span style="color: rgb(102, 102, 255);"&gt;//注意这里&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;br /&gt;&lt;br /&gt;&gt;&gt;&gt;&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;int&lt;/span&gt; fib&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;int&lt;/span&gt; n&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;if&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;n==&lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;0&lt;/span&gt;;&lt;br /&gt;    &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;if&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;n==&lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;;&lt;span style="color: rgb(102, 102, 255);"&gt;//注意这里&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;return&lt;/span&gt; fib&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;n-&lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;+fib&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;n-&lt;span style="color: rgb(0, 0, 0);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;cases.length 再增加n="2的测试" public="" void="" testfibonacci="" cases="{{0,0},{1,1},{2,1}};" int="" i="" 0="" 不=""&gt;&lt;cases.length i="" 测="" int="" return="" 0="" n=""&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;最终的结论是：&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;代码就像你的左脚，测试就像你的右脚。&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;你可以先迈左脚，再迈右脚。然后一直走下去。&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;也可以先迈右脚，再迈左脚。然后一直走下去。&lt;/span&gt;&lt;br /&gt;只要你不是一直单脚跳着前进，你都会走得很稳，而且没有人看得出区别来。 &lt;/cases.length&gt;&lt;/cases.length&gt;&lt;/cases.&gt;&lt;/cases.&gt;&lt;/cases.&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112818229382785878?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112818229382785878/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112818229382785878&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112818229382785878'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112818229382785878'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/10/tdd.html' title='TDD'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112798310914243000</id><published>2005-09-29T10:29:00.000+02:00</published><updated>2005-09-29T10:44:48.383+02:00</updated><title type='text'>Wait() and notify() problem</title><content type='html'>had read the following code of a team member yesterday, it seems there'd be deadlock, but it works, for such a basic point, don't dare to ask others( am not zhaoJing ), comments are welcome.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;Vector commandQueue;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;public void addCommand(int commandId) {&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;// the common monitor &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;        synchronized (&lt;span style="color: rgb(255, 0, 0);"&gt;commandQueue&lt;/span&gt;) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;            commandQueue.addElement(new Integer(commandId));&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;              // the unique place to notify commandQueue&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;            commandQueue.notify();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt; public void run() {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;        Integer command;  &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;        while (!stop) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;            command = null;     &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;            synchronized (&lt;span style="color: rgb(255, 0, 0);"&gt;commandQueue&lt;/span&gt;) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;                if (commandQueue.size() &gt; 0) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;                    command = (Integer) commandQueue.elementAt(0);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;                    commandQueue.removeElementAt(0);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;                } else {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;                    try {&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;// wait for '&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;addCommand(int commandId) ', but while the waiting will it release its monitor 'commandQueue'?&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;                        commandQueue.wait();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;                    } catch (InterruptedException e) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;                        e.printStackTrace();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;                    }&lt;/span&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;            if (command != null) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;                executeCommand(command.intValue());&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;            }&lt;/span&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112798310914243000?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112798310914243000/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112798310914243000&amp;isPopup=true' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112798310914243000'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112798310914243000'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/09/wait-and-notify-problem.html' title='Wait() and notify() problem'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112794921018137412</id><published>2005-09-29T01:01:00.000+02:00</published><updated>2005-09-29T01:13:30.186+02:00</updated><title type='text'>静态横切</title><content type='html'>静态横切和动态横切的区别在于它不修改一个给定对象的执行行为。相反，它允许通过引入附加的方法字段和属性来修改对象的结构。此外，静态横切可以把扩展和实现附加到对象的基本结构中。在AOP实现中，通常将静态横切称为introduce或者mixin。&lt;br /&gt;&lt;br /&gt;举例来说，当前已经实现了一个邮件收发系统，其中类Mail完成了收发邮件的功能。但在产品交付后，发现该系统存在缺陷，在收发邮件时，未曾实现邮件地址的验证功能。现在，第三方产品已经提供了验证功能的接口IValidatable：&lt;br /&gt;   &lt;p&gt;public interface IValidatable { boolean ValidateAddress(); }&lt;br /&gt;&lt;/p&gt; &lt;p&gt;我们可以利用设计模式中的Adapter模式，来完成对第三方产品API的调用。我们可以定义一个新的类MailAdapter，该类实现了IValidatable接口，同时继承了Mail类：&lt;br /&gt;&lt;/p&gt;              &lt;p&gt;public class MailAdapter extends Mail implements IValidatable {&lt;br /&gt;public bool ValidateAddress() {&lt;br /&gt;if(this.getToAddress() != null) {&lt;br /&gt;return true;&lt;br /&gt;} else {&lt;br /&gt;return false;&lt;br /&gt;}}}&lt;br /&gt;&lt;/p&gt;     &lt;p&gt;通过引入MailAdapter类，原来Mail对象完成的操作，将全部被MailAdapter对象取代。然而，此种实现方式虽然能解决引入新接口的问题，但类似下面的代码，却是无法编译通过的：&lt;br /&gt;Mail mail = new Mail();&lt;br /&gt;IValidatable validate = ((IValidatable)mail).ValidateAddress();&lt;br /&gt;必须将第一行代码作如下修改：&lt;br /&gt;Mail mail = new MailAdapter();&lt;/p&gt;   &lt;p&gt;利用AOP的静态横切技术，可以将IValidatable接口织入到原有的Mail类中，这是一种非常形象的introduce功能，其实现仍然是在aspect中完成：&lt;/p&gt;                &lt;p&gt;import com.acme.validate.Validatable;&lt;br /&gt;public aspect MailValidateAspect {&lt;br /&gt;declare parents: Mail implements IValidatable;&lt;br /&gt;public boolean Mail.validateAddress() {&lt;br /&gt;           if(this.getToAddress() != null) {&lt;br /&gt;                   return true;&lt;br /&gt;           } else {&lt;br /&gt;                   return false;&lt;br /&gt;           }&lt;br /&gt;} }&lt;br /&gt;&lt;/p&gt; &lt;p&gt;静态横切的方法，并没有引入类似MailAdapter的新类，而是通过定义的MailValidateAspect方面，利用横切技术为Mail类introduce了新的方法ValidateAddress()，从而实现了Mail的扩展。因此如下的代码完全可行。&lt;/p&gt;   &lt;p&gt;Mail mail = new Mail();&lt;br /&gt;IValidatable validate = ((IValidatable)mail).ValidateAddress();&lt;/p&gt; &lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112794921018137412?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112794921018137412/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112794921018137412&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112794921018137412'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112794921018137412'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/09/blog-post.html' title='静态横切'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112792800623638583</id><published>2005-09-28T19:13:00.000+02:00</published><updated>2005-09-28T20:03:21.540+02:00</updated><title type='text'>Zweite Änderungsordnung DPO-Informatik</title><content type='html'>&lt;span style="color: rgb(0, 0, 102);font-size:100%;" &gt;&gt;&gt; Die bislang 2 Fachprüfungen a 60 Min werden in insgesamt 4 a 30 Min.&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);font-size:100%;" &gt; aufgeteilt. Dies bedeutet eine organisatorische Vereinfachung für die&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);font-size:100%;" &gt; Prüfer und  eine Studienzeitverkürzung für die Studierenden.&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);font-size:100%;" &gt;&lt;span style="color: rgb(51, 255, 51);"&gt;2 * 60 &gt; 4 * 30 ? mh...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&gt;&gt; Der bislang in der Vertiefungsfachprüfung eingehende Vortrag zur&lt;br /&gt;Diplomarbeit wird zur Diplomarbeitsleistung gerechnet.&lt;br /&gt;&lt;br /&gt;Ferner wird die Fachprüfung im Vertiefungsgebiet vom Vortrag über die&lt;br /&gt;Diplomarbeit abgekoppelt und besteht nur noch aus einer 30-minütigen&lt;br /&gt;Prüfung.  Bislang können sich Gutachter der Diplomarbeit und Prüfer der&lt;br /&gt;Vertiefungsfachprüfung unterscheiden, so dass in diesem Fall ein&lt;br /&gt;Gutachter beispielweise keine Möglichkeit hat, eine Bewertung des&lt;br /&gt;Vortrags vorzunehmen. Durch die Änderung entsteht auch hier eine klarere&lt;br /&gt;Struktur der Bewertung der Abschlussarbeit, wie sie auch bei Bachelor-&lt;br /&gt;und Masterarbeiten gegeben ist.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;nicht genau verstanden, bitte ergänzen.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&gt;&gt; Die veränderte Prüfungszahl macht eine Anpassung der Gewichtung der&lt;br /&gt;Diplomarbeitsnote bei der Gesamtnotenermittlung notwendig. Statt&lt;br /&gt;Mittelwert aus vier Prüfungsnoten und doppelter Diplomarbeitsnote gibt&lt;br /&gt;es nun das Mittel aus sechs Prüfungsnoten und dreifacher Diplomarbeitsnote.&lt;br /&gt;&lt;br /&gt;&gt;&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);font-family:Arial;font-size:100%;"  lang="DE" &gt;&lt;span style=""&gt; &lt;/span&gt;Die mündliche Darstellung der Diplom Arbeit besteht aus einem etwa 20-minütigen universitätsöffentlichen Vortrag über das Thema der Diplomarbeit bzw. der Gruppenarbeit und einer 10-minütigen anschließenden Diskussion. Dieser Vortrag findet nach Abgabe der Arbeit statt.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);font-size:100%;" &gt; &lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);font-size:100%;" &gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:Arial;font-size:100%;"  lang="DE" &gt;&lt;span style=""&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;Die Diplomprüfung besteht aus den Fachprüfungen und der Diplomarbeit. Sie umfasst &lt;/span&gt;&lt;o:p style="color: rgb(0, 0, 102);"&gt;&lt;/o:p&gt;&lt;/span&gt;  &lt;p class="Default" style="margin-left: 18pt; color: rgb(0, 0, 102);"&gt;&lt;span style=";font-family:Arial;font-size:100%;"  lang="DE" &gt;1. eine Fachprüfung in Anwendungsorientierter Informatik, &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p class="Default" style="margin-left: 18pt; color: rgb(0, 0, 102);"&gt;&lt;span style=";font-family:Arial;font-size:100%;"  lang="DE" &gt;2. eine Fachprüfung in Praktischer Informatik, &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p class="Default" style="margin-left: 18pt; color: rgb(0, 0, 102);"&gt;&lt;span style=";font-family:Arial;font-size:100%;"  lang="DE" &gt;3. eine Fachprüfung in Technischer Informatik, &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p class="Default" style="margin-left: 18pt; color: rgb(0, 0, 102);"&gt;&lt;span style=";font-family:Arial;font-size:100%;"  lang="DE" &gt;4. eine Fachprüfung in Theoretischer Informatik, &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p class="Default" style="margin-left: 18pt; color: rgb(0, 0, 102);"&gt;&lt;span style=";font-family:Arial;font-size:100%;"  lang="DE" &gt;5. eine Fachprüfung im Vertiefungsgebiet (Stu­dienschwerpunkte) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p class="CM4" style="margin-left: 18pt;"&gt;&lt;span style=";font-family:Arial;font-size:100%;"  lang="DE" &gt;&lt;span style="color: rgb(0, 0, 102);"&gt;6. eine Fachprüfung im Nebenfach. &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;span style="color: rgb(0, 0, 102);font-size:100%;" &gt;&gt;&gt; &lt;/span&gt;&lt;span style=";font-family:Arial;font-size:100%;"  lang="EN-GB" &gt;&lt;span style="color: rgb(0, 0, 102);"&gt;Die Fachprüfungen sind mündliche Prüfungen (§ 8). Die Dau­er der je Kandidat und Fachprüfung zur Verfügung stehenden Prüfungszeit beträgt etwa 30 Minuten.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);font-size:100%;" &gt;Elfriede Fehr&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112792800623638583?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112792800623638583/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112792800623638583&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112792800623638583'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112792800623638583'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/09/zweite-nderungsordnung-dpo-informatik.html' title='Zweite Änderungsordnung DPO-Informatik'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112790561897706180</id><published>2005-09-28T13:02:00.000+02:00</published><updated>2005-09-28T20:05:56.883+02:00</updated><title type='text'>动态横切 2</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/1662/1091/1600/aop412.gif"&gt;&lt;img style="cursor: pointer;" src="http://photos1.blogger.com/blogger/1662/1091/320/aop412.gif" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;由于aspect是一个封装的对象，我们可以定义这样一个aspect：&lt;br /&gt;private static aspect AuthorizationAspect{……}&lt;br /&gt;然后在这个aspect中定义point cut，在point cut中，定义了需要截取上下文消息的方法，例如：&lt;br /&gt;private pointcut authorizationExecution():&lt;br /&gt;execution(public void OrderManager.AddOrder(Order))&lt;br /&gt;execution(public void OrderManager.DeleteOrder(Order))&lt;br /&gt;execution(public void ProductManager.AddProduct(Product))&lt;br /&gt;execution(public void ProductManager.DeleteProduct(Product));&lt;br /&gt;由于权限验证是在订单管理方法执行之前完成，因此在before advice中，定义权限检查：&lt;br /&gt;before(): authorizationExecution() {&lt;br /&gt;if !(permissions.Verify(Permission.ADMIN)) {&lt;br /&gt;throw new UnauthorizedException();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;通 过定义了这样一个完整的aspect，当系统调用OrderManager或ProductManager的相关方法时，就触发了point cut，然后调用相应的advice逻辑。如此以来，OrderManager和ProductManager模块就与权限管理模块完全解除了依赖关系， 同时也消除了传统设计中不可避免的权限判断的重复代码。这对于建立一个松散耦合、可扩展的系统软件是非常有利的。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112790561897706180?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112790561897706180/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112790561897706180&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112790561897706180'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112790561897706180'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/09/2.html' title='动态横切 2'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112790528697657996</id><published>2005-09-28T12:54:00.000+02:00</published><updated>2005-09-28T13:01:26.976+02:00</updated><title type='text'>动态横切 1</title><content type='html'>&lt;a href="http://photos1.blogger.com/blogger/1662/1091/1600/aop4.gif"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger/1662/1091/1600/aop32.gif"&gt;&lt;img style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="http://photos1.blogger.com/blogger/1662/1091/320/aop3.gif" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger/1662/1091/1600/aop31.gif"&gt;&lt;/a&gt;&gt;&gt; 动态横切是通过切入点和连接点在一个方面中创建行为的过程，连接点可以在执行时横向地应用于现有对象。动态横切通常用于帮助向对象层次中的各种方法添加日志记录或身份认证。在很多应用场景中，动态横切技术基本上代表了AOP。&lt;br /&gt;&lt;br /&gt;&gt;&gt; 动态横切技术的核心主要包括join point（连接点），point cut（切入点），advice（通知）和aspect（方面）。&lt;br /&gt;&lt;br /&gt;&gt;&gt; 考虑一个电子商务系统，需要对订单进行添加、删除等管理操作。毫无疑问，在实际的应用场景中，这些行为应与权限管理结合，只有获得授权的用户方能够实施这些行为。采用传统的设计方法，其伪代码如下：&lt;br /&gt;public class OrderManager {&lt;br /&gt;private ArrayList m_Orders;&lt;br /&gt;public OrderManager() {&lt;br /&gt;m_Orders = new ArrayList();&lt;br /&gt;}&lt;br /&gt;public void AddOrder(Order order) {&lt;br /&gt;if (permissions.Verify(Permission.ADMIN)) {&lt;br /&gt;m_Orders.Add(order);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;public void RemoveOrder(Order order) {&lt;br /&gt;if (permissions.Verify(Permission.ADMIN)) {&lt;br /&gt;m_Orders.Remove(order);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;同样的，在该电子商务系统中，还需要对商品进行管理，它采用了同样的授权机制：&lt;br /&gt;public class ProductManager {&lt;br /&gt;private ArrayList m_Products;&lt;br /&gt;public ProductManager() {&lt;br /&gt;m_Products = new ArrayList();&lt;br /&gt;}&lt;br /&gt;public void AddProduct(Product product) {&lt;br /&gt;if (permissions.Verify(Permission.ADMIN)) {&lt;br /&gt;m_Products.Add(product);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;public void RemoveProduct(Product product) {&lt;br /&gt;if (permissions.Verify(Permission.ADMIN)) {&lt;br /&gt;m_Products.Remove(product);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;如此以来，在整个电子商务系统中，核心业务包括订单管理和商品管理，它们都需要相同的权限管理.&lt;br /&gt;&lt;br /&gt;毫无疑问，利用AOP技术，我们可以分离出系统的核心关注点和横切关注点，从横向的角度，截取业务管理行为的内部消息，以达到织入权限管理逻辑的目的。当执行AddOrder()等方法时，系统将验证用户的权限，调用横切关注点逻辑，因此该方法即为AOP的join point。对于电子商务系统而言，每个需要权限验证的方法都是一个单独的join point。由于权限验证将在每个方法执行前执行，所以对于这一系列join point，只需要定义一个point cut。当系统执行到join point处时，将根据定义去查找对应的point cut，然后执行这个横切关注点需要实现的逻辑，即advice。而point cut和advice，就组合成了一个权限管理aspect。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112790528697657996?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112790528697657996/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112790528697657996&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112790528697657996'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112790528697657996'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/09/1.html' title='动态横切 1'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112790424115722597</id><published>2005-09-28T12:12:00.000+02:00</published><updated>2005-09-28T12:52:32.426+02:00</updated><title type='text'>AOP</title><content type='html'>&lt;a href="http://photos1.blogger.com/blogger/1662/1091/1600/aop3.gif"&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger/1662/1091/1600/aop12.gif"&gt;&lt;img style="FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="http://photos1.blogger.com/blogger/1662/1091/400/aop1.gif" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&gt;&gt; &lt;span style="color:#663333;"&gt;Aspect oriented Programming&lt;/span&gt;, a philosophy, which is related to style of programming, in this way it Likes &lt;span style="color:#663333;"&gt;structured programming&lt;/span&gt; and &lt;span style="color:#663333;"&gt;Object-Oriented programming&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&gt;&gt; AOP把软件系统分为两个部分：核心关注点和横切关注点。业务处理的主要流程是核心关注点，与之关系不大的部分是横切关注点。横切关注点的一个特点是，他们经常发生在核心关注点的多处，而各处都基本相似。比如权限认证、日志、事务处理。Aop 的作用在于分离系统中的各种关注点，将核心关注点和横切关注点分离开来。“将应用程序中的商业逻辑同对其提供支持的通用服务进行分离。”&lt;br /&gt;&lt;br /&gt;上图识别出来的关注点中，Business Logic属于核心关注点，它会调用到Security，Logging，Persistence等横切关注点。&lt;br /&gt;&lt;br /&gt;public class BusinessLogic&lt;br /&gt;{&lt;br /&gt;public void SomeOperation()&lt;br /&gt;{&lt;br /&gt;//验证安全性；Securtity关注点；&lt;br /&gt;//执行前记录日志；Logging关注点；&lt;br /&gt;DoSomething();&lt;br /&gt;//保存逻辑运算后的数据；Persistence关注点；&lt;br /&gt;//执行结束记录日志；Logging关注点；&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;AOP的目的，就是要将诸如Logging之类的横切关注点从BusinessLogic类中分离出来。利用AOP技术，可以对相关的横切关注点封装，形成单独的“aspect”。这就保证了横切关注点的复用。由于BusinessLogic类中不再包含横切关注点的逻辑代码，为达到调用横切关注点的目的，可以利用横切技术，截取BusinessLogic类中相关方法的消息，例如SomeOperation()方法，然后将这些“aspect”织入到该方法中。&lt;br /&gt;&lt;br /&gt;&gt;&gt; 通过利用AOP技术，改变了整个系统的设计方式。在分析系统需求之初，利用AOP的思想，分离出核心关注点和横切关注点。在实现了诸如日志、事务管理、权限控制等横切关注点的通用逻辑后，开发人员就可以专注于核心关注点，将精力投入到解决企业的商业逻辑上来。同时，这些封装好了的横切关注点提供的功能，可以最大限度地复用于商业逻辑的各个部分，既不需要开发人员作特殊的编码，也不会因为修改横切关注点的功能而影响具体的业务功能。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112790424115722597?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112790424115722597/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112790424115722597&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112790424115722597'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112790424115722597'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/09/aop.html' title='AOP'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112785048186403329</id><published>2005-09-27T21:36:00.000+02:00</published><updated>2005-09-27T21:59:18.603+02:00</updated><title type='text'>IOC</title><content type='html'>&lt;span style="color: rgb(0, 0, 102);"&gt;&gt;&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);" class="postbody"&gt;Inversion of Control，控制反转。在Java开发中，IoC意味着将你设计好的类交给系统去控制，而不是在你的类内部控制。这称为控制反转。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);" class="postbody"&gt;&gt;&gt; 一个Girl和一个Boy类，其中Girl有kiss方法，即Girl想要Kiss一个Boy。那么，我们的问题是，Girl如何能够认识这个Boy？&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="postbody"&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;在我们中国，常见的认识方式有以下几种&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;&gt;&gt;&gt;&gt; 青梅竹马：Girl从小就知道自己的Boy。&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;public class Girl {  &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;    void kiss(){ &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;       Boy boy = new Boy(); &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;    } &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 102);" class="postbody"&gt;然而从开始就创建的Boy缺点就是无法在更换。并且要负责Boy的整个生命周期。如果我们的Girl想要换一个怎么办？&lt;br /&gt;&lt;br /&gt;&gt;&gt;&gt;&gt; &lt;/span&gt;&lt;span class="postbody"&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;亲友介绍:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;public class Girl { &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;    void kiss(){ &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;       Boy boy = BoyFactory.createBoy();      &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;    } &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 102);" class="postbody"&gt;亲 友介绍，固然是好。如果不满意，尽管另外换一个好了。但是，亲友BoyFactory经常是以 Singleton的形式出现，不然就是，存在于Globals，无处不在，无处不能。实在是太繁琐了一点，不够灵活。我为什么一定要这个亲友掺和进来 呢？为什么一定要付给她介绍费呢？&lt;br /&gt;&lt;br /&gt;&gt;&gt;&gt;&gt;  &lt;/span&gt;&lt;span class="postbody"&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;父母包办：&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;public class Girl { &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;    void kiss(Boy boy){ &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;       // kiss boy  &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;      boy.kiss(); &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;    } &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="postbody"&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;Well，这是对Girl最好的方法，只要想办法贿赂了Girl的父母，并把Boy交给他。那么我们就可以轻松的和Girl来Kiss了。&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;这就是IOC，&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;将对象的创建和获取提取到外部。由外部容器提供需要的组件&lt;/span&gt;。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;好莱坞原则：“Do not call us, we will call you.” 意思就是，You, girlie, do not call the boy. We will feed you a boy。&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;好处是：多实现可以任意切换，防止 “everything depends on everything” 问题．即具体依赖于具体。&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;所以，我们的Boy应该是实现Kissable接口。这样一旦Girl不想kiss可恶的Boy的话，还可以kiss可爱的kitten和慈祥的grandmother。&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;interface Kissable{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;    void kiss() ;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;class boy implements Kissable{ ... }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;class Grandmother implements Kissable{ ... }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;public class Girl { &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;     void kiss(Kissable kissable){ &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;        // kiss boy  &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;       kissable.kiss(); &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;     } &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt; }&lt;/span&gt;&lt;br /&gt;&lt;span class="postbody"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112785048186403329?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112785048186403329/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112785048186403329&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112785048186403329'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112785048186403329'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/09/ioc.html' title='IOC'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112759949166168917</id><published>2005-09-24T23:47:00.000+02:00</published><updated>2005-09-25T00:04:51.666+02:00</updated><title type='text'>StudyPlan0506 of theOldManWhoLikesWind</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/1662/1091/1600/spw05061.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://photos1.blogger.com/blogger/1662/1091/400/spw05061.JPG" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;the new topic of the coming semester for theOldManWhoLikesWind is&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="color: rgb(102, 102, 0); font-weight: bold;"&gt;"slow down the steps, to live like a real old man."&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112759949166168917?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112759949166168917/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112759949166168917&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112759949166168917'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112759949166168917'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/09/studyplan0506-of-theoldmanwholikeswind.html' title='StudyPlan0506 of theOldManWhoLikesWind'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112757773700322490</id><published>2005-09-24T18:01:00.000+02:00</published><updated>2005-09-24T21:30:17.203+02:00</updated><title type='text'>11 Rules to make the code more effective</title><content type='html'>&lt;span style="color: rgb(102, 0, 0);font-size:85%;" &gt;1. Use StringBuffer instead of String because of the fact the String object can not&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 0, 0);font-size:85%;" &gt;be changed. Any modification to a String variable is actually a new object&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 0, 0);font-size:85%;" &gt;creation.&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 0, 0);font-size:85%;" &gt;2. Accessing class variables directly is faster then using setter and getter&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 0, 0);font-size:85%;" &gt;methods&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 0, 0);font-size:85%;" &gt;3. Using local variables are more efficient then instance/class variables&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 0, 0);font-size:85%;" &gt;4. Using variables are more efficient then arrays.&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 0, 0);font-size:85%;" &gt;5. Avoid synchronization in loops because there is an extra over head to lock and&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 0, 0);font-size:85%;" &gt;unlock each time the loop occurs&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 0, 0);font-size:85%;" &gt;6. Counting down in loops is faster then counting up&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 0, 0);font-size:85%;" &gt;7. Use compound operators like x += 1 instead o f x = x + 1 because fewer byte&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 0, 0);font-size:85%;" &gt;codes is generated&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 0, 0);font-size:85%;" &gt;8. Remove constant calculations in loops&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 0, 0);font-size:85%;" &gt;9. Reuse objects&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 0, 0);font-size:85%;" &gt;10. Assign null to unused objects, especially unused threads&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 0, 0);font-size:85%;" &gt;11. Try to use already built in methods, for example if you want to copy data from&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 0, 0);font-size:85%;" &gt;one array to another use System.arraycopy more then likely this method will&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 0, 0);font-size:85%;" &gt;be more efficient then the one you created yourself&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112757773700322490?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112757773700322490/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112757773700322490&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112757773700322490'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112757773700322490'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/09/11-rules-to-make-code-more-effective.html' title='11 Rules to make the code more effective'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112665576569869138</id><published>2005-09-14T01:54:00.000+02:00</published><updated>2005-09-14T02:00:40.106+02:00</updated><title type='text'>no  XP   no MDA,还剩下什么?</title><content type='html'>&lt;p&gt;&lt;a id="Header1_HeaderTitle" class="headermaintitle" href="http://blog.joycode.com/mvm/"&gt;屋顶上的木帷幕&lt;/a&gt;&lt;br /&gt;&lt;span style="color: rgb(128, 0, 128);font-size:85%;" &gt;&lt;a href="http://blog.joycode.com/mvm/archive/2004/11/12/38774.aspx"&gt;http://blog.joycode.com/mvm/archive/2004/11/12/38774.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="color: rgb(128, 0, 128);font-size:85%;" &gt;&lt;br /&gt;XP来自何处？Alexander的城市发展哲学。Alexander认为为一个城市发展建立Master Plan是罪恶的做法，最好的（最人性化的适合人居住的）城市是“自然”发展起来的那种小城镇。他的很多观点和某些道家废弃发展才能反哺归真的观点不谋而合。&lt;/span&gt;&lt;/p&gt;   &lt;p&gt;&lt;span style="color: rgb(128, 0, 128);font-size:85%;" &gt;纯粹的XP完全放弃长期规划和预测能力，放弃系统的整体设计和架构设计，强调群体的随机活动对整体架构的贡献，认为“自然”形成的架构是最好的架构。&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: rgb(128, 0, 128);font-size:85%;" &gt;MDA恰好相反，它把软件设计人员分成两种，一种人为架构师，一种人为coder苦力。架构师来自第一世界，苦力来自中国和印度。架构师工资高，最好进行高智商的工作，苦力工资很低，干什么无所谓。类似的思想以不同面目出现过，譬如古代的劳心者治人，现代的软件蓝领之类。&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: rgb(128, 0, 128);font-size:85%;" &gt;MDA和XP好像是恰好形成两个极端的思想。来自真实世界的实践家都有一个Bullshit探测器，我的这个探测器一接近这两极都会嘟嘟响。&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: rgb(128, 0, 128);font-size:85%;" &gt;我喜欢哲学，但那必须大家都先把探测器关上才能谈。呵呵&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112665576569869138?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112665576569869138/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112665576569869138&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112665576569869138'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112665576569869138'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/09/no-xp-no-mda.html' title='no  XP   no MDA,还剩下什么?'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112654881084947793</id><published>2005-09-12T20:09:00.000+02:00</published><updated>2005-09-12T20:13:30.853+02:00</updated><title type='text'>The history of programming language</title><content type='html'>&lt;a href="http://page.mi.fu-berlin.de/~zheng/file/prog_lang_poster.pdf"&gt; just a nice picture&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112654881084947793?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112654881084947793/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112654881084947793&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112654881084947793'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112654881084947793'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/09/history-of-programming-language.html' title='The history of programming language'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112644488044009598</id><published>2005-09-11T11:36:00.000+02:00</published><updated>2005-09-11T18:17:10.903+02:00</updated><title type='text'>Using CodePro to Create Design Patterns:</title><content type='html'>Although you can learn all the details of the design patterns and then implement them&lt;br /&gt;when you need them, it is often easier to use a program to automatically generate the&lt;br /&gt;basic structure of the patterns for you. A suite of Java development tools called CodePro&lt;br /&gt;contains wizards for design patterns as well as numerous other development tools such as&lt;br /&gt;metrics and code analyzing.&lt;br /&gt;&lt;br /&gt;CodePro is a commercial plug-in for Eclipse. There are several versions of CodePro.&lt;br /&gt;CodePro is split up into three parts, Advisor, Agility, and Build, each of which can be&lt;br /&gt;purchased separately.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.instantiations.com/eclipsepro/download.asp"&gt;to download:&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;You can also easily add your own design patterns to those that CodePro already supports.&lt;br /&gt;For more information on adding design patterns to CodePro, see the documentation at&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.instantiations.com/codepro/ws/docs/features/patterns/adding_new_patterns.html"&gt; add new pattern&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112644488044009598?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112644488044009598/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112644488044009598&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112644488044009598'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112644488044009598'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/09/using-codepro-to-create-design.html' title='Using CodePro to Create Design Patterns:'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112642977354175881</id><published>2005-09-11T10:45:00.000+02:00</published><updated>2005-09-11T11:09:36.060+02:00</updated><title type='text'>design patterns &gt;&gt; Template Method</title><content type='html'>The template method design pattern is a behavioral pattern that extracts common&lt;br /&gt;elements of program flow and places them in a superclass. This is a simple pattern that is&lt;br /&gt;used all the time. The template method pattern is used when common elements are&lt;br /&gt;placed in a base class where subclasses are used to implement the elements that vary.&lt;br /&gt;&lt;br /&gt;The base class in the template method pattern is often abstract. It will have one or more&lt;br /&gt;methods that are either abstract or have a default implementation that can be overridden&lt;br /&gt;by the subclasses.&lt;br /&gt;&lt;br /&gt;For an example, we will use the template method pattern to create classes to calculate&lt;br /&gt;interest. Interest is calculated two ways, with simple interest or with compound interest.&lt;br /&gt;The formula for simple interest is A = P(1 + ni) and the formula for compound interest is&lt;br /&gt;A = P(1 + i/q)nq , where A is the total amount, P is the principal amount, n is the number&lt;br /&gt;of years, i is the interest rate, and q is the number of times interest is compounded per&lt;br /&gt;year.&lt;br /&gt;&lt;br /&gt;We will create an abstract base class called Interest that has a method getAmount() that&lt;br /&gt;returns the total amount. The getAmount() method returns the product of the principal&lt;br /&gt;and the rest of the formula which is calculated by the subclasses in the abstract method&lt;br /&gt;calcInterest(). The Interest base class is shown below.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;public abstract class Interest {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;private double principal;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;public Interest(double principal) {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;this.principal = principal;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;public double getAmount() {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 0, 153);"&gt;// for simple interest is A = P(1 + ni)&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 0, 153);"&gt;// for compound interest is A = P(1 + i/q)nq &lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;return principal * calcInterest();&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;protected abstract double calcInterest();&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;br /&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;To calculate the simple interest, we create a class SimpleInterest that extends Interest.&lt;/span&gt;&lt;br /&gt; &lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;public class SimpleInterest extends Interest {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;private int numYears;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;private double interestRate;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;public SimpleInterest (double principal, int numYears, double interestRate) {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;super(principal);&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;this.numYears = numYears;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;this.interestRate = interestRate;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;protected double calcInterest() {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;return (1 + numYears * interestRate);&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To calculate the compound interest, we create a class CompoundInterest that extends&lt;br /&gt;Interest.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;public class CompoundInterest extends Interest {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;private int numYears;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;private double interestRate;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;private int compoundsPerYear;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;public CompoundInterest (double principal, int numYears, double interestRate, &lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;int compoundsPerYear) {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;super(principal);&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;this.numYears = numYears;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;this.interestRate = interestRate;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;this.compoundsPerYear = compoundsPerYear;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;protected double calcInterest() {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;return Math.pow(1 + interestRate / compoundsPerYear,&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;numYears * compoundsPerYear);&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Both classes above implement the calcInterest() method where they calculate the part of&lt;br /&gt;the formula that is unique to each kind of interest.&lt;br /&gt;&lt;br /&gt;As you can see, the template method design pattern is a fairly simple idea and you have&lt;br /&gt;probably used it often whether you knew it or not.  ^-^&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112642977354175881?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112642977354175881/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112642977354175881&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112642977354175881'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112642977354175881'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/09/design-patterns-template-method.html' title='design patterns &gt;&gt; Template Method'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112642817189409871</id><published>2005-09-11T10:30:00.000+02:00</published><updated>2005-09-11T10:42:53.130+02:00</updated><title type='text'>design patterns &gt;&gt; Iterator</title><content type='html'>The iterator design pattern is a behavioral pattern that iterates through a data structure.&lt;br /&gt;An iterator traverses a data structure and gives access to the data structure’s elements&lt;br /&gt;without revealing the data structure’s internal representation. It also allows you to&lt;br /&gt;traverse a data structure in several ways without bloating the data structure’s interface.&lt;br /&gt;&lt;br /&gt;An iterator has a next element method and often has a method to check if the end of the&lt;br /&gt;traversal has been reached. All of the traversal details can be hidden from the client so&lt;br /&gt;that one method call is all that is needed to get the next element. If the data structure is&lt;br /&gt;changed when using an iterator, only the iterator will have to be changed. The calling&lt;br /&gt;classes will not need to be modified.&lt;br /&gt;&lt;br /&gt;An iterator needs an iterator interface. Java already comes with two basic iterator&lt;br /&gt;interfaces that you can implement. They are called Iterator and Enumeration. Both are in&lt;br /&gt;the java.util package. Several data structures built into Java such as lists use one or both&lt;br /&gt;of these iterators. Listed below is the code from each of the iterators.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;public interface Iterator {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;public boolean hasNext();&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;public Object next();&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;public void remove();&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;public interface Enumeration {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;public boolean hasMoreElements();&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;public Object nextElement();&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;As you can see, both iterators have a method that checks if there are more elements, and&lt;br /&gt;both have a method that gets the next element. The Iterator interface, however, has one&lt;br /&gt;more method than the Enumeration interface. The remove() method removes that last&lt;br /&gt;received object from the data structure and can only be called once for each call to next().&lt;br /&gt;&lt;br /&gt;If you need an iterator that provides more functionality than the basic iterators provided&lt;br /&gt;for you by Java, you can simply write your own. Perhaps you would like several types of&lt;br /&gt;traversals possible. An example is if you want to traverse a list from the bottom or from&lt;br /&gt;the top.&lt;br /&gt;&lt;br /&gt;As an example, we will create a simple iterator for a Vector based on Java’s Iterator&lt;br /&gt;interface. Shown below is the VectorIterator class.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;import java.util.Iterator;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;import java.util.Vector;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;public class VectorIterator implements Iterator {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;private Vector v;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;private int current;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;private boolean removeEnabled;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;public VectorIterator(Vector v) {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;this.v = v;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;current = 0;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;removeEnabled = false;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;public boolean hasNext() {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;if (current &gt;= v.size()) return false;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;else return true;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;public Object next() {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;Object result = null;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;if (hasNext()) {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;result = v.elementAt(current);&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;current++;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;removeEnabled = true;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;return result;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;public void remove() {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;if (removeEnabled) {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;v.removeElementAt(--current);&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;removeEnabled = false;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The VectorIterator class implements Java’s Iterator interface, therefore it must have the&lt;br /&gt;methods hasNext(), next(), and remove(). One of the fields is a Vector, which is a&lt;br /&gt;reference to the Vector to be traversed. The field named current is the current position in&lt;br /&gt;the traversal. The removeEnabled flag is to allow only one call to remove() for each call&lt;br /&gt;to next().&lt;br /&gt;&lt;br /&gt;To use the VectorIterator in your code, first create a Vector and then pass it to the&lt;br /&gt;constructor when instantiating a VectorIterator, as shown below.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;Vector v = new Vector();&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;//add some elements to the Vector here&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;VectorIterator vi = new VectorIterator(v);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now you can iterate through the vector by calling the VectorIterator instance’s next()&lt;br /&gt;method.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112642817189409871?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112642817189409871/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112642817189409871&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112642817189409871'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112642817189409871'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/09/design-patterns-iterator.html' title='design patterns &gt;&gt; Iterator'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112642703088996298</id><published>2005-09-11T10:03:00.000+02:00</published><updated>2005-09-11T10:25:49.876+02:00</updated><title type='text'>design patterns &gt;&gt; Command</title><content type='html'>The command design pattern is a behavioral pattern that allows you to create a command&lt;br /&gt;as an object and then execute it as necessary. This pattern is useful if you want to create&lt;br /&gt;undo / redo operations, log operations, or execute commands at a later time.&lt;br /&gt;&lt;br /&gt;A command interface is necessary for this pattern. For an object to be a command object,&lt;br /&gt;it must implement a method that will execute its command. Shown below is a simple&lt;br /&gt;command interface with one method that needs to be implemented, execute().&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;public interface Command {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;void execute();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Any classes that are to be commands must now implement the command interface.&lt;br /&gt;Below is shown a simple command that prints “Hello World!” to the console when the&lt;br /&gt;command is executed.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;public class HelloCommand implements Command {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;public void execute() {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;System.out.println("Hello World!");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You can execute this command by creating an instance of HelloCommand and then by&lt;br /&gt;calling its execute method.&lt;br /&gt;&lt;br /&gt;To create a history of commands that would be useful for undo / redo and logging&lt;br /&gt;operations, you would need to have a command manager or command handler class.&lt;br /&gt;This class would receive all the commands, save the command in a history data structure,&lt;br /&gt;and then execute the command. The history could then be used to undo and redo&lt;br /&gt;operations or to resume operations up to the current point in case of a crash.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;public class History {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;private static List&lt;/span&gt;&lt;command&gt;&lt;span style="color: rgb(153, 51, 153);"&gt; commands = new ArrayList&lt;/span&gt;&lt;command&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;and the HelloCommand class should be changed like follow:&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;public class HelloCommand implements Command {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt; public void execute() {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt; System.out.println("Hello World!");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;History.commands.add( this );&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt; }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt; }&lt;/span&gt;&lt;/command&gt;&lt;/command&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112642703088996298?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112642703088996298/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112642703088996298&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112642703088996298'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112642703088996298'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/09/design-patterns-command.html' title='design patterns &gt;&gt; Command'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112638458043170236</id><published>2005-09-10T22:06:00.000+02:00</published><updated>2005-09-10T22:36:20.490+02:00</updated><title type='text'>design patterns &gt;&gt; Composite</title><content type='html'>The composite design pattern is a structural pattern and is used when you want objects to be either components or containers that can hold other components. This is similar to a tree design where the leaf nodes are the components and the non-leaf nodes are the containers. A common place to find the use of composites is in GUI widgets. SWT has a widget called composite which is able to hold other widgets, including other composites.&lt;br /&gt;&lt;br /&gt;Composites are able to be created in several ways. Sometimes you may allow leaf nodes to become non-leaf nodes by adding children to them, though usually leaf nodes are restricted from having children. You can also set up the structure of inheritance in different ways.&lt;br /&gt;&lt;br /&gt;In our example we will restrict the non-leaf nodes from having children. We will have an abstract component class with a concrete component class that extends it. The composite class extends the concrete component class.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(204, 51, 204);"&gt;import java.util.NoSuchElementException;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(204, 51, 204);"&gt;import java.util.Vector;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(204, 51, 204);"&gt;public abstract class AbstractComponent {&lt;/span&gt;&lt;br /&gt; &lt;br /&gt; &lt;span style="color: rgb(204, 51, 204);"&gt;protected AbstractComponent parent = null;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(204, 51, 204);"&gt;protected Vector children = new Vector();&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(204, 51, 204);"&gt;public AbstractComponent getParent() { &lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(204, 51, 204);"&gt;return parent; &lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(204, 51, 204);"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(204, 51, 204);"&gt;public abstract AbstractComponent getChild(int index)&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(204, 51, 204);"&gt;throws NoSuchElementException;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(204, 51, 204);"&gt;public abstract void addChild(AbstractComponent child)&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(204, 51, 204);"&gt;throws NoSuchElementException;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(204, 51, 204);"&gt;public abstract void removeChild(AbstractComponent child)&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(204, 51, 204);"&gt;throws NoSuchElementException;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(204, 51, 204);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Shown above is the abstract component class. It has a vector to hold the children, a parent, a method to get the parent and several abstract methods that are for performing operations on an object’s children. Since we want to restrict the leaf nodes from having children, we add throwable exceptions to the abstract methods.&lt;br /&gt;&lt;br /&gt;The component class extends the abstract component class. Since components are restricted from having children, any methods that perform operations on children throw an exception. Below is shown a basic component class.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;import java.util.NoSuchElementException;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;public class Component extends AbstractComponent {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;public void addChild(AbstractComponent child)&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;throws NoSuchElementException {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;throw new NoSuchElementException("Cannot add child to leaf");&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;public void removeChild(AbstractComponent child)&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;throws NoSuchElementException {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;throw new NoSuchElementException("Cannot remove child from leaf");&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;public AbstractComponent getChild(int index)&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;throws NoSuchElementException {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;throw new NoSuchElementException("Cannot get child from leaf");&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The composite class extends the concrete component class. Composites are allowed to have children, so the methods performing operations on children are properly implemented. Below is shown a basic composite class.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;import java.util.NoSuchElementException;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;public class Composite extends Component {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;public void addChild(AbstractComponent child)&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;throws NoSuchElementException {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;children.addElement(child);&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;public void removeChild(AbstractComponent child)&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;throws NoSuchElementException {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;children.removeElement(child);&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;public AbstractComponent getChild(int index)&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;throws NoSuchElementException {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;return (AbstractComponent) children.elementAt(index);&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To add individual components and composites to the example above, simply make classes that extend the component and composite classes. In a real program, you would probably have many more fields and methods in your classes to make them functional.&lt;br /&gt;&lt;br /&gt;Another way of structuring the composite design pattern is to have an abstract class for the components and an abstract class for the composites that extends the abstract component class. Then all components would extend the abstract component class and all composites would extend the abstract composite class.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112638458043170236?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112638458043170236/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112638458043170236&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112638458043170236'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112638458043170236'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/09/design-patterns-composite.html' title='design patterns &gt;&gt; Composite'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112638083151439520</id><published>2005-09-10T21:22:00.000+02:00</published><updated>2005-09-10T21:33:51.523+02:00</updated><title type='text'>design patterns &gt;&gt; Adapter</title><content type='html'>The adapter design pattern is a structural pattern that allows classes to work together even&lt;br /&gt;though they have &lt;span style="color: rgb(255, 0, 0);"&gt;incompatible&lt;/span&gt; interfaces. The adapter pattern converts one interface into&lt;br /&gt;another interface that is required by the associated class.&lt;br /&gt;&lt;br /&gt;The adapter design pattern is often used in the following scenario. You have a class&lt;br /&gt;already created that you wish to use. However, the application does not expect the&lt;br /&gt;interface of your class. It may expect an entirely different interface. To allow the&lt;br /&gt;application to use your class, an adapter needs to be made. The adapter receives requests&lt;br /&gt;from the application and then converts those requests to how your class is set up. In this&lt;br /&gt;way, the application thinks it is using a compatible class and you are able to use your&lt;br /&gt;class.&lt;br /&gt;&lt;br /&gt;To use the adapter pattern, you need to create an interface for the expected type. This&lt;br /&gt;interface is called the target interface. In our target interface shown below we have two&lt;br /&gt;methods that need to be implemented, &lt;span style="color: rgb(0, 0, 102);"&gt;add(String s) &lt;/span&gt;and &lt;span style="color: rgb(0, 0, 102);"&gt;remove(String s)&lt;/span&gt;. These are the&lt;br /&gt;methods that the application expects to see.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;public interface Target {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;public void add(String s);&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;public void remove(String s);&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The incompatible class that you wish to use is called the adaptee class. For the example&lt;br /&gt;we will say that our adaptee class has two methods, addItem(String s) and&lt;br /&gt;deleteItem(String s), that add and delete elements from a vector. The adaptee class is&lt;br /&gt;shown below.&lt;br /&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;import java.util.Vector;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;public class Adaptee {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;private Vector v;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;public Adaptee() {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;v = new Vector();&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;public void addItem(String s) {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;v.addElement(s);&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;public void deleteItem(String s) {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;v.removeElement(s);&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To use the adaptee class, even though the application expects the add() and remove()&lt;br /&gt;methods, we create an adapter class that implements the target interface. The adapter&lt;br /&gt;class creates an instance of the adaptee class and when the target methods are called, the&lt;br /&gt;appropriate adaptee methods are called by the adapter. The adapter class is shown below.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;public class Adapter implements Target {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;private Adaptee adaptee;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;public Adapter(Adaptee adaptee) {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;this.adaptee = adaptee;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;public void add(String s) {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;adaptee.addItem(s);&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;public void remove(String s) {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;adaptee.deleteItem(s);&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now if you want to use your class in your application, create an instance of the adapter&lt;br /&gt;and then call the methods that the application requires.&lt;br /&gt;&lt;br /&gt;The type of adapter shown above is the object adapter. In a slightly different form of&lt;br /&gt;adapter, called the class adapter, the adapter class extends the adaptee class and then&lt;br /&gt;implements the target interface. Since the adapter is a subclass of the adaptee, it can&lt;br /&gt;access its methods without having to first create an instance of the adaptee.&lt;br /&gt;&lt;br /&gt;Another common use of adapters is when you wish to implement an interface but do not&lt;br /&gt;need all parts of it. This often occurs while using event listeners in GUI design. For&lt;br /&gt;example, if you wish to implement the SelectionListener interface in SWT, you have to&lt;br /&gt;implement the methods widgetSelected() and widgetDefaultSelected() even if you only&lt;br /&gt;want to use one of them. If you use SelectionAdapter instead of SelectionListener, you&lt;br /&gt;only have to implement the methods that you want because the SelectionAdapter&lt;br /&gt;implements the SelectionListener and creates empty methods for widgetSelected() and&lt;br /&gt;widgetDefaultSelected().&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112638083151439520?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112638083151439520/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112638083151439520&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112638083151439520'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112638083151439520'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/09/design-patterns-adapter.html' title='design patterns &gt;&gt; Adapter'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112637151526426293</id><published>2005-09-10T18:47:00.000+02:00</published><updated>2005-09-10T18:59:54.353+02:00</updated><title type='text'>design patterns &gt;&gt; Factory Method</title><content type='html'>&lt;span style="color: rgb(51, 51, 51);"&gt;The factory principle involves a method which creates an instance of an object and then&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;returns the object. Parameters may be passed to the method which can be used to select&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;the type of object to return.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;The factory method design pattern uses inheritance to determine the correct object to&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;instantiate. A base creator class is created that may be abstract. Concrete creator classes&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;extend the creator class. The factory method is declared in the creator class. If the&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;factory method is abstract, all of the creator class’ subclasses must also have that method.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;If the factory method is not abstract, the subclasses may override it if necessary.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;A class may make an instance of one of the concrete creator classes. Then the class can&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;call the concrete creator class’ factory method to get the appropriate object.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;For an example, suppose we have two classes we want to make instances of, &lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 51);"&gt;Product1&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;and &lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 51);"&gt;Product2&lt;/span&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;. To be able to receive an instance of either of these two classes, they must&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;both extend or implement the same class or interface. We will create an interface called&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 51);"&gt;Product&lt;/span&gt;&lt;span style="color: rgb(51, 51, 51);"&gt; that &lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 51);"&gt;Product1&lt;/span&gt;&lt;span style="color: rgb(51, 51, 51);"&gt; and &lt;/span&gt;&lt;span style="font-style: italic; color: rgb(51, 51, 51);"&gt;Product2&lt;/span&gt;&lt;span style="color: rgb(51, 51, 51);"&gt; will implement.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;Next we will create the base creator class. We will create an abstract class called Creator,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;which is shown below. It will have one abstract method called getProduct().&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;public abstract class Creator {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;public abstract Product getProduct();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;We will now create two classes that extend Creator. We will call these classes&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;Product1Creator and Product2Creator. Each one has a getProduct() method that returns&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;the appropriate Product type. Product1Creator is shown below and Product2Creator is&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;identical except the getProduct() method returns a Product2 object.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;public class Product1Creator extends Creator {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;public Product getProduct() {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;return new Product1();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To create a new Product, a class must first have an instance of either Product1Creator or&lt;br /&gt;Product2Creator. Then they simply call the getProduct() method of that instance and&lt;br /&gt;they will receive the appropriate object.&lt;br /&gt;&lt;br /&gt;In the example above there is a one-to-one mapping between the creator classes and the&lt;br /&gt;product classes. This need not be the case. Several creator classes may return the same&lt;br /&gt;product class or a creator class may return several types of product classes, depending on&lt;br /&gt;parameters passed.&lt;br /&gt;&lt;br /&gt;The factory method design pattern is used when a class is unable to &lt;span style="color: rgb(255, 0, 0);"&gt;anticipate &lt;span style="color: rgb(0, 0, 153);"&gt;( more flexible than constructor )&lt;/span&gt;&lt;/span&gt; the exact object it must create.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112637151526426293?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112637151526426293/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112637151526426293&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112637151526426293'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112637151526426293'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/09/design-patterns-factory-method.html' title='design patterns &gt;&gt; Factory Method'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112637075791780111</id><published>2005-09-10T18:37:00.000+02:00</published><updated>2005-09-10T18:45:57.923+02:00</updated><title type='text'>design patterns &gt;&gt; singleton</title><content type='html'>A singleton class will only allow one instance of itself to be instantiated. It&lt;br /&gt;checks whether an instance has been created already and if so returns that instance.&lt;br /&gt;Shown below is the basic structure of a singleton class.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;public class Singleton {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;    private static Singleton instance;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;    private Singleton() {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;    public static Singleton getInstance() {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;        if (instance == null)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;            instance = new Singleton();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;        return instance;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In the singleton class there is a private static field of the singleton instance. The null&lt;br /&gt;constructor is made private so that a calling class cannot use the constructor to create an&lt;br /&gt;instance. The only way to get an instance of the singleton class is through the public&lt;br /&gt;static getInstance() method. The calling class would get the singleton instance with the&lt;br /&gt;following line:&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;Singleton instance = Singleton.getInstance();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The getInstance() method checks to see if an instance has been created already by testing&lt;br /&gt;if its instance field is null. If it is null, an instance has not yet been created so the&lt;br /&gt;instance field is then instantiated. If it is not null, an instance has already been created.&lt;br /&gt;The instance field is then returned. Once an instance has been created, the same instance&lt;br /&gt;will always be returned by the getInstance() method.&lt;br /&gt;&lt;br /&gt;A slightly different way of implementing a singleton class is to change the field&lt;br /&gt;declaration to&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;private static final Singleton instance = new Singleton();&lt;/span&gt;&lt;br /&gt;Using this approach, an instance of the singleton class is always created. The test to see&lt;br /&gt;if the instance has been created can then be removed so that the only thing the&lt;br /&gt;getInstance() method does is return the instance field.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112637075791780111?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112637075791780111/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112637075791780111&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112637075791780111'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112637075791780111'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/09/design-patterns-singleton.html' title='design patterns &gt;&gt; singleton'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112629721837560315</id><published>2005-09-09T22:16:00.000+02:00</published><updated>2005-09-10T11:47:45.473+02:00</updated><title type='text'>abstract class VS interface</title><content type='html'>&gt;&gt;  &lt;span class="postbody"&gt;一个对象有了外部和内部，使用者只能看到一个对象的外部，而内部的数据和程序则是不 可见的。一个对象是一个“三维实体”，而它的接口，就是一个“二维的表面”。一个class，就完全的“具足”了三个概念“数据、程序、接口”。如 果不是为了开发大规模的程序，仅仅有class，就足够了&lt;br /&gt;&lt;br /&gt;&gt;&gt; &lt;/span&gt;&lt;span class="postbody"&gt;abstract class。因为所有的class都只是模板，真正有意义的是class的实例，因此，多个对象的共性部分，也许并不够资格成为一个真正的对象的模板，因此，出现了abstract class的需要。&lt;br /&gt;&lt;br /&gt;重 申一遍：只有当多个对象所要继承的公共基类不能被实例化是，才需要abstract class。也就是说，如果这个公共基类可以被实例化，我们不该用abstract class，如果只有一个对象来扩展这个abstract class，那么这个abstract class也是多余的。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="postbody"&gt;抽象类的形象比喻。抽象类其实应该称之为不完整类，从几何的比喻来说，它同样是三维的，同样有外部、内部的区别。唯一的不同是不能通过它得到一个实例。&lt;/span&gt;&lt;br /&gt;&lt;span class="postbody"&gt;&lt;br /&gt;&gt;&gt; &lt;/span&gt;&lt;span class="postbody"&gt;二维表面-&gt;接口。interface与类、抽象类的最大的区别，它不是一个三维实体，它没有外部、内部之分。因此，千万不要将interface理解为抽象类的进一步抽象。作为一个二维表面，&lt;span style="color:red;"&gt;它的最大的作用不是实现多重继承&lt;/span&gt;。再重申一遍“&lt;span style="color:red;"&gt;java从来就没有提供过多重继承&lt;/span&gt;”。interface最大的作用，是提供对于一个类的多种可能的视角。&lt;br /&gt;&lt;br /&gt;你 将一个class的implements部分去掉，大多数类都照样可以编译，这个类的功能也同样没有减少，唯一的区别是：“按照那些接口来使用这个类的 用户会报错”。因此，相对于多重继承的“加法”，interface不是，也不可能给一个class带来新的实质内容，而只是提供了多重的视角。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="postbody"&gt;&gt;&gt; interface的作用在于把规范，协议这些东西作为first-class的类型使用。它唯一的作用就是帮你解耦。 把“类型”和“类”分开来看待。&lt;br /&gt;interface的最大作用，不在于可以给“类”提供什么东西，而是在于可以让你忘掉“类”，忘掉实现，直接面对规范，协议。&lt;br /&gt;&lt;br /&gt;简要地说：interface的重要性在于它本身的抽象性。而不在于"implements"这个keyword。&lt;br /&gt;凡是谈到和“类”相关的任何东西，都不是最重要的。&lt;br /&gt;&lt;br /&gt;&gt;&gt; &lt;/span&gt;&lt;span class="postbody"&gt;如果一个类要做成public的，漏到package外面，就考虑让它实现一个接口，隐藏构造函数，然后用静态工厂公开语义入口。这种api式的设计方式可以保证包内部的实现变化最小程度地影响包外面广大的用户。&lt;br /&gt;至于包内部的东西，就不见的有这个必要。毕竟这种设计是有额外代价的.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="postbody"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="postbody"&gt; &gt;&gt; 因此，结论如下：&lt;br /&gt;A、如果你定义的一个interface没有给一个class带来新的视角，那么这个interface就是浪费。&lt;br /&gt;B、如果你想实现多态，那么你应该使用abstract class，而不应该使用interface。因为他们语义不同。哪怕是一个“纯抽象”的抽象类，也不能等于interface。&lt;br /&gt;C、所有的语言元素都是因为需要而产生的，但是你总是可以误用他。&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112629721837560315?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112629721837560315/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112629721837560315&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112629721837560315'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112629721837560315'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/09/abstract-class-vs-interface.html' title='abstract class VS interface'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112621172972880610</id><published>2005-09-08T22:29:00.000+02:00</published><updated>2005-09-08T22:35:29.736+02:00</updated><title type='text'>Java方法调用</title><content type='html'>Java方法调用的一切中心都是栈(Stack).&lt;br /&gt;每一个方法调用都产生一个独立的栈桢(&lt;span style="color: rgb(255, 0, 0);"&gt;Stack Frame&lt;/span&gt;)。在方法调用开始的时候，会把操作数压栈，return的时候，如果有返回值，则把返回值压入调用者程序的栈。方法结束后其栈桢被销毁。&lt;br /&gt;&lt;br /&gt;所谓的传值就是这样实现的。&lt;br /&gt;&lt;br /&gt;进入call()方法后，t和t2都只是本地变量，t的引用值由调用者压栈。对t执行setName()显然仍然执行对原对象的调用。而最后t=t2是通过一次压栈和一次弹出完成的。但是请记住，这个栈桢在这一句后被立即销毁，不会对调用者的栈桢产生影响。&lt;br /&gt;&lt;br /&gt;对于如下程序：&lt;br /&gt;&lt;br /&gt; &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;public&lt;/span&gt; &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;static&lt;/span&gt; &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;void&lt;/span&gt; call&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;Test t&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;24&lt;/span&gt;:                Test t2 = &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;new&lt;/span&gt; Test&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;;&lt;br /&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;25&lt;/span&gt;:                t2.&lt;span style="color: rgb(0, 0, 0);"&gt;setName&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;"cba"&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;;&lt;br /&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;26&lt;/span&gt;:                t.&lt;span style="color: rgb(0, 0, 0);"&gt;setName&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;"abc"&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;;&lt;br /&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;27&lt;/span&gt;:                t = t2 ;&lt;br /&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;28&lt;/span&gt;:        &lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;29&lt;/span&gt;:&lt;br /&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;30&lt;/span&gt;:         &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;public&lt;/span&gt; &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;static&lt;/span&gt; &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;void&lt;/span&gt; main&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(170, 170, 221);"&gt;String&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;]&lt;/span&gt; arg&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;31&lt;/span&gt;:                Test obj = &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;new&lt;/span&gt; Test&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;;&lt;br /&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;32&lt;/span&gt;:                call &lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;obj&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt; ;&lt;br /&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;33&lt;/span&gt;:                &lt;span style="color: rgb(170, 170, 221);"&gt;System&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 0);"&gt;out&lt;/span&gt;.&lt;span style="color: rgb(0, 0, 0);"&gt;println&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;"obj"+obj.&lt;span style="color: rgb(0, 0, 0);"&gt;getName&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;/span&gt;;&lt;br /&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;34&lt;/span&gt;:        &lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="postbody"&gt;&lt;/span&gt;&lt;span class="postbody"&gt;实际上Java拜虚拟机所赐，他的内存已经可以严格隔离为常量池/静态方法区/堆栈区。在java中要牢 记“变量=堆栈”。换句话说，被调用的方法唯一能够影响调用者变量（即堆栈）的机会，就是return 一个对象/值，其生成的字节码是ireturn或者areturn，包含有一次对调用者栈桢的压栈操作。 &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112621172972880610?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112621172972880610/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112621172972880610&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112621172972880610'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112621172972880610'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/09/java.html' title='Java方法调用'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112449283001954229</id><published>2005-08-20T01:05:00.000+02:00</published><updated>2005-08-20T01:07:10.023+02:00</updated><title type='text'>挑战极限算法</title><content type='html'>假设有这样一种字符串，它们的长度不大于 26 ，而且若一个这样的字符串其长度为 m ，则这个字符串必定由 a, b, c ... z 中的前 m 个字母构成，同时我们保证每个字母出现且仅出现一次。比方说某个字符串长度为 5 ，那么它一定是由 a, b, c, d, e 这 5 个字母构成，不会多一个也不会少一个。嗯嗯，这样一来，一旦长度确定，这个字符串中有哪些字母也就确定了，唯一的区别就是这些字母的前后顺序而已。&lt;br /&gt; &lt;br /&gt; 现在我们用一个由大写字母 A 和 B 构成的序列来描述这类字符串里各个字母的前后顺序：&lt;br /&gt; &lt;br /&gt; 如果字母 b 在字母 a 的后面，那么序列的第一个字母就是 A （After），否则序列的第一个字母就是 B （Before）；&lt;br /&gt; 如果字母 c 在字母 b 的后面，那么序列的第二个字母就是 A ，否则就是 B；&lt;br /&gt; 如果字母 d 在字母 c 的后面，那么 …… 不用多说了吧？直到这个字符串的结束。&lt;br /&gt; &lt;br /&gt;这规则甚是简单，不过有个问题就是同一个 AB 序列，可能有多个字符串都与之相符，比方说序列“ABA”，就有“acdb”、“cadb”等等好几种可能性。说的专业一点，这一个序列实际上对应了一个 字符串集合。那么现在问题来了：给你一个这样的 AB 序列，问你究竟有多少个不同的字符串能够与之相符？或者说这个序列对应的字符串集合有多大？注意，只要求个数，不要求枚举所有的字符串。&lt;br /&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 0, 153);"&gt;做出来的直接贴代码，不用 bla bla ^^&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112449283001954229?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112449283001954229/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112449283001954229&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112449283001954229'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112449283001954229'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/08/blog-post_20.html' title='挑战极限算法'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112397141572944936</id><published>2005-08-14T00:16:00.000+02:00</published><updated>2005-08-14T00:18:51.220+02:00</updated><title type='text'>J M S</title><content type='html'>&lt;span style="font-weight: bold; color: rgb(204, 102, 0);font-size:130%;" &gt;&lt;span style="font-family:arial;"&gt;SOMETIMES ALSO CALLED JAVA MAIL SERVICE&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;AN EXCITING ZONE&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;AN EXCELLENT JOB&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;A SIMPLEST EXAMPLE&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;ALLREADY COMING  ...&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;ON OUR CVS SERVER&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;JUST CHECK IT NOW &gt;&gt;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112397141572944936?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112397141572944936/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112397141572944936&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112397141572944936'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112397141572944936'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/08/j-m-s.html' title='J M S'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112375678050299604</id><published>2005-08-11T12:36:00.000+02:00</published><updated>2005-08-11T13:38:28.010+02:00</updated><title type='text'>泛型</title><content type='html'>&lt;span style="font-size:180%;"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family: trebuchet ms;"&gt;why &lt;/span&gt;&lt;span style="font-family: trebuchet ms;font-size:130%;" &gt;&lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;"class&lt;/span&gt; A&lt;t r=""&gt; &lt;span style="color: rgb(153, 0, 102); font-weight: bold;"&gt;&lt;t&gt; extends&lt;/t&gt;&lt;/span&gt; T&lt;span style="color: rgb(153, 51, 153);"&gt;"&lt;/span&gt;&lt;/t&gt;&lt;/span&gt;&lt;span style="font-family: trebuchet ms;"&gt; is not acceptable ?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: times new roman;"&gt;Ajoo  says:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0); font-family: webdings;font-size:100%;" &gt;&lt;span class="postbody"&gt;时刻记着erasure这三个字，就应该知道"extends T"是绝对不行的。&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:180%;"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="color: rgb(255, 0, 0); font-family: webdings;font-size:100%;" &gt; &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112375678050299604?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112375678050299604/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112375678050299604&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112375678050299604'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112375678050299604'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/08/blog-post_11.html' title='泛型'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112367832949697792</id><published>2005-08-10T14:51:00.000+02:00</published><updated>2005-08-10T14:52:09.506+02:00</updated><title type='text'>idl to java</title><content type='html'>&lt;p&gt;The following table lists the main constructs of IDL and the corresponding constructs in Java.&lt;/p&gt;           &lt;table summary="main constructs of IDL and Java" border="1" cellpadding="5" cellspacing="0" width="100%"&gt; &lt;thead&gt;        &lt;th valign="top"&gt;           &lt;p align="left"&gt;IDL Type        &lt;/p&gt;&lt;/th&gt;&lt;th valign="top"&gt;           &lt;p align="left"&gt;Java Type        &lt;/p&gt;&lt;/th&gt;&lt;/thead&gt;     &lt;tbody&gt;&lt;tr&gt;        &lt;td&gt;           &lt;p&gt;module        &lt;/p&gt;&lt;/td&gt;&lt;td&gt;           &lt;p&gt;package        &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;        &lt;tr&gt;        &lt;td&gt;           &lt;p&gt;boolean        &lt;/p&gt;&lt;/td&gt;&lt;td&gt;           &lt;p&gt;boolean        &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;     &lt;tr&gt;        &lt;td&gt;           &lt;p&gt;char, wchar        &lt;/p&gt;&lt;/td&gt;&lt;td&gt;           &lt;p&gt;char        &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;     &lt;tr&gt;        &lt;td&gt;           &lt;p&gt;octet        &lt;/p&gt;&lt;/td&gt;&lt;td&gt;           &lt;p&gt;byte        &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;     &lt;tr&gt;        &lt;td&gt;           &lt;p&gt;string, wstring        &lt;/p&gt;&lt;/td&gt;&lt;td&gt;           &lt;p&gt;java.lang.String        &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;     &lt;tr&gt;        &lt;td&gt;           &lt;p&gt;short, unsigned short        &lt;/p&gt;&lt;/td&gt;&lt;td&gt;           &lt;p&gt;short        &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;     &lt;tr&gt;        &lt;td&gt;           &lt;p&gt;long, unsigned long        &lt;/p&gt;&lt;/td&gt;&lt;td&gt;           &lt;p&gt;int        &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;     &lt;tr&gt;        &lt;td&gt;           &lt;p&gt;long long, unsigned long long        &lt;/p&gt;&lt;/td&gt;&lt;td&gt;           &lt;p&gt;long        &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;     &lt;tr&gt;        &lt;td&gt;           &lt;p&gt;float        &lt;/p&gt;&lt;/td&gt;&lt;td&gt;           &lt;p&gt;float        &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;     &lt;tr&gt;        &lt;td&gt;           &lt;p&gt;double        &lt;/p&gt;&lt;/td&gt;&lt;td&gt;           &lt;p&gt;double        &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;        &lt;td&gt;           &lt;p&gt;fixed        &lt;/p&gt;&lt;/td&gt;&lt;td&gt;           &lt;p&gt;java.math.BigDecimal        &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;     &lt;tr&gt;        &lt;td&gt;           &lt;p&gt;enum, struct, union        &lt;/p&gt;&lt;/td&gt;&lt;td&gt;           &lt;p&gt;class        &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;     &lt;tr&gt;        &lt;td&gt;           &lt;p&gt;sequence, array        &lt;/p&gt;&lt;/td&gt;&lt;td&gt;           &lt;p&gt;array        &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;        &lt;td&gt;           &lt;p&gt;interface (non-abstract)        &lt;/p&gt;&lt;/td&gt;&lt;td&gt;           &lt;p&gt;signature interface and an operations interface, helper class, holder class        &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;  &lt;tr&gt;        &lt;td&gt;           &lt;p&gt;interface (abstract)        &lt;/p&gt;&lt;/td&gt;&lt;td&gt;           &lt;p&gt;signature interface, helper class, holder class        &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;    &lt;tr&gt;        &lt;td&gt;           &lt;p&gt;constant (not within an interface)        &lt;/p&gt;&lt;/td&gt;&lt;td&gt;           &lt;p&gt;public interface        &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;        &lt;td&gt;           &lt;p&gt;constant (within an interface)        &lt;/p&gt;&lt;/td&gt;&lt;td&gt;           &lt;p&gt;fields in the Java signature interface for non-abstract, or the sole          Java interface for abstract        &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;     &lt;tr&gt;        &lt;td&gt;           &lt;p&gt;exception        &lt;/p&gt;&lt;/td&gt;&lt;td&gt;           &lt;p&gt;class        &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;          &lt;tr&gt;        &lt;td&gt;           &lt;p&gt;Any                 &lt;/p&gt;&lt;/td&gt;&lt;td&gt;           &lt;p&gt;org.omg.CORBA.Any        &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;     &lt;tr&gt;        &lt;td&gt;           &lt;p&gt;type declarations nested within interfaces                 &lt;/p&gt;&lt;/td&gt;&lt;td&gt;           &lt;p&gt;"scoped" package        &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;         &lt;tr&gt;        &lt;td&gt;           &lt;p&gt;typedef                 &lt;/p&gt;&lt;/td&gt;&lt;td&gt;           &lt;p&gt;helper classes        &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;        &lt;tr&gt;        &lt;td&gt;           &lt;p&gt;pseudo objects                 &lt;/p&gt;&lt;/td&gt;&lt;td&gt;           &lt;p&gt;pseudo interface        &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;             &lt;tr&gt;        &lt;td&gt;           &lt;p&gt;readonly attribute        &lt;/p&gt;&lt;/td&gt;&lt;td&gt;           &lt;p&gt;accessor method        &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;     &lt;tr&gt;        &lt;td&gt;           &lt;p&gt;readwrite attribute        &lt;/p&gt;&lt;/td&gt;&lt;td&gt;           &lt;p&gt;accessor and modifer methods        &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;     &lt;tr&gt;        &lt;td&gt;           &lt;p&gt;operation        &lt;/p&gt;&lt;/td&gt;&lt;td&gt;           &lt;p&gt;method        &lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt; &lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112367832949697792?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112367832949697792/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112367832949697792&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112367832949697792'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112367832949697792'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/08/idl-to-java.html' title='idl to java'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112367703336896518</id><published>2005-08-10T14:14:00.000+02:00</published><updated>2005-08-10T14:40:56.406+02:00</updated><title type='text'>"halloworld" in CORBA</title><content type='html'>&lt;span style="font-weight: bold;"&gt;1.create a file which ends with .idl---just simple as make a txt file&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  Hello.idl&lt;br /&gt;&lt;br /&gt;  module HelloApp&lt;br /&gt;  {&lt;br /&gt;    interface Hello&lt;br /&gt;    {&lt;br /&gt;      string sayHello();&lt;br /&gt;      oneway void shutdown();&lt;br /&gt;    };&lt;br /&gt;  };&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2. open command window type : idlj -fall Hello.idl&lt;/span&gt;&lt;br /&gt;  Parameter -fall tells compiler to map all files for server and client&lt;br /&gt;&lt;br /&gt;  how does this Hello.ild work?&lt;br /&gt;  module HelloApp --&gt; package HelloApp&lt;br /&gt;  interface Hello()  --&gt; class Hello (it will be used mostly in client side)&lt;br /&gt;  you will get 6 files, in HelloApp package, don't care about it now.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;3. create HelloImpl.java HelloServer.java    HelloClient.java&lt;/span&gt; &lt;br /&gt;&lt;br /&gt;package HelloApp;&lt;br /&gt;&lt;br /&gt;//HelloServer.java&lt;br /&gt;//Copyright and License&lt;br /&gt;import org.omg.CORBA.ORB;&lt;br /&gt;&lt;br /&gt;class HelloImpl extends HelloPOA {&lt;br /&gt;private ORB orb;&lt;br /&gt;&lt;br /&gt;public void setORB(ORB orb_val) {&lt;br /&gt;orb = orb_val;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// implement sayHello() method&lt;br /&gt;public String sayHello() {&lt;br /&gt;return "\nHello world !!\n";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// implement shutdown() method&lt;br /&gt;public void shutdown() {&lt;br /&gt;orb.shutdown(false);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;--------------------------------------&lt;br /&gt;&lt;br /&gt;package HelloApp;&lt;br /&gt;&lt;br /&gt;import org.omg.CORBA.ORB;&lt;br /&gt;import org.omg.CosNaming.NameComponent;&lt;br /&gt;import org.omg.CosNaming.NamingContextExt;&lt;br /&gt;import org.omg.CosNaming.NamingContextExtHelper;&lt;br /&gt;import org.omg.PortableServer.POA;&lt;br /&gt;import org.omg.PortableServer.POAHelper;&lt;br /&gt;&lt;br /&gt;public class HelloServer {&lt;br /&gt;&lt;br /&gt;     public static void main(String args[]) {&lt;br /&gt;       try{&lt;br /&gt;         // create and initialize the ORB&lt;br /&gt;         ORB orb = ORB.init(args, null);&lt;br /&gt;&lt;br /&gt;         // get reference to rootpoa &amp; activate the POAManager&lt;br /&gt;         POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));&lt;br /&gt;         rootpoa.the_POAManager().activate();&lt;br /&gt;&lt;br /&gt;         // create servant and register it with the ORB&lt;br /&gt;         HelloImpl helloImpl = new HelloImpl();&lt;br /&gt;         helloImpl.setORB(orb);&lt;br /&gt;&lt;br /&gt;         // get object reference from the servant&lt;br /&gt;         org.omg.CORBA.Object ref = rootpoa.servant_to_reference(helloImpl);&lt;br /&gt;         Hello href = HelloHelper.narrow(ref);&lt;br /&gt;       &lt;br /&gt;         // get the root naming context&lt;br /&gt;         org.omg.CORBA.Object objRef =&lt;br /&gt;                 orb.resolve_initial_references("NameService");&lt;br /&gt;         // Use NamingContextExt which is part of the Interoperable&lt;br /&gt;         // Naming Service (INS) specification.&lt;br /&gt;         NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);&lt;br /&gt;&lt;br /&gt;         // bind the Object Reference in Naming&lt;br /&gt;         String name = "Hello";&lt;br /&gt;         NameComponent path[] = ncRef.to_name( name );&lt;br /&gt;         ncRef.rebind(path, href);&lt;br /&gt;&lt;br /&gt;         System.out.println("HelloServer ready and waiting ...");&lt;br /&gt;&lt;br /&gt;         // wait for invocations from clients&lt;br /&gt;         orb.run();&lt;br /&gt;       }&lt;br /&gt;     &lt;br /&gt;         catch (Exception e) {&lt;br /&gt;           System.err.println("ERROR: " + e);&lt;br /&gt;           e.printStackTrace(System.out);&lt;br /&gt;         }&lt;br /&gt;       &lt;br /&gt;         System.out.println("HelloServer Exiting ...");&lt;br /&gt;     &lt;br /&gt;     }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;------------------------------------------------------&lt;br /&gt;&lt;br /&gt;package HelloApp;&lt;br /&gt;&lt;br /&gt;import org.omg.CORBA.ORB;&lt;br /&gt;import org.omg.CosNaming.NamingContextExt;&lt;br /&gt;import org.omg.CosNaming.NamingContextExtHelper;&lt;br /&gt;&lt;br /&gt;public class HelloClient&lt;br /&gt;{&lt;br /&gt; static Hello helloImpl;&lt;br /&gt;&lt;br /&gt; public static void main(String args[])&lt;br /&gt;   {&lt;br /&gt;     try{&lt;br /&gt;       // create and initialize the ORB&lt;br /&gt;         ORB orb = ORB.init(args, null);&lt;br /&gt;&lt;br /&gt;       // get the root naming context&lt;br /&gt;       org.omg.CORBA.Object objRef =&lt;br /&gt;       orb.resolve_initial_references("NameService");&lt;br /&gt;       // Use NamingContextExt instead of NamingContext. This is&lt;br /&gt;       // part of the Interoperable naming Service.&lt;br /&gt;       NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);&lt;br /&gt;&lt;br /&gt;       // resolve the Object Reference in Naming&lt;br /&gt;       String name = "Hello";&lt;br /&gt;       helloImpl = HelloHelper.narrow(ncRef.resolve_str(name));&lt;br /&gt;&lt;br /&gt;       System.out.println("Obtained a handle on server object: " + helloImpl);&lt;br /&gt;       System.out.println(helloImpl.sayHello());&lt;br /&gt;       helloImpl.shutdown();&lt;br /&gt;&lt;br /&gt;   } catch (Exception e) {&lt;br /&gt;         System.out.println("ERROR : " + e) ;&lt;br /&gt;     e.printStackTrace(System.out);&lt;br /&gt;     }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;4. try it out. If you have made some changes, do it completely again.&lt;br /&gt;    I thought that this first step works always, but if i not restart it,&lt;br /&gt;     it's always going wrong.&lt;br /&gt;   &lt;/span&gt;first &gt; orbd -ORBInitialPort 1050 -ORBInitialHost localhost&lt;br /&gt;   second &gt;java HelloApp.HelloServer -ORBInitialPort 1050 -ORBInitialHost localhost&lt;br /&gt;   third &gt;  java HelloApp.HelloClient -ORBInitialPort 1050 -ORBInitialHost localhost&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;5.enjoy it ;)&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112367703336896518?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112367703336896518/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112367703336896518&amp;isPopup=true' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112367703336896518'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112367703336896518'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/08/halloworld-in-corba.html' title='&quot;halloworld&quot; in CORBA'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112367593281230033</id><published>2005-08-10T14:03:00.000+02:00</published><updated>2005-08-10T14:12:12.813+02:00</updated><title type='text'>几个名词解释</title><content type='html'>BOA:    (VisiBrokers)basic object adapter&lt;br /&gt;               需要外设工具——麻烦。   &lt;br /&gt;&lt;br /&gt;POA:    portable object adapter&lt;br /&gt;              &lt;br /&gt;Remote Method Invocation (RMI) enables the development of distributed applications by providing for remote communication between programs written in the Java programming language. RMI enables an object running in one Java Virtual Machine to invoke methods on an object running in another Java VM, which may be on a different host&lt;br /&gt;纯JAVA程序服务器与客户端的交互&lt;br /&gt;&lt;br /&gt;Java IDL technology adds CORBA (Common Object Request Broker Architecture) capability to the Java platform, providing standards-based interoperability and connectivity.&lt;br /&gt;通用程序服务器与客户端的交互.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112367593281230033?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112367593281230033/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112367593281230033&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112367593281230033'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112367593281230033'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/08/blog-post_10.html' title='几个名词解释'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112367464106332637</id><published>2005-08-10T13:46:00.000+02:00</published><updated>2005-08-10T14:01:35.366+02:00</updated><title type='text'>server/client</title><content type='html'>每个对象都是序列化的，在哪里体现的呢？&lt;br /&gt;对象的生成是有序的，决定了对象的取出也必需是有序的。&lt;br /&gt;服务器和客户机之间交互的数据流完全可以抽象成——对象的单链。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;server:&lt;br /&gt;&lt;br /&gt;1.ServerSocket sev=new ServerSocket(port) //starts service&lt;br /&gt;2.socket soc=sev.accept(); //accept a connection&lt;br /&gt;3.InputStream in=soc.getInputStream();    //get information from client&lt;br /&gt;4.ObjectInput o=new ObjectInputStream(in);  //cast information&lt;br /&gt;5.Object obj=(Object)o.readObject(); //read objects in order&lt;br /&gt;&lt;br /&gt;client:&lt;br /&gt;&lt;br /&gt;1.Socket soc=new Socket(HostAdd,Port);  //connects to a Host&lt;br /&gt;2.OutputStream out=soc.getOutputStream(); //send information&lt;br /&gt;3.ObjectOutput o= new ObjectOutput(out);  //cast in objects&lt;br /&gt;4.1 o.writeObject(obj);  //sent objects&lt;br /&gt;4.2 o.writeInt()...//requires Serverside readInt()...&lt;br /&gt;&lt;br /&gt;Bsp:&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;* Created on 2005-8-8&lt;br /&gt;*&lt;br /&gt;* TODO To change the template for this generated file go to&lt;br /&gt;* Window - Preferences - Java - Code Style - Code Templates&lt;br /&gt;*/&lt;br /&gt;package tutorial;&lt;br /&gt;&lt;br /&gt;import java.io.*;&lt;br /&gt;import java.net.*;&lt;br /&gt;import java.util.*;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* This example shows how to use sockets to send and receive objects.&lt;br /&gt;* This file contains the class Server, which does the receiving of objects&lt;br /&gt;* from class WriteSocket in file WriteSocket.java&lt;br /&gt;* The Server has to run first and wait for the WriteSocket&lt;br /&gt;* to send the information.&lt;br /&gt;*&lt;br /&gt;* Compiled and Tested with JDK1.1 &amp; JDK1.2&lt;br /&gt;*/&lt;br /&gt;public class Server {&lt;br /&gt;&lt;br /&gt;   /**&lt;br /&gt;    * Create the serversocket and use its stream to receive serialized objects&lt;br /&gt;    */&lt;br /&gt;   public static void main(String args[]) {&lt;br /&gt;&lt;br /&gt;     ServerSocket ser = null;&lt;br /&gt;     Socket soc = null;&lt;br /&gt;     String str = null;&lt;br /&gt;     String declare=null;&lt;br /&gt;     int num;&lt;br /&gt;     Date d = null;&lt;br /&gt;&lt;br /&gt;     try {&lt;br /&gt;   ser = new ServerSocket(8020);&lt;br /&gt;   /*&lt;br /&gt;    * This will wait for a connection to be made to this socket.&lt;br /&gt;        */ &lt;br /&gt;   soc = ser.accept();&lt;br /&gt;   InputStream o = soc.getInputStream();&lt;br /&gt;   ObjectInput s = new ObjectInputStream(o);&lt;br /&gt;   str = (String) s.readObject();&lt;br /&gt;   declare=(String)s.readObject();&lt;br /&gt;   num=s.readInt();&lt;br /&gt;   d = (Date) s.readObject();&lt;br /&gt;&lt;br /&gt;   s.close();&lt;br /&gt;&lt;br /&gt;   // print out what we just received&lt;br /&gt;   System.out.println(str);&lt;br /&gt;   System.out.println(declare);&lt;br /&gt;   System.out.println(num);&lt;br /&gt;   System.out.println(d);&lt;br /&gt;     } catch (Exception e) {&lt;br /&gt;            System.out.println(e.getMessage());&lt;br /&gt;     System.out.println("Error during serialization");&lt;br /&gt;     System.exit(1);&lt;br /&gt;     }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;* Created on 2005-8-8&lt;br /&gt;*&lt;br /&gt;* TODO To change the template for this generated file go to&lt;br /&gt;* Window - Preferences - Java - Code Style - Code Templates&lt;br /&gt;*/&lt;br /&gt;package tutorial;&lt;br /&gt;&lt;br /&gt;import java.io.*;&lt;br /&gt;import java.net.*;&lt;br /&gt;import java.util.*;&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* This example shows how to use sockets and serialization to send&lt;br /&gt;* objects that will be received&lt;br /&gt;* (see class Server to see the receiving part)&lt;br /&gt;*&lt;br /&gt;* Compiled and Tested with JDK1.1 &amp; JDK1.2&lt;br /&gt;*/&lt;br /&gt;public class Client {&lt;br /&gt;&lt;br /&gt;   public static void main(String args[]) {&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;     try {&lt;br /&gt;     // Create a socket&lt;br /&gt;     Socket soc = new Socket(InetAddress.getLocalHost(), 8020);&lt;br /&gt;&lt;br /&gt;     // Serialize today's date to a outputstream associated to the socket&lt;br /&gt;     OutputStream o = soc.getOutputStream();&lt;br /&gt;     ObjectOutput s = new ObjectOutputStream(o);&lt;br /&gt;  &lt;br /&gt;     s.writeObject("Today's date");&lt;br /&gt;     s.writeObject("I am serialized!");&lt;br /&gt;     s.writeInt(19);&lt;br /&gt;     s.writeObject(new Date());&lt;br /&gt;     s.flush();&lt;br /&gt;     s.close();&lt;br /&gt;     } catch (Exception e) {&lt;br /&gt;     System.out.println(e.getMessage());&lt;br /&gt;     System.out.println("Error during serialization");&lt;br /&gt;     System.exit(1);&lt;br /&gt;     }&lt;br /&gt; }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112367464106332637?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112367464106332637/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112367464106332637&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112367464106332637'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112367464106332637'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/08/serverclient.html' title='server/client'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112344790215806176</id><published>2005-08-07T22:42:00.000+02:00</published><updated>2005-08-07T23:00:31.753+02:00</updated><title type='text'>FUMULE WEITER ...</title><content type='html'>&lt;span style="color: rgb(51, 0, 153);"&gt;Wie Chaojing vorgeschlagt hat&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(51, 0, 153);"&gt;Sollen wir eventuell den FUMule Projekt weiter entwicklen&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(51, 0, 153);"&gt;Dafür wird Folgende CVS Server aufgebaut&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;:extssh:Username@troll.inf.fu-berlin.de:/home/bude/zheng/CVS&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 0, 153);"&gt;Klar, selbstverständlich Passwort noch&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(51, 0, 153);"&gt;Viel Spass daran !&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112344790215806176?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112344790215806176/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112344790215806176&amp;isPopup=true' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112344790215806176'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112344790215806176'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/08/fumule-weiter.html' title='FUMULE WEITER ...'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112332831501823222</id><published>2005-08-06T13:22:00.000+02:00</published><updated>2005-08-06T13:38:35.020+02:00</updated><title type='text'>入侵私有方法</title><content type='html'>假设现在有一个class Man&lt;br /&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;package hello;&lt;/span&gt;&lt;br /&gt;public class Man{&lt;br /&gt;    private void x("I am private!");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;现在有一个不同package的class AccessMan要来搞class Man的私有Method x&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;package etwas;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;import java.lang.reflect.AccessibleObject;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(255, 102, 0);"&gt;import java.lang.reflect.InvocationTargetException;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(255, 102, 0);"&gt;import java.lang.reflect.Method;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(255, 102, 0);"&gt;import hello.Man;&lt;/span&gt;&lt;br /&gt;public class AccessMan {&lt;br /&gt;    public static void main(String[] args) throws&lt;br /&gt;            InvocationTargetException,IllegalAccessException{&lt;br /&gt;     &lt;span style="color: rgb(0, 0, 153);"&gt;   // create new Man;&lt;/span&gt;&lt;br /&gt;        Man a = new Man();&lt;br /&gt;        &lt;span style="color: rgb(0, 0, 153);"&gt;// get the type of a;&lt;/span&gt;&lt;br /&gt;        Class c = a.getClass();&lt;br /&gt;        &lt;span style="color: rgb(0, 0, 153);"&gt;// get the methods of c;&lt;/span&gt;&lt;br /&gt;        Method[] m = c.getDeclaredMethods();&lt;br /&gt;         &lt;span style="color: rgb(0, 0, 153);"&gt;// kern step, to access the private methods&lt;/span&gt;&lt;br /&gt;        AccessibleObject.setAccessible(m,true);&lt;br /&gt;        &lt;span style="color: rgb(0, 0, 153);"&gt;// get the parameters of this method&lt;/span&gt;&lt;br /&gt;        Class[] parameters = m[0].getParameterTypes();&lt;br /&gt;        &lt;span style="color: rgb(0, 0, 153);"&gt;// call this method, now, "I am private" will be printed&lt;/span&gt;&lt;br /&gt;        m[0].invoke(a,(Object[])parameters);&lt;br /&gt;    }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112332831501823222?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112332831501823222/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112332831501823222&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112332831501823222'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112332831501823222'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/08/blog-post_112332831501823222.html' title='入侵私有方法'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112332424230966996</id><published>2005-08-06T12:25:00.000+02:00</published><updated>2005-08-06T12:30:42.316+02:00</updated><title type='text'>拉伸Array</title><content type='html'>&lt;span style="color: rgb(51, 51, 153);"&gt;import java.lang.reflect.Array;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;static Object ArrayGrow(Object o){&lt;br /&gt;        &lt;span style="color: rgb(0, 102, 0);"&gt;// assume the parameter o is an Array, else return null &lt;/span&gt;&lt;br /&gt;        Class c = o.getClass();&lt;br /&gt;        if(!c.isArray()) return null;&lt;br /&gt;      &lt;span style="color: rgb(0, 102, 0);"&gt;  // get the component type of an Array&lt;/span&gt;&lt;br /&gt;        Class componentType = c.getComponentType();&lt;br /&gt;       &lt;span style="color: rgb(0, 102, 0);"&gt; // get the Array length&lt;/span&gt;&lt;br /&gt;        int length = Array.getLength(o);&lt;br /&gt;        &lt;span style="color: rgb(0, 102, 0);"&gt;// extends the length&lt;/span&gt;&lt;br /&gt;        int newLength = length +10;&lt;br /&gt;       &lt;span style="color: rgb(0, 102, 0);"&gt; // create a new Array&lt;/span&gt;&lt;br /&gt;        Object newArray = Array.newInstance(componentType,newLength);&lt;br /&gt;        &lt;span style="color: rgb(0, 102, 0);"&gt;// copy values to the new Array&lt;/span&gt;&lt;br /&gt;        System.arraycopy(o,0,newArray,0,length);&lt;br /&gt;        return newArray;&lt;br /&gt;    }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112332424230966996?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112332424230966996/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112332424230966996&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112332424230966996'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112332424230966996'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/08/array.html' title='拉伸Array'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112332354613338118</id><published>2005-08-06T12:10:00.000+02:00</published><updated>2005-08-06T12:19:06.140+02:00</updated><title type='text'>client/server模式</title><content type='html'>sever:&lt;br /&gt;        1，开放端口&lt;br /&gt;         2，启动服务----设定好的主机和客户机交互Protocol&lt;br /&gt;client:&lt;br /&gt;        1，与服务器建立连接----Socket clientSocket=new Socket(severAddress,Port);&lt;br /&gt;        2,  输出数据流&amp;接收数据流,从System.in接收本机数据输入&lt;br /&gt;        3,    关闭输入,输出数据流&lt;br /&gt;        4,    关闭socket-----clientSocket.close();&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112332354613338118?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112332354613338118/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112332354613338118&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112332354613338118'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112332354613338118'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/08/clientserver.html' title='client/server模式'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112331888258546465</id><published>2005-08-06T10:46:00.000+02:00</published><updated>2005-08-06T11:01:22.596+02:00</updated><title type='text'>入侵私有变量</title><content type='html'>比如说有一个Class&lt;br /&gt;&lt;span style="color: rgb(255, 102, 102);"&gt;package hello;&lt;/span&gt;&lt;br /&gt;public class Man{&lt;br /&gt;     private int age = 50;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;现在我在package hallo里面，也就是说跟Class Man不同的package里面，现在要搞到age的值而且要改变它&lt;br /&gt;&lt;span style="color: rgb(255, 102, 102);"&gt;package hallo;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;import java.lang.reflect.AccessibleObject;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;import java.lang.reflect.Field;&lt;/span&gt;&lt;br /&gt;public class RefelectionFiledTest {&lt;br /&gt; public static void main(String[] args) throws&lt;br /&gt;   NoSuchFieldException,IllegalAccessException{&lt;br /&gt;  Man m = new Man();&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;                // get the type of object m&lt;/span&gt;&lt;br /&gt;  Class c = m.getClass();&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;                // get the fields array of Class c, all fields, private inclusive&lt;/span&gt;&lt;br /&gt;  Field[] f = c.getDeclaredFields();&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;                // let the private fields can also be accessible&lt;/span&gt;&lt;br /&gt;  AccessibleObject.setAccessible(f,true);&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;                // get the value of 1st field which correponds to object m&lt;/span&gt;&lt;br /&gt;               Object o = f[0].get(m);&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;                // sure 50 will be printed here&lt;/span&gt;&lt;br /&gt;  System.out.println(o);&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;                // set the value of 1st field of m to 200&lt;/span&gt;&lt;br /&gt;  f[0].set(m,200);&lt;br /&gt;&lt;span style="color: rgb(51, 204, 0);"&gt;                // now even the private field value is also changed to 200  :)&lt;/span&gt;&lt;br /&gt;  o = f[0].get(m);&lt;br /&gt;               System.out.println(o);&lt;br /&gt; }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112331888258546465?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112331888258546465/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112331888258546465&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112331888258546465'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112331888258546465'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/08/blog-post.html' title='入侵私有变量'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112328234610312994</id><published>2005-08-06T00:51:00.000+02:00</published><updated>2005-08-06T01:01:39.530+02:00</updated><title type='text'>set up your JSP</title><content type='html'>&lt;a href="http://www.7880.com/Info/Article-3b518c0.html"&gt;struts入门&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;1. 下载并安装tomcat。下载地址：http://jakarta.apache.org/tomcat&lt;br /&gt;2. 编写自己的JSP网页和Java对象。&lt;br /&gt;3. 配置自己的Web应用。配置方法：&lt;br /&gt;   在TOMCAT_HOME/conf/server.xml文件中加入一行：&lt;br /&gt;   &lt;Content path="/appName" docBase="webapps/appName" debug="0" reloadable="true"/&gt;&lt;br /&gt;   其中，TOMCAT_HOME是tomcat的主目录，appName是你的Web应用的名称。&lt;br /&gt;4. 将你的jsp文件、html文件、image文件拷贝到TOMCAT_HOME/webapps/appName目录下。&lt;br /&gt;5. 编译你的java文件。&lt;br /&gt;6. 将编译好的class文件拷贝到TOMCAT_HOME/webapps/WEB-INF/classes目录下。也可将class文件打包成jar文件放到TOMCAT_HOME/webapps/WEB-INF/lib目录下。&lt;br /&gt;7. ALL IS OK! 你可以在你的浏览器上看到你的成果了：&lt;br /&gt;   http://localhost:8080/appName/youjsp.jsp&lt;br /&gt;   其中，appName是你配的Web应用名称，youjsp.jsp是你编写的jsp文件名。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112328234610312994?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112328234610312994/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112328234610312994&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112328234610312994'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112328234610312994'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/08/set-up-your-jsp.html' title='set up your JSP'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112319577447740461</id><published>2005-08-05T00:39:00.000+02:00</published><updated>2005-08-05T00:49:34.486+02:00</updated><title type='text'>Extends Rules</title><content type='html'>&lt;span style="color: rgb(255, 102, 0);"&gt;Rule 1, &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;Constructor can't call methods, which is overridable&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;Here's an Example:&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;public class Super(){&lt;br /&gt;    public Super(){&lt;br /&gt;        m();&lt;br /&gt;    }&lt;br /&gt;    public void m(){&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;final class Sub extends Super{&lt;br /&gt;    private final Date date;&lt;br /&gt;    Sub(){&lt;br /&gt;        date = new Date();&lt;br /&gt;    }&lt;br /&gt;    public void m() {&lt;br /&gt;        System.out.println(date);&lt;br /&gt;    }&lt;br /&gt;    public static void main(String[] args){&lt;br /&gt;       Sub s = new Sub();&lt;br /&gt;        s.m();     &lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt; &lt;span style="color: rgb(0, 0, 153);"&gt;The output is null &amp; date;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 0, 153);"&gt;wow, a final variable date has now strangely 2 different values&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112319577447740461?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112319577447740461/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112319577447740461&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112319577447740461'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112319577447740461'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/08/extends-rules.html' title='Extends Rules'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112187818200866519</id><published>2005-07-20T18:35:00.000+02:00</published><updated>2005-07-20T18:50:12.943+02:00</updated><title type='text'>B+ Tree</title><content type='html'>&gt;&gt; ISAM (indexed sequential access method) is a static indexing structure&lt;br /&gt;&lt;br /&gt;&gt;&gt; B+ trees, dynamic, adjusts under inserts and deletes&lt;br /&gt;&lt;br /&gt;&gt;&gt; The B-tree is the classic disk-based data structure for indexing records based on an ordered key set.&lt;br /&gt;&lt;br /&gt;&gt;&gt; The B+-tree (sometimes written B+-tree, B+tree, or just B-tree) is a variant of the original B-tree in which all records are stored in the leaves and all leaves are linked sequentially. The B+-tree is used as a (dynamic) indexing method in relational database management systems.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112187818200866519?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112187818200866519/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112187818200866519&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112187818200866519'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112187818200866519'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/07/b-tree.html' title='B+ Tree'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112187703462893433</id><published>2005-07-20T18:26:00.000+02:00</published><updated>2005-07-20T18:30:34.633+02:00</updated><title type='text'>Achtung</title><content type='html'>Hier's Mail von Yark Schröder:&lt;br /&gt;&lt;br /&gt;Hallo Leute,ich habe jetzt die Klausur in der Endfassung gesehen und kann ausschließen:&lt;br /&gt;- Recovery&lt;br /&gt;- Optimistische Verfahren&lt;br /&gt;&lt;br /&gt;Schaut euch auf jeden Fall noch einmal an:&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;- RAID&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;- R+-Baum --&gt; geändert zu B+-Baum&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;- ResultSet in Java&lt;/span&gt;&lt;br /&gt;Ansonsten wie im Tutorium schon angekündigt.&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;Vegesst die verschiedenen Varianten der Sperrprotokolle nicht! &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;Rechnen müsst ihr übrigens auch.&lt;/span&gt; (Was für Rechnen?~~)&lt;br /&gt;Noch viel Erfolg beim Lernen!&lt;br /&gt;GrußYark&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112187703462893433?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112187703462893433/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112187703462893433&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112187703462893433'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112187703462893433'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/07/achtung.html' title='Achtung'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112187306225775072</id><published>2005-07-20T16:42:00.000+02:00</published><updated>2005-07-20T17:59:38.870+02:00</updated><title type='text'>RAID -- Redundant Arrays of Independent Disks</title><content type='html'>&gt;&gt; 磁盘阵列分为软阵列 (Software Raid)和硬阵列 (Hardware Raid) 两种&lt;br /&gt;&lt;br /&gt;&gt;&gt; 软阵列通过软件程序并由计算机的CPU提供运行能力所成. 软件程式不是一个完整系统故, 只能提供最基本的RAID容错功能&lt;br /&gt;&lt;br /&gt;&gt;&gt; 硬阵列是由独立操作的硬件提供整个磁盘阵列的控制和计算功能. 不依靠系统的CPU资源. 硬阵列是一个完整的系统, 功能结棍&lt;br /&gt;&lt;br /&gt;&gt;&gt; 如果你想把系统也做到磁盘阵列中, 硬阵列是唯一的选择. 市场上 RAID 5 级的磁盘阵列均为硬阵列&lt;br /&gt;&lt;br /&gt;&gt;&gt; 软阵列只适用于 Raid 0 和 Raid 1&lt;br /&gt;&lt;br /&gt;&gt;&gt; 作为高性能的存储系统, 其级别分别是0、1、2、3、4、5, 最常用的是0、1、3、5四个级别。&lt;br /&gt;&lt;br /&gt;&gt;&gt; RAID 0：不具有冗余，并行I/O，速度最快,将多个磁盘并列起来，成为一个大硬盘。在存放数据时，其将数据按磁盘的个数来进行分段，然后同时将这些数据写进这些盘中. 如果一个磁盘（物理）损坏，则所有的数&lt;br /&gt;据都无法使用。&lt;br /&gt;&lt;br /&gt;&gt;&gt; RAID 1：两组相同的磁盘系统互作镜像，速度没有提高，但是允许单个磁盘错，可靠性最高。RAID 1就是镜像。其原理为在主硬盘上存放数据的同时也在镜像硬盘上写一样的数据。当主硬盘（物理）损坏时，镜像硬盘则代替主硬盘的工作。因为有镜像硬盘做数据备份，所以RAID 1的数据安全性在所有的RAID级别上来说是最好的。但是其磁盘的利用率却只有50%，是所有RAID上磁盘利用率最低的一个级别。&lt;br /&gt;&lt;br /&gt;&gt;&gt; RAID 3: 以一个硬盘来存放数据的奇偶校验位，数据则分段存储于其余硬盘中。它象RAID 0一样以并行的方式来存放数，但速度没有RAID 0快。如果数据盘（物理）损坏，只要将坏硬盘换掉，RAID控制系统则会根据校验盘的数据校验位在新盘中重建坏盘上的数据。不过，如果校验盘（物理）损坏的话，则全部数据都&lt;br /&gt;无法使用。利用单独的校验盘来保护数据虽然没有镜像的安全性高，但是硬盘利用率得到了很大的提高，为n-1。&lt;br /&gt;&lt;br /&gt;&gt;&gt; RAID 5：向阵列中的磁盘写数据，奇偶校验数据存放在阵列中的各个盘上，允许单个磁盘出错。RAID 5也是以数据的校验位来保证数据的安全，但它不是以单独硬盘来存放数据的校验位，而是将数据段的校验位交互存放于各个硬盘上。这样, 任何一个硬盘损坏，都可以根据其它硬盘上的校验位来重建损坏的数据。硬盘的利用率为n-1。&lt;br /&gt;&lt;br /&gt;&gt;&gt; RAID 0－1：同时具有RAID 0和RAID 1的优点。&lt;br /&gt;&lt;br /&gt;&gt;&gt; 冗余：采用多个设备同时工作，当其中一个设备失效时，其它设备能够接替失效设备继续工作的体系。在PC服务器上，通常在磁盘子系统、电源子系统采用冗余技术。&lt;br /&gt;&lt;br /&gt;&gt;&gt; 磁盘阵列是把多个磁盘组成一个阵列,当作单一磁盘使用,它将数据以分段(striping)的方式储存在不同的磁盘中,存取数据时,阵列中的相关磁盘一起动作,大幅减低数据的存取时间,同时有更佳的空间利用率.&lt;br /&gt;&lt;br /&gt;&gt;&gt; 磁盘延伸(Disk Spanning): 如图磁盘阵列控制器,联接了四个磁盘,这四个磁盘形成一个阵列(array),而磁盘阵列的控制器(RAID controller)是将此四个磁盘视为单一的磁盘,如DOS环境下的C:盘。这是disk spanning的意义,因为把小容量的磁盘延伸为大容量的单一磁盘,用户不必规划数据在各磁盘的分布,而且提高了磁盘空间的使用率。并使磁盘容量几乎可作无限的延伸;而各个磁盘一起作取存的动作,比单一磁盘更为快捷。很明显的,有此阵列的形成而产生RAID的各种技术&lt;br /&gt;&lt;br /&gt;&gt;&gt; 磁盘或数据分段(Disk Striping or Data Striping): 因为磁盘阵列是将同一阵列的多个磁盘视为单一的虚拟磁盘(virtual disk),所以其数据是以分段(block or segment)的方式顺序存放在磁盘阵列中,数据按需要分段,从第一个磁盘开始放,放到最後一个磁盘再回到第一个磁盘放起,直到数据分布完毕。至于分段&lt;br /&gt;的大小视系统而定,有的系统或以1KB最有效率,或以4KB,或以6KB,甚至是4MB或8MB的,但除非数据小于一个扇区(sector,即512bytes),否则其分段应是512byte的倍数. 因为磁盘的读写是以一个扇区为单位,若数据小于512bytes,系统读取该扇区后,还要做组合或分组(视读或写而定)的动作,浪费时间。从上图我们可以看出,数据以分段于在不同的磁盘,整个阵列的各个磁盘可同时作读写,故数据分段使数据的存取有最好的效率,理论上本来读一个包含四个分段的数据所需要的时间约=(磁盘的access time+数据的tranfer time)X4次,现在只要一次就可以完成。&lt;br /&gt;&lt;br /&gt;&gt;&gt; 若以N表示磁盘的数目,R表示读取,W表示写入,S表示可使用空间,则数据分段的性能为:&lt;br /&gt;R:N(可同时读取所有磁盘)&lt;br /&gt;W:N(可同时写入所有磁盘)&lt;br /&gt;S:N(可利用所有的磁盘,并有最佳的使用率)&lt;br /&gt;&lt;br /&gt;&gt;&gt; RAID 1,每一笔数据都储存两份:&lt;br /&gt;R:N(可同时读取所有磁盘)&lt;br /&gt;W:N/2(同时写入磁盘数)&lt;br /&gt;S:N/2(利用率)&lt;br /&gt;读取数据时可用到所有的磁盘,充分发挥数据分段的优点;写入数据时,因为有备份,所&lt;br /&gt;以要写入两个磁盘,其效率是N/2,磁盘空间的使用率也只有全部磁盘的一半。&lt;br /&gt;&lt;br /&gt;&gt;&gt; 目前市面上的磁盘阵列系统大部份是硬件磁盘阵列,软件磁盘阵列较少。&lt;br /&gt;&lt;br /&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;Widerholen&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;br /&gt;&lt;br /&gt;&gt;&gt; RAID 0: 并不是真正的RAID结构, 没有数据冗余. RAID 0 连续地分割数据并并行地读/写于多个磁盘上.因此具有很高的数据传输率. 但RAID 0在提高性能的同时,并没有提供数据可靠性,如果一个磁盘失效,将影响整个数据.因此RAID 0 不可应用于需要数据高可用性的关键应用.&lt;br /&gt;&lt;br /&gt;&gt;&gt; RAID 1: RAID 1通过数据镜像实现数据冗余, 在两对分离的磁盘上产生互为备份的数据. RAID 1可以提高读的性能, 当原始数据繁忙时, 可直接从镜像拷贝中读取数据.RAID 1是磁盘阵列中费用最高的, 但提供了最高的数据可用率. 当一个磁盘失效, 系统可以自动地交换到镜像磁盘上, 而不需要重组失效的数据.&lt;br /&gt;&lt;br /&gt;&gt;&gt; RAID 2: 从概念上讲, RAID 2 同RAID 3类似, 两者都是将数据条块化分布于不同的硬盘上, 条块单位为位或字节.然而RAID 2使用称为"加重平均纠错码"的编码技术来提供错误检查及恢复. 这种编码技术需要多个磁盘存放检查及恢复信息, 使得RAID 2技术实施更复杂. 因此,在商业环境中很少使用.&lt;br /&gt;&lt;br /&gt;&gt;&gt; RAID 3: 不同于RAID 2, RAID 3使用单块磁盘存放奇偶校验信息. 如果一块磁盘失效, 奇偶盘及其他数据盘可以重新产生数据. 如果奇偶盘失效,则不影响数据使用.RAID 3对于大量的连续数据可提供很好的传输率, 但对于随机数据, 奇偶盘会成为写操作的瓶颈.&lt;br /&gt;&lt;br /&gt;&gt;&gt; RAID 4: 同RAID 2, RAID 3一样, RAID 4, RAID 5也同样将数据条块化并分布于不同的磁盘上, 但条块单位为块或记录. RAID 4使用一块磁盘作为奇偶校验盘, 每次写操作都需要访问奇偶盘, 成为写操作的瓶颈. 在商业应用中很少使用.&lt;br /&gt;&lt;br /&gt;&gt;&gt; RAID 5: 没有单独指定的奇偶盘, 而是交叉地存取数据及奇偶校验信息于所有磁盘上. 在RAID5 上, 读/写指针可同时对阵列设备进行操作, 提供了更高的数据流量. RAID 5更适合于小数据块, 随机读写的数据.RAID 3与RAID 5相比, 重要的区别在于RAID 3每进行一次数据传输,需涉及到所有的阵列盘.而对于RAID 5来说, 大部分数据传输只对一块磁盘操作, 可进行并行操作.在RAID 5中有"写损失", 即每一次写操作,将产生四个实际的读/写操作, 其中两次读旧的数据及奇偶信息, 两次写新的数据及奇偶信息.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112187306225775072?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112187306225775072/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112187306225775072&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112187306225775072'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112187306225775072'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/07/raid-redundant-arrays-of-independent.html' title='RAID -- Redundant Arrays of Independent Disks'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112180903520396063</id><published>2005-07-19T23:35:00.000+02:00</published><updated>2005-07-19T23:37:15.206+02:00</updated><title type='text'>一个清华学生在香港留学受到的心灵震憾</title><content type='html'>&lt;a href="http://forum.javaeye.com/viewtopic.php?t=14652&amp;sid=f96f767ffbd2f178d2cd4b883108912e"&gt;http://forum.javaeye.com/viewtopic.php?t=14652&amp;amp;sid=f96f767ffbd2f178d2cd4b883108912e&lt;/a&gt; sehr empfehlenswert&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112180903520396063?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112180903520396063/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112180903520396063&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112180903520396063'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112180903520396063'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/07/blog-post_19.html' title='一个清华学生在香港留学受到的心灵震憾'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112141137012408882</id><published>2005-07-15T09:07:00.000+02:00</published><updated>2005-07-15T09:09:30.130+02:00</updated><title type='text'>java类的static块什么时候执行？ from eway</title><content type='html'>&lt;a href="http://befresh.bjug.org"&gt;http://befresh.bjug.org&lt;/a&gt;&lt;br /&gt;  &lt;br /&gt;&lt;br /&gt;很多人包括我自己，过去常常以为类是在第一次被装在的时候运行static块，其实不然。&lt;br /&gt;&lt;br /&gt;例子：&lt;br /&gt;Class A{   &lt;br /&gt;   static{&lt;br /&gt;      System.out.println("static block invoked!")&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;static块到底在什么时候运行的呢？如果了解JVM原理，我们可以知道，一个类的运行分为以下步骤：&lt;br /&gt;1、装载；2、链接；3、初始化；4、初始化；5，实例化（创建新的实例）&lt;br /&gt;&lt;br /&gt;实际上，static块的执行发生在“初始化”的阶段。初始化阶段，jvm主要完成对静态变量的初始化，静态块执行等工作。&lt;br /&gt;下面我们看看执行static块的几种情况：&lt;br /&gt;1、第一次new A()的过程会打印""；因为这个过程包括了初始化&lt;br /&gt;2、第一次Class.forName("A")的过程会打印""；因为这个过程相当于Class.forName("A",true,this.getClass().getClassLoader());&lt;br /&gt;3、第一次Class.forName("A",false,this.getClass().getClassLoader())的过程则不会打印""。因为false指明了装载类的过程中，不进行初始化。不初始化则不会执行static块。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112141137012408882?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112141137012408882/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112141137012408882&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112141137012408882'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112141137012408882'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/07/javastatic-from-eway.html' title='java类的static块什么时候执行？ from eway'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112103415637462944</id><published>2005-07-11T00:21:00.000+02:00</published><updated>2005-07-11T00:22:36.376+02:00</updated><title type='text'>Exception &lt;&gt; 异常 Autor:Robbin</title><content type='html'>绝大多数的Java程序员根本就没有领悟“Exception”的真正用处。他们就是把Exception当做异常来理解，没有明白Exception实际上代表了一个UseCase中的异常流的处理。 在使用UseCase来描述一个场景的时候，有一个主事件流和n个异常流。异常流可能发生在主事件流的过程，而try语句里面实现的是主事件流，而catch里面实现的是异常流，在这里Exception不代表程序出现了异常或者错误，Exception只是面向对象化的业务逻辑控制方法。如果没有明白这一点，那么我认为并没有真正明白应该怎么使用Java来正确的编程。 而我自己写的程序，会自定义大量的Exception类，所有这些Exception类都不意味着程序出现了异常或者错误，只是代表非主事件流的发生的，用来进行那些分支流程的流程控制的。例如你往权限系统中增加一个用户，应该定义1个异常类，UserExistedException，抛出这个异常不代表你插入动作失败，只说明你碰到一个分支流程，留待后面的catch中来处理这个分支流程。传统的程序员会写一个if else来处理，而一个合格的OOP程序员应该有意识的使用try catch 方式来区分主事件流和n个分支流程的处理，通过try catch，而不是if else来从代码上把不同的事件流隔离开来进行分别的代码撰写。 总之 Exception &lt;&gt; 异常&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112103415637462944?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112103415637462944/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112103415637462944&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112103415637462944'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112103415637462944'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/07/exception-autorrobbin.html' title='Exception &lt;&gt; 异常 Autor:Robbin'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112103068341678397</id><published>2005-07-10T23:24:00.000+02:00</published><updated>2005-07-10T23:24:43.420+02:00</updated><title type='text'>数据库时代的终结</title><content type='html'>&lt;a href="http://www.jdon.com/jive/thread.jsp?forum=91&amp;thread=20162&amp;amp;msRange=15"&gt;http://www.jdon.com/jive/thread.jsp?forum=91&amp;thread=20162&amp;amp;msRange=15&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112103068341678397?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112103068341678397/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112103068341678397&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112103068341678397'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112103068341678397'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/07/blog-post_10.html' title='数据库时代的终结'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112102406201825513</id><published>2005-07-10T21:27:00.000+02:00</published><updated>2005-07-10T21:55:27.816+02:00</updated><title type='text'>西域藏宝图</title><content type='html'>&lt;p&gt;&lt;a href="http://page.mi.fu-berlin.de/~zheng/file/jdk.gif" /&gt;西域藏宝图&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&gt;&gt; 运行时数据区就是存储器，包含多种不同形式的数据区，譬如方法区、堆和Java栈等。运行时数据区可以存储字节码、对象、局部变量以及运算的中间结果等。&lt;/p&gt;&lt;p&gt;&gt;&gt; 执行引擎任何Java VM实现的核心都是它的执行引擎，有点类似于CPU，执行引擎进行指令调度，Java VM有自身、独立的指令集。&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&gt;&gt; 执行引擎与Java VM一样，也有三种不同的理解，包括抽象规范、具体实现和运行时的实例。作为运行时实例的执行引擎就是一个线程，正在运行的Java程序中的每一个线程都是一个独立的虚拟机执行引擎的实例。&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&gt;&gt; Java VM一般会存在两种不同的线程：一种是对用户程序不可见的，这样的线程不需要是实现的执行引擎的实例，譬如GC；另外一种就是属于用户运行程序的线程，这些线程都是在实际工作的执行引擎。&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112102406201825513?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112102406201825513/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112102406201825513&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112102406201825513'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112102406201825513'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/07/blog-post.html' title='西域藏宝图'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112040667121810445</id><published>2005-07-03T18:03:00.000+02:00</published><updated>2005-07-03T18:04:31.223+02:00</updated><title type='text'>XiXi Blog</title><content type='html'>http://www.iamxixi.com/blogview.asp?logID=507&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112040667121810445?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112040667121810445/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112040667121810445&amp;isPopup=true' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112040667121810445'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112040667121810445'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/07/xixi-blog.html' title='XiXi Blog'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112039115031893418</id><published>2005-07-03T13:44:00.000+02:00</published><updated>2005-07-03T13:45:50.316+02:00</updated><title type='text'></title><content type='html'>&lt;a href="http://page.mi.fu-berlin.de/~yang/links/ALP4.txt"&gt;Komplette Wissensfrage&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112039115031893418?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112039115031893418/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112039115031893418&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112039115031893418'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112039115031893418'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/07/komplette-wissensfrage.html' title=''/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-112022818211837755</id><published>2005-07-01T16:26:00.000+02:00</published><updated>2005-07-10T22:15:06.886+02:00</updated><title type='text'></title><content type='html'>&lt;div class="entry"&gt;&lt;br /&gt;&lt;p&gt;Google has released &lt;a href="http://video.google.com/video_download.html"&gt;Google Video Viewer&lt;/a&gt;, a browser plugin based on &lt;a href="http://www.videolan.org/vlc/"&gt;VLC&lt;/a&gt;. Here’s one of the features they’ve &lt;a href="http://code.google.com/vlc-diff.txt"&gt;added&lt;/a&gt;:&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;+    // Google mods&lt;br /&gt;+    const char* allowed_host = \"video.google.com\";&lt;br /&gt;+    char * host_found = strstr(p_sys-&gt;url.psz_host, &lt;/pre&gt;&lt;pre&gt;allowed_host);&lt;br /&gt;+    if ((host_found == NULL)&lt;br /&gt;+ ((host_found + strlen(allowed_host)) !=&lt;br /&gt;+  (p_sys-&gt;url.psz_host + strlen(p_sys-&gt;url.psz_host&lt;/pre&gt;&lt;pre&gt;)))) {&lt;br /&gt;+      msg_Warn( p_access, \"invalid host, only &lt;/pre&gt;&lt;pre&gt;video.google.com is allowed\" );&lt;br /&gt;+      goto error;&lt;br /&gt;+    }&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;This “feature” prevents you from playing videos that are not hosted on Google’s servers. Download and run &lt;a title="Google Video Viewer Patch" href="http://nanocrew.net/wp-content/GVVPatch.exe"&gt;this patch&lt;/a&gt; I wrote to remove this restriction. Running the patch requires a &lt;a href="http://www.microsoft.com/downloads/info.aspx?na=90&amp;p=&amp;amp;SrcDisplayLang=en&amp;SrcCategoryId=&amp;amp;SrcFamilyId=262d25e3-f589-4842-8157-034d1e7cf3a3&amp;genscs=&amp;amp;u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2fa%2fa%2fc%2faac39226-8825-44ce-90e3-bf8203e74006%2fdotnetfx.exe"&gt;.NET runtime&lt;/a&gt;.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;b&gt;Update:&lt;/b&gt; Journalists never cease to amaze me with their ability to &lt;a href="http://news.google.com/news?q=google+johansen"&gt;blow things out of proportion&lt;/a&gt;. For the record, I haven’t spoken to or exchanged emails with a single journalist about this, so when the Associated Press &lt;a href="http://www.businessweek.com/ap/financialnews/D8B1AUC80.htm"&gt;writes&lt;/a&gt; “said he needed only one day” that’s a complete and utter fabrication since I’ve said no such thing here on my blog.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Some of you have requested the source code for the patch: &lt;a title="Google Video Viewer Patch Source Code" href="/wp-content/GVVPatch.cs"&gt;GVVPatch.cs&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-112022818211837755?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/112022818211837755/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=112022818211837755&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112022818211837755'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/112022818211837755'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/07/google-has-released-google-video.html' title=''/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-111978024626774049</id><published>2005-06-26T11:59:00.000+02:00</published><updated>2005-06-26T20:50:30.906+02:00</updated><title type='text'></title><content type='html'>&lt;span style="font-size:12;"&gt;&lt;span id="tpid833640"&gt;&lt;span id="spid833640"&gt;&lt;span id="text833640"&gt;张 纪中为今年6月即将开拍的张国荣传记片《阿飞之死》召开新闻发布会。男主角，出演张国荣的李亚鹏也出席了新闻发布会。他在回答记者提问那时说：“我相信， 我能把张国荣演好。其实，我一直很欣赏张国荣，他是香港为数不多的几个好演员之一，他演电影很真诚，很值得我学习。” 在自信之余，李亚鹏也承认，自己在演出时会有一些困难，特别是声音上有较大距。但是他表示神似比形似更加重要，自己一定会演好。 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:7;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;img src="http://page.mi.fu-berlin.de/~zheng/file/leslie.jpg" /&gt;&lt;/img&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-111978024626774049?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/111978024626774049/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=111978024626774049&amp;isPopup=true' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111978024626774049'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111978024626774049'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/06/6.html' title=''/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-111968901997235261</id><published>2005-06-25T10:37:00.000+02:00</published><updated>2005-06-25T10:43:39.976+02:00</updated><title type='text'>Schachtlung?Aber nicht</title><content type='html'>every subject has one and only one lock :) thats have nothing to do with variants&lt;br /&gt;or somewhat references.&lt;br /&gt;public class Schach {&lt;br /&gt; String test =new String();&lt;br /&gt; String copy=test;&lt;br /&gt; &lt;br /&gt; public  void a() {&lt;br /&gt;  synchronized(test){&lt;br /&gt;   &lt;br /&gt;   System.out.println("here I am, in a()");&lt;br /&gt;   synchronized(copy){&lt;br /&gt;    System.out.println("here I am, in b()");&lt;br /&gt;   };&lt;br /&gt;   }; &lt;br /&gt; }&lt;br /&gt; public static void main(String[] args){&lt;br /&gt;  new Schach().a();&lt;br /&gt; }&lt;br /&gt; }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-111968901997235261?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/111968901997235261/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=111968901997235261&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111968901997235261'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111968901997235261'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/06/schachtlungaber-nicht.html' title='Schachtlung?Aber nicht'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-111960654173483448</id><published>2005-06-24T11:42:00.000+02:00</published><updated>2005-06-24T11:49:01.736+02:00</updated><title type='text'>DBS</title><content type='html'>&lt;a href="http://page.mi.fu-berlin.de/~yang/links/transfer.rar"&gt;dbs&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-111960654173483448?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/111960654173483448/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=111960654173483448&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111960654173483448'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111960654173483448'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/06/dbs.html' title='DBS'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-111956356517070743</id><published>2005-06-23T23:24:00.000+02:00</published><updated>2005-06-23T23:52:45.186+02:00</updated><title type='text'>The Art of Search with Google</title><content type='html'>&gt;&gt; Bool logic&lt;br /&gt;space " " == &amp;&amp;amp;&lt;br /&gt;- == without, e.g. A-B&lt;br /&gt;OR ==&lt;br /&gt;* == a sequential characters e.g. "JAVA ist * ein Insel"&lt;br /&gt;? == a character&lt;br /&gt;&lt;br /&gt;&gt;&gt; to be a gosu&lt;br /&gt;- "night club" tips site:&lt;a href="http://www.x.com" target="_blank"&gt;www.x.com&lt;/a&gt; OR site:&lt;a href="http://www.y.cc" target="_blank"&gt;www.y.cc&lt;/a&gt; ==&gt; to find&lt;span style="color:#ffff66;"&gt; "night club" tips&lt;/span&gt; only in those 2 sites.&lt;br /&gt;- filetype:ppt "moving object database" ==&gt; to find actual useful Powerpoint files with the subject about &lt;span style="color:#ffff99;"&gt;"moving object database"&lt;/span&gt;&lt;br /&gt;- inurl:mp3 "don't cry any more" ==&gt; to find the song &lt;span style="color:#ffff66;"&gt;"don't cry any more"&lt;/span&gt; in the web path 'mp3'&lt;br /&gt;- intitle:"berlin night club" ==&gt; &lt;a href="http://www.google.de/search?biw=1003&amp;hl=de&amp;amp;q=intitle%3A%22berlin+night+club%22&amp;btnG=Google-Suche&amp;amp;meta"&gt;the result&lt;/a&gt;&lt;br /&gt;- link:&lt;a href="http://www.inf.fu-berlin.de" target="_blank"&gt;www.inf.fu-berlin.de&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.google.com/press/zeitgeist.html"&gt;http://www.google.com/press/zeitgeist.html&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-111956356517070743?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/111956356517070743/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=111956356517070743&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111956356517070743'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111956356517070743'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/06/art-of-search-with-google.html' title='The Art of Search with Google'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-111947846044202904</id><published>2005-06-23T00:11:00.000+02:00</published><updated>2005-06-23T00:14:20.446+02:00</updated><title type='text'>uebung9</title><content type='html'>&lt;a href="http://page.mi.fu-berlin.de/~yang/links/uebung9.doc"&gt;uebung9&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-111947846044202904?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/111947846044202904/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=111947846044202904&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111947846044202904'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111947846044202904'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/06/uebung9.html' title='uebung9'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-111930538408572094</id><published>2005-06-21T00:09:00.000+02:00</published><updated>2005-06-21T00:09:44.090+02:00</updated><title type='text'>Semaphores</title><content type='html'>class Semaphore {&lt;br /&gt;   private int count;&lt;br /&gt;   public Semaphore(int n) {&lt;br /&gt;      this.count = n;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   public synchronized void acquire() {&lt;br /&gt;      while(count == 0) {&lt;br /&gt;         try {&lt;br /&gt;            wait();&lt;br /&gt;         } catch (InterruptedException e) {&lt;br /&gt;            //keep trying&lt;br /&gt;         }&lt;br /&gt;      }&lt;br /&gt;      count--;&lt;br /&gt;   }&lt;br /&gt;  &lt;br /&gt;   public synchronized void release() {&lt;br /&gt;      count++;&lt;br /&gt;      notify(); //alert a thread that's blocking on this semaphore&lt;br /&gt;   }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-111930538408572094?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/111930538408572094/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=111930538408572094&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111930538408572094'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111930538408572094'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/06/semaphores.html' title='Semaphores'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-111930068184891717</id><published>2005-06-20T22:48:00.000+02:00</published><updated>2005-06-20T22:51:21.853+02:00</updated><title type='text'>moving object database</title><content type='html'>移动目标数据库(moving object database)有别于一般数据库技术的重要特征之一就是不仅可以对移动目标在数据库记录的时刻进行位置查询,而且可以对不同记录时刻之间以及未来时刻的位置进行查询,其研究的首要问题是建立移动目标运动及位置更新模型.目前有大量依靠其他辅助设备(如GSM网络)定位的盲终端设备(如移动电话,PDA等),存在着MOD管理的潜在需求,需要对它们建立合适的运动及位置更新模型,来为移动用户提供基于位置的服务.针对这类无自定位能力的移动目标,利用它们通常运动在城市的道路网络上这一特点,提出了基于道路网络的移动目标历史和未来速度计算模型,在此基础上提出了基于道路网络的非等时位置更新模型.与传统的速度计算模型相比,基于道路网络的移动目标历史和未来速度计算模型在考虑移动目标定位误差时可以降低移动目标位置预测的误差;与等时位置更新模型相比,基于道路网络的非等时位置更新模型在平均预测误差相近的情况下,可以减少移动目标和定位设施之间的通信量.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-111930068184891717?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/111930068184891717/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=111930068184891717&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111930068184891717'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111930068184891717'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/06/moving-object-database.html' title='moving object database'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-111926684176531240</id><published>2005-06-20T13:23:00.000+02:00</published><updated>2005-06-20T13:27:21.770+02:00</updated><title type='text'>Safe construction techniques</title><content type='html'>public class Safe { &lt;br /&gt;&lt;br /&gt;  private Object me;&lt;br /&gt;  private Set set = new HashSet();&lt;br /&gt;  private Thread thread;&lt;br /&gt;&lt;br /&gt;  public Safe() { &lt;br /&gt;    // Safe because "me" is not visible from any other thread&lt;br /&gt;    me = this;&lt;br /&gt;&lt;br /&gt;    // Safe because "set" is not visible from any other thread&lt;br /&gt;    set.add(this);&lt;br /&gt;&lt;br /&gt;    // Safe because MyThread won't start until construction is complete&lt;br /&gt;    // and the constructor doesn't publish the reference&lt;br /&gt;    thread = new MyThread(this);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public void start() {&lt;br /&gt;    thread.start();&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  private class MyThread(Object o) {&lt;br /&gt;    private Object theObject;&lt;br /&gt;&lt;br /&gt;    public MyThread(Object o) { &lt;br /&gt;      this.theObject = o;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    ...&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public class Unsafe {&lt;br /&gt;  public static Unsafe anInstance;&lt;br /&gt;  public static Set set = new HashSet();&lt;br /&gt;  private Set mySet = new HashSet();&lt;br /&gt;&lt;br /&gt;  public Unsafe() {&lt;br /&gt;    // Unsafe because anInstance is globally visible&lt;br /&gt;    anInstance = this;&lt;br /&gt;&lt;br /&gt;    // Unsafe because SomeOtherClass.anInstance is globally visible&lt;br /&gt;    SomeOtherClass.anInstance = this;&lt;br /&gt;&lt;br /&gt;    // Unsafe because SomeOtherClass might save the "this" reference&lt;br /&gt;    // where another thread could see it&lt;br /&gt;    SomeOtherClass.registerObject(this);&lt;br /&gt;&lt;br /&gt;    // Unsafe because set is globally visible &lt;br /&gt;    set.add(this);&lt;br /&gt;&lt;br /&gt;    // Unsafe because we are publishing a reference to mySet&lt;br /&gt;    mySet.add(this);&lt;br /&gt;    SomeOtherClass.someMethod(mySet);&lt;br /&gt;&lt;br /&gt;    // Unsafe because the "this" object will be visible from the new&lt;br /&gt;    // thread before the constructor completes&lt;br /&gt;    thread = new MyThread(this);&lt;br /&gt;    thread.start();&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public Unsafe(Collection c) {&lt;br /&gt;    // Unsafe because "c" may be visible from other threads&lt;br /&gt;    c.add(this);&lt;br /&gt;  }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-111926684176531240?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/111926684176531240/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=111926684176531240&amp;isPopup=true' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111926684176531240'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111926684176531240'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/06/safe-construction-techniques.html' title='Safe construction techniques'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-111925999058858286</id><published>2005-06-20T11:31:00.000+02:00</published><updated>2005-06-20T11:33:10.603+02:00</updated><title type='text'>(Java Memory Model) FAQ</title><content type='html'>JSR 133 (Java Memory Model) FAQ&lt;br /&gt;Jeremy Manson and Brian Goetz, February 2004&lt;br /&gt;Table of Contents&lt;br /&gt;&lt;br /&gt;    * What is a memory model, anyway?&lt;br /&gt;    * Do other languages, like C++, have a memory model?&lt;br /&gt;    * What is JSR 133 about?&lt;br /&gt;    * What is meant by reordering?&lt;br /&gt;    * What was wrong with the old memory model?&lt;br /&gt;    * What do you mean by incorrectly synchronized?&lt;br /&gt;    * What does synchronization do?&lt;br /&gt;    * How can final fields appear to change their values?&lt;br /&gt;    * How do final fields work under the new JMM?&lt;br /&gt;    * What does volatile do?&lt;br /&gt;    * Does the new memory model fix the "double-checked locking" problem?&lt;br /&gt;    * What if I'm writing a VM?&lt;br /&gt;    * Why should I care?&lt;br /&gt;&lt;br /&gt;What is a memory model, anyway?&lt;br /&gt;&lt;br /&gt;In multiprocessor systems, processors generally have one or more layers of memory cache, which improves performance both by speeding access to data (because the data is closer to the processor) and reducing traffic on the shared memory bus (because many memory operations can be satisfied by local caches.) Memory caches can improve performance tremendously, but they present a host of new challenges. What, for example, happens when two processors examine the same memory location at the same time? Under what conditions will they see the same value?&lt;br /&gt;&lt;br /&gt;At the processor level, a memory model defines necessary and sufficient conditions for knowing that writes to memory by other processors are visible to the current processor, and writes by the current processor are visible to other processors. Some processors exhibit a strong memory model, where all processors see exactly the same value for any given memory location at all times. Other processors exhibit a weaker memory model, where special instructions, called memory barriers, are required to flush or invalidate the local processor cache in order to see writes made by other processors or make writes by this processor visible to others. These memory barriers are usually performed when lock and unlock actions are taken; they are invisible to programmers in a high level language.&lt;br /&gt;&lt;br /&gt;It can sometimes be easier to write programs for strong memory models, because of the reduced need for memory barriers. However, even on some of the strongest memory models, memory barriers are often necessary; quite frequently their placement is counterintuitive. Recent trends in processor design have encouraged weaker memory models, because the relaxations they make for cache consistency allow for greater scalability across multiple processors and larger amounts of memory.&lt;br /&gt;&lt;br /&gt;The issue of when a write becomes visible to another thread is compounded by the compiler's reordering of code. For example, the compiler might decide that it is more efficient to move a write operation later in the program; as long as this code motion does not change the program's semantics, it is free to do so.  If a compiler defers an operation, another thread will not see it until it is performed; this mirrors the effect of caching.&lt;br /&gt;&lt;br /&gt;Moreover, writes to memory can be moved earlier in a program; in this case, other threads might see a write before it actually "occurs" in the program.  All of this flexibility is by design -- by giving the compiler, runtime, or hardware the flexibility to execute operations in the optimal order, within the bounds of the memory model, we can achieve higher performance.&lt;br /&gt;&lt;br /&gt;A simple example of this can be seen in the following code:&lt;br /&gt;&lt;br /&gt;Class Reordering {&lt;br /&gt;  int x = 0, y = 0;&lt;br /&gt;  public void writer() {&lt;br /&gt;    x = 1;&lt;br /&gt;    y = 2;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public void reader() {&lt;br /&gt;    int r1 = y;&lt;br /&gt;    int r2 = x;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Let's say that this code is executed in two threads concurrently, and the read of y sees the value 2. Because this write came after the write to x, the programmer might assume that the read of x must see the value 1. However, the writes may have been reordered. If this takes place, then the write to y could happen, the reads of both variables could follow, and then the write to x could take place. The result would be that r1 has the value 2, but r2 has the value 0.&lt;br /&gt;&lt;br /&gt;The Java Memory Model describes what behaviors are legal in multithreaded code, and how threads may interact through memory. It describes the relationship between variables in a program and the low-level details of storing and retrieving them to and from memory or registers in a real computer system. It does this in a way that can be implemented correctly using a wide variety of hardware and a wide variety of compiler optimizations.&lt;br /&gt;&lt;br /&gt;Java includes several language constructs, including volatile, final, and synchronized, which are intended to help the programmer describe a program's concurrency requirements to the compiler. The Java Memory Model defines the behavior of volatile and synchronized, and, more importantly, ensures that a correctly synchronized Java program runs correctly on all processor architectures.&lt;br /&gt;Do other languages, like C++, have a memory model?&lt;br /&gt;&lt;br /&gt;Most other programming languages, such as C and C++, were not designed with direct support for multithreading. The protections that these languages offer against the kinds of reorderings that take place in compilers and architectures are heavily dependent on the guarantees provided by the threading libraries used (such as pthreads), the compiler used, and the platform on which the code is run.  &lt;br /&gt;What is JSR 133 about?&lt;br /&gt;&lt;br /&gt;Since 1997, several serious flaws have been discovered in the Java Memory Model as defined in Chapter 17 of the Java Language Specification. These flaws allowed for confusing behaviors (such as final fields being observed to change their value) and undermined the compiler's ability to perform common optimizations.&lt;br /&gt;&lt;br /&gt;The Java Memory Model was an ambitious undertaking; it was the first time that a programming language specification attempted to incorporate a memory model which could provide consistent semantics for concurrency across a variety of architectures. Unfortunately, defining a memory model which is both consistent and intuitive proved far more difficult than expected. JSR 133 defines a new memory model for the Java language which fixes the flaws of the earlier memory model. In order to do this, the semantics of final and volatile needed to change.&lt;br /&gt;&lt;br /&gt;The full semantics are available at http://www.cs.umd.edu/users/pugh/java/memoryModel, but the formal semantics are not for the timid. It is surprising, and sobering, to discover how complicated seemingly simple concepts like synchronization really are. Fortunately, you need not understand the details of the formal semantics -- the goal of JSR 133 was to create a set of formal semantics that provides an intuitive framework for how volatile, synchronized, and final work.&lt;br /&gt;&lt;br /&gt;The goals of JSR 133 include:&lt;br /&gt;&lt;br /&gt;    * Preserving existing safety guarantees, like type-safety, and strengthening others. For example, variable values may not be created "out of thin air": each value for a variable observed by some thread must be a value that can reasonably be placed there by some thread.&lt;br /&gt;    * The semantics of correctly synchronized programs should be as simple and intuitive as possible.&lt;br /&gt;    * The semantics of incompletely or incorrectly synchronized programs should be defined so that potential security hazards are minimized.&lt;br /&gt;    * Programmers should be able to reason confidently about how multithreaded programs interact with memory.&lt;br /&gt;    * It should be possible to design correct, high performance JVM implementations across a wide range of popular hardware architectures.&lt;br /&gt;    * A new guarantee of initialization safety should be provided. If an object is properly constructed (which means that references to it do not escape during construction), then all threads which see a reference to that object will also see the values for its final fields that were set in the constructor, without the need for synchronization.&lt;br /&gt;    * There should be minimal impact on existing code.&lt;br /&gt;&lt;br /&gt;What is meant by reordering?&lt;br /&gt;&lt;br /&gt;There are a number of cases in which accesses to program variables (object instance fields, class static fields, and array elements) may appear to execute in a different order than was specified by the program. The compiler is free to take liberties with the ordering of instructions in the name of optimization. Processors may execute instructions out of order under certain circumstances. Data may be moved between registers, processor caches, and main memory in different order than specified by the program.&lt;br /&gt;&lt;br /&gt;For example, if a thread writes to field a and then to field b, and the value of b does not depend on the value of a, then the compiler is free to reorder these operations, and the cache is free to flush b to main memory before a. There are a number of potential sources of reordering, such as the compiler, the JIT, and the cache.&lt;br /&gt;&lt;br /&gt;The compiler, runtime, and hardware are supposed to conspire to create the illusion of as-if-serial semantics, which means that in a single-threaded program, the program should not be able to observe the effects of reorderings. However, reorderings can come into play in incorrectly synchronized multithreaded programs, where one thread is able to observe the effects of other threads, and may be able to detect that variable accesses become visible to other threads in a different order than executed or specified in the program.&lt;br /&gt;&lt;br /&gt;Most of the time, one thread doesn't care what the other is doing. But when it does, that's what synchronization is for.&lt;br /&gt;What was wrong with the old memory model?&lt;br /&gt;&lt;br /&gt;There were several serious problems with the old memory model. It was difficult to understand, and therefore widely violated. For example, the old model did not, in many cases, allow the kinds of reorderings that took place in every JVM. This confusion about the implications of the old model was what compelled the formation of JSR-133.&lt;br /&gt;&lt;br /&gt;One widely held belief, for example, was that if final fields were used, then synchronization between threads was unnecessary to guarantee another thread would see the value of the field. While this is a reasonable assumption and a sensible behavior, and indeed how we would want things to work, under the old memory model, it was simply not true. Nothing in the old memory model treated final fields differently from any other field -- meaning synchronization was the only way to ensure that all threads see the value of a final field that was written by the constructor. As a result, it was possible for a thread to see the default value of the field, and then at some later time see its constructed value. This means, for example, that immutable objects like String can appear to change their value -- a disturbing prospect indeed.&lt;br /&gt;&lt;br /&gt;The old memory model allowed for volatile writes to be reordered with nonvolatile reads and writes, which was not consistent with most developers intuitions about volatile and therefore caused confusion.&lt;br /&gt;&lt;br /&gt;Finally, as we shall see, programmers' intuitions about what can occur when their programs are incorrectly synchronized are often mistaken. One of the goals of JSR-133 is to call attention to this fact.&lt;br /&gt;What do you mean by “incorrectly synchronized”?&lt;br /&gt;&lt;br /&gt;Incorrectly synchronized code can mean different things to different people. When we talk about incorrectly synchronized code in the context of the Java Memory Model, we mean any code where&lt;br /&gt;&lt;br /&gt;   1. There is a variable (an instance field, a static, or an array element) that is read by more than one thread.&lt;br /&gt;   2. There is at least one write to that variable.&lt;br /&gt;   3. The write and the read are not ordered by synchronization (of one form or another).&lt;br /&gt;&lt;br /&gt;When these rules are violated, we say we have a data race on that variable. A program with a data race is an incorrectly synchronized program.&lt;br /&gt;What does synchronization do?&lt;br /&gt;&lt;br /&gt;Synchronization has several aspects. The most well-understood is mutual exclusion -- only one thread can hold a monitor at once, so synchronizing on a monitor means that once one thread enters a synchronized block protected by a monitor, no other thread can enter a block protected by that monitor until the first thread exits the synchronized block.&lt;br /&gt;&lt;br /&gt;But there is more to synchronization than mutual exclusion. Synchronization ensures that memory writes by a thread before or during a synchronized block are made visible in a predictable manner to other threads which synchronize on the same monitor. After we exit a synchronized block, we release the monitor, which has the effect of flushing the cache to main memory, so that writes made by this thread can be visible to other threads. Before we can enter a synchronized block, we acquire the monitor, which has the effect of invalidating the local processor cache so that variables will be reloaded from main memory. We will then be able to see all of the writes made visible by the previous release.&lt;br /&gt;&lt;br /&gt;Discussing this in terms of caches, it may sound as if these issues only affect multiprocessor machines. However, the reordering effects can be easily seen on a single processor. It is not possible, for example, for the compiler to move your code before an acquire or after a release. When we say that acquires and releases act on caches, we are using shorthand for a number of possible effects.&lt;br /&gt;&lt;br /&gt;The new memory model semantics create a partial ordering on memory operations (read field, write field, lock, unlock) and other thread operations (start and join), where some actions are said to happen before other operations. When one action happens before another, the first is guaranteed to be ordered before and visible to the second. The rules of this ordering are as follows:&lt;br /&gt;&lt;br /&gt;    * Each action in a thread happens before every action in that thread that comes later in the program's order.&lt;br /&gt;    * An unlock on a monitor happens before every subsequent lock on that same monitor.&lt;br /&gt;    * A write to a volatile field happens before every subsequent read of that same volatile.&lt;br /&gt;    * A call to start() on a thread happens before any actions in the started thread.&lt;br /&gt;    * All actions in a thread happen before any other thread successfully returns from a join() on that thread.&lt;br /&gt;&lt;br /&gt;This means that any memory operations which were visible to a thread before exiting a synchronized block are visible to any thread after it enters a synchronized block protected by the same monitor, since all the memory operations happen before the release, and the release happens before the acquire.&lt;br /&gt;&lt;br /&gt;Another implication is that the following pattern, which some people use to force a memory barrier, doesn't work:&lt;br /&gt;&lt;br /&gt;synchronized (new Object()) {}&lt;br /&gt;&lt;br /&gt;This is actually a no-op, and your compiler can remove it entirely, because the compiler knows that no other thread will synchronize on the same monitor. You have to set up a happens-before relationship for one thread to see the results of another.&lt;br /&gt;&lt;br /&gt;Important Note: Note that it is important for both threads to synchronize on the same monitor in order to set up the happens-before relationship properly. It is not the case that everything visible to thread A when it synchronizes on object X becomes visible to thread B after it synchronizes on object Y. The release and acquire have to "match" (i.e., be performed on the same monitor) to have the right semantics. Otherwise, the code has a data race.&lt;br /&gt;How can final fields appear to change their values?&lt;br /&gt;&lt;br /&gt;One of the best examples of how final fields' values can be seen to change involves one particular implementation of the String class.&lt;br /&gt;&lt;br /&gt;A String can be implemented as an object with three fields -- a character array, an offset into that array, and a length. The rationale for implementing String this way, instead of having only the character array, is that it lets multiple String and StringBuffer objects share the same character array and avoid additional object allocation and copying. So, for example, the method String.substring() can be implemented by creating a new string which shares the same character array with the original String and merely differs in the length and offset fields. For a String, these fields are all final fields.&lt;br /&gt;&lt;br /&gt;String s1 = "/usr/tmp";&lt;br /&gt;String s2 = s1.substring(4); &lt;br /&gt;&lt;br /&gt;The string s2 will have an offset of 4 and a length of 4. But, under the old model, it was possible for another thread to see the offset as having the default value of 0, and then later see the correct value of 4, it will appear as if the string "/usr" changes to "/tmp".&lt;br /&gt;&lt;br /&gt;The original Java Memory Model allowed this behavior; several JVMs have exhibited this behavior. The new Java Memory Model makes this illegal.&lt;br /&gt;How do final fields work under the new JMM?&lt;br /&gt;&lt;br /&gt;The values for an object's final fields are set in its constructor. Assuming the object is constructed "correctly", once an object is constructed, the values assigned to the final fields in the constructor will be visible to all other threads without synchronization. In addition, the visible values for any other object or array referenced by those final fields will be at least as up-to-date as the final fields.&lt;br /&gt;&lt;br /&gt;What does it mean for an object to be properly constructed? It simply means that no reference to the object being constructed is allowed to "escape" during construction. (See Safe Construction Techniques for examples.)  In other words, do not place a reference to the object being constructed anywhere where another thread might be able to see it; do not assign it to a static field, do not register it as a listener with any other object, and so on. These tasks should be done after the constructor completes, not in the constructor.&lt;br /&gt;&lt;br /&gt;class FinalFieldExample {&lt;br /&gt;  final int x;&lt;br /&gt;  int y;&lt;br /&gt;  static FinalFieldExample f;&lt;br /&gt;  public FinalFieldExample() {&lt;br /&gt;    x = 3;&lt;br /&gt;    y = 4;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  static void writer() {&lt;br /&gt;    f = new FinalFieldExample();&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  static void reader() {&lt;br /&gt;    if (f != null) {&lt;br /&gt;      int i = f.x;&lt;br /&gt;      int j = f.y;&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;The class above is an example of how final fields should be used. A thread executing reader is guaranteed to see the value 3 for f.x, because it is final. It is not guaranteed to see the value 4 for y, because it is not final. If FinalFieldExample's constructor looked like this:&lt;br /&gt;&lt;br /&gt;public FinalFieldExample() { // bad!&lt;br /&gt;  x = 3;&lt;br /&gt;  y = 4;&lt;br /&gt;  // bad construction - allowing this to escape&lt;br /&gt;  global.obj = this;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;then threads that read the reference to this from global.obj are not guaranteed to see 3 for x.&lt;br /&gt;&lt;br /&gt;The ability to see the correctly constructed value for the field is nice, but if the field itself is a reference, then you also want your code to see the up to date values for the object (or array) to which it points. If your field is a final field, this is also guaranteed. So, you can have a final pointer to an array and not have to worry about other threads seeing the correct values for the array reference, but incorrect values for the contents of the array. Again, by "correct" here, we mean "up to date as of the end of the object's constructor", not "the latest value available". For the latest value, you must use synchronization or the volatile modifier.&lt;br /&gt;&lt;br /&gt;There is no defined behavior if you want to use JNI to change final fields.&lt;br /&gt;What does volatile do?&lt;br /&gt;&lt;br /&gt;Volatile fields are special fields which are used for communicating state between threads. Each read of a volatile will see the last write to that volatile by any thread; in effect, they are designated by the programmer as fields for which it is never acceptable to see a "stale" value as a result of caching or reordering. The compiler and runtime are prohibited from allocating them in registers. They must also ensure that after they are written, they are flushed out of the cache to main memory, so they can immediately become visible to other threads. Similarly, before a volatile field is read, the cache must be invalidated so that the value in main memory, not the local processor cache, is the one seen. There are also additional restrictions on reordering accesses to volatile variables.&lt;br /&gt;&lt;br /&gt;Under the old memory model, accesses to volatile variables could not be reordered with each other, but they could be reordered with nonvolatile variable accesses. This undermined the usefulness of volatile fields as a means of signaling conditions from one thread to another.&lt;br /&gt;&lt;br /&gt;Under the new memory model, writing to a volatile field has the same memory effect as a monitor release, and reading from a volatile field has the same memory effect as a monitor acquire. In effect, because the new memory model places stricter constraints on reordering of volatile field accesses with other field accesses, volatile or not, anything that was visible to thread A when it writes to volatile field f becomes visible to thread B when it reads f.&lt;br /&gt;&lt;br /&gt;Here is a simple example of how volatile fields can be used:&lt;br /&gt;&lt;br /&gt;class VolatileExample {&lt;br /&gt;  int x = 0;&lt;br /&gt;  volatile boolean v = false;&lt;br /&gt;  public void writer() {&lt;br /&gt;    x = 42;&lt;br /&gt;    v = true;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public void reader() {&lt;br /&gt;    if (v == true) {&lt;br /&gt;      //uses x - guaranteed to see 42.&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Assume that one thread is calling writer, and another is calling reader. The write to v in writer releases the write to x to memory, and the read of v acquires that value from memory. Thus, if the reader sees the value true for v, it is also guaranteed to see the write to 42 that happened before it. This would not have been true under the old memory model.  If v were not volatile, then the compiler could reorder the writes in writer, and reader's read of x might see 0.&lt;br /&gt;&lt;br /&gt;Effectively, the semantics of volatile have been strengthened substantially, almost to the level of synchronization. Each read or write of a volatile field acts like "half" a synchronization, for purposes of visibility.&lt;br /&gt;&lt;br /&gt;Important Note: Note that it is important for both threads to access the same volatile variable in order to properly set up the happens-before relationship. It is not the case that everything visible to thread A when it writes volatile field f becomes visible to thread B after it reads volatile field g. The release and acquire have to "match" (i.e., be performed on the same volatile field) to have the right semantics.&lt;br /&gt;Does the new memory model fix the "double-checked locking" problem?&lt;br /&gt;&lt;br /&gt;The (infamous) double-checked locking idiom (also called the multithreaded singleton pattern) is a trick designed to support lazy initialization while avoiding the overhead of synchronization. In very early JVMs, synchronization was slow, and developers were eager to remove it -- perhaps too eager. The double-checked locking idiom looks like this:&lt;br /&gt;&lt;br /&gt;// double-checked-locking - don't do this!&lt;br /&gt;&lt;br /&gt;private static Something instance = null;&lt;br /&gt;&lt;br /&gt;public Something getInstance() {&lt;br /&gt;  if (instance == null) {&lt;br /&gt;    synchronized (this) {&lt;br /&gt;      if (instance == null)&lt;br /&gt;        instance = new Something();&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;  return instance;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;This looks awfully clever -- the synchronization is avoided on the common code path. There's only one problem with it -- it doesn't work. Why not? The most obvious reason is that the writes which initialize instance and the write to the instance field can be reordered by the compiler or the cache, which would have the effect of returning what appears to be a partially constructed Something. The result would be that we read an uninitialized object. There are lots of other reasons why this is wrong, and why algorithmic corrections to it are wrong. There is no way to fix it using the old Java memory model. More in-depth information can be found at Double-checked locking: Clever, but broken and The "Double Checked Locking is broken" declaration&lt;br /&gt;&lt;br /&gt;Many people assumed that the use of the volatile keyword would eliminate the problems that arise when trying to use the double-checked-locking pattern. In JVMs prior to 1.5, volatile would not ensure that it worked (your mileage may vary). Under the new memory model, making the instance field volatile will "fix" the problems with double-checked locking, because then there will be a happens-before relationship between the initialization of the Something by the constructing thread and the return of its value by the thread that reads it.&lt;br /&gt;&lt;br /&gt;However, for fans of double-checked locking (and we really hope there are none left), the news is still not good. The whole point of double-checked locking was to avoid the performance overhead of synchronization. Not only has brief synchronization gotten a LOT less expensive since the Java 1.0 days, but under the new memory model, the performance cost of using volatile goes up, almost to the level of the cost of synchronization. So there's still no good reason to use double-checked-locking.&lt;br /&gt;&lt;br /&gt;Instead, use the Initialization On Demand Holder idiom, which is thread-safe and a lot easier to understand:&lt;br /&gt;&lt;br /&gt;private static class LazySomethingHolder {&lt;br /&gt;  public static Something something = new Something();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public static Something getInstance() {&lt;br /&gt;  return LazySomethingHolder.something;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;What if I'm writing a VM?&lt;br /&gt;You should look at http://gee.cs.oswego.edu/dl/jmm/cookbook.html .&lt;br /&gt;Why should I care?&lt;br /&gt;&lt;br /&gt;Why should you care? Concurrency bugs are very difficult to debug. They often don't appear in testing, waiting instead until your program is run under heavy load, and are hard to reproduce and trap. You are much better off spending the extra effort ahead of time to ensure that your program is properly synchronized; while this is not easy, it's a lot easier than trying to debug a badly synchronized application.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-111925999058858286?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/111925999058858286/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=111925999058858286&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111925999058858286'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111925999058858286'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/06/java-memory-model-faq.html' title='(Java Memory Model) FAQ'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-111920990452992299</id><published>2005-06-19T21:35:00.000+02:00</published><updated>2005-06-19T21:47:14.856+02:00</updated><title type='text'>Aufgabe 7 wieder</title><content type='html'>Um das Programm auszuführen, bitte mit folgendem Befehl:&lt;br /&gt;java -jar Compiler.jar in.txt&lt;br /&gt;in.txt ist eigentlich schon in .jar datei vorliegt&lt;br /&gt;um das richtig auszuführen, bitte unbedingt unter dem Verzeichnis, wo Compiler.jar liegt, sonst kann das Programm solche in.txt Datei nicht finden.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://page.mi.fu-berlin.de/~zheng/file/ALPIV_A7.doc"&gt;ALPIV_A7.doc&lt;/a&gt;&lt;br /&gt;&lt;a href="http://page.mi.fu-berlin.de/~zheng/file/Compiler.jar"&gt;Compiler.jar&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;by the way, there're still 2 books,&lt;br /&gt;&lt;a href="http://page.mi.fu-berlin.de/~zheng/file/Java.pdf"&gt;JavaMultiThreads.pdf,only 34 pages&lt;/a&gt;&lt;br /&gt;&lt;a href="http://page.mi.fu-berlin.de/~zheng/file/effective.pdf"&gt;effective.pdf,must had heard effective c++ before, so, no need to be recommended any more lor&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-111920990452992299?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/111920990452992299/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=111920990452992299&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111920990452992299'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111920990452992299'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/06/aufgabe-7-wieder.html' title='Aufgabe 7 wieder'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-111901041243172442</id><published>2005-06-17T14:09:00.000+02:00</published><updated>2005-06-17T14:15:15.280+02:00</updated><title type='text'>通过JDBC连接oracle数据库的十大技巧</title><content type='html'>&lt;span id="post1" style="font-size: 12px; color: rgb(255, 255, 0);"&gt; Java数据库连接（JDBC）API是一系列能够让Java编程人员访问数据库的接口，各个开发商的接口并不完全相同。在使用多年的Oracle公司的JDBC后，我积累了许多技巧，这些技巧能够使我们更好地发挥系统的性能和实现更多的功能。&lt;br /&gt;&lt;br /&gt;　　1、在客户端软件开发中使用Thin驱动程序&lt;br /&gt;&lt;br /&gt;　 　在开发Java软件方面，Oracle的数据库提供了四种类型的驱动程序，二种用于应用软件、applets、servlets等客户端软件，另外二种 用于数据库中的Java存储过程等服务器端软件。在客户机端软件的开发中，我们可以选择OCI驱动程序或Thin驱动程序。OCI驱动程序利用Java本 地化接口（JNI），通过Oracle客户端软件与数据库进行通讯。Thin驱动程序是纯Java驱动程序，它直接与数据库进行通讯。为了获得最高的性 能，Oracle建议在客户端软件的开发中使用OCI驱动程序，这似乎是正确的。但我建议使用Thin驱动程序，因为通过多次测试发现，在通常情况下， Thin驱动程序的性能都超过了OCI驱动程序。&lt;br /&gt;&lt;br /&gt;　　2、关闭自动提交功能，提高系统性能&lt;br /&gt;&lt;br /&gt;　　在第一次建立与数据库的连接时，在缺省情况下，连接是在自动提交模式下的。为了获得更好的性能，可以通过调用带布尔值false参数的Connection类的setAutoCommit()方法关闭自动提交功能，如下所示：&lt;br /&gt;&lt;br /&gt;　　conn.setAutoCommit(false);&lt;br /&gt;&lt;br /&gt;　　值得注意的是，一旦关闭了自动提交功能，我们就需要通过调用Connection类的commit()和rollback()方法来人工的方式对事务进行管理。&lt;br /&gt;&lt;br /&gt;　　3、在动态SQL或有时间限制的命令中使用Statement对象&lt;br /&gt;&lt;br /&gt;　 　在执行SQL命令时，我们有二种选择：可以使用PreparedStatement对象，也可以使用Statement对象。无论多少次地使用同一个 SQL命令，PreparedStatement都只对它解析和编译一次。当使用Statement对象时，每次执行一个SQL命令时，都会对它进行解析 和编译。这可能会使你认为，使用PreparedStatement对象比使用Statement对象的速度更快。然而，我进行的测试表明，在客户端软件 中，情况并非如此。因此，在有时间限制的SQL操作中，除非成批地处理SQL命令，我们应当考虑使用Statement对象。&lt;br /&gt;&lt;br /&gt;　　此外，使用Statement对象也使得编写动态SQL命令更加简单，因为我们可以将字符串连接在一起，建立一个有效的SQL命令。因此，我认为，Statement对象可以使动态SQL命令的创建和执行变得更加简单。&lt;br /&gt;&lt;br /&gt;　　4、利用helper函数对动态SQL命令进行格式化&lt;br /&gt;&lt;br /&gt;　 　在创建使用Statement对象执行的动态SQL命令时，我们需要处理一些格式化方面的问题。例如，如果我们想创建一个将名字O'Reilly插入表 中的SQL命令，则必须使用二个相连的“''”号替换O'Reilly中的“'”号。完成这些工作的最好的方法是创建一个完成替换操作的helper方 法，然后在连接字符串心服用公式表达一个SQL命令时，使用创建的helper方法。与此类似的是，我们可以让helper方法接受一个Date型的值， 然后让它输出基于Oracle的to_date()函数的字符串表达式。&lt;br /&gt;&lt;br /&gt;　　5、利用PreparedStatement对象提高数据库的总体效率&lt;br /&gt;&lt;br /&gt;　 　在使用PreparedStatement对象执行SQL命令时，命令被数据库进行解析和编译，然后被放到命令缓冲区。然后，每当执行同一个 PreparedStatement对象时，它就会被再解析一次，但不会被再次编译。在缓冲区中可以发现预编译的命令，并且可以重新使用。在有大量用户的 企业级应用软件中，经常会重复执行相同的SQL命令，使用PreparedStatement对象带来的编译次数的减少能够提高数据库的总体性能。如果不 是在客户端创建、预备、执行PreparedStatement任务需要的时间长于Statement任务，我会建议在除动态SQL命令之外的所有情况下 使用PreparedStatement对象。&lt;br /&gt;&lt;br /&gt;　　6、在成批处理重复的插入或更新操作中使用PreparedStatement对象&lt;br /&gt;&lt;br /&gt;　 　如果成批地处理插入和更新操作，就能够显著地减少它们所需要的时间。Oracle提供的Statement和 CallableStatement并不真正地支持批处理，只有PreparedStatement对象才真正地支持批处理。我们可以使用 addBatch()和executeBatch()方法选择标准的JDBC批处理，或者通过利用PreparedStatement对象的 setExecuteBatch()方法和标准的executeUpdate()方法选择速度更快的Oracle专有的方法。要使用Oracle专有的批 处理机制，可以以如下所示的方式调用setExecuteBatch()：&lt;br /&gt;&lt;br /&gt;PreparedStatement pstmt3D null;&lt;br /&gt;try {&lt;br /&gt;((OraclePreparedStatement)&lt;br /&gt;pstmt).setExecuteBatch(30);&lt;br /&gt;...&lt;br /&gt;pstmt.executeUpdate();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;　 　调用setExecuteBatch()时指定的值是一个上限，当达到该值时，就会自动地引发SQL命令执行，标准的executeUpdate()方 法就会被作为批处理送到数据库中。我们可以通过调用PreparedStatement类的sendBatch()方法随时传输批处理任务。&lt;br /&gt;&lt;br /&gt;　　7、使用Oracle locator方法插入、更新大对象（LOB）&lt;br /&gt;&lt;br /&gt;　 　Oracle的PreparedStatement类不完全支持BLOB和CLOB等大对象的处理，尤其是Thin驱动程序不支持利用 PreparedStatement对象的setObject()和setBinaryStream()方法设置BLOB的值，也不支持利用 setCharacterStream()方法设置CLOB的值。只有locator本身中的方法才能够从数据库中获取LOB类型的值。可以使用 PreparedStatement对象插入或更新LOB，但需要使用locator才能获取LOB的值。由于存在这二个问题，因此，我建议使用 locator的方法来插入、更新或获取LOB的值。&lt;br /&gt;&lt;br /&gt;　　8、使用SQL92语法调用存储过程&lt;br /&gt;&lt;br /&gt;　　在调用存储过程时，我们可以使用SQL92或Oracle PL/SQL，由于使用Oracle PL/SQL并没有什么实际的好处，而且会给以后维护你的应用程序的开发人员带来麻烦，因此，我建议在调用存储过程时使用SQL92。&lt;br /&gt;&lt;br /&gt;　　9、使用Object SQL将对象模式转移到数据库中&lt;br /&gt;&lt;br /&gt;　 　既然可以将Oracle的数据库作为一种面向对象的数据库来使用，就可以考虑将应用程序中的面向对象模式转到数据库中。目前的方法是创建Java bean作为伪装的数据库对象，将它们的属性映射到关系表中，然后在这些bean中添加方法。尽管这样作在Java中没有什么问题，但由于操作都是在数据 库之外进行的，因此其他访问数据库的应用软件无法利用对象模式。如果利用Oracle的面向对象的技术，可以通过创建一个新的数据库对象类型在数据库中模 仿其数据和操作，然后使用JPublisher等工具生成自己的Java bean类。如果使用这种方式，不但Java应用程序可以使用应用软件的对象模式，其他需要共享你的应用中的数据和操作的应用软件也可以使用应用软件中的 对象模式。&lt;br /&gt;&lt;br /&gt;　　10、利用SQL完成数据库内的操作&lt;br /&gt;&lt;br /&gt;　　我要向大家介绍的最重要的经验是充分利用SQL的面向集合的方法来解决数据库处理需求，而不是使用Java等过程化的编程语言。&lt;br /&gt;&lt;br /&gt;　 　如果编程人员要在一个表中查找许多行，结果中的每个行都会查找其他表中的数据，最后，编程人员创建了独立的UPDATE命令来成批地更新第一个表中的数 据。与此类似的任务可以通过在set子句中使用多列子查询而在一个UPDATE命令中完成。当能够在单一的SQL命令中完成任务，何必要让数据在网上流来 流去的？我建议用户认真学习如何最大限度地发挥SQL的功能。&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-111901041243172442?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/111901041243172442/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=111901041243172442&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111901041243172442'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111901041243172442'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/06/jdbcoracle.html' title='通过JDBC连接oracle数据库的十大技巧'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-111887060573174996</id><published>2005-06-15T23:09:00.000+02:00</published><updated>2005-06-16T00:34:59.893+02:00</updated><title type='text'>Die Lösung von Christoph Thöns</title><content type='html'>&lt;span style="color:#ffff00;"&gt;Meine Lösung ist im Anhang, aber ich hab heute rausgefunden, das sie&lt;br /&gt;nicht ganz richtig ist. Das was da am Anfang im Kommentar steht stimmt&lt;br /&gt;nicht. Ich glaube dir Lösung für Signal and Return ist wohl die gleiche&lt;br /&gt;wie die für Signal and Continue. Hab mein Blatt aber schon abgegeben,&lt;br /&gt;deswegen hab ichs noch nicht geändert.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://page.mi.fu-berlin.de/~zheng/file/ALP4_A8.doc"&gt;ALP4_A8.doc&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://page.mi.fu-berlin.de/~yang/links/ALP4_A8.doc"&gt;uebung 8&lt;br /&gt;&lt;/a&gt;&lt;br /&gt;100% original von ihm, habe ich gar nix geändert, allerdings nur 2 Bier gekostet :) Chaojing, Beim Abgeben bitte unbedingt was ändern !!! aber wenn du das benutzen willst nur^^&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Habt jemand das neue icebat erzeugt? mh. warscheinlich eine gute Versuche&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-111887060573174996?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/111887060573174996/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=111887060573174996&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111887060573174996'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111887060573174996'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/06/die-lsung-von-christoph-thns.html' title='Die Lösung von Christoph Thöns'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-111882909830340182</id><published>2005-06-15T11:49:00.000+02:00</published><updated>2005-06-15T11:58:18.336+02:00</updated><title type='text'>Comparision of Multithreading with Multiprocessing folie</title><content type='html'>Unser RA Folie 4.76-4.78 ist unklar, aber es ist ziemlich wichtig. schauen mal hier:&lt;br /&gt;&lt;a href="http://www.inf.fu-berlin.de/inst/ag-tech/teaching/LehreFUSeiten/SS04/19522-V/K04-4.76-4.78.pdf"&gt;http://www.inf.fu-berlin.de/inst/ag-tech/teaching/LehreFUSeiten/SS04/19522-V/K04-4.76-4.78.pdf&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-111882909830340182?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/111882909830340182/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=111882909830340182&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111882909830340182'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111882909830340182'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/06/comparision-of-multithreading-with.html' title='Comparision of Multithreading with Multiprocessing folie'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-111866943132988460</id><published>2005-06-13T15:27:00.000+02:00</published><updated>2005-06-13T15:30:31.340+02:00</updated><title type='text'>原生以及引用类型存于stack, 对象存于heap</title><content type='html'>静态属性如果是基本类型，或者是这样的样子： &lt;br /&gt;&lt;br /&gt;static String str = "Hello World"; &lt;br /&gt;&lt;br /&gt;在声明的同时就赋值，那么是存放在类的常量池中(stack)的，也就是存放在内存指令区，如果是 &lt;br /&gt;&lt;br /&gt;static String str ; &lt;br /&gt;&lt;br /&gt;.... &lt;br /&gt;&lt;br /&gt;str = "Hello World"; &lt;br /&gt;&lt;br /&gt;那么静态属性的地址指针存放在内存指令区(stack)，而内容放在heap中，地址指针是一个4字节的定长数据结构。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-111866943132988460?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/111866943132988460/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=111866943132988460&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111866943132988460'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111866943132988460'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/06/stack-heap.html' title='原生以及引用类型存于stack, 对象存于heap'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-111849471785412946</id><published>2005-06-11T14:55:00.000+02:00</published><updated>2005-06-11T17:20:35.590+02:00</updated><title type='text'>RA Folie, recommended</title><content type='html'>&lt;a href="http://page.mi.fu-berlin.de/~yang/links/Architektur.doc"&gt;&lt;br /&gt;http://page.mi.fuberlin.de/~yang/links/Architektur.doc&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.programmersheaven.com/"&gt;http://www.programmersheaven.com/&lt;/a&gt;&lt;br /&gt;better als SouceForge? :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-111849471785412946?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/111849471785412946/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=111849471785412946&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111849471785412946'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111849471785412946'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/06/ra-folie-recommended.html' title='RA Folie, recommended'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-111830925634628947</id><published>2005-06-09T11:23:00.000+02:00</published><updated>2005-06-09T11:29:04.806+02:00</updated><title type='text'>ALP4 A7</title><content type='html'>&lt;a href=http://page.mi.fu-berlin.de/~zheng/file/AssemblerImpl.java&gt;.java&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href=http://page.mi.fu-berlin.de/~zheng/file/A7.jar&gt;.jar&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-111830925634628947?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/111830925634628947/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=111830925634628947&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111830925634628947'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111830925634628947'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/06/alp4-a7.html' title='ALP4 A7'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-111824367458953471</id><published>2005-06-08T17:05:00.000+02:00</published><updated>2005-06-08T17:19:11.350+02:00</updated><title type='text'>uebung 7 makes me crazy ....</title><content type='html'>i have spended almost 10 hours on it, it really drives me crazy :(&lt;br /&gt;Problem: assignments of Objectsarray&lt;br /&gt;public class CodeLine&lt;br /&gt;   {&lt;br /&gt;    String lable;&lt;br /&gt;    String opcode;&lt;br /&gt;    String operand;&lt;br /&gt;    }&lt;br /&gt;CodeLine[] myProg;&lt;br /&gt;how can i give every member of this array a value?&lt;br /&gt;have any idea?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-111824367458953471?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/111824367458953471/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=111824367458953471&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111824367458953471'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111824367458953471'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/06/uebung-7-makes-me-crazy.html' title='uebung 7 makes me crazy ....'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12718556.post-111806299147294691</id><published>2005-06-06T14:50:00.000+02:00</published><updated>2005-06-06T15:03:11.476+02:00</updated><title type='text'>JSAdmin</title><content type='html'>Click &lt;a href="http://page.mi.fu-berlin.de/~zheng/file/JSAdmin.jar"&gt;JSAdmin.jar&lt;/a&gt; to download,&lt;br /&gt;&lt;br /&gt;&gt;&gt; pure JAVA&lt;br /&gt;&lt;br /&gt;&gt;&gt; our database oriented, so no need to input url or port any more&lt;br /&gt;&lt;br /&gt;&gt;&gt; will be requested for username and password, e.g. introdbs_ delphi_ ...zzz&lt;br /&gt;&lt;br /&gt;&gt;&gt; can select or update....zzz, e.g. select * from student, then click submit&lt;br /&gt;&lt;br /&gt;&gt;&gt; with enough passion can also be used as model part of coming "Web-Anbindung"&lt;br /&gt;&lt;br /&gt;&gt;&gt; use the command line 'java -jar JSAdmin.jar' to run&lt;br /&gt;&lt;br /&gt;&gt;&gt; thanks for using or playing, haiz^^haiz^^&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12718556-111806299147294691?l=chinavampire.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://chinavampire.blogspot.com/feeds/111806299147294691/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12718556&amp;postID=111806299147294691&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111806299147294691'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12718556/posts/default/111806299147294691'/><link rel='alternate' type='text/html' href='http://chinavampire.blogspot.com/2005/06/jsadmin.html' title='JSAdmin'/><author><name>chinavampire</name><uri>http://www.blogger.com/profile/11617357287825319915</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://page.mi.fu-berlin.de/~ding/image/foto.jpg'/></author><thr:total>1</thr:total></entry></feed>
