Friday, April 29, 2011

Create custom Registry for Performance\Store configuration

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.

Add the Registry entry into wc-server.xml

<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());
}
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&registryName=CustomConfigRegistry

7 comments:

  1. Wcs has concept of session bean and registry manager, which one is useful to load static table data.
    Can ejb session bean hit data base while accessing the bean. what is the maximum size can be define for registry.

    We have static table data which access using access bean, is it ok to move that to custom registry.

    ReplyDelete
  2. I have seen some great stuff here. Worth bookmarking for revisiting. I surprise how much effort you put to create such a great informative website. Your work is truly appreciated around the clock and the globe. cbd tinture

    ReplyDelete
  3. I have read your blog it is very helpful for me. I want to say thanks to you. I have bookmark your site for future updates. cbd vape oil

    ReplyDelete
  4. I am jovial you take pride in what you write. It makes you stand way out from many other writers that can not push high-quality content like you. just cbd

    ReplyDelete
  5. Thankyou for this wondrous post, I am glad I observed this website on yahoo. cbd deals justcbd

    ReplyDelete
  6. I really loved reading your blog. It was very well authored and easy to undertand. Unlike additional blogs I have read which are really not tht good. I also found your posts very interesting. In fact after reading, I had to go show it to my friend and he ejoyed it as well! CBT Bulk Email Sender Software

    ReplyDelete
  7. I haven’t any word to appreciate this post.....Really i am impressed from this post....the person who create this post it was a great human..thanks for shared this with us. Send Mass Emails with CBT Bulk Email Sender Desktop Software

    ReplyDelete