资源预览内容
第1页 / 共35页
第2页 / 共35页
第3页 / 共35页
第4页 / 共35页
第5页 / 共35页
第6页 / 共35页
第7页 / 共35页
第8页 / 共35页
第9页 / 共35页
第10页 / 共35页
亲,该文档总共35页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
外文原文In web applications, most of the tasks is done in a to prevent the user from long time waiting for the way. In Google search this example, reduce the waiting time is essential to the user experience. A solution to the asynchronous task is to create a thread in user submission (to handle asynchronous task), but it can not solve the need to certain time interval repeat operation tasks, or at a specified time running task everyday situations.Let us from a database of examples of statements to have a look the task scheduling can do to help improve the system design. The report may be perplexing, depending on the user for data types, and if they need from one or more database collect large amounts of data. The user may take a long time to run such an on-demand report. Therefore, we extend this report example add task scheduling mechanism, so that the user can be arranged in any they need time to generate a report, and in the PDF or other format in email transmission. Users can make report on every day in the morning 2:22, the system is running at low load; also can choose to only run at a specific time at a time. By the addition of task scheduling in report application, we can add a useful function for the product, and improve the user experience.Fortunately, there is a powerful open source solutions can let us in a standard way in the application of web (or any Java application) in the implementation of task scheduling. The following example shows the application of web, how to use Quartz to create a task scheduling framework. This example also uses the Struts Action framework plug-in, so that in the web application startup initialization task scheduling mechanism. Struts is the most common MVC framework, familiar to most developers. Of course, in addition to many frameworks can help the realization of MVC model in Web application.Startup initialization task scheduler we first need to do is create a Struts plugin, let it create task scheduler we in the container startup. In the following example, we choose Tomcat as the web application container, but these examples in other container should also can run. We want to create a Struts plug-in class, and adding a few lines of code in struts-config.xml in order to make it work. This plugin has two configurable parameters: startOnLoad specifies whether to start the task scheduler immediately in the container startup, and startupDelay specifies the waiting time before starting the task scheduler. Start delay is very useful, because we may need to perform some of the more important initialization steps. In addition, you can also use the listener mechanism, in a more complicated way to notify SchedulerPlugIn when to start Quartz Scheduler.We want to create a Struts plug-in interface list of org.apache.struts.action.PlugIn class SchedulerPlugIn. Struts will appear in the order according to the configuration file initializes each plug-in. Special attention should be paid to the init () method in the code, we initialize the required Quartz objects, and Scheduler. The task information we will submit to a org.quartz.Scheduler object, which will be discussed in the subsequent. The Scheduler object by Quartz servlet according to its initial configuration, the ActionServlet class as the Struts initialization.JDK provides a number of class library for programmers, and in order to keep the library reusability, scalability and flexibility, which use a lot of design patterns, this paper will introduce to use JDK I/O package in the Decorator mode, and using this model, the realization of a new output stream class.Decorator mode Decorator mode or wrapper (Wrapper), its main purpose is to add some additional responsibilities to an object dynamically. Compared with the subclass, it has more flexibility. Sometimes, we need an object and not the whole class to add some new functions, for example, add a scrollbar functionality to a text area. We can use the inheritance mechanism to achieve this function, but this method is not flexible enough, we can not control the text area and the scroll bar mode and time. And when the text area need to add more features, such as the border, you need to create a new class, and when the combined use of these functions will undoubtedly caused an explosion required. We can use a more flexible approach, is to make text area into a scroll bar. The scrollbar class is equivalent to a decorative text area. This decoration (scroll) must and decorated component (text) inherited from the same interface, so that users dont need to care, decoration, because it is transparent. Decoration will forward the user request to the appropriate component (that is, call the appropriate method), and may do some extra action in the forwarding and (such as add scroll). By this method, we can according to different combinations of text region nested decoration, so as to add any more function. The method of adding functions will not object this dynamic caus
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号