/ Published in: Java
Strategic Pattern v3
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
public abstract class Dashboard { public Dashboard(){} @Autowired private ActionBulletinService actionBulletinService; WorkFlowDashboardBehavior behavior; public List<OrderDetail> retrieveDashBoardList(UserMaster user, List<UserRole> roles){ return actionBulletinService.retrieveTaskListByUserIdByRoleList(user.getId() , roles ); } public void commonMethod() { } public void setWorkFlowDashboard(WorkFlowDashboardBehavior dashBoardBehavior){ behavior = dashBoardBehavior; } } @Configurable @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class TeamLeadBehavior implements WorkFlowDashboardBehavior{ public TeamLeadBehavior( ){ } @Override public void WorkFlowBehaviour(){ } } @Configurable @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class RnoBehavior implements WorkFlowDashboardBehavior{ @Autowired private ActionBulletinService actionBulletinService; public RnoBehavior( ){ } @Override public void WorkFlowBehaviour() { } } @Configurable @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class TeamLeadDashBoard extends Dashboard{ public TeamLeadDashBoard(){ behavior = new TeamLeadBehavior(); } @Override public void commonMethod(){ } } public interface WorkFlowDashboardBehavior { public void WorkFlowBehaviour(); } @Scope("session") public class ActionBulletinManagedBean extends BasePageBean{ private static final long serialVersionUID = 1L; @Autowired private ActionBulletinService actionBulletinService; @Autowired @Getter @Setter private ActionBulletinPojo actionBulletinPojo; @Autowired private Dashboard board ; @PostConstruct @Override setPageId(PageIds.BACKENDUSR_USER_MGNT); actionBulletinPojo = null; actionBulletinPojo = new ActionBulletinPojo (); actionBulletinPojo.backendTaskList = new ArrayList<OrderDetail>(); manageDashBoard(); } public void manageDashBoard(){ board = new TeamLeadDashBoard(); board.commonMethod(); actionBulletinPojo.setBackendTaskList(board.retrieveDashBoardList(getCurrentUser(), getCurrentUserRoles())); } }