<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    afunms

    My Software,My Dream—Forge a more perfect NMS product.

    #

    布什告別演說(shuō)

     

    THE PRESIDENT: Fellow citizens: For eight years, it has been my honor to serve as your President. The first decade of this new century has been a period of consequence — a time set apart. Tonight, with a thankful heart, I have asked for a final opportunity to share some thoughts on the journey that we have traveled together, and the future of our nation.

    Five days from now, the world will witness the vitality of American democracy. In a tradition dating back to our founding, the presidency will pass to a successor chosen by you, the American people. Standing on the steps of the Capitol will be a man whose history reflects the enduring promise of our land. This is a moment of hope and pride for our whole nation. And I join all Americans in offering best wishes to President-Elect Obama, his wife Michelle, and their two beautiful girls.

    Tonight I am filled with gratitude — to Vice President Cheney and members of my administration; to Laura, who brought joy to this house and love to my life; to our wonderful daughters, Barbara and Jenna; to my parents, whose examples have provided strength for a lifetime. And above all, I thank the American people for the trust you have given me. I thank you for the prayers that have lifted my spirits. And I thank you for the countless acts of courage, generosity, and grace that I have witnessed these past eight years.

    This evening, my thoughts return to the first night I addressed you from this house — September the 11th, 2001. That morning, terrorists took nearly 3,000 lives in the worst attack on America since Pearl Harbor. I remember standing in the rubble of the World Trade Center three days later, surrounded by rescuers who had been working around the clock. I remember talking to brave souls who charged through smoke-filled corridors at the Pentagon, and to husbands and wives whose loved ones became heroes aboard Flight 93. I remember Arlene Howard, who gave me her fallen son’s police shield as a reminder of all that was lost. And I still carry his badge.

    As the years passed, most Americans were able to return to life much as it had been before 9/11. But I never did. Every morning, I received a briefing on the threats to our nation. I vowed to do everything in my power to keep us safe.

    Over the past seven years, a new Department of Homeland Security has been created. The military, the intelligence community, and the FBI have been transformed. Our nation is equipped with new tools to monitor the terrorists’ movements, freeze their finances, and break up their plots. And with strong allies at our side, we have taken the fight to the terrorists and those who support them. Afghanistan has gone from a nation where the Taliban harbored al Qaeda and stoned women in the streets to a young democracy that is fighting terror and encouraging girls to go to school. Iraq has gone from a brutal dictatorship and a sworn enemy of America to an Arab democracy at the heart of the Middle East and a friend of the United States.

    There is legitimate debate about many of these decisions. But there can be little debate about the results. America has gone more than seven years without another terrorist attack on our soil. This is a tribute to those who toil night and day to keep us safe — law enforcement officers, intelligence analysts, homeland security and diplomatic personnel, and the men and women of the United States Armed Forces.

    Our nation is blessed to have citizens who volunteer to defend us in this time of danger. I have cherished meeting these selfless patriots and their families. And America owes you a debt of gratitude. And to all our men and women in uniform listening tonight: There has been no higher honor than serving as your Commander-in-Chief.

    The battles waged by our troops are part of a broader struggle between two dramatically different systems. Under one, a small band of fanatics demands total obedience to an oppressive ideology, condemns women to subservience, and marks unbelievers for murder. The other system is based on the conviction that freedom is the universal gift of Almighty God, and that liberty and justice light the path to peace.

    This is the belief that gave birth to our nation. And in the long run, advancing this belief is the only practical way to protect our citizens. When people live in freedom, they do not willingly choose leaders who pursue campaigns of terror. When people have hope in the future, they will not cede their lives to violence and extremism. So around the world, America is promoting human liberty, human rights, and human dignity. We’re standing with dissidents and young democracies, providing AIDS medicine to dying patients — to bring dying patients back to life, and sparing mothers and babies from malaria. And this great republic born alone in liberty is leading the world toward a new age when freedom belongs to all nations.

    For eight years, we’ve also strived to expand opportunity and hope here at home. Across our country, students are rising to meet higher standards in public schools. A new Medicare prescription drug benefit is bringing peace of mind to seniors and the disabled. Every taxpayer pays lower income taxes. The addicted and suffering are finding new hope through faith-based programs. Vulnerable human life is better protected. Funding for our veterans has nearly doubled. America’s air and water and lands are measurably cleaner. And the federal bench includes wise new members like Justice Sam Alito and Chief Justice John Roberts.

    When challenges to our prosperity emerged, we rose to meet them. Facing the prospect of a financial collapse, we took decisive measures to safeguard our economy. These are very tough times for hardworking families, but the toll would be far worse if we had not acted. All Americans are in this together. And together, with determination and hard work, we will restore our economy to the path of growth. We will show the world once again the resilience of America’s free enterprise system.

    Like all who have held this office before me, I have experienced setbacks. There are things I would do differently if given the chance. Yet I’ve always acted with the best interests of our country in mind. I have followed my conscience and done what I thought was right. You may not agree with some of the tough decisions I have made. But I hope you can agree that I was willing to make the tough decisions.

    The decades ahead will bring more hard choices for our country, and there are some guiding principles that should shape our course.

    While our nation is safer than it was seven years ago, the gravest threat to our people remains another terrorist attack. Our enemies are patient, and determined to strike again. America did nothing to seek or deserve this conflict. But we have been given solemn responsibilities, and we must meet them. We must resist complacency. We must keep our resolve. And we must never let down our guard.

    At the same time, we must continue to engage the world with confidence and clear purpose. In the face of threats from abroad, it can be tempting to seek comfort by turning inward. But we must reject isolationism and its companion, protectionism. Retreating behind our borders would only invite danger. In the 21st century, security and prosperity at home depend on the expansion of liberty abroad. If America does not lead the cause of freedom, that cause will not be led.

    As we address these challenges — and others we cannot foresee tonight — America must maintain our moral clarity. I’ve often spoken to you about good and evil, and this has made some uncomfortable. But good and evil are present in this world, and between the two of them there can be no compromise. Murdering the innocent to advance an ideology is wrong every time, everywhere. Freeing people from oppression and despair is eternally right. This nation must continue to speak out for justice and truth. We must always be willing to act in their defense — and to advance the cause of peace.

    President Thomas Jefferson once wrote, “I like the dreams of the future better than the history of the past.” As I leave the house he occupied two centuries ago, I share that optimism. America is a young country, full of vitality, constantly growing and renewing itself. And even in the toughest times, we lift our eyes to the broad horizon ahead.

    I have confidence in the promise of America because I know the character of our people. This is a nation that inspires immigrants to risk everything for the dream of freedom. This is a nation where citizens show calm in times of danger, and compassion in the face of suffering. We see examples of America’s character all around us. And Laura and I have invited some of them to join us in the White House this evening.

    We see America’s character in Dr. Tony Recasner, a principal who opened a new charter school from the ruins of Hurricane Katrina. We see it in Julio Medina, a former inmate who leads a faith-based program to help prisoners returning to society. We’ve seen it in Staff Sergeant Aubrey McDade, who charged into an ambush in Iraq and rescued three of his fellow Marines.

    We see America’s character in Bill Krissoff — a surgeon from California. His son, Nathan — a Marine — gave his life in Iraq. When I met Dr. Krissoff and his family, he delivered some surprising news: He told me he wanted to join the Navy Medical Corps in honor of his son. This good man was 60 years old — 18 years above the age limit. But his petition for a waiver was granted, and for the past year he has trained in battlefield medicine. Lieutenant Commander Krissoff could not be here tonight, because he will soon deploy to Iraq, where he will help save America’s wounded warriors — and uphold the legacy of his fallen son.

    In citizens like these, we see the best of our country - resilient and hopeful, caring and strong. These virtues give me an unshakable faith in America. We have faced danger and trial, and there’s more ahead. But with the courage of our people and confidence in our ideals, this great nation will never tire, never falter, and never fail.

    It has been the privilege of a lifetime to serve as your President. There have been good days and tough days. But every day I have been inspired by the greatness of our country, and uplifted by the goodness of our people. I have been blessed to represent this nation we love. And I will always be honored to carry a title that means more to me than any other - citizen of the United States of America.

    And so, my fellow Americans, for the final time: Good night. May God bless this house and our next President. And may God bless you and our wonderful country. Thank you. (Applause.) 

    2009.1.15 8:14 P.M. EST

    posted @ 2009-01-16 20:25 afunms 閱讀(318) | 評(píng)論 (0)編輯 收藏

    改進(jìn)后的發(fā)現(xiàn)結(jié)果

    今天在公司測(cè)試SourceView3.0發(fā)現(xiàn)程序,找出所有支持SNMP的設(shè)備以及它們的鏈路,
    包括服務(wù)器到交換機(jī)的鏈路:

    Discovery log:

    2009-01-15 14:09:44 - INFO - ----[SourceView3.0]Starting ----

    2009-01-15 14:09:45 - INFO - Parsing configuration file [struts-default.xml]

    2009-01-15 14:09:45 - INFO - Parsing configuration file [struts-plugin.xml]

    2009-01-15 14:09:45 - INFO - Parsing configuration file [struts.xml]

    2009-01-15 14:09:45 - INFO - Overriding property struts.i18n.reload - old value: false new value: true

    2009-01-15 14:10:45 - INFO - 新主機(jī)加入:

    1.路由器:ip=192.168.0.254,

     sysOid=1.3.6.1.4.1.9.1.110,

     sysName=C3640,

     community=cisco,

     symbol=cisco

    ---------------------

    2009-01-15 14:10:46 - INFO - 新子網(wǎng)加入:

    Subnet.2.addr[192.168.0.0],mask[255.255.255.0]

    2009-01-15 14:10:56 - INFO - 新主機(jī)加入:

    3.路由交換機(jī):ip=192.168.0.253,

     sysOid=1.3.6.1.4.1.9.1.633,

     sysName=3560,

     community=cisco,

     mac=00:19:55:d9:9c:80,

     symbol=cisco

    ---------------------

    2009-01-15 14:10:57 - INFO - 新鏈路加入:

    4.C3640[Ethernet0/1]<-->3560[Fa0/23],[route link](路由器到三層交換機(jī))

    2009-01-15 14:10:57 - INFO - 新子網(wǎng)加入:

    Subnet.5.addr[192.168.1.0],mask[255.255.255.0]

    2009-01-15 14:10:57 - INFO - 新子網(wǎng)加入:

    Subnet.6.addr[192.168.2.0],mask[255.255.255.128]

    2009-01-15 14:10:57 - INFO - 新子網(wǎng)加入:

    Subnet.7.addr[192.168.2.128],mask[255.255.255.240]

    2009-01-15 14:10:57 - INFO - 新子網(wǎng)加入:

    Subnet.8.addr[192.168.3.0],mask[255.255.255.0]

    2009-01-15 14:10:57 - INFO - 新子網(wǎng)加入:

    Subnet.9.addr[192.168.4.0],mask[255.255.255.0]

    2009-01-15 14:10:57 - INFO - 新子網(wǎng)加入:

    Subnet.10.addr[192.168.5.0],mask[255.255.255.0]

    2009-01-15 14:10:57 - INFO - 新子網(wǎng)加入:

    Subnet.11.addr[192.168.6.0],mask[255.255.255.0]

    2009-01-15 14:12:08 - INFO - 新主機(jī)加入:

    12.路由交換機(jī):ip=192.168.3.252,

     sysOid=1.3.6.1.4.1.2011.2.23.22,

     sysName=Quidway,

     community=cisco,

     mac=00:e0:fc:0c:9d:1b,

     symbol=huawei

    ---------------------

    2009-01-15 14:12:58 - INFO - 新主機(jī)加入:

    13.服務(wù)器:ip=192.168.2.133,

     sysOid=1.3.6.1.4.1.2.3.1.2.1.1.3,

     sysName=localhost,

     community=public,

     symbol=aix

    ---------------------

    2009-01-15 14:15:18 - INFO - 新主機(jī)加入:

    14.服務(wù)器:ip=192.168.2.18,

     sysOid=1.3.6.1.4.1.311.1.1.3.1.2,

     sysName=SOFTDEPT18,

     community=public,

     symbol=windows

    ---------------------

    2009-01-15 14:15:58 - INFO - ----discovering Layer 2 using the common method----

    2009-01-15 14:15:58 - INFO - 新鏈路加入:

    15.3560[Fa0/14]<-->localhost[en0; Product: PCI Ethernet Adapter (23100020) Man],[arp link](服務(wù)器到三層交換機(jī))

    2009-01-15 14:15:58 - INFO - find link from switch to the router or server:

    0.null,[arp link]

    2009-01-15 14:15:58 - INFO - find link from switch to the router or server:

    0.null,[arp link]

    2009-01-15 14:15:58 - INFO - find link from switch to the router or server:

    0.null,[arp link]

    2009-01-15 14:15:58 - INFO - find link from switch to the router or server:

    0.null,[arp link]

    2009-01-15 14:15:58 - INFO - find link from switch to the router or server:

    15.3560[Fa0/14]<-->localhost[en0; Product: PCI Ethernet Adapter (23100020) Man],[arp link]

    2009-01-15 14:15:58 - INFO - find link from switch to the router or server:

    0.null,[arp link]

    2009-01-15 14:15:58 - INFO - 新鏈路加入:

    16.3560[Fa0/18]<-->SOFTDEPT18[Attansic L2 Fast Ethernet 10/100 Base-T Controller],[arp link] (服務(wù)器到三層交換機(jī))

    2009-01-15 14:15:58 - INFO - find link from switch to the router or server:

    16.3560[Fa0/18]<-->SOFTDEPT18[Attansic L2 Fast Ethernet 10/100 Base-T Controller],[arp link]

    2009-01-15 14:15:58 - INFO - 新鏈路加入:

    17.3560[Fa0/7]<-->Quidway[Vlan-interface7],[arp link] (交換機(jī)到三層交換機(jī))

    2009-01-15 14:15:58 - INFO - find link from switch to the router or server:

    0.null,[arp link]

    2009-01-15 14:15:58 - INFO - find link from switch to the router or server:

    0.null,[arp link]

    2009-01-15 14:15:59 - INFO - ========全部發(fā)現(xiàn)完成了========

    posted @ 2009-01-15 22:18 afunms 閱讀(326) | 評(píng)論 (0)編輯 收藏

    用戶手冊(cè)


    完成用戶手冊(cè),標(biāo)志我們的軟件向產(chǎn)品化、標(biāo)準(zhǔn)化又邁進(jìn)了一步。
    希望2009年能把3.0做得更好。

    posted @ 2009-01-01 09:07 afunms 閱讀(125) | 評(píng)論 (0)編輯 收藏

    SV2.0實(shí)施案例3--惠州市ZFW

    背景:
             用戶環(huán)境比較簡(jiǎn)單,三臺(tái)路由器和一臺(tái)交換機(jī)。

    問(wèn)題總結(jié):        
             1.長(zhǎng)時(shí)間開(kāi)著拓?fù)鋱D,內(nèi)存只增不減;
             2.要一直開(kāi)著IE才能及時(shí)看到報(bào)警,3.0準(zhǔn)備開(kāi)發(fā)一個(gè)windows客戶端;
             3.Tomcat使用了8080端口與Oracle使用的HTTP服務(wù)器端口沖突;
             4.添加鏈路時(shí),如果有一個(gè)接口是VLAN的,會(huì)有出錯(cuò)。

    posted @ 2008-12-30 15:27 afunms 閱讀(121) | 評(píng)論 (0)編輯 收藏

    寶寶三個(gè)月

    寶寶三個(gè)月,終于會(huì)爬了。

    posted @ 2008-12-29 17:18 afunms 閱讀(110) | 評(píng)論 (0)編輯 收藏

    SV2.0實(shí)施案例2--潮州市ZFW

    背景:
            
    用戶環(huán)境比較簡(jiǎn)單,一臺(tái)路由器、3臺(tái)windows2003服務(wù)器和一個(gè)Tomcat。

    問(wèn)題總結(jié):         
             1.報(bào)表的數(shù)據(jù)存貯結(jié)構(gòu)設(shè)計(jì)不好,導(dǎo)致程序復(fù)雜,容易出bug,而出了bug也不容易調(diào)試;
             2.在這種相對(duì)簡(jiǎn)單的網(wǎng)絡(luò)環(huán)境中,拓?fù)湓侔l(fā)現(xiàn)還是很有用的,在3.0要實(shí)現(xiàn)這個(gè)功能;
             3.應(yīng)該支持在輪詢時(shí)的發(fā)現(xiàn),而不是要手動(dòng)更改配置文件,這個(gè)在3.0中要改進(jìn);
             4.報(bào)警配置經(jīng)過(guò)上次的修改,現(xiàn)在已經(jīng)比較好了,這是進(jìn)步。



    posted @ 2008-12-18 10:28 afunms 閱讀(123) | 評(píng)論 (0)編輯 收藏

    opennms discovery流程

    opennms的發(fā)現(xiàn)流程,基本看明白了:

    posted @ 2008-12-11 08:57 afunms 閱讀(301) | 評(píng)論 (0)編輯 收藏

    opennmsDiscovery--fdb(bridge) table


    基于fdb表的發(fā)現(xiàn),是二層發(fā)現(xiàn)最關(guān)鍵的部分。opennms這部分寫(xiě)得很好,給我很多啟發(fā)。
    另,1) 對(duì)backBoneBirdgePort的判定:對(duì)已經(jīng)確定有鏈路的port為backBoneBirdgePort
            2) 對(duì)bridgeIdentifier的判定:bridgeMac和fdb表中status=4的為bridgeIdentifier



    posted @ 2008-12-08 13:41 afunms 閱讀(364) | 評(píng)論 (0)編輯 收藏

    opennmsDiscovery--stp table

    很可惜,沒(méi)看明白o(hù)pennms關(guān)于stp發(fā)現(xiàn)這塊。我覺(jué)得沒(méi)這么復(fù)雜吧?

    還好,我自己也能把基于STP的發(fā)現(xiàn)做出來(lái)。

    posted @ 2008-12-07 13:17 afunms 閱讀(143) | 評(píng)論 (0)編輯 收藏

    opennmsDiscovery--cdp table

    opennms 對(duì)CDP表的探測(cè)流程:

    opennms對(duì)鏈路的發(fā)現(xiàn)全部在DiscoveryLink這個(gè)類里。由于opennms對(duì)節(jié)點(diǎn)的發(fā)現(xiàn)沒(méi)有確定節(jié)點(diǎn)
    的設(shè)備類型,導(dǎo)致發(fā)現(xiàn)鏈路更加復(fù)雜。

    posted @ 2008-12-05 13:13 afunms 閱讀(221) | 評(píng)論 (0)編輯 收藏

    opennmsDiscovery--route table

    opennms拓?fù)浒l(fā)現(xiàn)模塊中,對(duì)路由表的探測(cè)流程如下:

    posted @ 2008-12-03 15:51 afunms 閱讀(181) | 評(píng)論 (0)編輯 收藏

    寶寶二個(gè)月

    posted @ 2008-11-30 17:26 afunms 閱讀(101) | 評(píng)論 (0)編輯 收藏

    SV2.0實(shí)施案例1--廣東省JJ

    背景:
            客戶的WebSphere經(jīng)常出問(wèn)題,部署網(wǎng)管主要用于WebSphere的監(jiān)控。

    問(wèn)題總結(jié):
            1. 對(duì)中間件的監(jiān)控做得還不夠細(xì),可能我們以前的重點(diǎn)都放在對(duì)設(shè)備的監(jiān)控。
            2. 對(duì)中間件的監(jiān)控可能對(duì)中間件性能造成影響,是否考慮改變監(jiān)控方式?

    posted @ 2008-11-05 09:15 afunms 閱讀(125) | 評(píng)論 (0)編輯 收藏

    女兒滿月

    2008.10.30 女兒滿月

    posted @ 2008-10-30 10:00 afunms 閱讀(82) | 評(píng)論 (0)編輯 收藏

    充分利用Java元數(shù)據(jù)

    http://www.oracle.com/technology/global/cn/pub/articles/hunter_meta.html

    了解如何使用 J2SE 5.0 中提供的元數(shù)據(jù)批注

    最新的 J2SE 5.0 版本(也以代號(hào) "Tiger" 著稱)為 Java 語(yǔ)言引進(jìn)了許多變化,這些變化旨在使 Java 編程更有表現(xiàn)力、更加開(kāi)發(fā)人員友好和更安全。我在 2003 年 9 月的一篇題目為“Java 即將發(fā)生巨大變化”的文章中介紹了許多 Java 新特性。我沒(méi)有介紹的一個(gè)重大的變化 — 那時(shí)還沒(méi)有完整概述它 — 是 Java 的元數(shù)據(jù)工具。從本文開(kāi)始,在一個(gè)新的分為四個(gè)部分的文章系列中,我將從一年前離開(kāi)的地方繼續(xù)向您顯示如何充分利用 Java 的元數(shù)據(jù)。

    在第一篇文章中,我將說(shuō)明元數(shù)據(jù)的用途并演示如何使用在核心的 J2SE 資料庫(kù)中提供的元數(shù)據(jù)批注。

    在第二篇文章中,我將顯示如何編寫(xiě)您自己的批注(首先編寫(xiě)類似 @Copyright 的簡(jiǎn)單的批注,然后看看與核心語(yǔ)言中內(nèi)置的那些批注類似的更高級(jí)的批注)。

    在第三篇文章中,我將演示工具如何在構(gòu)建時(shí)使用批注(創(chuàng)建新的源文件或支持文件)以及程序如何在運(yùn)行時(shí)使用批注(以改變代碼的行為)。

    在最后的第四篇文章中,我將介紹如何利用在 JSR-181 下開(kāi)發(fā)的標(biāo)準(zhǔn)元數(shù)據(jù)批注的幫助使編輯和部署 Web 服務(wù)在未來(lái)變得更容易(Oracle 是 JSR-181 的專家組的成員,并且是在開(kāi)發(fā)工具中增加對(duì)設(shè)計(jì)時(shí)元數(shù)據(jù)的支持的一個(gè)積極的擁護(hù)者。)

    元數(shù)據(jù)

    我承認(rèn)當(dāng)我第一次看到 JSR-175 的提案“用于 Java 編程語(yǔ)言的元數(shù)據(jù)工具”(在 2004 年 9 月發(fā)布;Oracle 也是該專家組的成員)時(shí),我預(yù)測(cè)它將創(chuàng)建必須放在 JAR 的 META-INF 目錄下的另一個(gè)屬性文件,或者必須與 JAR 捆綁的另一個(gè) XML 部署描述符。幸運(yùn)的是,這不是元數(shù)據(jù)要做的。事實(shí)上,它正好相反。Java 的新的元數(shù)據(jù)工具提供了從 Java 代碼內(nèi)部批注 Java 代碼的一種標(biāo)準(zhǔn)方式。它使您能夠在要說(shuō)明的元素的旁邊放置描述性的元數(shù)據(jù)。

    當(dāng)討論元數(shù)據(jù)時(shí),您將經(jīng)??吹綆讉€(gè)類似的術(shù)語(yǔ),因此下面提供了一個(gè)小術(shù)語(yǔ)表來(lái)幫助您了解它們的差異:

    術(shù)語(yǔ) 定義
    元數(shù)據(jù) 關(guān)于數(shù)據(jù)的數(shù)據(jù)。JSR-175 的目標(biāo)是在 Java 語(yǔ)言中提供元數(shù)據(jù)工具。
    批注 一種特殊的 Java 結(jié)構(gòu),用來(lái)修飾類、方法、字段、參數(shù)、變量、構(gòu)造器或包。它是 JSR-175 選擇用來(lái)提供元數(shù)據(jù)的工具。
    批注類型 具有特殊實(shí)施的各種命名批注
    屬性 由批注指定的一個(gè)特殊的元數(shù)據(jù)項(xiàng)目。有時(shí)可以和批注交替使用

     

    例如:富士蘋(píng)果有一個(gè)屬性:它是紅色的。假定有一個(gè) FujiApple 類,您可以使用 @Color 批注類型的一個(gè)批注來(lái)指定它的顏色。通過(guò)這么做,您就提供了關(guān)于蘋(píng)果的元數(shù)據(jù)。

    自 1.0 版以來(lái)在 Java 中一直存在對(duì)元數(shù)據(jù)的需求。Java 從來(lái)沒(méi)有提供記錄元數(shù)據(jù)的標(biāo)準(zhǔn)機(jī)制,因而我們編程人員找到了各種技巧和竅門(mén)使用任意的工具來(lái)添加元數(shù)據(jù)。您看到在 J2SE 1.4 和更低版本中使用元數(shù)據(jù)的一些地方有:

    • transient 關(guān)鍵字
    • Serializable 標(biāo)記接口
    • SingleThreadModel servlet 接口
    • web.xml 部署描述符內(nèi)部的元素
    • META-INF/MANIFEST.MF 文件
    • BeanInfo 接口
    • @deprecated Javadoc 注釋
    • 所有的 XDoclet Javadoc 標(biāo)記。

     

    當(dāng)使用這些技巧時(shí),您可能沒(méi)有想到您正在添加元數(shù)據(jù),但事實(shí)上您的確在添加元數(shù)據(jù)。上述方法存在的問(wèn)題是它們都是解決同一問(wèn)題的不同方法,但通用性不好。每一種方法都至少有一個(gè)缺點(diǎn)在新的元數(shù)據(jù)工具中得到了解決。

    對(duì)于這個(gè)列表中的一些方法,局限很明顯。使用關(guān)鍵字不能伸縮;您不能使用用戶自己定義的關(guān)鍵字。標(biāo)記接口沒(méi)有提供除它們的存在性之外的任何信息(即,它們沒(méi)有帶參數(shù)),并且它們只能處理類,而不能處理字段或方法或包。

    列表中的其他一些方法可能看起來(lái)合理。使用 XML 支持文件似乎是個(gè)好主意,而事實(shí)上在許多情況下仍是個(gè)好主意。但對(duì)于我們使用 XML 文件的許多用途,例如指示類的哪一個(gè)方法應(yīng)當(dāng)看作是 web 服務(wù),在 Java 代碼內(nèi)部將規(guī)則直接放在方法的旁邊將更加高效。利用元數(shù)據(jù),您可以使 XML 描述符文件僅包含與部署相關(guān)的決策。

    該列表中可能最高效的元數(shù)據(jù)的用法是 @deprecated Javadoc 注釋和在其鏡像中創(chuàng)建的 XDoclet 標(biāo)記。這可能是 JSR-175 語(yǔ)法為什么看起來(lái)與 @deprecated 標(biāo)記非常類似的原因(正如我們將在下一部分中看到的那樣)。

    批注

    批注可以很容易地附加到代碼結(jié)構(gòu)上。您可以寫(xiě)一個(gè) "at" 符號(hào) (@),然后是批注類型名稱,并將批注直接放在要批注的項(xiàng)目前面。下面是一個(gè)簡(jiǎn)單的例子:

    import javax.jws.WebService;
    import javax.jws.WebMethod;
    @WebService
    public class HelloWorldService {
    @WebMethod
    public String helloWorld() {
    return "Hello World!";
    }
    }
    

     

    當(dāng)部署在正確的環(huán)境中時(shí),增加 @WebService@WebMethod 批注將指示 web 服務(wù)環(huán)境將該類變?yōu)?web 服務(wù)。

    您可以批注方法、類、字段、參數(shù)、變量、構(gòu)造器甚至整個(gè)包(利用一個(gè)特殊的外部 package-info.java 文件)。批注可以在括號(hào)內(nèi)帶任意數(shù)量的命名參數(shù)。下面是使用批注進(jìn)行修飾以創(chuàng)建 web 服務(wù)的一個(gè)更高級(jí)的示例類。它包含了一個(gè)理論上的 JNDI 環(huán)境變量查找:

    @WebService(
    name = "PingService",
    targetNamespace="http://acme.com/ping"
    )
    @SOAPBinding(
    style=SOAPBinding.Style.RPC,
    use=SOAPBinding.Use.LITERAL
    )
    public class Ping {
    public @env double level = 500.0;  // JNDI lookup
    public @WebMethod(operationName = "Foo") {
    void foo() { }
    }
    }
    

     

    這個(gè)例子顯示了附加到類、變量和方法(在類上實(shí)際上有兩個(gè)方法)上的批注。@env 批注沒(méi)有任何參數(shù),因此它不需要括號(hào)。其他批注有一個(gè)或更多的命名參數(shù)。

    當(dāng)創(chuàng)建新的批注類型時(shí),您將限定允許哪些參數(shù)名以及它們的類型。批注接受的類型是嚴(yán)格限定的;它們只可以是基本類型、String、Class、枚舉類型、批注類型和前面這些類型的數(shù)組。傳遞的參數(shù)必須始終是非空的編譯時(shí)常量。

    要了解本示例中顯示的批注有什么效果必須等到本系列的第四篇文章。讓我們開(kāi)始看看 J2SE 5.0 提供的簡(jiǎn)單的批注類型:@Override、@Deprecated@SuppressWarnings。

    內(nèi)置的批注

    當(dāng)我們看這三種標(biāo)準(zhǔn)的用戶級(jí)批注時(shí),必須考慮:在可以提供的所有可能的批注類型中,為什么 Tiger 恰恰提供三種?原因是提供大量的標(biāo)準(zhǔn)批注并不是目標(biāo)所在。

    JSR-175 的宗旨嚴(yán)格規(guī)定了它是要定義一個(gè)元數(shù)據(jù)工具。編寫(xiě)自定義批注類型的任務(wù)留給了編程人員,而編寫(xiě)一組標(biāo)準(zhǔn)的批注類型的任務(wù)留給了其他 JSR。例如,有一個(gè)新的名稱為“Java 平臺(tái)的通用批注”的 JSR-250,其宗旨是“為 J2SE 和 J2EE 平臺(tái)中的通用的語(yǔ)義概念開(kāi)發(fā)適用于各種技術(shù)的批注”。JSR-250 計(jì)劃在 2005 年春天的某個(gè)時(shí)候在 javax.annotations 程序包中提供它的標(biāo)準(zhǔn)的批注集。還有之前提到的 JSR-181,它將使得在 J2EE 容器中編寫(xiě) Web 服務(wù)變得更容易(我們將在本系列中的第四篇文章中進(jìn)行介紹)。事實(shí)上,大多數(shù)新的企業(yè) JSR(從 Servlets 2.5 到 EJB 3.0 到 JDBC 4.0)都在考慮批注可以提供哪些優(yōu)點(diǎn)。

    @Override

    第一個(gè) J2SE 標(biāo)準(zhǔn)批注 @Override 使您能夠在代碼中增加新的可選的編譯器檢查。它在方法中存在表示該方法用于覆蓋父類中的方法。如果編譯器檢測(cè)到該方法實(shí)際上沒(méi)有覆蓋任何東西,那么將出現(xiàn)編譯錯(cuò)誤。經(jīng)常使用,@Override 可以幫助您避免當(dāng)方法標(biāo)記沒(méi)有完全匹配時(shí) — 當(dāng)多態(tài)變?yōu)椋梢苑Q之為)“單態(tài)” ("unimorphism") 時(shí) — 將得到的細(xì)微的 bug。

    例如,以下代碼可能看起來(lái)很合理:

    public class OverrideExample {
    @Override
    public boolean equals(OverrideExample obj) {
    return false;
    }
    }
    

     

    然而,當(dāng)您編譯 OverrideExample.java 時(shí),您將得到一個(gè)錯(cuò)誤,該錯(cuò)誤指示一個(gè)細(xì)微的問(wèn)題。

    % javac OverrideExample.java
    javac OverrideExample.java
    OverrideExample.java:3: method does not override a method from its superclass
    @Override
    ^
    1 error
    

     

    通過(guò)提示編譯器您希望進(jìn)行覆蓋,使編譯器能夠捕獲到 equals() 方法帶 Object 類型參數(shù)的細(xì)微 bug。

    @Override 批注在實(shí)際中有用嗎?只有當(dāng)您是一個(gè)愿意用 @Override 來(lái)標(biāo)記每一個(gè)覆蓋方法的非常嚴(yán)謹(jǐn)?shù)木幊倘藛T時(shí)才有用。我們中有多少人能聲稱可以達(dá)到這種嚴(yán)謹(jǐn)程度?我認(rèn)為我不能。可能 IDE 將找到一種方式來(lái)鼓勵(lì)或強(qiáng)制使用 @Override。

    @Deprecated

    第二種標(biāo)準(zhǔn)批注是 @Deprecated,它與 @deprecated Javadoc 標(biāo)記有幾乎相同的行為。您可以用類似以下的方式來(lái)使用它:

    public class DeprecatedExample {
    @Deprecated
    public static void badMethod() {
    }
    }
    public class DeprecatedUser {
    public static void main(String[] args) {
    DeprecatedExample.badMethod();
    }
    }
    

     

    The @Deprecated 批注看起來(lái)非常像 @deprecated 標(biāo)記,除了它出現(xiàn)在注釋外面的方法或類聲明的前面,并且有一個(gè)大寫(xiě)字母 "D"。如果您試圖編譯上面的代碼,javac 將產(chǎn)生警告:

    % javac Deprecated*.java
    Note:DeprecatedUser.java uses or overrides a deprecated API.
    Note:Recompile with -Xlint:deprecation for details.
    1 error
    

     

    如果您遵循警告的建議并用 -Xlint:deprecation 進(jìn)行編譯,那么您將得到關(guān)于警告的詳細(xì)信息:

    % javac -Xlint:deprecation
    DeprecatedUser.java:3: warning: [deprecation] badMethod() in DeprecatedExample
    has been deprecated
    DeprecatedExample.badMethod();
    

     

    @Deprecated 批注比 @Override 更有用嗎?我不這么認(rèn)為。該批注不支持任何參數(shù),因此與 Javadoc 標(biāo)記不同,您不能提供一個(gè)字符串來(lái)說(shuō)明不贊成使用該方法并推薦一個(gè)替代的方法進(jìn)行使用。@Deprecated 批注提供的價(jià)值實(shí)際上比 @deprecated 標(biāo)記少。該批注唯一的優(yōu)勢(shì)是您可以通過(guò)編程的方式在運(yùn)行時(shí)檢測(cè)不贊成使用的項(xiàng)目。因此,傳統(tǒng)觀點(diǎn)認(rèn)為應(yīng)當(dāng)同時(shí)使用 @deprecated 標(biāo)記和 @Deprecated 標(biāo)記,一個(gè)用于文檔,另一個(gè)用于運(yùn)行時(shí)反射。

    我覺(jué)得很不幸 JSR-175 沒(méi)有選擇對(duì) @Deprecated 做更多的工作。至少該批注應(yīng)當(dāng)復(fù)制 @deprecated 標(biāo)記的功能,包含一個(gè)字符串說(shuō)明,從而編譯器可以將其與“不贊成使用” (Deprecation) 警告一起輸出。利用額外的參數(shù),@Deprecated 還可以接收 "isError" 布爾類型參數(shù),以指示是否完全不鼓勵(lì)使用該方法或者使用它將被認(rèn)為是編譯錯(cuò)誤(利用解釋錯(cuò)誤原因的清楚的自定義說(shuō)明來(lái)進(jìn)行完善)。查看 C# 的示例 1 找到屬性 [Obsolete],該屬性正好實(shí)現(xiàn)了這一點(diǎn),它被證明非常有用。

    @SuppressWarnings

    J2SE 提供的最后一個(gè)批注是 @SuppressWarnings。該批注的作用是給編譯器一條指令,告訴它對(duì)被批注的代碼元素內(nèi)部的某些警告保持靜默。

    一點(diǎn)背景:J2SE 5.0 為 Java 語(yǔ)言增加了幾個(gè)新的特性,并且和它們一起增加了許多新的警告并承諾在將來(lái)增加更多的警告。您可以為 "javac" 增加 -Xlint 參數(shù)來(lái)控制是否報(bào)告這些警告(如上面的 @Deprecated 部分所示)。

    默認(rèn)情況下,Sun 編譯器以簡(jiǎn)單的兩行的形式輸出警告。通過(guò)添加 -Xlint:keyword 標(biāo)記(例如 -Xlint:finally),您可以獲得關(guān)鍵字類型錯(cuò)誤的完整說(shuō)明。通過(guò)在關(guān)鍵字前面添加一個(gè)破折號(hào),寫(xiě)為 -Xlint:-keyword,您可以取消警告。(-Xlint 支持的關(guān)鍵字的完整列表可以在 javac 文檔頁(yè)面上找到。)下面是一個(gè)清單:

    關(guān)鍵字 用途
    deprecation 使用了不贊成使用的類或方法時(shí)的警告
    unchecked 執(zhí)行了未檢查的轉(zhuǎn)換時(shí)的警告,例如當(dāng)使用集合時(shí)沒(méi)有用泛型 (Generics) 來(lái)指定集合保存的類型。
    fallthrough 當(dāng) Switch 程序塊直接通往下一種情況而沒(méi)有 Break 時(shí)的警告。
    path 在類路徑、源文件路徑等中有不存在的路徑時(shí)的警告。
    serial 當(dāng)在可序列化的類上缺少 serialVersionUID 定義時(shí)的警告。
    finally 任何 finally 子句不能正常完成時(shí)的警告。
    all 關(guān)于以上所有情況的警告。

     

    @SuppressWarnings 批注允許您選擇性地取消特定代碼段(即,類或方法)中的警告。其中的想法是當(dāng)您看到警告時(shí),您將調(diào)查它,如果您確定它不是問(wèn)題,您就可以添加一個(gè) @SuppressWarnings 批注,以使您不會(huì)再看到警告。雖然它聽(tīng)起來(lái)似乎會(huì)屏蔽潛在的錯(cuò)誤,但實(shí)際上它將提高代碼安全性,因?yàn)樗鼘⒎乐鼓鷮?duì)警告無(wú)動(dòng)于衷 — 您看到的每一個(gè)警告都將值得注意。

    下面是使用 @SuppressWarnings 來(lái)取消 deprecation 警告的一個(gè)例子:

    public class DeprecatedExample2 {
    @Deprecated
    public static void foo() {
    }
    }
    public class DeprecatedUser2 {
    @SuppressWarnings(value={"deprecation"})
    public static void main(String[] args) {
    DeprecatedExample2.foo();
    }
    }
    

     

    @SuppressWarnings 批注接收一個(gè) "value" 變量,該變量是一個(gè)字符串?dāng)?shù)組,它指示將取消的警告。合法字符串的集合隨編譯器而變化,但在 JDK 上,可以傳遞給 -Xlint 的是相同的關(guān)鍵字集合(非常方便)。并且要求編譯器忽略任何它們不能識(shí)別的關(guān)鍵字,這在您使用一些不同的編譯器時(shí)非常方便。

    因?yàn)?@SuppressWarnings 批注僅接收一個(gè)參數(shù),并為該參數(shù)使用了特殊的名稱 "value",所以您可以選擇省略 value=,作為一種方便的縮寫(xiě):

    public class DeprecatedUser2 {
      @SuppressWarnings({"deprecation"})
    public static void main(String[] args) {
        DeprecatedExample2.foo();
      }
    }

    您可以將單個(gè)數(shù)組參數(shù)中的任意數(shù)量的字符串值傳遞給批注,并在任何級(jí)別上放置批注。例如,以下示例代碼指示將取消整個(gè)類的 deprecation 警告,而僅在 main() 方法代碼內(nèi)取消 unchecked 和 fallthrough 警告:

    import java.util.*;

    @SuppressWarnings({"deprecation"})
    public class NonGenerics {

      @SuppressWarnings({"unchecked","fallthrough"})
    public static void main(String[] args) {
        Runtime.runFinalizersOnExit();

        List list = new ArrayList();
        list.add("foo");
      }

      public static void foo() {
        List list = new ArrayList();
        list.add("foo");
      }
    }

    @SuppressWarnings 是否比前兩個(gè)批注更有用?絕對(duì)是這樣。不過(guò),在 JDK 1.5.0 版本中還沒(méi)有完全支持該批注,如果您用 1.5.0 來(lái)嘗試它,那么它將類似無(wú)操作指令。調(diào)用 -Xlint:-deprecation 也沒(méi)有任何效果。Sun 沒(méi)有聲明什么時(shí)候?qū)⒃黾又С郑凳具@將在即將推出的一個(gè) dot 版本中實(shí)現(xiàn)。

    posted @ 2008-10-01 14:12 afunms 閱讀(269) | 評(píng)論 (0)編輯 收藏

    僅列出標(biāo)題
    共25頁(yè): 上一頁(yè) 1 2 3 4 5 6 7 8 9 下一頁(yè) Last 

    My Links

    News

    留言簿(18)

    隨筆檔案

    相冊(cè)

    搜索

    最新評(píng)論

    閱讀排行榜

    主站蜘蛛池模板: 国产在线观看麻豆91精品免费| 亚洲色成人中文字幕网站| 亚洲中字慕日产2020| 亚洲免费观看视频| 亚洲尤码不卡AV麻豆| 一区在线免费观看| 亚洲国产成人精品女人久久久| 亚洲av无码片vr一区二区三区| 最近中文字幕免费mv视频7| 亚洲一区精品视频在线| 国产成人福利免费视频| 久久综合亚洲色HEZYO社区| 久久国产精品免费看| 好看的亚洲黄色经典| 中文字幕视频在线免费观看| 亚洲综合av永久无码精品一区二区| 人妻巨大乳hd免费看| 亚洲精品成人片在线观看| 免费国产va在线观看| 亚洲福利视频一区二区| 免费无遮挡无码视频在线观看| 日产国产精品亚洲系列| 理论片在线观看免费| 亚洲A∨午夜成人片精品网站| 日韩在线观看视频免费| 亚洲精品成人网久久久久久| 国产精品hd免费观看| 亚洲中文字幕第一页在线| 99麻豆久久久国产精品免费 | 久久精品国产亚洲Aⅴ香蕉| 一级中文字幕乱码免费| 亚洲午夜精品一级在线播放放| 免费又黄又爽又猛大片午夜| 亚洲精品成人在线| 一个人看的免费观看日本视频www| 久久久精品国产亚洲成人满18免费网站 | 久久丫精品国产亚洲av不卡 | 国产男女性潮高清免费网站| 日本亚洲中午字幕乱码 | 免费无码午夜福利片69| 亚洲午夜久久久影院伊人|