2007年12月28日星期五

七大健康"谎言"

Translation:

根据一项最新的研究显示,即使是医生,也会为一些常见的医学常识误解所困扰。此文章会直接谈到一些比如从人死后毛发变长的现象到万圣节糖果的危险。

没有一个医学学位,从一大堆人们的猜想中找出医学事实是令人头疼的,比如:在昏暗的光线中阅读是否真的会损伤视力?我们实际上只用了百分之十的大脑容量?似乎一些医生也把这些话当作他们的格言。一篇在英国医学杂志12月刊上的研究报告描述了令很多医生都认为是真的七个医学“谎言“。问题在于,很多人都把医生所说的当作信条一样,但有时它们没有科学的事实依据。医生Aaron Carroll(阿伦卡罗尔),一位是工作在印第安那州纳波利斯regenstrief研究的儿科助理教授以及这份研究报告的合作作者。 "病人和家长应该自由地询问为什么那些医生所说的是真的,他们(医生)对此应该态度诚实" 。为了减少一些医学"谎言"和增加一点点医学事实,与少小说和多一点,其实,这里有七个最常见的健康“谎言”:

1 .在昏暗的环境中阅读会对你的视力有害。显然这是一个世界上人们代代喜欢的”谎言“,但它缺少科学依据。昏暗的环境中阅读,可造成临时性的眼睛疲劳,但它会迅速消失,一旦你回到明亮的地方。近视患者的度数提高被归咎在昏暗中阅读,但卡罗尔说,这些说法并不完全符合科学证据,我们住在最好的照明条件下,世界从未见过的。 " 70年前,我们在烛光下阅读,但我们眼睛并没有瞎。" 卡罗尔说。 "不管怎样,对此没有任何科学依据" 。

2 .用手机在医院是很危险的。除了在急救室的等候室的手机信号,有研究显示,只有极少量的信号与医疗设备发生干扰。 2005年梅奥(英文名:Mayo 爱尔兰的一个县市) 一个诊所做了510测试, 其中有16个医疗设备和6个蜂窝无线移动手机。重要的临床干扰的发生率只有1.2 % 。2007年的一个研究表明,在300份对75个诊断室的测试中,普通模式下的手机使用,(对医疗设备)没有任何干扰。

3 .人死后,指甲和头发变长。 "头发和指甲的成长,是一个十分复杂的荷尔蒙过程, "卡罗尔说,在人死亡后这是不可能发生的。那么这个"谎言"如何站得住脚的?很可能是因为人死后皮肤开始收缩,这样会导致在人眼的观测下即指甲越来越长。

4 .我们只用了10 %的大脑容量。我们的大脑没有全面使用的观念是没有根据的。 "很多不同类型的脑功能成像研究表明,没有一个大脑的区域是完全未使用或不活跃。而且更加详细的试验未能找出这些"非功能性"的 90 %大脑区域。",卡罗尔和印第安纳大学医学院的儿科助理教授Rachel vreeman ,在英国医学杂志一篇研究报告中写到。卡罗尔说,这个观念可能来自于20世纪初的蛇油推销员,他们用这个“谎言”来做销售,并称这些补品可以将增加人脑的智力。

5 .每天应该至少喝八杯水。这个“谎言”可能来自于一篇在1945年由国家研究中心发表的文章,它声称成人"适当的水饮用"为2.5升每天,尽管文章的结尾指出,上述大部分的水是已经包含在我们吃的食品中。现有的研究表明,一个经常忽略的事实是要了解水的摄取的关键。我们在日常生活消费中摄取了足够的水分,比果汁,牛奶和甚至含有咖啡因的饮料。喝太多的水可导致水中毒,严重的电解质失衡,其中当纳入过量的水分时,细胞会膨胀,甚至死亡。

6 .剃光头发会使头发恢复的更快和粗糙。图蜡,剪头发或者剃头发,不管你以何种方式来去掉头发,你也不会轻易改变头发的质地以及它恢复的速度。腿部发发似乎更加粗糙,当它要长回去的时候。因为它开始重新长出。 "头发在初期生长的时候比较钝,它还没有时间形成锥形,因此他看起来更加偏暗。"卡罗尔说。但是,如果等到它得长一点,而且暴露在阳光下,它会和你的开始的头发一摸一样了。(如需了解更多信息关于这个"谎言",可以在最近新闻周刊上找到)。

7 。陌生人碰过的糖果,在万圣节的时候是危险的(不知道如何翻译:Halloween threat)。因为这个并没出现在英国医学杂志上的研究上,它是其中一个令卡罗尔不高兴的个人小把戏 。每一个万圣节带来了一系列的关于有毒糖糕的杀人故事,一些医院甚至设立X射线用来对付一些特殊的警告小把戏或者当作治疗器。但是从未有人吃毒万圣节糖果而中毒的资料记录,他说,尽管有,但一直都是一些亲属故意这样做的极少数事例而已。



Source(原文):
http://www.newsweek.com/id/82138/page/2
Title:Top Seven Health Myths(NewsWeek)

2007年12月25日星期二

本土化(localization),是福,还是祸?

和其他很多留学生一样,我也加入了快速本土化的队列,当然这种自我适应当地环境的过程有很典型的三种不同形式:

第一种形式,经过很长的时间,一部分人完全几乎100%接受和认同西欧的社会体制和价值观,反过来,他们非常不喜欢国内的体制,对国内任何东西总是带有异样的眼光,这种本土化的过程我个人把它叫做“异地同化”(Visitor Localization),与之相对应的“本土同化”(Home Localization),即一些没有国外长期生活经历的人在国内就已经非常认同,甚至崇拜西欧。

第二种形式,有选择性同化,就像Matrix中,对于环境的变化,作出个人偏好的选择,也就是说保留了自身独特的文化和思想,同时接受和适应了当地习俗,也就是“取其精华,弃其糟粕”,这种选择性同化的过程玩玩包含了很多复杂的自我定位和自我评价,因为往往作出选择比放弃选择要难多了。

第三种形式,保持自身的陌生化和完整性。比如很多早期的华人,经常年如一日在餐馆工作,几乎从来没接触过当地人,语言和文化完全陌生,生活环境和国内几乎没有什么区别。他们虽然在国外呆了数十年,但是保留了几乎完全的中国文化,同时也没有吸收当地的文化。

对于有着第一种形式的很多留学生,接纳了西欧的价值观体系,开始以完全西欧化的角度看待中国,比如一味批评中国,总是认为西欧社会的优越性,失去了中国文化的独立性思考。据我个人了解,这些人数量不少。

对于曾经历第二个形式的人,首先我个人表示尊敬,因为在西欧文化社会里,对于一个中国人,能够对精华和糟粕有着自己评判的标准,而不是一味的一边倒,实在非常困难,因为他们经济上的强大就就足以让你低头。我个人非常欣赏一些美国朋友非常独立和独特的个人判断能力,当然这需要大量的个人生活交流经历。

对于第三种形式,留学生非常少,这里省略。

2007年12月21日星期五

美国人比欧洲人更富有活力,乐观,而且更加快乐




Translation:

"沉默与哑巴 " ,是一个美国现代经典喜剧片,讲述的是一个很随和可亲的白痴,名叫Lloyd Christmas,他爱上了一个漂亮的女孩,名叫mary swanson。在一个场景中,他问她, "一个像你一样(漂亮)女孩和一个像我一样(傻傻)的男孩在一起的机会会有吗?, 他得到的答复是"不好,不可能" ,"就像一百个人中会出现这样一个的几率?"Lloyd 问道。 "更像一百万人中出现这样一个的几率, "mary 答复道。Lloyd 停顿了一会儿,然后再问道, "那么你是在告诉我还是有这么一个机会的吗" ?

这就是美国精神。美国人向来就非常乐观,而且比欧洲人自我幸福感更强。美国人认为,每个人可以决定他们自己的命运,而不是成为命运的玩物。他们还认为,他们的后代将过上比他们更好的生活。

这有助于解释富有活力的美国经济。美国人把失败甚至破产,看做是道路上的一块绊脚石,而不是命运的诅咒。这也有助于解释美国人喜欢尝试的浓厚兴趣。 "美国人天生就是乐观的, "肯尼迪曾经说过。 "他们是实验者,发明者和建设者,当被要求做得出色时候总能够做得最好,于是欧洲人会问, "为什么(why)? "然而美国人会问: "为什么不呢(why not)?"

