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