<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    hengheng123456789

      BlogJava :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
      297 Posts :: 68 Stories :: 144 Comments :: 0 Trackbacks

    Reactor pattern Beginning

     

     

    The Reactor pattern has been introduced in  [Schmidt95] as a general architecture for event-driven systems. It explains how to register handlers for particular event types, and how to activate handlers when events occur, even when events come from multiple sources, in a single-threaded environment. In other words, the reactor allows for the combination of multiple event-loops, without introducing additional threads.


    The Reactor pattern

    • activate handlers when events occur
    • allow events from multiple sources
    • in single threaded process

    See D.C. Schmidt, Using Design Patterns to Develop Reusable Object-oriented Communication Software, CACM October '95, 38(10): 65-74


    slide: The Reactor pattern


    The abstract layout of the software architecture needed to realize the pattern is depicted in slide reactor-structure. The reactor environment must allow for binding handlers to particular types of events. In addition, it must be able to receive events, and select a handler to which the event can be dispatched.



    slide: The Reactor pattern -- structure


    Events may be organized in a hierarchy. There are two possible choices here. Either the topmost event class has a fat interface, containing all the methods that an event may ever need to support, or the topmost event class can be lean, so that additional methods need to be added by the subclasses of event. The first solution is chosen for hush, because in C++ it is not possible to load new classes dynamically. The latter solution is the way Java does it. In Java new event types can be added at the reactor level without recompiling the system. In the Java AWT and Swing libraries, handlers are called Listeners.

    Concrete handlers, derived from an abstract handler, must provide a method, such as operate(Event) that can be called by the reactor when the handler is selected after receiving an event.



    slide: The Reactor Pattern - interaction


    The interaction between the application, its handlers, the reactor and the environment from which the events originate is depicted in slide reactor-interaction. First, the reactor must be initialized, then one or more handlers can be registered, providing a binding for particular types of events. The reactor must then start to execute its eventloop. When it receives an event from the environment, it selects a handler and dispatches the event to that handler, by calling operate(Event).

    Consequences

    Modularity is one of the advantages of an event-driven software architecture. Handlers can be composed easily, since their invocation is controlled by the reactor. Another advantage is the decoupling of application-independent mechanisms from application-specific policies. In other words, handler objects need not be aware of how events are dispatched. This is the responsibility of the system or framework.

    The fact that control is handed over to the environment has, however, also some disadvantages. First of all, as experience with student assignments shows, it is difficult to learn in the beginning. But even when mastered, applications may be hard to debug, since it is not always clear why a particular handler was invoked, and because it may be difficult to repeat the computation preceding the fault.

    Applicability

    Some variant of the reactor pattern is used in Unix (X) Windows, (MS) Windows, and also GUI libraries such as Interviews, ET++ and hush. Another example is the Orbacus object request broker, that supports a reactor mode for server objects, which allows for receiving messages from multiple sources in a single thread. The Orbacus broker, however, also allows for multi-threaded servers.

    posted on 2007-06-28 18:18 哼哼 閱讀(449) 評論(0)  編輯  收藏 所屬分類: JAVA-Common
    主站蜘蛛池模板: 国产又黄又爽胸又大免费视频| 最近最新高清免费中文字幕| 亚洲成AV人在线播放无码| 99热在线免费观看| 午夜在线亚洲男人午在线| 亚洲国产精品久久66| 日本不卡视频免费| 成人片黄网站色大片免费观看APP| 亚洲伊人久久大香线焦| 综合久久久久久中文字幕亚洲国产国产综合一区首 | 一级毛片**不卡免费播| 亚洲熟妇AV一区二区三区浪潮| 亚洲AV无码成人精品区大在线| 一级成人a毛片免费播放| 免费亚洲视频在线观看| 中文字幕亚洲精品| 亚洲成A人片77777国产| 久久精品a一国产成人免费网站| 成年网站免费入口在线观看| 亚洲人成免费网站| 亚洲精品无码久久久久去q| 女人18毛片特级一级免费视频| 一区二区三区在线免费| 精品国产成人亚洲午夜福利| 亚洲国产综合无码一区| 国产精品自在自线免费观看| 99久久免费观看| 成人精品视频99在线观看免费| 亚洲国产成人精品无码区花野真一| 久久久无码精品亚洲日韩蜜桃| 日本免费一本天堂在线| 91久久成人免费| 野花香高清视频在线观看免费| 无忧传媒视频免费观看入口| 国产精品亚洲综合五月天| 亚洲AV日韩精品久久久久久| 亚洲性日韩精品国产一区二区| 卡1卡2卡3卡4卡5免费视频 | 国产做床爱无遮挡免费视频| 在线视频精品免费| 99视频精品全部免费观看|