但过去五年来已产生了一些使人们心情不愉快的戏剧性事情。四分之三的美国人现在认为,国家正在"错误的轨道上" 。已经开始有很多人对贸易和移民产生敌对的情绪,同样有不少人认为美国应少参与国际事务。对政府的信任的比例,只是2001年的一半。总统和国会得到了像廉价商品一样的批级。越来越多的人对未来感到悲观。勉强三分之一的人认为他们孩子生活将来会比他们更好。Barack Obama之所以带来希望的消息以及Mike Huckabee为希望喝彩做得如此出色的原因是,希望是如此的渺茫。

这样的忧虑是有原因的。人们厌倦了布什政府,其党派偏见和无法胜任的资格。伊拉克战争损毁了原本强大,友善的美国巨人形象。伊拉克意味着混乱以及Abu Ghraib(在西边巴格达正北部, 巴格达国际机场,居民数量约在750,000 和1,500,000之间.伊拉克的政府创造了Abu-Ghraib 区 1944 年),而不是自我得意的民主意识的国际延伸。战争可能会持续更久,但多数美国人仍然认为,这场战斗是不值的。关于经济的坏消息淹没了关于爆发的好消息,对"激增" 。美国人习惯于思考他们的房子作为黄金(房子可以作为银行抵押,当你需要一点额外现金的时候),但现在黄金正在变成铅。

这是在悲观中创造一个牛市。就像Bill O'Reilly和Lou Dobbs靠着关于文化衰退和破碎的社会边缘的激昂演讲把他们自己转变成为有线电视明星。Patrick Buchanan 最近的一本书"结账的时刻:傲慢,意识形态和贪婪是如何把美国撕裂了" 。 "我们现正处于自杀的道路上" ,他说。美国不仅是处在"正在分离" ,而且还处在"分解" 。

状况当然不是平安无事。在过去几年中,暴力犯罪率在上升,非法活动也相当活跃。但是当今社会却与70年代完全不一样,当文化领导者开始指向罪恶之都的时候。在敏感的社会政策所帮助下的美国公民社会,正在修复过去几十年中的伤害。

(中间省略...)

事实上,美国人始终有一个有力的悲观传统,它与乐观的传统相协调。在1819年John Adams ((1735-1826) 2nd president of the United States (1797-1801))担心地说,"我们巨大的美国帝国"能够维持的时间, 1948年Richard Hofstadter抱怨"竞争与机遇"已经进入衰退,并认为,美国人正在找过去历史的黄金时代" 。许多今天的悲观情绪可能证明为毫无根据的,美国人应该重新拾回那个尽管是白痴,叫做Lloyd Christmas的(美国)精神。

----------------------------------------------------------
很难看见一篇美国编辑的文章,作为还能拿的出手的英国杂志,The Economist 算是经得起一读的杂志,至少在欧洲此类杂志类里面,个人认为德国的杂志以前还不错,但是现在面临中国的经济的强大,Der Spiegel(明镜周刊)也开始抓狂了,不管客观不客观,先发泄了再说,总是那么老一套的欧洲中心论的思想,守着一大推祖宗留下的技术干着急。最可怕的就是看一些没有任何外国编辑的杂志,看了就想自慰,比如BBC,sucks! 里面骂中国的,清一色的欧洲人,对着干的大多数都是美国人,欧洲人真是一群可怕的殖民"动物"。

Source(原文):http://www.economist.com/world/na/displaystory.cfm?story_id=10328926 title:The spirit of Christmas (The Economist-December 22nd 2007-January 4th 2008)

2007年11月1日星期四

Test for WMA10 Pro coding at VBR mode.

In my article “Comparing WMA10 Pro formats at middle-high and high bit rates (96Kbps-256Kbps) ” I’ve compared the WMA10 Pro formats at different bit rates (actually at CBR), but one of most important feature that is built in WMA10 Pro codes is its VBR mode, so I’ll make several simple illustrations to compare the performance of WMA10 Pro VBR coding. For test, I use the sample music file “Vengaboys - We like to Party (Airplay).wave” (Size: 38416Kb, length:03:43, channel:2(strereo), bit rate: 1411kbps, Sample rate: 44100Hz)













Conclusions:

As we can see, the WMA10 Pro VBR10 performanced very well at small size(Only 1544Kb), surprisingly for the VBR25 and VBR50 mode I could only say, it is barely enough. However, some improvements at VBR75 mode comparing to VBR50 are still remarkable. The VBR90 mode has brought a nearly excellent performance with small size(3839Kb) and even at VBR98(at best VBR mode) it has shown the perfect wave with size 6499Kb which surely can be accepted by a lot of music fans, in fact, it is a great news for them, especially for the guys who don't have much space in harddisk! (100 CDs (about 1000 Songs) in Flac or Ape format eat up at least 20G! but in WMA10 VBR98 mode, it could be 5G!)

2007年10月31日星期三

Comparing WMA10 Pro formats at middle-high and high bit rates(96Kbps-256Kbps)

