⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 run-at.xtp

📁 解压在c盘
💻 XTP
字号:
<s1 title="run-at: Periodic Services"><p>Some web applications need a task to be run at regular intervals, e.g. oncean hour or once a day.  For example, a search application might want tospider the web site every day to automatically pick up any new pages.Syndication applications might poll their news sites every hour to check forupdates.</p><p>Resin's <var/run-at/> servlets make periodic tasks simple.  At thespecified interval, Resin will execute a configured servlet.  Because theperiodic task is implemented as a servlet, the API is familiar anddebugging is simple.</p><p><var/run-at/> has several advantages over spawning a new thread.First, when you spawn a thread, you need to make sure you close it properlywhen the servlet is unloaded.  Servlets can be unloaded at any time.Also, <var/run-at/> automatically handles classloader issues.  A threadimplementation needs to ensure that the running thread has the sameclassloader as the application.</p><s2 title="Sample Service"><p>The following example doesn't do much.  When the service routine is called,is just prints a message to the standard output.</p><p>Because there is no request, the <var/request/> and <var/response/>objects are just stubs.  There's no reason to ever use them in a<var/run-at/> service.  (Yes, that makes the arguments a little silly, butit's better than creating a new API.)</p><p>The service does have access to the <var/ServletConfig/>and <var/ServletContext/> objects.</p><example title="TestAlarm.java">package test;import javax.servlet.*;public class TestAlarm extends GenericServlet {  public void service(ServletRequest request,                      ServletResponse response)    throws IOException, ServletException  {    System.out.println("alarming");  }}</example><p>The alarm is configured as any other servlet, with the addition of the<var/run-at/> tag.  The following configuration runs the servlet every15 minutes.  If the hour is missing, e.g. <var/:15/> the service isrun at the specified minute.</p><example title="15 minute configuration">...&lt;servlet name='alarm' servlet-class='test.TestAlarm'>  &lt;run-at>:00, :15, :30, :45&lt;/run-at>&lt;/servlet>...</example><p>You can also run an alarm every hour.  Just specify the fullhour:minute in the run-at.  For example, <var/16:30/> runs the service oncea day at 4:30 PM.</p><example title="Daily at 4:30 PM Configuration">...&lt;servlet name='alarm' servlet-class='test.TestAlarm'>  &lt;run-at>16:30&lt;/run-at>&lt;/servlet>...</example></s2></s1>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -