Custom request attributes for servlet caching
You can create custom request attributes for servlet caching by adding them to the
<map> tag.
In a store that runs in the Transaction server, the
DynaCacheFilterMappings component tag in the
wc-server.xml file has a property that defines several
<map> tags.
In a store that runs in the Store server, set this configuration in the workspace_dir/xml/config/wc-store.xml file.
Each
<map> tag defines how a request attribute can be added to the
HttpServletRequest object. Each <map> tag can
specify the following attributes:- className
- The fully qualified Java class name of the class that provides a static method that can be called to determine the attribute value.
- dynacacheAttributeName
- The name of the attribute to be added to the
HttpServletRequestobject. - methodName
- The name of a static method of the class that is specified by the
classNameattribute. The static method returns ajava.lang.Stringand accepts the following parameters:- javax.servlet.http.HttpServletRequest
- The request object
- com.ibm.commerce.command.CommandContext
- The command context for this request
- java.lang.String
- The name of the attribute (the value of the
dynacacheAttributeName <map>configuration attribute).When the returned String value is not null and is not empty, it is added to the
HttpServletRequestby using thesetAttributemethod.
You can call the
MyClass.getMyAttributeValue method on each request to
generate an attribute value for a request attribute that is named
"MyAttribute", which is then added to the request object. To call
this method on each request, specify the following <map>
tag:
<map
className="com.mycompany.MyClass"
display="false" dynacacheAttributeName="MyAttribute"
methodName="getMyAttributeValue" name="getMyAttributeValue"/>