In the last article (see http://jilluh.blogspot.com/2007/10/amazing-test-mp3oggwma10-pro-format.html), I’ve compared Mp3, OGG and WMA10 Pro formats at low bit rates---64kbps that the WMA10 Pro (64kbps) reached an amazing high level (almost over 21000HZ) nearly to normal CD audio quality.

But this time I have tried to transfer the original file into WMA10 Pro formats with different profiles in order to see that if WMA10 Pro codes also have high music performance at middle-high and high bit rates.








Conclusions:

1.WMA10 Pro CBR 96Kbps has a very nice frequency spectrum as well as WMA10 Pro CBR 64Kbps. Its figure looks quite similar to the WMA10 Pro CBR 192Kbps,actually it's even a little bit better, e.g., it provides high quality of music with smaller size. No doubt, it's a very good choice for streaming media.

2. The performance of WMA10 Pro 128Kbps and WMA10 Pro 160Kbps are obviously pretty disappointing, their highest frequencies are even much lower than WMA10 Pro 96Kbps, although the WMA10 Pro 256Kbps shows a great spectrum as the original(its size might not be satisfied).

3. Eventually we can call WMA10 Pro----the killer at lower bit rates instead of Ogg, that is, of course, questionless.

2007年10月30日星期二

Amazing Test---Mp3,OGG,WMA10 Pro format comapring at low bitrates!

I use the sample music WES - Alane (Radio-Mix).wave (size 38Mb, CD Name: Summer Time Hits 3rd CD) as the source file to test. Then I've transferred it to different formats at low bitrates 64k bps:


Then I use the wave editor to generate their frequency spectrums.


The original wave spectrum:


The mp3 wave spectrum:


The ogg wave spectrum:


The WMA wave spectrum:


Conclusions:
1. Apparently the MP3 frequency reaches maximal approximately 12000Hz, which is very unsatisfactory to listen as voice instead of general music. Comparing with mp3, OGG reaches highest frequency of 16000Hz, this is much better than MP3 (its quality almost reaches the level of MP3 at 128kbps, which can be frequently heard from the official website as well as some official audio testing). So it is not surprised that a lot of audio magazines call the OGG format the killer at low bit rates (<128kbps)>
2. What a great surprising is that, the WMA amazingly reaches the highest frequency of 21000Hz! It nearly fits the original wave unbelievably. So the new WMA10 Professional codes which is promoted by Microsoft is really powerful, it theoretically provides much higher quality of music at smaller size at 64kbps comparing to OGG format(from the figures) as well as its former WMA9. However, the open source project OGG music format is becoming more popular currently and it’s expected that it will replace the MP3 in the future, as long as more content providers or music companies give support.


3. For voice or stream application, it is pretty wise to choose WMA10 or OGG, but the popularization of WMA10 may still have a long way to go because of its patent fee, unlike OGG---an open source format can be accepted much easily by electronic manufactures.

Therefore quality ranking: WMA10 (64kbps)>OGG (64kbps)>MP3 (64kbps)
WMA10 Pro: ++++++
OGG: ++++
MP3:++

Attachment:
The same sample music file is transformed using WMA9 codes; it’s only a little bit better than mp3 above.


Links:
Lame MP3: http://lame.sourceforge.net/index.php
OGG Vorbis: http://www.vorbis.com/
WMA:http://www.microsoft.com/windows/products/winfamily/mediaplayer/default.mspx

2007年10月29日星期一

Gmails attachments-limit up to 20M !

Fortunately i found that the gmail's limit of attachment is already up to the 20M now! see the help of Gmail wesite: http://mail.google.com/support/bin/answer.py?answer=8770&topic=1517

"What's the maximum attachment size?
With Gmail, you can send and receive messages up to 20 megabytes (MB) in size. However, the precise amount allowable will depend on the attachment."

2007年10月8日星期一

Adoration for Japan---The German’s love-knot

After I was trying to make new friends here with full of energy and time, I got something that makes me very disappointed and depressed. Apparently, it’s not the great friendship, it is the prejudice. I was too naive and ignorant to make the decision to know more local friends here and I was ever so expecting to obtain something new and different among the communities. Almost every time I was well behaved or I showed my knowledge and experiences, I was always getting this question from the surrounding: “Kommst du aus Japan? (It means do you come from Japan?) Or sometimes they told you unbelievable directly their experiences about Japanese food or Japanese culture without the previous question. You can hardly believe, how I was feeling at that situation, firstly surprised, then pleased and last sad!

There is one story I have to tell. It happened actually on a Japanese girl in my former German language school who was learning with me together in the same class. She was one of my best Japanese friends. She came to Germany for a long holiday for about one year and I was so lucky to know her in our language school. I must say, we really had a very good time not only in learning but also in traveling. At last she had to leave Germany for her home, so I came to the Airport to say goodbye to her. Of course she has already several friends there, a middle-aged German woman, who is her room hirer; a young Japanese girl and a young Japanese guy, who were both learning in my language school. I don’t know why the German woman was so excited and moved with tears in eye, especially when my friend was leaving. Until today I have no idea what has happened to them and what for a particular relationship between the two women, actually a young girl and an old women? Like a daughter and mother or other roles unusual? As I know, my Japanese friend has already boyfriend, so the case of other roles should be nonsense, at least in sex. Perhaps they are very very close friends, is that the reason? But just one year is enough to let the German woman cry for the leaving of my Japanese friend? It sounds really crazy, otherwise there is another explanation: she is too sensitive. Even it has some logics in certain sense, but how could a middle-aged women, who has a daughter in the high school, cried just for a room renter---a Japanese girl, just because of her leaving? Now take a consideration about my situation: I have lived in small room in a big house which is owned by my landlord---a 35 year old German woman over 16 months, and we are really very close friends. As a matter of fact, I had celebrated a lot of party in her house. Of course, I never forgot to invite her every time. A small party might not take much money, but it takes much time and energy for cooking Chinese food. On the day I was moving out, she was quite warm to say goodbye to me and I asked her for some help for transporting my new furniture. She really did later as a normal good friend and I was really appreciated for her favor, however, I noticed that she never really gave me a touching feeling. It seems that she did me some favors just in the way of manners as a hirer.

To be honest, she is the one and only good and best German friend of mine until now! At least it is the greatest comfort for me, since I tried different ways to learn new German friends with my own coins and seconds, which has been proved a great failure actually, because most of them have very strong prejudice against me---a Chinese guy. So I have become smarter now and I never want to beg for their friendship or something, on the contrary, I have begun to look down upon them. Currently I’ve got dozen of American friends.

2007年9月27日星期四

The pathetic English guys

There is a so good way to enjoy them that the English media love dipping their finger into the blood of others. That is why the British Empire has been a great economical unit over a century as well as its deep falling down in the last 50 years. It’s a big pity that those few domestic geniuses, who have realized the problems, were gone to USA mostly. We can hardly imagine that how the new ideas put up by the new generation talents against old-fashioned nob and political inertia are raped by the “Your highness”. This looks just like a ship racing, the English ship has fallen behind after centuries’ racing and now some new racers are catching up with it, such as China, India, East Europe… Participants are getting older and older meanwhile, so they must need mass of supplies from the government without much diligent working, anyway the life must go on, it got to find out a way to drive the people forward--- they can still enjoy the living in the sun with slight differences comparing before, after all they have plundered so much enough by their Colonialism as part of their belief system for the future generations, otherwise there wouldn’t be American civil war for independence. (All attempts to bolster up colonialism are bound to fail, histories have indicated it.)

England doesn’t have much industry left and now they have to face the great challenge of globalization to redefine the British identity. It will be too difficult to recovery themselves, because it’s impossible to make the falling sun rise again unless you are god.

2007年9月26日星期三

The service of Deusche Bank sucks.

Eventually I canceled my Deusche-Bank's account and applied a new one at Citi-Bank. I really could take a deep breath now to get rid of the nightmare-service from Deusche Bank. When I was coming to Germany at the beginning, I was unable to get enough German phrases to express myself, so I got to swallow a lot of terrible feelings when I was served at the branch of Deutsche Bank. The most disgusting one I can never forget is about the picking some money at a branch at Alexander Platz. A female stuff changed her attitude completely after she had finished serving a German just in front of me, I could imagine that I was looking like shit in that situation, German language problem as well as the feeling of a stranger make me so uncomfortable, I really need about 2000 Euro for my language school (Goethe Institute), so I said a little bit lower and then I got a response that I never expected, “Haben Sie so viel Geld?”(Means Have you got so much money?), what a fucking answer! If I didn’t have enough money, I wouldn’t have come here! Even I had not got much money in my account, she could just tell me that peacefully. It was hard to believe that she was asking with a strange voice, it seemed that I came from the poorest place all over the world. I think I only got a suggestion for her, she should be fired and take a trip overseas to see how greatly the current world has been changed. Among all my banking experiences, this was really the fucking “best”!


I’m wondering that even I was the poorest man in China and want to pick some money from Bank; I guess nobody would think out that stupid question, never!

2007年9月19日星期三

I really wasn't aware of that big differences!

I wrote this article really too late until I’ve discovered the huge differences between American and European (especially west European). This illustration, that there seem slight differences between USA and Europe, was not only owned by me but also by a large number of Chinese students who are growing up in mainland china and then go for study abroad. It is probably due to the 300 years’ industrialization of western countries when the middle empire (China) closed the door to the outside communication, thus all the people in china have been strongly impressed by the highly developed modernization over centuries and along with the school education as well as inheritance of social value, the old generations get even much more respect for the westerns than the young generation while a lot of parents who were born in early or middle period 20h century are eager to save money to send their children abroad for studying, however, the young generations who have more experiences of intercultural communications and more self-confidences due to the economical emerging than their predecessors, therefore the more foreign friends they make, the more differences they are feeling.

Big differences between American and European (perhaps more changing in the future, who knows?!):

1. Most of American guys are much easier to be friends than the European

2. Americans are normally very self-confidence, but the European not.

3. Americans like judging foreign people by real abilities, and the European seem to love appearance and superficiality much more for the foreigners.

4. Some Americans really love cooking correctly (real shopping, preparation and cuisine) although there are a lot of instant food (McDonald, Pizza Hut, KFC…) in USA, but almost no body in Europe do that(perhaps only in the countryside).

5. The character of American life-style can be described with “Passion” and “Shift”. “Shiftless” and “non-self-examination” might be proper for the European.

6. The most of Americans are very active and curious to try something new. “Yeah, why not?” is the typical way to express that. For the European, “Hmm…err…, na…, okay ” can be heard very often.

7. The Americans love going outside no matter where, but the European love staying in house and enjoy their so called “comfortable Living”.

8. American love exploring, but the European love safety more.

9. The American young guys are more independent than the young European.

10. Young Americans love various entertainments, but the young European seems only like smoking and drinking alcohol.

11. The Americans have much stronger family responsibilities than the European.

12. Americans are quite modest, but the European love boasting, especially the young guys.

Okay, that is all I’ve found, some features might come originally from the foreign culture.

2007年7月23日星期一

What fucking is the problem with the chinese goverment?

I never thought that the korean goverment has barefacedly applied the Dragon-Boat Festival that has been belonging to China over 2000 years for their own world cultural heritage. I can still remember ,When I was child, I was so eager to get the special food called rice dumpling which looks like this:(Most of people eat it in memory of the famous poet "Quyuan"), it is so delicious, but acutally I havn't eaten that since I went to University.


The most popular symbol that reflect this festival is the sport called dragon-boat race which is not only held in China but also abroad, e.g., in USA and Germany in 2007, it was so welcomed by the local people for its funny style. However, we are in the way to be far from our own culture--- the poem, the funny time, the memory...

If looking back to the yesterday,the chinese goverment has been alway losing something even it becomes economically stronger, hundred years ago it lost the two important cities Mecao and Hongkong, today it is witnessing the departure of its culture and wealth, I don't know whether the goverment really want to make his effort to keep at least some radical culture for our later generation, the Dragon-Boat Festival we've lost is not just food and sport, it is a kind of spirit.

I really miss the food ---rice dumpling !

2007年7月18日星期三

Book-Recommendation---The great encounter of China and West

Photos about ...

Author:D.E.Mungello

Publication Time:2005
Publiched in the United States of America by Rowman & Littlefield Publishers, Inc.


A very good historical lecture for all those who have ever missed their history lectures in the elementary school! No matter where u r from.

Introduction about this book of back cover:

In the Twenty-first century, China has emerged as the leading challenger to U.S. global dominance. China is often seen as a sleeping giant, emerging out of poverty, backwardness, and totalitarianism and moving toward modernization. However, history shows that this vast country is not newly awakening, but rather returning to its previous state of wold eminence. With this compelling perspective in mind, D.E. Mungello convincingly shows that contemporary relations between China and the West are far more like the 1500-1800 period than the more recent past. This fully revised second edition retains the clear and concise qualities of its predecessor, while developing important new social and cultural themes such as gender, sexuality, music, and technology. Drawing from the author's thirty years of experience teaching world history, this book illustrates the importance of history to students and general readers trying to understand today's world.

2007年7月12日星期四

Let it go and let’s do it

My first feeling on the phrase that is printed on the T-shirt designed by a German designer “Fuck u, China” was angry. Perhaps the designer is angry as well about the flooding of counterfeit commodities that are “well” made in China. Or he just wants to be the first German who creates history in 21st century that he reminds some Chinese that they should make use of brains to create not to copy or some guys have been gone off with jobs that should belong to German workers.

The reason is not important, what more important is, we should let it go and create our own intellectual fortune that will support the forwarding of our later generations. Maybe it is a little bit earlier to embrace such beautiful hope, however, the fact is, the European are still staying in a advanced situation and we have to learn much from them just like they did thousand years ago. This doesn’t mean whatever we must catch up with them one day and laugh at them eventually, what we are trying is the stepping near the interconnectivities between different nations, to be better understood not only by our citizens also by foreigner from different cultural regions.

What I always believe is that, changing makes communications. A lot of European people have got used to their living stand and industry advancement over two hundred years and they would currently prefer to choose a situation in which Europe will be always the civilization-center of the world, so it is not so surprising that you are always underestimated, no matter where you come from in Asian (except Japan), even sometimes you are well brought up and rich in creations.

Thus the prejudice has been always brewing in our minds, not only rich against poor---the arrogance, but also poor against rich---the inferiority. The dreamful balance can be only found in the mathematical book in the elementary school, but so what? We are still on the right way to the balance and we are trying, aren’t we? Let’s do it!

2007年7月2日星期一

The European should rediscover the Chinese history

Over last 300 years Europe has been always considering as the center of civilization of the world, which has become a common sense almost for all the human beings, they are always staying on a higher position while they are trying to make communications with other people from the third world, i.e. most of counties in Asian except Japan. And please never get such a silly hope that the European can recognize the people from different Asian countries.
If the present focus is Japan, they will then make much more concerning about future threat that Japan might bring and they will probably consider every Asian guy in the street in Europe as Japanese.

So the same thing has happened to China, they will certainly think the people who have an Asian face, who are making “mistakes”, as the confounded Chinese that they’ve despised over 3 centuries, you know, it looks really like such an example, it would make them much more comfortable, if African always stay in the poor situation with the help from Europe, because that brings them a prior feeling everywhere and they have get used to it too long, so they are willing to keep that forever.

Thus it’s not so difficult to make a conclusion that the European love keeping something except changing. That is why the employment system in German as well as in other west European countries looks like a “diamond” which means on one hand the experience accumulation of their ancestors and on the other hand few flexibilities. That is why so many experts are leaving here for the USA and so many professors are unable to get rid of their positions.

What makes me so surprised that a lot of Chinese students, who come to foreigner countries for their further studying, are always having so little self-confidence that the Europe is considered at all times more advanced than China by them. As a matter of fact, it was not what they thought 300 years ago at all.

China's science and technology fell behind that of Europe by the 17th century. Political, social and cultural reasons have been given for this, although recent historians focus more on economic causes, such as the high level equilibrium trap. Since the PRC's market reforms China has become better connected to the global economy and is placing greater emphasis on science and technology.” Such histories they should read to enforce their national spirits and individual confidence. Another important reason that the history lectures in the elementary school and junior school have been often replaced or taken by other lessens such as Math, Physics…etc has caused that problem. As we all know, the modern high industrialization of Western Europe is being followed by the eastern countries, and we cannot overlook meantime that over thousand years in the long historical river the merchant marine from the East full of flourishing civilizations was driving slowly to the Europe.

2007年6月27日星期三

Showing respect for some german?!

Before I came to Germany I’ve been always appreciating two strong national characters of all Germany people: Reason (Vernünftigkeit) und fortitude (Stärke). I’m forced to change that mind after I’ve made two years’ life experiences here and there in Germany. Even sometimes I have strong feeling to show my disdain for some guys, but I give up this bad idea eventually for the manners.

A simple story can begin from the house-renter of my friend. As I planned earlier, I lived in a German family while I was so eager to improve my Germany faster. Thus I’ve known some friends in the language school quite soon and fortunately the house-renter of a Chinese friend as well, who has been living here over 4 years but cannot speak Germany well, and however, I realize that it was popular here in Germany about 1 year later. So I got a chance to make more communication in German with a German guy ---the house renter. So every time my friend invites me to go shopping or a party, I am always asking his renter whether he could go with us together, the answer seemed whatever a little bit reluctant and unzealous, besides he was always telling me the fucking dirty reports about China from some magazines, actually I was ever about to invite him to a good restaurant while waiting for a positive and objective comments. I found I was so puerile to make such expectation. What’s more, he wrote me email one or two times per month and always about the same topic: the negative sides. Perhaps he didn’t learn how to make fair estimation from his excellent mates during the college days, so it seems he was ever not so diligent or his obstinacy cannot be up to date.

He is the first German for whom I have no impatience and respect unless he can learn how to catch up with the trend. I am afraid until now I have wasted so much money and energy on the ludicrous communication with some Germans who are have deep prejudice against the Asian guys except Japanese, and they are always contemptuous if you are trying to give them any suggestion, i.e. to make a trip in Asian, while they are at all time thinking the society that their ancestor have created always the best, unfortunately the Asian seems still absolute mysterious for them and what is worse, most of them are feeding themselves so well by the social wealth and not willing to show any interest and to say nothing of the explorer spirit of the American. Anyway they should feel so lucky that their former generations have created so wonderful scientific social frameworks that make the basement of their pride and the model of our studying.

The two characters of German are still on the right way to be persuasive as long as they decide to explore the new world from different sides.

2007年6月26日星期二

The Visa to Japan

This will be my first trip from Germany to Japan and I’m so glad that I cannot wait to see my old Japanese friends who I’ve known in my former language school.

I’ve received the invitation letter in the last week--- a letter that will be used not only for my visa application to Japan but also for my young brother. Then I’ve scanned them into e-documentation and sent to him, until today I’ve got a message from him that he got some troubles with the visa application in the Japanese embassy in UK because of non-original documents. So one way is, I have to post him the letter after my successful application of visa, but it will be too later while it takes about 2-4 weeks and we’ll set off in 4 weeks, even I’ve no idea whether the letter will be needed during the process, if no(they'll only see it face to face, that's all), I can post it to my brother immediately without any problem, that would be certainly so nice.

Besides the visa, I can’t just help making some thinking about such complicated visa application process. Why must we, who have the mainland passport, always need so many administrative docs, have we destroyed our trust reputation around the world? Has our government always shoveling in the profits of the crazy increasing economic with few considerations about its people? Have our ancestor who came so earlier abroad lost their trust with those illegal business activities? Why have the guys from western counties always the prejudice against us with their aged memories of 60s or 70s because only they’ve always been proud of their advanced industry creation? Why can’t we travel around the world freer like the America, European, or Japanese, even like a normal citizen in Hong Kong or Taiwan? It reminds me meantime a humorous sentence from Han-Chinese in USA, “I really want to love my land, but it’s too difficult to find something that makes me to love.”

2007年5月30日星期三

机箱前置面板的音频线解法

一般前置麦克风和音频的接线办法:
1.
Azalia
compliant definition

PORT1 L GND
PORT1 R PRESENCE#
PORT2 R SENSE1_RETUR
E_SEND (null)
PORT2 L SENSE2_RETUR

2.
Legacy AC 97
compliant definition

MIC2 ---GND(Ground)
MICPWR ---+5VA (注意这里接头线可能显示的是MC_PW,其实都一样只是缩写)
Line out_R--- BLINE_OUT_R
NC (No Connection)
Line_out_L --- BLINE_OUT_L


假设从上到下(总共9个接口),
1 6
2 7
3 8
4 9(空)
5 10
如果你有7个接头,麦克风的power接MICPWR(2), GND接6, Line_R和Line_L分别接3和5, OUT_R和OUT_L分别接8和10,最后NC(4)和+5VA(7)留空。

Reference:

yjfxue,"2006,P5PL2主板前置麦不好使",,pp.2, http://www.cpcfan.com/viewarticle.php?id=3725

2007年4月28日星期六

汽车工业化的“南京大屠杀”?

2006全国道路交通事故死亡人数据权威机构统计,全国每年交通事故死人超过10万,伤人约4~5倍,也就是约50万。1997年全国记录在案的交通事故共计304217起,死亡73861人,伤190128人,直接经济损失18.5亿元,分别比1996年增长5.7%。这就相当于中国每年有25个大学的学生全部从地球上蒸发掉,照这种速度下去,每隔3年,就相当于一次“南京大屠杀”,如果说任何的进步都要求牺牲,但是我们的汽车工业化的进步所带来的如此大的牺牲,是值得么?国人发烧一般追求汽车消费,也许带来的是像拉动了前所未有庞大的市场和无数的投资,但是背后令人无可奈何的是环境的破坏所威胁到的子孙万代的生存。

也许就像我们在小时候学会走路注定要知道和理解摔跤的痛苦一样,那么这种真正意义上的理解必须通过“切身”的体验才能永远的记的。中国的社会就像一个小孩子一样,什么都不懂,什么都要尝试,所以不断地犯错;西欧社会就像一个经历沧桑的老人,一切都非常成熟,新的尝试总是举步维艰;美国社会就像一个激情澎湃的年轻小伙子,不断地探索不断地创新,敢于挑战一切。那么我希望的是,我们的伟大的“小孩子”不要走上歧路,或许这种希望只是一种对现实的无奈,毕竟生活还是要继续的,但是生活的地点是可以选择的,至少对某部分人来说。不过习惯就是一种生活。

---纪念死去的Auntie Zhang

2007年2月20日星期二

Error "Unable to create this part due to an internal error. Reason for the failure: assertion failed: " in the Eclipse

I've met a bad errror in Eclipse 3.2: Unable to create this part due to an internal error. Reason for the failure: assertion failed:
But at last I've solved this problem,it might be caused by the synchronization of the updates, for example if you make a the latest update to Eclipse 3.2, but at the same time perhaps you can not use the plugin that you've installed successfully and then the error above may appear,another reason that i surmise is that two same files(such as *.java) in the build path that belongs to one workbench.

Two suggested way to resolve it:
1.make your eclipse and plugin update synchronous
2.save your project in another directory and delete it in your workbench, restart the eclipse and rebuild again, if it doesn't work, try method 1.

2007年2月18日星期日

This is my simple implementation of BP algorithm for MLP classification.(seems not so exhaustive :D)
(InputUnits:alternative hiddenUnits:alternative outputUnit:1,)

package bpSolve;

import java.util.Random;
import java.io.*;

public class BackPropagaion {

/**
* BP Algorithm Para:InputLayerNo,HiddenLayerNo
*
*
* @Jay
*/
private static int OutputNo = 1;

public static void main(String[] args) throws Throwable, IOException {
// get the HiddenUnits Number
String s1 = "1.Please Input the Number of HiddenLayerUnits:";
String s2 = "2.Please Input the Learning-Rate:";
int inputNo = 2;// by default
int hiddenNo = 0;
double rate = 0;
hiddenNo = Integer.parseInt(readIn(s1));
rate = Double.parseDouble(readIn(s2));

// get the SampleDatas from given file
String s3 = "Please input the SampleData Path:";
String Path = null;
Path = readIn(s3);

// get the sample and Targe
int Groups = 10; // the number of smaple groups
int Dimension = 2; // the number of Dimension
int i = 0;
double[][] sample = new double[Groups][Dimension];
double[] target = new double[Groups];
String Content = null;
FileReader fr = new FileReader(Path);
BufferedReader buffer = new BufferedReader(fr);
while ((Content = buffer.readLine()) != null) {
String[] str = Content.split(",");
int L = str.length;
for (int d = 0; d < L - 1; d++) {
sample[i][d] = Double.parseDouble(str[d]);
}
target[i] = Double.parseDouble(str[L - 1]);
i += 1;
}

// firstly to scale all the sample data

for (int k = 0; k < Dimension; k++) {
double[] array = new double[Groups];
for (int m = 0; m < Groups; m++) {
array[m] = sample[m][k];
}
double[] scale_array = scale(array);
for (int c = 0; c < Groups; c++) {
sample[c][k] = scale_array[c];
}
}

// begin the BackPropagation
BackPropagation(sample, target, rate, inputNo, OutputNo, hiddenNo);
}

// To do backpropagation
public static void BackPropagation(double[][] sample, double[] target,
double rate, int inputNo, int outputNo, int hiddenNo) {
// set the deault error to 0
double Error = 0;
// here we set a value to control the error scope, if the network error
// is larger than it,then run the circle again until it's lower than it.
double E = 0.01;
Error = E + 1;

// ----------------initialization of the weights-------------

// weights of InputLayer
double[] w_input = intial(inputNo);
// weights of HiddenLayer to InputLayer
double[][] w_hidden = intial(inputNo, hiddenNo);
// weights between OutputLayer and HiddenLayer
double[] w_output = intial(hiddenNo);

// network initialization
double[] input_hiddenlayer = new double[hiddenNo];
double[] input_inputlayer = new double[inputNo];
double input_outputlayer;

while (Error > E) {

int K = sample.length;
Error = 0;
// there are together K SampleVectors
for (int p = 0; p < K; p++) {
// p is the Pth Vector

/*-------------------Procedure of ForwardPropagation------------------*/

// calculation of input of the inputlayerUnits
for (int i = 0; i < inputNo; i++) {
input_inputlayer[i] = w_input[i] * sample[p][i];
}

// calculation of input of the hiddenlayerUnits
for (int i = 0; i < hiddenNo; i++) {
double temp = 0;
for (int j = 0; j < inputNo; j++) {
temp = temp + sigmoid(input_inputlayer[j])
* w_hidden[i][j];
}
input_hiddenlayer[i] = temp;
}

// calculation of input of the outputlayerUnits
double sum_hidden = 0;
for (int i = 0; i < hiddenNo; i++) {
sum_hidden = sum_hidden + w_output[i]
* sigmoid(input_hiddenlayer[i]);
}
input_outputlayer = sum_hidden;

/*-------------------Procedure of BackPropagation------------------*/

// calculate the delta of outputlayerUnits
double delta_output;

delta_output = target[p] - sgn(input_outputlayer);

// calculate the error of the networkoutput
double error_K = 0.5 * delta_output * delta_output;
Error = Error + error_K;

// calculate the delta of hiddenlayerUnits
double[] delta_hidden = new double[hiddenNo];
for (int i = 0; i < hiddenNo; i++) {
double derivative_hidden = sigmoid(input_hiddenlayer[i])
* (1 - sigmoid(input_hiddenlayer[i]));
delta_hidden[i] = w_output[i] * delta_output
* derivative_hidden;
}

// calculate the delta of inputlayerUnits
double[] delta_input = new double[inputNo];
for (int i = 0; i < inputNo; i++) {
double temp = 0;
for (int j = 0; j < hiddenNo; j++) {
temp = temp + w_hidden[j][i] * delta_hidden[j];
}
delta_input[i] = sigmoid(input_inputlayer[i])
* (1 - sigmoid(input_inputlayer[i])) * temp;
}

/*-------------------Regulation of the Weights------------------*/

// WeightRegulation of outputlayer
for (int i = 0; i < hiddenNo; i++) {
w_output[i] = w_output[i] + rate * delta_output
* sigmoid(input_hiddenlayer[i]);

}

// WeightRegulation of hiddenlayer
for (int i = 0; i < hiddenNo; i++) {
for (int j = 0; j < inputNo; j++) {
w_hidden[i][j] = w_hidden[i][j] + rate
* delta_hidden[i]
* sigmoid(input_inputlayer[j]);
}
}

// WeightRegulation of inputlayer
for (int i = 0; i < inputNo; i++) {
w_input[i] = w_input[i] + rate * delta_input[i]
* sample[p][i];
}
}
System.out.println(Error);
}
}

// to read Input on the monitor
public static String readIn(String display) throws IOException {
System.out.println(display);
BufferedReader buffer = new BufferedReader(new InputStreamReader(
System.in));
String string = buffer.readLine();
return string;
}

// outputlayer model function
public static double sgn(double x) {
if (x > 0)
return 1;
else
return -1;
}

// hiddenlayer model function
public static double sigmoid(double x) {
double g;
g = 1 / (1 + Math.exp(-x));
return (double) g;
}

// To generate the weights of inputlayer and outputlayer
public static double[] intial(int M) {
Random r = new Random();
double weight[] = new double[M];
for (int i = 0; i < M; i++) {
weight[i] = r.nextDouble() - 0.5;
}
return weight;
}

// to generate the random weights of hiddenlayer between[-0.5,0.5],
// N: number of forwardlayer units, M: number of backwardlayer units.
public static double[][] intial(int M, int N) {
Random r = new Random();
double weight[][] = new double[N][M];
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
weight[i][j] = r.nextDouble() - 0.5;
}
}
return weight;
}

