日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

fabrication的拦截器Interceptors简介

發(fā)布時間:2024/9/20 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 fabrication的拦截器Interceptors简介 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

簡介:

Interceptors(攔截器),主要目的是為了改變PureMVC的消息通知在到達Commands和Mediators的正常執(zhí)行順序。 在攔截器里可以:

·廢棄notification不再向外廣播

·修改notificationg再向外廣播

·使用新的notification替換原有的notification

·無限制發(fā)送這一次notification

·Interceptors與commands類似,可以使用PureMVC實例訪問和修改應用程序

?

依賴:

Fabrication V0.6+ 可使用此功能

?

Interceptors的注冊

Interceptors使用registerInterceptor方法來進行的注冊,該方法可在FabricationFacade或是SimpleFabricationCommand的子類中使用。

語法,registerInterceptor(noteName:String, clazz:Class, parameters:Object=null)

noteName:注冊notification它的名稱

clazz:攔截器的處理類

parameters:可選參數(shù),供攔截器處理類使用

// registers the interceptor for the save notification name.
registerInterceptor("save", MyInterceptor);

// registers the interceptor with save notification with extra parameters
registerInterceptor("save", MyInterceptor, {foo:"bar"});?Interceptors的實現(xiàn)攔截類的處理類(前面提及的clazz),必須繼承自AbstractInterceptor類,并實現(xiàn)intercept方法。當注冊的Notifications被發(fā)送時(使用sendNotification或是routerNotification方法進行發(fā)送),攔截器會調(diào)用該處理類的intercept方法,這些方法中可以直接使用的對象有:notification:被攔截的notification對象parameters:攔截器注冊時傳入的可選參數(shù)processor:對外提供的幾種方法,忽略、跳過或中止該notification的廣播,包含三個方法<proceed|abort|skip>?proceed:允許notification繼續(xù)進行廣播,可以使用新的notification替換當前的notification。skip:如果所有對該notification的攔截器處理已經(jīng)完成,就直接調(diào)用完成方法。不然就再調(diào)用該notification的其它攔截器實例abort:直接中止該notification的廣播,并立即調(diào)用完成方法。?在框架源碼中可以看到上述三個方法中的實現(xiàn): 1: public function getNotification():INotification { 2: return notification; 3: } 4:? 5: /** 6: * Adds a interceptor to the list of interceptors for the current notification. 7: * 8: * @param interceptor The interceptor object to register. 9: */ 10: public function addInterceptor(interceptor:IInterceptor):void { 11: interceptor.processor = this; 12: interceptors.push(interceptor); 13: } 14:? 15: /** 16: * Removes the specified interceptor from the list of interceptors. 17: * 18: * @param interceptor The interceptor object to remove. 19: */ 20: public function removeInterceptor(interceptor:IInterceptor):void { 21: var index:int = interceptors.indexOf(interceptor); 22: if (index >= 0) { 23: interceptors.splice(index, 1); 24: interceptor.dispose(); 25: } 26: } 27:? 28: /** 29: * Runs all interceptors registered with this NotificationProcessor. 30: */ 31: public function run():void { 32: var n:int = interceptors.length; 33: var interceptor:IInterceptor; 34: for (var i:int = 0; i < n; i++) { 35: interceptor = interceptors[i]; 36: 37: interceptor.notification = notification; 38: interceptor.intercept(); 39: } 40: } 41:? 42: /** 43: * Sends a proceed event so that the notification can be send to the rest of 44: * the PureMVC actors. Flags this instance as complete to ignore other interceptors. 45: * Also sends a finish event to indicate that the processor can be disposed. 46: * 47: * @param note The notification to proceed with. If null the current notification object is used. 48: */ 49: public function proceed(note:INotification = null):void { 50: if (!finished) { 51: dispatchEvent(new NotificationProcessorEvent(NotificationProcessorEvent.PROCEED, note)); 52: finish(); 53: } 54: } 55:? 56: /** 57: * Sends an abort event. Flags this instance as complete to ignore other interceptors. 58: * Also sends a finish event to indicate that the processor can be disposed. 59: */ 60: public function abort():void { 61: if (!finished) { 62: dispatchEvent(new NotificationProcessorEvent(NotificationProcessorEvent.ABORT)); 63: finish(); 64: } 65: } 66:? 67: /** 68: * If all interceptors have been skipped then sends a finish event to indicate 69: * that the processor can be disposed. 70: */ 71: public function skip():void { 72: if (!finished && ++skipCount == interceptors.length) { 73: finish(); 74: } 75: } 76:? 77: /** 78: * Flags the notification as finished and sends a finish event. 79: */ 80: public function finish():void { 81: finished = true; 82: dispatchEvent(new NotificationProcessorEvent(NotificationProcessorEvent.FINISH)); 83: }

