in reviewing the strengths and weaknesses of ejb and how they fit in an event distribution subsystem, we can determine the following:
ejb doesnt provide a mechanism for the event distribution system to inform the remote components that an event has occurred (no callback mechanism). 【程序编程相关:java tips】 ejb allows remote components to send events to the event distribution system. 【推荐阅读:字节码如何防止内存错误及提高代码质量】 ejbs transactional model doesnt help us in the event distribution subsystem, since events are not transactional in nature.this article and its sequel will show you one possible way to handle these vast requirements in a simple, straightforward framework so that your application will be able to handle events as easily as it handles normal, transaction-oriented, multitiered processing.
what is an event, anyway? 【扩展信息:java程序编码规范】
the ejb server provides all the features required for a highly scalable, fault-tolerant, load-balanced application. in most java development circles, when event handling is discussed its normally in association with the awt event model. in the awt model the component interested in the event (consumer) simply registers with the producer of events (producer). the producer then iterates its list of interested parties (consumers), sending the event to all who have registered with it. this is a classic implementation of the observer pattern, and it works well in an application that runs in a single vm.when an application begins to span multiple vms, and components are created on the fly without notification to other components, the awt model of tight coupling between the consumer of events and the producer of events gets to be unworkable. how does the consumer know that a producer of events has started on a machine somewhere else on the network?
consumers of events dont care who generated the event, just that the event occurred. if a database is out of space, the event consumer doesnt care what process detected that the database needs more disk space. it just knows that its job is to notify the administrator of this fact. conversely, the event producer doesnt care who needs the event, or what theyre going to do with it, just that the event was detected and that consumers may be interested in it.
the mediator pattern can be used to allev... 下一页