// to get the scaled array between [0.1]
public static double[] scale(double[] original) {
int length = original.length;
double[] scale = new double[length];
for (int i = 0; i < length; i++) {
scale[i] = (original[i] - min(original)
/ (max(original) - min(original)));
}
return scale;
}

// to generate the maximum of the array
private static double max(double[] array) {
double max = array[0];
for (int i = 0; i < array.length - 1; i++) {
if (max <= array[i + 1])
max = array[i + 1];
}
return max;
}

// to generate the minimum of the array
private static double min(double[] array) {
double min = array[0];
for (int i = 0; i < array.length - 1; i++) {
if (min >= array[i + 1])
min = array[i + 1];
}
return min;
}
}


the parameters must be correctly set and the sampledata format must also be right, such as
1.6032,3.2925,-1
2.5699,1.2673,-1
2.156,3.0256,-1
0.72343,2.6734,-1
1.2626,0.66255,1
2.2493,3.0249,-1
3.2421,1.0224,-1
3.2475,1.1921,-1
2.0848,3.6309,-1
1.1158,0.94013,1

[Source:WWW.Javawolrd.com]Build an SOA application from exisiting services

Build an SOA application from exisiting services

Put heterogeneous services together with the Petals ESB


Due
to global networks, heterogeneous information systems, and the need for agility,
conventional architectures have evolved. The tasks of building entirely new applications,
making specific adaptors for legacy systems, or rewriting existing applications
are now obsolete. Largely promoted by Web services connectivity, the service-oriented
architecture (SOA) is now considered the preferred approach to designing an information
system.


