Strategic Pattern v3


/ Published in: Java
Save to your folder(s)

Strategic Pattern v3


Copy this code and paste it in your HTML
  1. public abstract class Dashboard {
  2.  
  3. public Dashboard(){}
  4.  
  5. @Autowired
  6. private ActionBulletinService actionBulletinService;
  7.  
  8. WorkFlowDashboardBehavior behavior;
  9.  
  10.  
  11. public List<OrderDetail> retrieveDashBoardList(UserMaster user, List<UserRole> roles){
  12. return actionBulletinService.retrieveTaskListByUserIdByRoleList(user.getId() , roles );
  13. }
  14.  
  15. public void commonMethod() {
  16. System.out.println("All different dashboard share this same method !");
  17. }
  18.  
  19. public void setWorkFlowDashboard(WorkFlowDashboardBehavior dashBoardBehavior){
  20. behavior = dashBoardBehavior;
  21. }
  22. }
  23.  
  24. @Configurable
  25. @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
  26. public class TeamLeadBehavior implements WorkFlowDashboardBehavior{
  27.  
  28. public TeamLeadBehavior( ){
  29.  
  30. }
  31.  
  32. @Override
  33. public void WorkFlowBehaviour(){
  34. System.out.println("@@@@@@@@@@@@@@@@@@@ TeamLeadDashBoard :::");
  35. }
  36.  
  37. }
  38.  
  39.  
  40. @Configurable
  41. @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
  42. public class RnoBehavior implements WorkFlowDashboardBehavior{
  43.  
  44. @Autowired
  45. private ActionBulletinService actionBulletinService;
  46.  
  47. public RnoBehavior( ){
  48.  
  49. }
  50.  
  51. @Override
  52. public void WorkFlowBehaviour() {
  53. System.out.println("@@@@@@@@@@@@@@@@@ rno Behavior");
  54.  
  55. }
  56.  
  57. }
  58.  
  59.  
  60.  
  61. @Configurable
  62. @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
  63. public class TeamLeadDashBoard extends Dashboard{
  64.  
  65. public TeamLeadDashBoard(){
  66. behavior = new TeamLeadBehavior();
  67. }
  68.  
  69. @Override
  70. public void commonMethod(){
  71. System.out.println("@@@@ This is TeamLeadDashboard");
  72. }
  73. }
  74.  
  75. public interface WorkFlowDashboardBehavior {
  76.  
  77. public void WorkFlowBehaviour();
  78. }
  79.  
  80.  
  81.  
  82. @Scope("session")
  83. public class ActionBulletinManagedBean extends BasePageBean{
  84.  
  85. private static final long serialVersionUID = 1L;
  86.  
  87. @Autowired
  88. private ActionBulletinService actionBulletinService;
  89.  
  90. @Autowired
  91. @Getter @Setter
  92. private ActionBulletinPojo actionBulletinPojo;
  93.  
  94. @Autowired
  95. private Dashboard board ;
  96.  
  97. @PostConstruct
  98. @Override
  99. public void init() throws Exception {
  100.  
  101. setPageId(PageIds.BACKENDUSR_USER_MGNT);
  102.  
  103. actionBulletinPojo = null;
  104. actionBulletinPojo = new ActionBulletinPojo ();
  105.  
  106. actionBulletinPojo.backendTaskList = new ArrayList<OrderDetail>();
  107.  
  108. manageDashBoard();
  109.  
  110. }
  111.  
  112. public void manageDashBoard(){
  113. board = new TeamLeadDashBoard();
  114. board.commonMethod();
  115. actionBulletinPojo.setBackendTaskList(board.retrieveDashBoardList(getCurrentUser(), getCurrentUserRoles()));
  116. }
  117.  
  118.  
  119. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.