Network Deployment (Distributed operating systems), v8.0 > Scripting the application serving environment (wsadmin) > Configure servers with scripting


Configure servlet caching using wsadmin.sh

We can configure servlet caching with scripting and the wsadmin tool. The dynamic cache service works within an application server JVM, intercepting calls to cacheable objects. For example, it intercepts calls through a servlet service method or a command execute method, and either stores the output of the object to the cache or serves the content of the object from the dynamic cache.

Before you can configure servlet caching, configure dynamic cache. Use the configureDynamicCache Jython script in the AdminServerManagement script library to configure dynamic caching. The wsadmin tool automatically loads the script when the tool starts. Use the following syntax to configure dynamic caching using the configureDynamicCache script:

AdminServerManagement.configureDynamicCache(nodeName, serverName,  defaultPriority,cacheSize, externalCacheGroupName,  externalCacheGroupType, otherAttributeList)
For additional information and argument definitions, see the documentation for the AdminServerMananagment script library.

After a servlet is invoked and completes generating the output to cache, a cache entry is created containing the output and the side effects of the servlet. These side effects can include calls to other servlets or JSP files or metadata about the entry, including timeout and entry priority information. Configure servlet caching to save the output of servlets and JSP files to the dynamic cache.

If you use wsadmin.sh to enable servlet caching, verify that portlet fragment caching is also enabled. Similarly, if you use the wsadmin tool to disable servlet caching, verify that portlet fragment caching is also disabled. The settings for these two caching functions must remain synchronized. If you enable or disable servlet caching using the admin console, synchronization performed automatically.

To see a list of parameters associated with dynamic caching, use the attributes command. For example:

$AdminConfig attributes DynamicCache


Procedure

  1. Start wsadmin.sh.

  2. Retrieve the configuration ID of the server object.

    The following example sets the first server found to the s1 variable:

      ### Jacl

      set s1 [$AdminConfig getid /Server:server1/]
      

      ### Jython

      s1 = AdminConfig.getid('/Server:server1/')
      

  3. Retrieve the web containers for the server of interest. and assign them to the wc variable.

    The following example sets the web container to the wc variable:

      ### Jacl

      set wc [$AdminConfig list WebContainer $s1]
      

      ### Jython

      wc = AdminConfig.list('WebContainer', s1)
      

  4. Set a variable with the new value for the enableServletCaching attribute.

    Set the enableServletCaching attribute to true and assign it to the serEnable variable, as the following example demonstrates:

      ### Jacl

      set serEnable "{enableServletCaching true}"
      

      ### Jython

      serEnable = [['enableServletCaching', 'true']]
      

  5. Enable dynamic caching.

    Use the AdminConfig object to modify the application server configuration, as the following example demonstrates:

      ### Jacl

      $AdminConfig modify $wc $serEnable
      

      ### Jython

      AdminConfig.modify(wc, serEnable)
      


Configure servlet caching
Automate server administration using wsadmin.sh


Related


Introduction: Dynamic cache
Server settings configuration scripts
Commands for the AdminConfig object using wsadmin.sh

+

Search Tips   |   Advanced Search