SOA proposes to provide existing functions of an information system as
"services" that can be accessed in a loosely coupled way, independently from the
technical platform. An application is seen as an orchestration of requests for those
services. That is why an SOA generally comes with workflow or orchestration concepts.


An enterprise service bus (ESB) is an implementation of an SOA. It is
middleware for connecting heterogeneous services and orchestrating them. Related
to these concepts, the Java Business Integration specification (JBI, Java Specification
Request 208) defines a standard framework for integration.


In this article, I use the Petals ESB, an open
source JBI container, to illustrate how to connect existing heterogeneous services
and put together an online travel agency Web application.


Java Business Integration


The Java Business Integration specification defines a standard means for
assembling integration components. The goal is to create integration solutions that
enable an SOA in an enterprise information system. These components are plugged
into a JBI environment and can provide or consume services through it in a loosely
coupled way. The JBI environment then routes the exchanges between those components.


Two kinds of components can be plugged into a JBI environment:



  • Service engines provide logic in the environment, such as XSL (Extensible
    Stylesheet Language) transformations or BPEL orchestration (Business Process
    Execution Language).

  • Binding components are "connectors" to external services or applications.
    They allow communication with various protocols, such as SOAP, Java Message
    Service (JMS), remote method invocation (RMI), or ebXML.


