Value List Handler Pattern


EJB design: Value List Handler Pattern

  1. Value List Handler Pattern (4 messages)

    Hi everyone
    I have a question in implementing value list handler pattern.
    is it better to implement the value list handler class as a stateful session bean or simple java class ? and why i should put session facade before my value list handler class ? [i'm using DataSource as my DAO and it supports caching ] [see for more detail about my question]
    I want to know what is the best way to implement a mechanism to execute select statements on database.

    Threaded Messages (4)

  2. Value List Handler Pattern[ Go to top ]

    You generally need some way of managing conversational state in the handler. In an EJB architecture this would be an SFSB. In a web based architecture you could use a simple java class and keep the instance in the http session.
  3. I have a similar query. I have to show a report of all items (large resultset)for a specific category. There are around 15 categories in the database. If i implement Stateful Session Bean to store the Item List, the container will create a separate List for each client. Just imagine what will happens when 500 users are requesting the report.

    Is it possible to cache the results in a centralized location which is accessible to all the users. In this case, at most 15 item list will be created irrespective of the number of users accessing it.
  4. my suggest[ Go to top ]

    we using dao like this:
      public ValueListHandler findXXByXXName(String XXName);

    XXDAOimp implements XXDAO
      public ValueListHandler findXXByXXName(String XXName)
       ..............//sql query and changethe resultset into TOs(Vector)
       return new ValueListHandlerimp(TOs);

    1. findXXByXXName is a finder method.
    2. ValueListHandler is a interface ,ValueListHandlerimp is ValueListHandler 's implementer
  5. My suggestions[ Go to top ]

    1. Implement the DAO as a POJO, because then you can write and test it outside your EJB server (which makes testing ever so much easier).

    2. If you want to do caching for your DAO, (a) consider switching to CMP (which will do caching) or (b) finding an ORM (Object-to-Relational-Mapping) tool that is EJB friendly and does caching, such as Hibernate. Caching logic gets very complicated very quickly, and there are plenty of tools out there that have already done it.