Designing application flow
        Posted  
        
            by 
                Umesh Awasthi
            
        on Programmers
        
        See other posts from Programmers
        
            or by Umesh Awasthi
        
        
        
        Published on 2013-04-17T04:06:03Z
        Indexed on 
            2013/11/13
            16:16 UTC
        
        
        Read the original article
        Hit count: 527
        
I am creating a web application in java where I need to mock the following flow.
When user trigger a certain process (add product to cart), I need to pass through following steps
- Need to see in HTTP Session if user is logged in.
- Check HTTP Session if shopping cart is there
- If user exist in HTTP Session and his/her cart do not exist in HTTP Session
- Get user cart from the database.
- add item to cart and save it to HTTP session and update cart in DB.
- If cart does not exist in DB, create new cart and and save in it HTTP Session.
Though I missed a lot of use cases here (do not want question length to increase a lot), but most of the flow will be same as I described in above steps.
My flow will start from the Controller and will go towards Service Layer and than ends up in the DAO layer.
Since there will be a lot of use cases where I need to check HTTP session and based on that need to call Service layer, I was planning to add a Facade layer which should be responsible to do this for me like checking Session and interacting with Service layer.
Please suggest if this is a valid approach or any other best approach can be implemented here?
One more point where I am confused is how to handle HTTP session in facade layer? do I need to pass HTTP session object each time I call my Facade or any other approach can be used here?
© Programmers or respective owner