These configurable components enable communication between heterogeneous
services. The JBI specification introduces the service assembly, which
defines the configuration of these components and the links between them. The goal
of the components (bindings or engines) is to expose external and internal services.
Each service exposed in the JBI environment can be accessed through the service
endpoint, the address of the service.


The messages exchanged between components are called message exchanges.
The exchange pattern between the components is a send-accept message pattern.


An online travel agency application with JBI


This article's travel agency Website allows users to book flights and
accommodations, and sends an email to users to confirm these reservations. To deliver
this functionality, the Website sends to the workflow engine all the information
provided by the user in XML. This workflow engine then connects to the airline to
book the flight, then to the hotel chain to book the room. It sends a confirmation
email to the user via the mail engine.


Even if the data exchanged during the process is XML, the XML schemas
requested or provided by the various services differ. Thus, an XSLT (Extensible
Stylesheet Language Transformation) engine is used to process transformations from
XML to another format.


I discuss the business process later in this article. Let's first look at Figure
1, which shows how this application is built with the Petals ESB.





Figure 1. Application architecture. Click on thumbnail to view full-sized
image.



Now let's define the different parts that are key to this architecture.


Service assembly


A service assembly is a descriptor that configures a JBI component for
integration with applications. A service assembly is deployed on the JBI container
as a simple ZIP archive. The container analyzes all the content in this archive
and configures the affected components. The configuration for a component is called
a service unit. When we configure a component with a service unit, we say
that we deploy an artifact on it. Note that the content of a service unit is opaque
to the container and is just provided to the component.


If the service assembly contains link definitions between services (also
called connections), the container creates them. Connections can be seen as aliases
to real service endpoints.


The service assembly is a ZIP archive containing an XML descriptor file
that defines to which component a service unit is provided and the connections between
services. The service assembly also contains each service unit to deploy to components.
These service units are also ZIP archives.





Figure 2. A service assembly. Click on thumbnail to view full-sized image.



To recap, the role of a service assembly is to define the glue between
a set of services to create an application in an SOA way. As multiple service assemblies
are deployed on the container, multiple applications can run on and share the same
services.


Service unit


A service unit is a set of elements deployed to a JBI component. A service
unit contains an XML descriptor that the component can read and any artifacts that
the component can require. For instance, a service unit for an XSLT engine contains
an XSL stylesheet, and the descriptor file tells the component that this stylesheet
must be used when a message is received on a particular service endpoint.





Figure 3. A service unit. Click on thumbnail to view full-sized image.



The ESB explodes the service unit archive in a directory, calls the component's
service unit manager (part of a JBI component) to inform it that a new service unit
is available, and indicates the directory where the service unit has exploded. The
component's service unit manager registers this new service in the JBI environment
and configures the component to use the related artifact with the registered service
endpoint.





Figure 4. Deploy a service unit on a component. Click on thumbnail to view
full-sized image.



When the component receives a message for a particular service endpoint, it knows
which artifact to use.





Figure 5. Use artifact for particular service endpoint. Click on thumbnail
to view full-sized image.



Connection


A connection is defined in a service assembly's descriptor. It can be
viewed as an alias for a real service endpoint. For example, a component can specify
"I want to send a message to the service endpoint called My Endpoint,"
and a connection specifies that My Endpoint is in fact My Real Endpoint.
Thus, when the component sends the message to My Endpoint, it is sent to
My Real Endpoint.


The interest of using such a mechanism is to dynamically reconfigure the
links between components. For instance, a component, such as the travel agency workflow
engine, is configured to call a service where the service endpoint name is "airline
service endpoint." Then, depending on the travel agency's partnership with the airline,
the connection will link the airline service endpoint with, for instance,
MyLowCostAirlineCompanyEndpoint
or AnotherAirlineCompanyEndpoint.
The service's consumer needs no change to connect to the right service. By deploying
various service assemblies containing different connections, the application will
dynamically change the services used.





Figure 6. Resolve a connection. Click on thumbnail to view full-sized image.



The travel agency application


