<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.

    #

    布什告別演說

     

    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 閱讀(320) | 評論 (0)編輯 收藏

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

    今天在公司測試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 閱讀(334) | 評論 (0)編輯 收藏

    用戶手冊


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

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

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

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

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

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

    寶寶三個月

    寶寶三個月,終于會爬了。

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

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

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

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



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

    opennms discovery流程

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

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

    opennmsDiscovery--fdb(bridge) table


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



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

    opennmsDiscovery--stp table

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

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

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

    opennmsDiscovery--cdp table

    opennms 對CDP表的探測流程:

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

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

    opennmsDiscovery--route table

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

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

    寶寶二個月

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

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

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

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

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

    女兒滿月

    2008.10.30 女兒滿月

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

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

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

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

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

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

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

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

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

    元數(shù)據(jù)

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

    當(dāng)討論元數(shù)據(jù)時,您將經(jīng)常看到幾個類似的術(shù)語,因此下面提供了一個小術(shù)語表來幫助您了解它們的差異:

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

     

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

    自 1.0 版以來在 Java 中一直存在對元數(shù)據(jù)的需求。Java 從來沒有提供記錄元數(shù)據(jù)的標(biāo)準(zhǔn)機(jī)制,因而我們編程人員找到了各種技巧和竅門使用任意的工具來添加元數(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ù)據(jù),但事實(shí)上您的確在添加元數(shù)據(jù)。上述方法存在的問題是它們都是解決同一問題的不同方法,但通用性不好。每一種方法都至少有一個缺點(diǎn)在新的元數(shù)據(jù)工具中得到了解決。

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

    列表中的其他一些方法可能看起來合理。使用 XML 支持文件似乎是個好主意,而事實(shí)上在許多情況下仍是個好主意。但對于我們使用 XML 文件的許多用途,例如指示類的哪一個方法應(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 語法為什么看起來與 @deprecated 標(biāo)記非常類似的原因(正如我們將在下一部分中看到的那樣)。

    批注

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

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

     

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

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

     

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

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

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

    內(nèi)置的批注

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

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

    @Override

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

    例如,以下代碼可能看起來很合理:

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

     

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

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

     

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

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

    @Deprecated

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

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

     

    The @Deprecated 批注看起來非常像 @deprecated 標(biāo)記,除了它出現(xiàn)在注釋外面的方法或類聲明的前面,并且有一個大寫字母 "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)記不同,您不能提供一個字符串來說明不贊成使用該方法并推薦一個替代的方法進(jìn)行使用。@Deprecated 批注提供的價(jià)值實(shí)際上比 @deprecated 標(biāo)記少。該批注唯一的優(yōu)勢是您可以通過編程的方式在運(yùn)行時檢測不贊成使用的項(xiàng)目。因此,傳統(tǒng)觀點(diǎn)認(rèn)為應(yīng)當(dāng)同時使用 @deprecated 標(biāo)記和 @Deprecated 標(biāo)記,一個用于文檔,另一個用于運(yùn)行時反射。

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

    @SuppressWarnings

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

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

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

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

     

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

    下面是使用 @SuppressWarnings 來取消 deprecation 警告的一個例子:

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

     

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

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

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

    您可以將單個數(shù)組參數(shù)中的任意數(shù)量的字符串值傳遞給批注,并在任何級別上放置批注。例如,以下示例代碼指示將取消整個類的 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 是否比前兩個批注更有用?絕對是這樣。不過,在 JDK 1.5.0 版本中還沒有完全支持該批注,如果您用 1.5.0 來嘗試它,那么它將類似無操作指令。調(diào)用 -Xlint:-deprecation 也沒有任何效果。Sun 沒有聲明什么時候?qū)⒃黾又С郑凳具@將在即將推出的一個 dot 版本中實(shí)現(xiàn)。

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

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

    My Links

    News

    留言簿(18)

    隨筆檔案

    相冊

    搜索

    最新評論

    閱讀排行榜

    主站蜘蛛池模板: 免费国产黄网站在线观看可以下载 | 毛片基地看看成人免费| 综合亚洲伊人午夜网| 日本高清免费网站| 国产成人1024精品免费| 亚洲精品一区二区三区四区乱码 | 高清永久免费观看| fc2免费人成在线视频| 2022国内精品免费福利视频| 国产黄片不卡免费| a毛片在线还看免费网站| 青柠影视在线观看免费高清 | 亚洲中文字幕久久精品蜜桃| 精品国产亚洲一区二区在线观看| 午夜亚洲国产成人不卡在线| 久久国产色AV免费看| 美女视频黄频a免费大全视频| 香港一级毛片免费看| 亚洲精品黄色视频在线观看免费资源| 国产精品美女久久久免费| 久久性生大片免费观看性| 永久在线观看免费视频| 久久久久久国产精品免费无码 | 一区二区免费在线观看| 亚洲日韩在线观看免费视频| 99久久婷婷免费国产综合精品| 在线成人精品国产区免费| 亚洲一区在线免费观看| 在线观看免费成人| 亚洲国产人成精品| 亚洲乱色熟女一区二区三区丝袜 | 天堂亚洲免费视频| 亚洲国产精品国自产拍AV| 国产免费牲交视频| 国产香蕉九九久久精品免费 | 日本免费一区二区久久人人澡| 四虎精品免费永久免费视频| 丁香花在线视频观看免费| 精品国产免费人成电影在线观看 | 午夜精品免费在线观看| 97人伦色伦成人免费视频|