interceptor的處理過程是異步的,實例中對”save”這條消息進行了監(jiān)聽響應,也對“save”進行了攔截處理,但只有在點擊“繼續(xù)”按鈕的時候才繼續(xù)廣播該notification。

?

英文原文(能力有限,本文翻譯的可能有誤,歡迎批評和斧正):http://code.google.com/p/fabrication/wiki/Interceptors#Requirements

示例demo的源碼:http://code.google.com/p/fabrication/source/browse/examples/interceptor_demo/src#src%2Fmain%2Fflex%2Fcontroller%253Fstate%253Dclosed

?

本地查看效果實例:

?

如需要本示例程序的完整代碼,立即下載>>

轉(zhuǎn)載于:https://www.cnblogs.com/meteoric_cry/archive/2012/02/01/2334442.html

總結(jié)

以上是生活随笔為你收集整理的fabrication的拦截器Interceptors简介的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 成人免费毛片xxx | 闫嫩的18sex少妇hd | 日本妇乱大交xxxxx | 免费高清视频在线观看 | 蜜桃做爰免费网站 | 国产乱妇无码大片在线观看 | 久久人人妻人人人人妻性色av | 成人午夜小视频 | 影音先锋在线看 | 国产一级一区 | 91一区二区三区四区 | 岛国av免费看 | 亚洲国产精品成人综合 | 香蕉网在线播放 | 精品国产一区二区三区在线 | 中文字幕观看在线 | 亚洲第一网站 | 国产精品第8页 | 亚洲夜夜夜 | 国产综合久久久久 | 在线观看国产精品入口男同 | 国产成人高清在线 | 久久99精品国产.久久久久久 | 亚洲av成人精品一区二区三区 | av黄色影院| 91狠狠干| 91精品国自产在线 | 亚洲免费大片 | 免费视频福利 | 四虎成人精品永久免费av九九 | 欧美我不卡 | 奇米成人影视 | 97久久国产亚洲精品超碰热 | 午夜剧场成人 | 稀缺小u女呦精品呦 | 久久这里只有精品久久 | youjizz韩国| 不卡三区 | 日本少妇在线 | 成年人免费在线观看视频网站 | 樱桃视频污污 | 成人一区av | eeuss国产一区二区三区 | 麻豆传媒在线看 | 国产黄在线观看 | 国产又粗又猛又爽又黄的 | 日中文字幕 | 国内激情自拍 | 亚洲性激情 | 亚洲精品久久久久avwww潮水 | 国产肥老妇视频 | 先锋资源av网 | 网站黄在线 | 国产老熟妇精品观看 | 女王人厕视频2ⅴk | 中文字幕一区二区av | 久久精品人妻一区二区三区 | 亚洲无在线观看 | 婷婷狠狠爱| 欧美性www| 国产色在线 | 精品丰满少妇一区二区三区 | 亚洲无卡 | www.四虎在线 | 7777在线视频 | 国产黄色片免费看 | 少妇性bbb搡bbb爽爽爽欧美 | 天天爽天天摸 | 欧美性受xxxx白人性爽 | 91久久国产综合久久 | 国产精品毛片一区 | av片久久 | 午夜在线精品偷拍 | 国产 欧美 日韩 | 亚洲欧美精品aaaaaa片 | 中文在线观看高清视频 | 午夜精品影院 | 亚洲天堂资源在线 | 日本理论片午伦夜理片在线观看 | 男人的天堂在线播放 | 亚洲AV无码精品色毛片浪潮 | aa黄色片| 一区二区三区欧美日韩 | 亚洲熟妇无码av | 欧美在线导航 | 美女的胸给男人玩视频 | av高清一区 | 在线国产精品视频 | 黄色香蕉网站 | 国内精品99 | 午夜影院在线 | 日批在线观看 | 一本一道久久a久久精品综合 | 毛片基地在线播放 | 中文成人在线 | 污网在线观看 | 天天插天天射天天干 | 性久久久久久久久 | 波多野结衣在线一区二区 |