The global process for our travel agency application proceeds as follows:



  1. The Website sends the user's reservation requests through a SOAP request
    to the SOAP binding component. This information is called Website XML content.
    Note that this communication is external to JBI.

  2. Now, we enter the JBI environment. The SOAP binding component is configured
    to send the Website XML content via a message exchange to the endpoint
    BookingWorkflowEndPoint
    (hosted by the BPEL engine).

  3. The BPEL engine sends the Website XML content to the XSLT_1_Endpoint
    (hosted by the XSLT engine).

  4. The XSLT engine transforms the Website XML content to a format recognized
    by the airline service and returns it as the flight-request XML.

  5. The BPEL engine sends the Website XML content to the XSLT_2_Endpoint
    (hosted by the XSLT engine).

  6. The XSLT engine transforms the Website XML content to a format recognizable
    by the hotel service and returns it as the hotel-request XML.

  7. The BPEL engine sends the flight-request XML to the AirLineEndpoint,
    resolved as MyAirLineCompanyEndpoint (hosted by the SOAP binding
    component).

  8. The SOAP binding component is configured to send the fight-request XML through
    a SOAP request to the MyAirLineCompany Web service (external to JBI). The result
    is the confirmed flight-response XML and is returned to the BPEL engine.

  9. The BPEL engine sends the hotel-request XML to the HotelEndpoint,
    resolved as MyHotelEndpoint (hosted by the RMI binding component).

  10. The RMI binding component is configured to send the hotel-request XML through
    an RMI call to the MyHotel RMI server (external to JBI). The result is the confirmed
    hotel-response XML and is returned to the BPEL engine.

  11. As the result of the two reservations, the BPEL engine concatenates the
    flight-response XML and hotel-response XML to flight-and-hotel-response XML.
    Then it sends this XML to the XSLT_3_Endpoint (hosted by the XSLT
    engine).

  12. The XSLT engine transforms the flight-and-hotel-response XML to text that
    summarizes the reservations. This email XML returns to the travel agency workflow
    engine.

  13. The BPEL engine sends the email XML to the EmailEndpoint (hosted
    by the email binding component).

  14. The email binding component sends an email with the email XML to the user
    (external to JBI). The process is now complete.


The components


The JBI components needed for the application are the SOAP binding component
(communication with the Website and the airline Web service), the JMS binding component
(communication with the hotel JMS service), the XSLT engine (XML transformation),
the email engine (send confirmation email to the user), and the BPEL engine. These
JBI components are distributed with the Petals JBI container.


To create our application, we just install those components in the JBI container.
(See Resources for more about JBI component installation.)


At this point, the architecture looks like this:





Figure 7. After component installation. Click on thumbnail to view full-sized
image.



Note that the mail engine natively exposes its single service endpoint
to the JBI environment, as it requires no configuration and always performs the
same task (which is, in fact, to send email).


When the components are installed, we must configure them. Thus, we need
to create the service assembly that links these elements together. The service units
described below make up this service assembly.


Website service unit


A service unit is created to be deployed on the SOAP binding component
(SOAP BC). This service unit defines an http://travel.com/workflowService Web service
that will map to the internal service endpoint WorkflowEndpoint.


With this service unit, the SOAP BC consumes the WorkflowEndpoint
service endpoint:


 






<jbi version="1.0" xmlns='http://java.sun.com/xml/ns/jbi' ...>
<services binding-component="true">
<consumes service-name =" BookingWorkflowService "
endpoint-name =" BookingWorkflowEndpoint " />
<petals:address> http://travel.com/workflowService </petals:address>
</services>
</jbi>



When the service unit deploys, the SOAP BC exposes a new Web service,
called http://travel.com/workflowService. When an external call to this Web service
is performed (from the Website, for instance), the SOAP BC transfers it to the
BookingWorkflowEndpoint service endpoint, that is, the application
workflow engine.


Booking process service unit


A service unit is created for deployment on the BPEL engine. This service
unit contains a BPEL definition of the booking process. This definition lists the
different service endpoints that must be called by the workflow engine. This process
definition maps to the internal service endpoint, the BookingWorkflowEndpoint:


 






<jbi version="1.0" xmlns='http://java.sun.com/xml/ns/jbi' ...>
<services binding-component="false">
<provides service-name =" BookingWorkflowService "
endpoint-name =" BookingWorkflowEndpoint " />
<petals:address> file://travel-booking.bpel </petals:address>
</services>
</jbi>



The travel-booking.bpel file is contained in this service unit and describes
the process.


Service unit for the airline Web service


Another service unit is created for deployment on the SOAP BC. This service unit
defines a MyAirlineCompanyEndpoint that will map to the external Web
service http://myairline.com/flightBookingService.


With this service unit, the SOAP BC provides the MyAirlineCompanyEndpoint
service endpoint:


 






<jbi version="1.0" xmlns='http://java.sun.com/xml/ns/jbi' …>
<services binding-component="true">
<provides service-name =" MyAirLineCompanyService "
endpoint-name =" MyAirLineCompanyEndpoint " />
<petals:address> http://myairline.com/flightBookingService </petals:address>
</services>
</jbi>



When the service unit deploys, the SOAP BC activates in the JBI environment
the MyAirlineCompanyEndpoint service endpoint. When a JBI component
sends a message to this service endpoint, the SOAP BC transfers it to the external
http://myairline.com/flightBookingService Web service, that is, the airline booking
Web service.


Hotel JMS service unit


The hotel JMS service unit looks like the airline service unit. The JMS BC provides
a MyHotelEndpoint service endpoint that maps to JMS message exchanges
with the hotel JMS server.


XSLT service unit


The XSLT engine is used for three transformations:



  • The initial XML from the Website to the flight-request XML

  • The initial XML to the hotel-request XML

  • The flight-and-hotel-response XML to the email XML


So three service units must be provided, each one containing an XSL stylesheet
for the correct transformation. The XSLT engine will provide three services through
three service endpoints.


Airline and hotel connections


As seen before, we can use connections to independently link the application
workflow engine to the airline and hotel services, and dynamically reconfigure this
link by deploying a new service assembly.


For instance, the connection to the My Low Cost Airline Company looks like this:


 






<jbi version="1.0" xmlns…>
<service-assembly>
...
<connections>
<connection>
<consumer service-name ="AirLineService"
endpoint-name ="AirLineServiceEndpoint"/>
<provider service-name ="MyLowCostAirLineCompany"
endpoint-name ="MyLowCostAirLineCompanyEndpoint"/>
</connection>
</connections>
</service-assembly>
</jbi>



This code shows that when a service consumer (the application workflow engine)
consumes the AirlineService service, the MyLowCostAirLine
service is really consumed.


The global service assembly


All of these service units are packaged in one service assembly. The service
assembly's descriptor file contains the connections.





Figure 8. The application service assembly. Click on thumbnail to view full-sized
image.



This service assembly is deployed in the Petals JBI container, and all the service
units are delivered to their components.


 





Figure 9. Deploy the application service assembly. Click on thumbnail to
view full-sized image.



The components register their related service endpoints, the container sets the
connections, and the application is now ready to run.





Figure 10. The configured container. Click on thumbnail to view full-sized
image.



Conclusion


The JBI specification leverages the best concepts of SOA and standardizes
an approach for composing applications from existing services. JBI basically standardizes
the ESB concept.


Building an SOA application with the Petals JBI container is quite simple:
use some standard JBI binding or engine components, write a few XML descriptions
to explain how to connect to your services, and deploy them in the Petals JBI container.


With such a container, the challenge becomes writing or using relevant services
with good granularity, not assembling them.


Author Bio


Adrien Louis works as chief architect at
EBM WebSourcing, and has six years
of experience working with Java EE technologies. Currently, he is working on enterprise
integration solution problems. Louis is the project manager of the
Petals open source project. The goal
of the Petals project is to provide a distributed JBI container packaged in various
integration solutions like B2B integration or business-process-based integration.

From www.JavaWorld.com,

Commet:Good lecture about SOA building!

2007年2月14日星期三

[转载]BPEL: Service composition for SOA

BPEL: Service composition for SOA

Get started developing business processes based on the Business Process Execution Language

BPEL (Business Process Execution Language) has become one of the most important technologies of SOA (service-oriented architecture) and enables easy and flexible composition of services into business processes. BPEL is particularly important because it introduces a new concept into application development—programming-in-the-large. This concept enables us to develop processes quickly by defining the order in which services will be invoked. This way, applications (and information systems) become more flexible and can better adapt to the changes in business processes.

Business processes are usually of dynamic nature. Companies have to improve and modify, act in an agile manner, optimize, and adapt processes to improve the responsiveness of the whole company. Every change and improvement in a business process has to reflect in applications that provide support for them. Although this requirement may not sound very difficult to fulfill, the real-world situation shows us a different picture. Changing and modifying applications is often a difficult job, which requires time. Therefore applications cannot react instantly to changes in business processes—rather, they require some time to implement, test, and deploy the modifications.

Making information systems more flexible and adaptable to changes, and better aligned with business processes is the major promise of SOA. In this article, I show why BPEL is so important and demonstrate how to develop a BPEL process.

Service-oriented approach

