Creating registry is a great alternate solution for things you can not cache using dynacache. Another purpose would be to store configuration data for store. If you use registry, you don't need a server restart and org admin console provides a nice interface to refresh registry. You can load the registry on server start and connect a table to the registry and if you need to add stuff dynamically, you would need a registry refresh from admin console.
<registry
name="CustomConfigRegistry" regClassName="com.vendor.registry.CustomConfigRegistry"/>
public class CustomConfigRegistry implements Registry {
private static final String CLASSNAME = "CustomConfigRegistry";
private static CustomConfigRegistry singleton = new CustomConfigRegistry();
private Timestamp lastRefreshTimeStamp = null;
private final int INITIAL_CACHE_SIZE = 20000;
private Hashtable configCache = null;
public CustomConfigRegistry () {}
public void initialize() throws Exception {
singleton = this;
configCache = new Hashtable(INIT_CACHE_SIZE);
}
public static CustomConfigRegistry getInstance() {
return singleton;
}
public boolean enabled() {
return (singleton != null && configCache != null);
}
public void refresh() throws Exception {
if (getCacheSize() > 0) {
System.out.println(" [CustomConfigRegistry] cache size = " + getCacheSize());
}
System.out.println(" [CustomConfigRegistry] cache size = " + getCacheSize());
}
configCache = new Hashtable(INIT_CACHE_SIZE);
lastRefreshTimeStamp = new Timestamp(System.currentTimeMillis());
PerformLogic();
}
public int getCacheSize() {
if (enabled()) {
return configCache.size();
} else {
return -1;
}
}
public void performLogic(){
}
}
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
or
Directly refresh
http://myhostname/webapp/wcs/stores/servlet/RefreshRegistry?URL=/webapp/wcs/Admin/homepg®istryName=CustomConfigRegistry