Registry is an alternate solution for those which can’t be cached using Dyna cache.
The Registry Manager maintains a set of registries for caching WebSphere Commerce runtime data. Each registry provides methods to enable adding, deleting, and refreshing of the registry content. These methods are available to the URL interface by using the ListRegistry and the RefreshRegistry commands.
If the data in the tables that are associated with a registry is changed, you must refresh that registry for the change to take effect.
Steps to Create a new custom registry in WCS
1. Register the registry in wc-server.xml.
<Registries>
--
--
--
--
--
--
<registry initialCapacity="20" name="ShippingRegistry" regClassName="com.XXX.commerce.fulfillment.registry.XXXShippingRegistry"/>
</Registries>
</Registries>
2.Create a class that implements interface com.ibm.commerce.registry.Registry
package com.XXX.commerce.fulfillment.registry;
import java.util.HashMap;
import com.ibm.commerce.exception.ECException;
import com.ibm.commerce.registry.Registry;
import com.ibm.commerce.registry.RegistryManager;
public class XXXShippingRegistry implements Registry {
/**
* This method initializes the registry. It is being called when server starts.
*/
public void initialize() throws Exception {
RegistryManager.singleton().addRegistry("CustomRegistry ", this);
try {
this.initialRegistry();
} catch (ECException e) {
e.printStackTrace();
}
}
/**
* This method is used to refresh the registry. It is being called when user
* updates the registry through Site Admin console.
*/
public void refresh() throws Exception {
final String methodName = "refresh";
if (TraceLogger.isLoggable(Level.INFO))
TraceLogger.entry(CLASSNAME, methodName);
HashMap shippingRangeMapCache = new HashMap();
populate();
if (TraceLogger.isLoggable(Level.INFO))
TraceLogger.exit(CLASSNAME, methodName);
}
/**
* This method implements how the cached registry is populated.
*
* @param aCache
* HashMap
* @throws Exception
* e
*/
private synchronized void populate() throws Exception {
final String methodName = "populate";
if (TraceLogger.isLoggable(Level.INFO))
TraceLogger.entry(CLASSNAME, methodName);
//populate shipping ranges
shippingRangeMapCache = XXXShippingHelper.getInstance().populateShippingRanges();
initialized = true;
//TraceLogger.trace(CLASSNAME, methodName, "shippingRangeMapCache --> "+shippingRangeMapCache);
if (TraceLogger.isLoggable(Level.INFO))
TraceLogger.exit(CLASSNAME, methodName);
}
}
Login to Admin Console->Registry->check the CustomConfigRegistry registry and update.
or
Directly refresh
http://myhostname/webapp/wcs/stores/servlet/RefreshRegistry?URL=/webapp/wcs/Admin/homepg®istryName=CustomConfigRegistry
No comments:
Post a Comment