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();
                }
}

12 comments:

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

    ReplyDelete
  2. Que buen blog tenéis, me encanta leer todos vuestros artículos es de los mejores blog. Además son super útiles y claros.

    ReplyDelete
  3. Me gusta mucho tu página en general y este artículo en particular me ha encantado, siento que le dedicas mucho tiempo y que disfrutas lo que haces. mucha suerte!!!

    ReplyDelete
  4. No se si estoy de acuerdo con todo lo que has escrito pero sin ninguna duda lo haces desde el respeto y la educación. Tener puntos de vista distintos a los míos es una oportunidad para poder aprender cosas nuevas. Deseando que subas más contenido. Un saludo!!!

    ReplyDelete
  5. No tenía mucha idea acerca del tema y la verdad es que vuestra información ha sido muy útil e instructiva, he aprendido muchas cosas que podré poner en práctica a partir de ahora. ¡Muchas gracias!

    ReplyDelete
  6. No es lo que buscaba en estos momentos, pero me he parado a leerlo y me ha interesado más de lo que me esperaba , muchísimas gracias.

    ReplyDelete
  7. Buenas!! que interesante tu artículo, ha sido una información muy útil que estoy segura que
    usaré. Estoy deseando que subas nuevo contenido pronto. saludos <3

    ReplyDelete