The SOA approach for efficient automation of business processes requires:

  • Standardized way to expose and access the functionality of applications as services
  • Enterprise bus infrastructure for communication and management of services, including message interception, routing, transformation, etc.
  • Specialized language for composition of exposed functionalities of applications into business processes

The first requirement is fulfilled by the latest distributed architecture—Web services. The second requirement is fulfilled by the ESB (enterprise service bus), which provides support for centralized, declarative, and well-coordinated management of services and their communications. The third requirement, composition of services into processes, is fulfilled by BPEL, the commonly accepted specialized language for business process definition and execution.

A business process, as seen by BPEL, is a collection of coordinated service invocations and related activities that produce a result, either within a single organization or across several. For example, a business process for planning business travels will invoke several services. In an oversimplified scenario, the business process will require us to specify the employee name, destination, dates, and other travel details. Then the process will invoke a Web service to check the employee status. Based on the employee status, it will select the appropriate travel class. Then it will invoke Web services of several airline companies (such as American Airlines, Delta Airlines, etc.) to check the airfare price and buy the one with the lowest price.



Page 2 of 4

For the clients, the BPEL process will expose its functionality in the same way as any other Web service. From the client perspective, it will look exactly like any other Web service. This is important and useful, as it allows us to compose services into simple processes, simple processes into more complex processes, and so on. This also means that each BPEL process will be described with a WSDL (Web Services Description Language) description.

Core concepts

BPEL is an XML-based language. A BPEL process consists of steps. Each step is called an activity. BPEL supports primitive and structure activities. Primitive activities represent basic constructs and are used for common tasks, such as those listed below:

  • Invoking Web services, using
  • Waiting for the request, using
  • Manipulating data variables, using
  • Indicating faults and exceptions, using , etc.

We can then combine these activities into more complex algorithms that specify the steps of a business process. To combine primitive activities, BPEL supports several structure activities. The most important are:

  • Sequence () for defining a set of activities that will be invoked in an ordered sequence
  • Flow () for defining a set of activities that will be invoked in parallel
  • Case-switch construct () for implementing branches
  • While () for defining loops, etc.

As we will see, BPEL is not that different from programming languages, such as Java. But we will see that BPEL differs from Java and supports the characteristics of business processes. BPEL also provides fault and compensation handlers, event handlers, and correlation sets. It provides means to express complex parallel flows. It also makes it relatively easy to call asynchronous operations and wait for callbacks.

BPEL processes require a runtime environment—a BPEL server, which gives us good control over their execution. Typically, BPEL servers provide control over process instances that are executing and those that have finished. They support long-running processes and can dehydrate process state to save resources. Some servers provide control over process activities and allow their monitoring. Finally, using a BPEL server, all our processes are deployed centrally, which simplifies maintenance. All this makes the BPEL server the preferred environment for running and managing processes.

Choosing the right BPEL server can be quite difficult, however, as there are several choices. Some of the most popular BPEL servers that are based on Java EE (Sun's new name for J2EE) include Oracle BPEL Process Manager, IBM WebSphere Business Integration Server Foundation, BEA WebLogic Integration, and AquaLogic. There are also at least four open source BPEL servers available: ActiveBPEL Engine, FiveSight PXE, bexee, and Apache Agila.

Example process

Let us now look at an example BPEL process for business travels that we have described above. We will develop an asynchronous process that will use a synchronous call to check the employee travel status and two asynchronous calls to acquire the plane ticket prices. The figure below shows the overall structure of our process. On the left, we see the client that invokes the process. The process first calls the employee travel status Web service. Then it invokes both airlines' Web services concurrently and asynchronously. This means that the process will have to implement the callback operation (and a port type), through which the airlines will return the flight ticket confirmation. Finally, the process returns the best airline ticket offer to the client. In this example, to maintain simplicity, we will not implement any fault handling, which is crucial in real-world scenarios.



Page 3 of 4

Let us now write the BPEL code. We start with the process declaration—the root element, where we define the process name and the namespaces

 
targetNamespace="http://packtpub.com/bpel/travel/"
xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
xmlns:trv="http://packtpub.com/bpel/travel/"
xmlns:emp="http://packtpub.com/service/employee/"
xmlns:aln="http://packtpub.com/service/airline/" >

Next, we have to define the partner links. Partner links define different parties that interact with the BPEL process. This includes all Web services that will be invoked and the client of the process. Each partner link specifies up to two attributes: myRole that indicates the role of the business process itself and partnerRole that indicates the role of the partner. In our example, we define four partner links:

 
partnerLinkType="trv:travelLT"
myRole="travelService"
partnerRole="travelServiceCustomer"/>
partnerLinkType="emp:employeeLT"
partnerRole="employeeTravelStatusService"/>
partnerLinkType="aln:flightLT"
myRole="airlineCustomer"
partnerRole="airlineService"/>
partnerLinkType="aln:flightLT"
myRole="airlineCustomer"
partnerRole="airlineService"/>

To store messages and to reformat and transform them, we need variables. Usually we use a variable for every message sent to the Web services and received from them. In our example, we will need a few variables. For each variable, we have to specify the type. We can use a WSDL message type, an XML Schema simple type, or an XML Schema element. In our example, we use WSDL message types for all variables:

 















Now we are ready to write the main process body. It contains only one top-level activity. Usually, this is a that allows us to define several activities that will be performed sequentially. Within the sequence, we first specify the input message that starts the business process. We do this with the construct, which waits for the matching message. In our case, this is the TravelRequest message. Within the construct, we do not specify the message directly. Rather, we specify the partner link, the port type, the operation name, and, optionally, the variable that holds the received message for consequent operations. We link the message reception with the client partner and wait for the TravelApproval operation to be invoked on port type TravelApprovalPT. We store the received message in the TravelRequest variable:

 

portType="trv:TravelApprovalPT"
operation="TravelApproval"
variable="TravelRequest"
createInstance="yes" />

Next, we need to invoke the Employee Travel Status Web service. Before this, we have to prepare the input for this Web service. We can construct such a message by copying the employee part of the message that the client sent. Now we can invoke the Employee Travel Status Web service. We make a synchronous invocation, for which we use the activity. We use the employeeTravelStatus partner link and invoke the EmployeeTravelStatus operation on the EmployeeTravelStatusPT port type. We have prepared the input message in the EmployeeTravelStatusRequest variable. Because it is a synchronous invocation, the call waits for the reply and stores it in the EmployeeTravelStatusResponse variable:


 









portType="emp:EmployeeTravelStatusPT"
operation="EmployeeTravelStatus"
inputVariable="EmployeeTravelStatusRequest"
outputVariable="EmployeeTravelStatusResponse" />

The next step is to invoke both airline Web services. Again, we first prepare the required input message (which is equal for both Web services). We will make concurrent asynchronous invocations. To express concurrency, BPEL provides the activity. The invocation to each Web service will consist of two steps:



Page 4 of 4

  1. The activity is used for the asynchronous invocation
  2. The activity is used to wait for the callback

We use to group both activities. The two invocations differ only in the partner link name. We use AmericanAirlines for one and DeltaAirlines for the other:


 









portType="aln:FlightAvailabilityPT"
operation="FlightAvailability"
inputVariable="FlightDetails" />


portType="aln:FlightCallbackPT"
operation="FlightTicketCallback"
variable="FlightResponseAA" />



...

In this stage of the process, we have two ticket offers. In the next step, we have to select one. For this, we use the activity:


 





...
...





...



We have come to the final step of the BPEL business process—to return a reply to the client using the callback to the client:

 
portType="trv:ClientCallbackPT"
operation="ClientCallback"
inputVariable="TravelResponse" />




Conclusion

We have seen that BPEL is one of the most important cornerstones of SOA. It differs from common programming languages, such as Java, and is relatively easy to learn and use. Because BPEL has been designed specifically for definition of business processes, it provides good support for various specifics of business processes, such as support for long running transactions, compensation, event management, correlation, etc. BPEL is well suited for use with the Java EE platform, and many BPEL servers build on top of it. Java developers, particularly those who are involved in the development of enterprise applications and SOA, should therefore take a closer look at BPEL and start using the benefits it provides.

Author Bio

Dr Matjaz B. Juric is a professor at the University of Maribor. He is coauthor of the book Business Process Execution Language for Web Services, 2nd Edition, and the coauthor of the BPEL Cookbook, both published by Packt Publishing, and several other books, articles, and conference presentations. He is also the author of courses offered by BPELmentor.com, a training, mentoring, and consulting company.

---From www.Javaworld.com

Comment: A nice introduction about BPEL!