Skip to main content

Webpshere Commerce Registry

Registry is an another solution for those which can’t be cached using Dyna cache. Another use would be to store configuration data for a store. By using registry, you don't need a server restart every time as organization admin console provides an interface to refresh registry. The new custom registries will be appearing in the admin console under the registry section.




Steps to create a new custom registry in WCS
Step 1. Register the registry in wc-server.xml.

<Registries>
......
.....
<registry
name="TestRegistry" regClassName="com.wcs.registry.TestRegistry "/> 
</Registries>
Step 2.Create  a class that implements   interface com.ibm.commerce.registry.Registry
package com.wcs.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 TestRegistry  implements Registry {
private HashMap sampleRegistry ;
/** * @return Returns the hashSampleRegistry. */
 public Hashtable getSampleRegistry() 
{
 return sampleRegistry ;
 }
                  
/**
 * This method initializes the registry. It is being called when server starts. 
 */
public void initialize() throws Exception {
RegistryManager.singleton().addRegistry("TestRegistry  ", 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 {
try {
//Write the business  logic to fetch  data  and put it  in a variable
RoleAccessBean rab = new RoleAccessBean();
rab = rab.findByName("Site Administrator");
sampleRegistry .put(rab.getRoleId(), rab.getName());
} catch (ECException e) {
   e.printStackTrace();
}
               
}
/**
* This methods refreshes the registry with initial data.
*/
private void initialRegistry() throws Exception {
 //Write the business  logic to fetch initial  data  and put it  in a variable
                               
}
}
Step3: Create the  Data bean which will be used for reading registry values.
package com.wcs.registry;
public class TestRegistryBean extends SmartDataBeanImpl     implements     SmartDataBean
 
private HashMap registry;  
public void populate() throws com.ibm.commerce.exception.ECException {   
TestRegistry   testRegistry  ;  
testRegistry   =( TestRegistry  )(RegistryManager.singleton().getRegistry("TestRegistry"));
//Set  the Registry
setRegistry(testRegistry .getSampleRegistry()); 
}
public Hashtable getRegistry() 
{
return registry;
 
public void setRegistry(HashMap mapRegistry) {
this.registry = mapRegistry; 

}
Step4: Print the registry values  in Jsp using the data bean
<jsp:useBean id="testRegistryBean" class=" com.test.registry. TestRegistryBean" scope="page"> <%com.ibm.commerce.beans.DataBeanManager.activate(testRegistryBean,request); %>
</jsp:useBean>
<c:forEach var="registry" items="${testRegistryBean.registry}">  
c:out value="${registry.value}"/>
< /c:forEach>

Comments

Popular posts from this blog

How to read applied promotions codes

The below snippet will give you to read the promotions codes which are applied to order number, String orderId = "978593958"; OrderKey orderKey = new OrderKey(new Long(orderId)); PromotionArgumentSessionBeanPersistenceManager promoManager = new PromotionArgumentSessionBeanPersistenceManager(); PromotionArgument promArg = promoManager.load(orderKey); Iterator prmoExeRecds = promArg.getPromotionExecutionRecords(); while(prmoExeRecds.hasNext()) { PromotionExecutionRecord promotionExeecutionRecord = (PromotionExecutionRecord) prmoExeRecds.next(); Promotion promotion = promotionExeecutionRecord.getPromotion(); System.out.println("Name: " + promotion.getName()); System.out.println("Admin description: " + promotion.getDescription(commandContext.getLocale(), com.ibm.commerce.marketing.promotion.Description.SHOPPER_SHORT_DESC)); }

IBM Announces version 9 of WebSphere Commerce!

What’s new in Version 9 includes information about new functionality and changes in existing functionality from previous WebSphere Commerce Version to the modernized WebSphere Commerce Version 9 release: Micro services architecture , with lightweight, self-contained, distributed servers, supports horizontal scaling, parallel development, and utilization of modern, open source tools. Docker containers deliver key benefits for DevOps , including deployment automation, delivery acceleration, and application portability. Flexible deployment options for  Docker containers  gives IT organizations more infrastructure choices for e-commerce workloads, including all cloud options: private, public, or hybrid deployment. Evolution of the technology stacks  makes customization of the brand and business user experience more efficient and cost effective. Key changes include adoption of lightweight IBM WebSphere Liberty, replacement of Enterprise JavaBeans™ (EJBs) with Java™ Pers...

How to do Email Configurations in Web sphere Commerce

Web sphere commerce allows to send email messages to customers by making use of the below mentioned steps. Create the JSP which will be used for generating contents of the email  For e.g.: SendEmail.jsp Create View for the JSP in Struts-Config-Ext.xml Make an Entry in Struts-Config-Ext.xml file for .jsp as below < action path='/SendEmailView' type='com.ibm.commerce.struts.BaseAction'>     < set-property property ='authenticate' value ='10001:1'/>      < set-property property ='https' value ='10001:1'/> < /action> < forward name="SendEmailView /10001/-3" path="/< location of JSP file >/ TestEmail.jsp" className="com.ibm.commerce.struts.ECActionForward">     < set-property property="implClassName"     value="com.ibm.commerce.messaging.viewcommands.MessagingViewCommandImpl"/>     < set-property property="int...