1.Create a new CallBack class for the custom business context.
public class MyCompanyCallBack {
//private static String className = com.ibm.commerce.dynacache.filter.MyCompanyCallBack.className;
private MyCompanyCallBack() { }
public static String getMyCompany(SessionAttrMap m, CacheFilterContext cfc){
CommandContext cc = cfc.getCmdctx();
MyCompanyContext shipContext = (MyCompanyContext) cc.getContext(MyCompanyContext.CONTEXT_NAME);
return shipContext.getCountry();
}
public static void setMyCompany(SessionAttrMap m, CacheFilterContext cfc){
CommandContext cc = cfc.getCmdctx();
MyCompanyContext shipContext = (MyCompanyContext) cc.getContext(MyCompanyContext.CONTEXT_NAME);
String country = shipContext.getShipToCountry();
cfc.getRequest().setAttribute(m.getDynacacheAttributeName(), country);
}
}
2.Add the call back entry in wc-server.xml.
<component
compClassName="com.ibm.commerce.dynacache.filter.CacheFilterAttributeMapHelper"
enable="true" name="DynaCacheFilterMappings">
<property display="false" refreshInterval="300000">
<map
className="com.ibm.commerce.context.base.BaseContext"
display="false" dynacacheAttributeName="DC_storeId"
methodName="getStoreId" name="getStoreId"/>
<map
className="com.ibm.commerce.context.base.BaseContext"
display="false" dynacacheAttributeName="DC_userId"
methodName="getCallerId" name="getCallerId"/>
<map
className="com.ibm.commerce.context.globalization.GlobalizationContext"
display="false" dynacacheAttributeName="DC_lang"
methodName="getLanguageId" name="getLanguageId"/>
<map
className="com.ibm.commerce.context.globalization.GlobalizationContext"
display="false" dynacacheAttributeName="DC_curr"
methodName="getCurrency" name="getCurrency"/>
<map
className="com.ibm.commerce.dynacache.filter.ParentOrganizationCallBack"
display="false" dynacacheAttributeName="DC_porg"
methodName="setParentOrg" name="setParentOrg"/>
<map
className="com.ibm.commerce.dynacache.filter.ActiveOrganizationCallBack"
display="false" dynacacheAttributeName="DC_aorg"
methodName="setActiveOrg" name="setActiveOrg"/>
<map
className="com.ibm.commerce.dynacache.filter.MemberGroupsCallBack"
display="false" dynacacheAttributeName="DC_mg"
methodName="setMemberGroups" name="setMemberGroups"/>
<map
className="com.ibm.commerce.dynacache.filter.CatalogAndPriceCallBack"
display="false" dynacacheAttributeName="DC_cont"
methodName="setContracts" name="setContracts"/>
<map
className="com.ibm.commerce.dynacache.filter.UserTypeCallBack"
display="false" dynacacheAttributeName="DC_userType"
methodName="setUserType" name="setUserType"/>
<map
className="com.ibm.commerce.dynacache.filter.PortalAndWapCallBack"
display="false" dynacacheAttributeName="PORTAL"
methodName="setPortalAndWap" name="setPortalAndWap"/>
<map
className="com.ibm.commerce.dynacache.filter.MyCompanyCallBack "
display="false" dynacacheAttributeName="DC_Company"
methodName="setPortalAndWap" name="setCompany"/>
</property>
</component>
3.Then use the parameter in the cachespec.xml as a cacheId
<cache-entry>
<class>servlet</class>
<name>/StorefrontAssetStore/Widgets/Footer/Footer.jsp</name>
<property name="do-not-consume">true</property>
<property name="save-attributes">false</property>
<property name="consume-subfragments">true</property>
<cache-id>
<component id="storeId" type="parameter">
<required>true</required>
</component>
<component id="DC_Company" type="attribute">
<required>true</required>
</component>
</cache-id>
<dependency-id>FlexFlowFeatureUpdate</dependency-id>
<dependency-id>
storeId
<component id="storeId" type="parameter">
<required>true</required>
</component>
</dependency-id>
<dependency-id>
StoreFooter:storeId
<component id="storeId" type="parameter">
<required>true</required>
</component>
</dependency-id>
</cache-entry>
public class MyCompanyCallBack {
//private static String className = com.ibm.commerce.dynacache.filter.MyCompanyCallBack.className;
private MyCompanyCallBack() { }
public static String getMyCompany(SessionAttrMap m, CacheFilterContext cfc){
CommandContext cc = cfc.getCmdctx();
MyCompanyContext shipContext = (MyCompanyContext) cc.getContext(MyCompanyContext.CONTEXT_NAME);
return shipContext.getCountry();
}
public static void setMyCompany(SessionAttrMap m, CacheFilterContext cfc){
CommandContext cc = cfc.getCmdctx();
MyCompanyContext shipContext = (MyCompanyContext) cc.getContext(MyCompanyContext.CONTEXT_NAME);
String country = shipContext.getShipToCountry();
cfc.getRequest().setAttribute(m.getDynacacheAttributeName(), country);
}
}
2.Add the call back entry in wc-server.xml.
<component
compClassName="com.ibm.commerce.dynacache.filter.CacheFilterAttributeMapHelper"
enable="true" name="DynaCacheFilterMappings">
<property display="false" refreshInterval="300000">
<map
className="com.ibm.commerce.context.base.BaseContext"
display="false" dynacacheAttributeName="DC_storeId"
methodName="getStoreId" name="getStoreId"/>
<map
className="com.ibm.commerce.context.base.BaseContext"
display="false" dynacacheAttributeName="DC_userId"
methodName="getCallerId" name="getCallerId"/>
<map
className="com.ibm.commerce.context.globalization.GlobalizationContext"
display="false" dynacacheAttributeName="DC_lang"
methodName="getLanguageId" name="getLanguageId"/>
<map
className="com.ibm.commerce.context.globalization.GlobalizationContext"
display="false" dynacacheAttributeName="DC_curr"
methodName="getCurrency" name="getCurrency"/>
<map
className="com.ibm.commerce.dynacache.filter.ParentOrganizationCallBack"
display="false" dynacacheAttributeName="DC_porg"
methodName="setParentOrg" name="setParentOrg"/>
<map
className="com.ibm.commerce.dynacache.filter.ActiveOrganizationCallBack"
display="false" dynacacheAttributeName="DC_aorg"
methodName="setActiveOrg" name="setActiveOrg"/>
<map
className="com.ibm.commerce.dynacache.filter.MemberGroupsCallBack"
display="false" dynacacheAttributeName="DC_mg"
methodName="setMemberGroups" name="setMemberGroups"/>
<map
className="com.ibm.commerce.dynacache.filter.CatalogAndPriceCallBack"
display="false" dynacacheAttributeName="DC_cont"
methodName="setContracts" name="setContracts"/>
<map
className="com.ibm.commerce.dynacache.filter.UserTypeCallBack"
display="false" dynacacheAttributeName="DC_userType"
methodName="setUserType" name="setUserType"/>
<map
className="com.ibm.commerce.dynacache.filter.PortalAndWapCallBack"
display="false" dynacacheAttributeName="PORTAL"
methodName="setPortalAndWap" name="setPortalAndWap"/>
<map
className="com.ibm.commerce.dynacache.filter.MyCompanyCallBack "
display="false" dynacacheAttributeName="DC_Company"
methodName="setPortalAndWap" name="setCompany"/>
</property>
</component>
3.Then use the parameter in the cachespec.xml as a cacheId
<cache-entry>
<class>servlet</class>
<name>/StorefrontAssetStore/Widgets/Footer/Footer.jsp</name>
<property name="do-not-consume">true</property>
<property name="save-attributes">false</property>
<property name="consume-subfragments">true</property>
<cache-id>
<component id="storeId" type="parameter">
<required>true</required>
</component>
<component id="DC_Company" type="attribute">
<required>true</required>
</component>
</cache-id>
<dependency-id>FlexFlowFeatureUpdate</dependency-id>
<dependency-id>
storeId
<component id="storeId" type="parameter">
<required>true</required>
</component>
</dependency-id>
<dependency-id>
StoreFooter:storeId
<component id="storeId" type="parameter">
<required>true</required>
</component>
</dependency-id>
</cache-entry>
No comments:
Post a Comment