學習筆記:Eclipse中Subversion插件如何使用詳解 下篇
本文繼續(xù)上節(jié)文章介紹Subversion插件在Eclipse中是如何使用的,希望大家能學到更多知識,同時也請各位多提寶貴意見,以便共同進步。以下是介紹Subversion插件
【Displayhook銷毀機制】
在Displaydevice中我們看了如下個hook接口:
- /** *Causestherunmethodoftherunnableto
- *beinvokedbytheuser-erfacethreadjustbeforethe
- *receiverisdisposed.
- */ publicvoiddisposeExec(Runnablerunnable){
- //注冊用戶自定義runnable在displayrelease時候回調(diào)此runnable
- 將runnable注冊到disposeList
- }
- disposeList中線程會在displayrelease時候被如下:
- /***Releasesanyernalresourcesbacktotheoperating
- *systemandclearsallfieldsexceptthedevicehandle.
- */ protectedvoidrelease{……
- //會執(zhí)行用戶注冊銷毀線程
- (disposeList!=null){
- for(i=0;i (disposeList[i]!=null)disposeList[i].run;
- }}
- ……}
看來SWT并沒有把事情做絕了還是給開發(fā)者留下條后路Display允許開發(fā)者注冊個自定義線程hook到Displayrelease過程開發(fā)者可以用如下方式來確保開發(fā)者使用系統(tǒng)資源在Displayrelease時候被銷毀:
- display.disposeExec(Runnable{
- publicvoidrun{//銷毀系統(tǒng)資源邏輯代碼
- image.dispose;
- ……}});
以上方式其實也是JFace中圖片資源管理(ImageRegistry、ResourceManager)能夠確保Displayrelease時候能夠徹底釋放被ImageRegistry托管圖片資源.到這里回顧下SWT中資源釋放途徑吧:
1、覆寫相應Component對應dispose思路方法這有別于Displayhook機制其能夠在Display運行期間(未被release的前)就釋放掉系統(tǒng)資源***方式。
2、利用Displayhook機制確保在Display被release時候能夠銷毀資源注意請不要過多依賴此方式很容易造成在Display被release的前已經(jīng)發(fā)生了系統(tǒng)crash問題。
Eclipse的本身只是一個框架平臺,但是眾多插件的支持使得Eclipse擁有其他功能相對固定的IDE軟件很難具有的靈活性。許多軟件開發(fā)商以Eclipse為框架開發(fā)自己的IDE。
【JFace中圖片資源管理--ImageDescriptor】
前面我們已經(jīng)見過SWT中Image和ImageData類型了在繼續(xù)下面內(nèi)容的前我們先看下在JFace中我們最常用來創(chuàng)建圖片資源個工廠類:ImageDescriptor在ImageDescriptor類型介紹說明中告訴我們有兩種使用ImageDescriptor創(chuàng)建圖片方式分別通過createImage和createResource接口“TherearetwowaystogetanImagefromanImageDescriptor.ThemethodcreateImagewillalwaysaImagewhichmustbedisposedbythecaller.Alternatively,createResourcesasharedImage.WhenthecallerisdonewithanimageobtainedfromcreateResource,theymustcalldestroyResourceratherthandisposingtheImagedirectly.”分析如下:
首先看下createResource方式ImageDescriptor是種DeviceResourceDescriptor后者對外操作如下:
- /** *Createstheresourcedescribedbythisdescriptor */
- publicabstractObjectcreateResource(Devicedevice)throwsDeviceResourceException; /**
- *Undoeseverythingthatwasdonebyapreviouscalltocreate(...) */
- publicabstractvoiddestroyResource(ObjectpreviouslyCreatedObject);
本篇對Eclipse中如何使用Subversion插件已經(jīng)全部介紹完畢。請關注本文的其他相關報道。
【編輯推薦】