public aspect TraceAspect{
private Logger _logger = Logger.getLogger("trace");
pointcut traceMethods(): execution(* *.*(..))&&!within(TraceAsptect);
before() : traceMethods(){
Signature sig = thisJoinPointStaticPart.getSignature();
_logger.logp(Level.INFO, sig.getDeclaringType().getName(), sig.getName(), "Entering");
}
}
What’s wrong with conventional logging ?
When a new module is added to the system, all of its methods that need logging must be instrumented. Such instrumentation is invasive, causing the tangling of the core concerns with the logging concern. Further, if you ever happen to change the logging toolkit to a different API, you need to revisit every logging statement and modify it.
Consistency is the single most important requirement of logging. It means that if the logging specification requires that certain kinds of operations be logged, then the implementation must log every invocation of those operations. When things go wrong in a system, doubting the logging consistency is probably the last thing you want to do. Missed logging calls can make output hard to understand and sometimes useless. Achieving consistency using conventional logging is a lofty goal, and while systems can attain it initially, it requires continuing vigilance to keep it so. For example, if you add new classes to the system or new methods in existing classes, you must ensure that they implement logging that matches the current logging strategy.
The beauty of AspectJ-based logging
The limitations are not a result of the logging APIs or their implementations; rather, they stem from the fundamental limitations of objectoriented programming, which require embedding the logging invocations in each module. AOP and AspectJ overcome those limitations. AspectJ easily implements the invocation of logging statements from all the log points. The beauty is that you do not need to actually instrument any log points; writing an aspect does it automatically. Further, since there is a central place to control logging operations, you achieve consistency easily.
The most fundamental difference between conventional logging and AspectJbased logging is modularization of the logging concern. Instead of writing modules that implement core concepts in addition to invoking logging operations, with AspectJ you write a few aspects that advise the execution of the operations in the core modules to perform the logging. That way, the core modules do not carry any logging-related code. By modularizing, you separate the logging concern
from the core concerns.
With AspectJ-based logging, the logger aspect separates the core modules and the logger object. Instead of the core modules’ embedding the log() method invocations in their source code, the logger aspect weaves the logging invocations into the core modules when they are needed. AspectJ-based logging reverses the dependency between the core modules and the logger; it is the aspect that encodes how the operations in the core modules are logged instead
of each core module deciding for itself.
posted @
2005-08-29 10:52 Dave 閱讀(815) |
評論 (2) |
編輯 收藏
Eclipse 運行命令行參數大全
包括英文版本和中文版本兩種的說明, 特別需要值得一提的是那個 -nl 參數, 可以指定程序啟動時所使用的語言. 例如:
eclipse -nl en_US
將啟動英文語言, 這個特性在安裝了國際化語言包以后特別有用, 可以方便的切換各個語言的版本. 注意 IBM WSAD v5.1 也支持這個功能.
運行 Eclipse
將 Eclipse 驅動程序安裝(解壓縮)到某個目錄(例如,c:\eclipse)中之后,通過運行頂級安裝目錄中的 Eclipse 可執行文件來啟動"工作臺"。在 Windows 系統上,該可執行文件稱為 eclipse.exe,而在 Linux 系統上稱為 eclipse。注意:下列討論描述 Windows 系統上的設置。Linux 上的設置是相似的。
如果您沒有另行指定,則平臺將缺省工作區目錄創建為可執行文件的兄弟目錄(例如 c:\eclipse\workspace)。此工作區目錄用作項目的缺省內容區,還用于保存任何必需的元數據。要進行共享安裝或多工作區安裝,應明確指出工作區的位置而不是使用缺省值。有兩種控制工作區位置的方法:使用當前工作目錄或使用 -data 命令行自變量。
將工作區位置設置為在當前工作目錄內
在此方案中,工作區位置將是當前工作目錄中稱為 workspace 的目錄。
實現此目的最容易的方法可能是使用下列步驟來創建快捷方式:
導航到 Windows 資源管理器中的 eclipse.exe 并使用右鍵拖動來創建 eclipse.exe 的快捷方式。
編輯快捷方式的屬性,以使啟動位置:字段標識工作區位置的父目錄(例如,c:\users\robert)。
關閉屬性對話框并雙擊快捷方式(如果提供的目錄為 c:\users\robert,則工作區位置將為 c:\users\robert\workspace)。
當然,您也可以使用命令提示符(通過將目錄切換為工作區父目錄然后運行 eclipse.exe)來獲得同樣的效果。
使用 -data 設置工作區的特定位置
要使用 -data 命令行自變量,只要將 -data your_workspace_location(例如,-data c:\users\robert\myworkspace)添加至快捷方式屬性中的目標字段或顯式地將它包括在命令行上。
使用 -vm 設置 java VM
建議顯式指定在運行 Eclipse 時要使用哪個 Java VM。使用 -vm 命令行自變量(例如,-vm c:\jre\bin\javaw.exe)可以實現此目的。如果不使用 -vm,則 Eclipse 將使用在 O/S 路徑上找到的一個 Java VM。當安裝其它產品時,它們可更改您的路徑,導致在下一次啟動 Eclipse 時使用另一 Java VM。
運行 Eclipse 中的高級主題
Eclipse 可執行文件及平臺本身提供了人們感興趣的開發或調試 Eclipse 各部件的許多執行選項。運行 Eclipse 可執行文件的一般格式是:
eclipse [platform options] [-vmargs [Java VM arguments]]
Eclipse 啟動參數 命令 描述 原因
-arch architecture
定義 Eclipse 平臺在其上運行的處理器體系結構。Eclipse 平臺通常使用 Java os.arch 屬性的常用值來計算最佳設置。如果在此處指定該項,則這是 Eclipse 平臺使用的值。此處指定的值可作為 BootLoader.getOSArch() 用于插件。示例值有:"x86"、"sparc"、"PA-RISC"和"ppc"。 2.0
-application applicationId
要運行的應用程序。應用程序由向 org.eclipse.core.runtime.applications 擴展點提供擴展的插件來聲明。通常不需要此自變量。如果指定了此項,則該值會覆蓋配置提供的值。如果不指定此項,則會運行"Eclipse 工作臺"。 1.0
-boot bootJarURL
(建議不使用;用 -configuration 代替;支持 1.0 兼容)。Eclipse 平臺的引導插件代碼(boot.jar)的位置,表示為 URL。如果指定此項,則會用它來為裝入 Eclipse 平臺引導程序類裝入器的類裝入器設置類路徑。僅當更改 startup.jar 和 boot.jar 的相對位置時才需要它。注意,不允許使用相對 URL。 *1.0
-classloaderproperties [file]
如果指定的話,則使用給定位置處的類裝入器屬性文件來激活平臺類類裝入器增強。文件自變量可以是文件路徑或 URL。注意,不允許使用相對 URL。單擊此處以獲得更多詳細信息。 2.0.2
-configuration configurationFileURL
Eclipse 平臺配置文件的位置,表示為 URL。配置文件確定 Eclipse 平臺、可用插件集和主要功能部件的位置。注意,不允許使用相對 URL。當安裝或更新 Eclipse 平臺時配置文件被寫至此位置。 2.0
-consolelog
將 Eclipse 平臺的錯誤日志鏡像到用來運行 Eclipse 的控制臺。與 -debug 組合時很方便使用。 1.0
-data workspacePath
要運行 Eclipse 平臺的工作區的路徑。工作區位置也是項目的缺省位置。相對于從中啟動 eclipse 的目錄來解釋相對路徑。 1.0
-debug [optionsFile]
將平臺置于調試方式,并從給定位置處的文件裝入調試選項(如果指定的話)。此文件指示哪些調試點可用于插件以及是否已啟用它們。如果未給出文件位置,則平臺在啟動 eclipse 的目錄中查找稱為".options"的文件。URL 和文件系統路徑都可作為文件位置。 1.0
-dev [classpathEntries]
將平臺置于開發方式。將可選類路徑條目(用逗號分隔的列表)添加至每個插件的運行時類路徑。例如,當工作區包含要開發的插件時,指定 -dev bin 會為每個插件項目的名為 bin 的目錄添加類路徑條目,允許在其中存儲最新生成的類文件。除去了冗余或不存在的類路徑條目。 1.0
-endsplash params
用于在 Eclipse 平臺啟動并運行時關閉閃屏的內部選項。此選項在閃屏處理鏈中不同的位置有不同的語法和語義。 2.0
-feature featureId
主要功能部件的標識。主要功能部件為 Eclipse 的已啟動實例提供了產品個性,并確定使用的產品定制信息。 2.0
-keyring keyringFilePath
磁盤上授權數據庫(或"密鑰環"文件)的位置。此自變量必須與 -password 選項配合使用。相對于從中啟動 eclipse 的目錄來解釋相對路徑。 1.0
-nl locale
定義 Eclipse 平臺在其上運行的語言環境的名稱。Eclipse 平臺通常自動計算最佳設置。如果在此處指定該項,則這是 Eclipse 平臺使用的值。此處指定的值可作為 BootLoader.getNL() 用于插件。示例值有:"en_US"和"fr_FR_EURO"。 2.0
-nolazyregistrycacheloading
取消激活裝入優化的平臺插件注冊表高速緩存。缺省情況下,僅當需要時才從注冊表高速緩存(可用時)中裝入擴展的配置元素,以減少內存占用。此選項將在啟動時強制完全裝入注冊表高速緩存。 2.1
-noregistrycache
繞過讀寫內部插件注冊表高速緩存文件。 2.0
-nosplash
運行平臺而不顯示閃屏。 1.0
-os operatingSystem
定義 Eclipse 平臺在其上運行的操作系統。Eclipse 平臺通常使用 Java os.name 屬性的常用值來計算最佳設置。如果在此處指定該項,則這是 Eclipse 平臺使用的值。此處指定的值可作為 BootLoader.getOS() 用于插件,并用于解析插件清單文件中提及的路徑中 $os$ 變量的出現。示例值有:"win32"、"linux"、"hpux"、"solaris"和"aix"。 1.0
-password password
授權數據庫的密碼。與 -keyring 選項配合使用。 1.0
-perspective perspectiveId
啟動時要在活動工作臺窗口中打開的透視圖。如果沒有指定該參數,則將打開關閉時活動的透視圖。 1.0
-plugincustomization propertiesFile
包含插件首選項缺省設置的屬性文件的位置。這些缺省設置覆蓋在主要功能部件中指定的缺省設置。相對于從中啟動 eclipse 的目錄來解釋相對路徑。 2.0
-plugins pluginsFileURL
(建議不使用;用 -configuration 代替;支持 1.0 兼容)。 指定 Eclipse 平臺查找插件的文件的位置,表示為 URL。該文件為屬性文件格式,其中鍵是任意用戶定義名稱,值是指向 plugin.xml 文件的顯式路徑或指向包含插件的目錄的路徑的用逗號分隔的列表。注意,不允許使用相對 URL。如果指定此項,則此選項會導致創建適當的臨時配置。 *1.0
-refresh
啟動時執行工作區的全局刷新的選項。這將使從上次平臺運行以來在文件系統中所做的任何更改一致。 1.0
-showlocation
用于在窗口標題欄中顯示工作區的位置的選項。在發行版 2.0 中,此選項僅與 -data 命令行自變量一起使用。 2.0
-showsplash params
用于顯示閃屏(由可執行的 Eclipse 平臺啟動器執行)的內部選項。此選項在閃屏處理鏈中不同的位置有不同的語法和語義。 2.0
-vm vmPath
要用來運行 Eclipse 平臺的"Java 運行時環境"(JRE)的位置。如果不指定此項,則 JRE 位于 jre(它是 Eclipse 可執行文件的兄弟目錄)。相對于從中啟動 eclipse 的目錄來解釋相對路徑。 1.0
-ws windowSystem
定義 Eclipse 平臺在其上運行的 Windows 系統。Eclipse 平臺通常使用 Java os.name 屬性的常用值來計算最佳設置。如果在此處指定該項,則這是 Eclipse 平臺使用的值。此處指定的值可作為 BootLoader.getWS() 用于插件、用于配置 SWT 以及用于解析插件清單文件中提及的路徑中 $ws$ 變量的出現。示例值有:"win32"、"motif"和"gtk"。 1.0
將 -vmargs 條目后面的所有自變量(但不包括 -vmargs)作為虛擬機自變量(即,在要運行的類的前面)直接傳遞到所指示的 Java VM。注意:如果 Eclipse 啟動在 Java vm 自變量(-vmargs)之后提供的自變量(例如,-data),則 Eclipse 將不會啟動并且您將接收到"JVM 已終止。出口代碼為 1"的錯誤。
在不同的 VM 上運行
在 J9 上運行 Eclipse
當在 J9 版本 1.5 上運行 Eclipse 時,建議使用以下 VM 選項:
eclipse.exe [eclipse arguments] -vm path_to_j9w.exe -vmargs -ms:32 -mm:2048 -mo:32768 -moi:32768 -mca:32 -mco:128 -mx:2000000
當在 J9 版本 2.0 上運行 Eclipse 時,J9W 選擇的缺省自變量應為合適的選項。但是,要覆蓋 Eclipse 可執行文件以內部方式自動設置的參數,必須指定 -vmargs 不帶任何參數,如下所示:
eclipse.exe [eclipse arguments] -vm path_to_j9w.exe -vmargs
有關進一步信息,參考 J9 VM 文檔和幫助。
在 IBM Developer Kit, Java(TM) Technology Edition VM 上運行 Eclipse
IBM Developer Kit, Java(TM) Technology Edition 1.3 Linux 的缺省 VM 設置適合進行初期研究工作,但在進行大型開發時是不夠的。對于大型開發,應修改 VM 自變量以使有更多的堆可用。例如,下列設置將允許 Java 堆增大為 256MB:
posted @
2005-08-22 10:49 Dave 閱讀(215) |
評論 (0) |
編輯 收藏