Monday, July 29, 2013

Abstract Task command multi store esites model

This is my 100th blog and am happy to share my leanings. Please do leave a comment, if you have any ideas or questions or you like reading any specific areas.
 It is very important to understand the classic java abstract classes and methods and it is very useful when implementing task commands in multiple e-site scenario's, specially for tax/shipping/environment fee and other country specific, site specific entities.

Command Reg entries:  Making sure common command is registered to store 0 so all stores can pick up that command and store specific customization, can be implemented and registered for specific store e.g. 10151 below.

            interfacename="com.custom.commerce.order.commands.CustomCalculateTaxTaskCmd"
        classname="com.custom.commerce.order.commands.CustomUSCalculateTaxTaskCmdTaskCmdImpl"
        description="US store implementation of tax command" />
   
            interfacename="com.custom.commerce.order.commands.CustomCalculateTaxTaskCmd"
        classname="com.custom.commerce.order.commands.CustomNonUSCalculateTaxTaskCmdTaskCmdImpl"
        description="Non US store implementation of tax command" />



Creating abstract Task command with abstract methods:

public interface CustomCalculateTaxTaskCmd extends TaskCommand {
    public void seTaxId(String taxId);
}
public abstract class CustomCalculateTaxTaskCmdTaskCmdImplextends TaskCommandImpl
        implements CustomCalculateTaxTaskCmd{
                protected String taxId;
                public void setTaxId(taxId) {
                       this.taxId=taxId;
                }
                public void performExecute() throws ECException {
                            super.performExecute();
                            initialize();
                            customFilter();
                }
               private void initialize() throws Exception {
                //Implement common initialization of access beans and any common params
               }
               protected void  filter1() {
                     //custom filter
               }
               protected void  filter2() {
                     //custom filter code
               }
.....
               protected void  filter5() {
                     //custom filter code
               }
              protected abstract void customFilter() throws Exception;
              
}
//Custom implementation extending abstract command where the abstract method customFilter() is implemented and filter1 and filter2 methods are implemented in the abstract command
public CustomUSCalculateTaxTaskCmdTaskCmdImpl extends CustomCalculateTaxTaskCmdTaskCmdImplextends {
                public void performExecute() throws ECException {
                           super.performExecute();
                }
                protected void customFilter() throws Exception {
                           filter1();
                           filter2();
                }
}
//Custom implementation extending abstract command, where the abstract method customFilter() is implemented and filter1() and filter2() methods are implemented in the abstract command
public CustomNonUSCalculateTaxTaskCmdTaskCmdImpl extends CustomCalculateTaxTaskCmdTaskCmdImpl {
                public void performExecute() throws ECException {
                           super.performExecute();
                }
                protected void customFilter() throws Exception {
                           filter1();
                           filter5();
                }
}

7 comments:

  1. This is such a great resource that you are providing and you give it away for free. I love seeing websites that understand the value of providing a quality resource for free. It?s the old what goes around comes around routine. Did you acquired lots of links and I see lots of trackbacks??
    Dynamics AX training

    ReplyDelete
  2. First of all thank you for this lovely little peice of work.....
    websphere Online Training

    ReplyDelete