Timer Servlet

The timer servlet allows a command to be executed at a specified interval.

This page discusses:

Overview

The timer servlet uses the following parameters in the FRAMEWORK.timer_servlet.web.xml.part.deactivated file:

  • ematrix.timer.agent—The user name for the context that executes the command. User privileges can be handled internally in the program.
  • ematrix.timer.agent.key—The password for the user. User privileges can be handled internally in the program.
  • ematrix.timer.interval—The elapsed time, in seconds, between execution of the command.
  • ematrix.timer.command—The command to run. If you are using BPS, use the command shown in the example below.

The timer servlet fragment is called SERVERHOME/PLATFORM/resources/warutil/fragment/M1DeploymentUtilities.timer_servlet.web.xml.part.deactivated. With the file suffix .deactivated, the WAR Utility ignores the fragment. To activate the fragment, you must rename it to M1DeploymentUtilities.timer_servlet.web.xml.part.

The following is an example of these parameters with sample values:

<context-param id="ContextParam_15">
   <param-name>ematrix.timer.agent</param-name> 
   <param-value></param-value>
</context-param>
<context-param id="ContextParam_16"> 
   <param-name>ematrix.timer.agent.key</param-name>
   <param-value></param-value>
</context-param>
<context-param id="ContextParam_17">
   <param-name>ematrix.timer.interval</param-name> 
   <param-value>21600</param-value>
</context-param>
<context-param id="ContextParam_18">
   <param-name>ematrix.timer.command</param-name>
   <param-value>execute program emxProjectSpace -method performTaskEscalation</param-value>
</context-param>

To configure the static browser content cache

Web pages typically reference a lot of fairly static content files such as images and Javascripts, which change infrequently if ever. Web browsers are able to cache such static content, but they conservatively keep going back to the server to check whether their cached copy of the content is still valid. They do this by sending requests with the If-Modified-Since: header. If the resource has been modified since it was last transferred, it is transferred again, otherwise the browser uses the cached copy that it has. This protocol saves having to transfer content that has not changed, but it still involves a round trip to the server. Across a high-latency network, all these round trips to the server result in significant degradation in user interface responsiveness.

These round trip requests can be reduced or eliminated by setting an expiration time on content sent by the server. The server does this by adding the header Expires: or Cache-Control: to the response. Both tell the browser that it may cache and not re-check the validity of the content for a specific amount of time. When the cached content expires, the browser once again sends an If-Modified-Since: request, receives a new expiration time, and the cycle repeats.

Static content declarations are located in the fragment SERVERHOME/PLATFORM/resources/warutil/fragment/M1DeploymentUtilities.static_content.web.xml.part.

The following example is the configuration provided out of the box to cache specified static browser content for a period of 7 days. The browser will cache and not re-check the validity of the content for a 7days.

<filter>
   <filter-name>StaticContentCaching</filter-name>
   <filter-class>com.matrixone.servlet.StaticContentCaching</filter-class>
   <init-param> 
      <param-name>ematrix.cache-control.ResourceLifetime</param-name>   
      <param-value>7d</param-value>
   </init-param>
</filter>
<filter-mapping>
   <filter-name>StaticContentCaching</filter-name>
   <url-pattern>*.html</url-pattern>
</filter-mapping>
<filter-mapping>
   <filter-name>StaticContentCaching</filter-name>
   <url-pattern>*.js</url-pattern>
</filter-mapping>
<filter-mapping>
   <filter-name>StaticContentCaching</filter-name>
   <url-pattern>*.css</url-pattern>
</filter-mapping>
<filter-mapping>
   <filter-name>StaticContentCaching</filter-name>
   <url-pattern>*.xsl</url-pattern>
</filter-mapping>
   <filter-mapping>
   <filter-name>StaticContentCaching</filter-name>
   <url-pattern>*.gif</url-pattern>
</filter-mapping>
<filter-mapping>
   <filter-name>StaticContentCaching</filter-name>
   <url-pattern>*.jpg</url-pattern>
</filter-mapping>

You can modify, add, and remove filter-mapping entries in this configuration. Each entry enables the cache control for a specific file type.

ematrix.cache-control.ResourceLifetime—Sets the amount of time to cache static browser content in the configuration. For example, the parameter could be:

<init-param> 
   <param-name>ematrix.cache-control.ResourceLifetime</param-name>  
   <param-value>7d</param-value>
</init-param>

The default is 7d. Select a number followed by a single character, s (seconds), m (minutes), h (hours), or d (days). A value of zero turns off the filter and no cache control is enabled. A value of 0s means expire immediatly or after zero seconds.