J2EE Design Pattern : Business Tier Patterns : Value List Handler Design Pattern
|Value List Handler Design Pattern?|
Value List Handler manages query execution, results caching, and results processing.
Many J2EE applications have clients that perform various searches. Frequently, these searches are initiated by the presentation tier, executed by the business tier and displayed in the browser. When these searches that result in a large number of matching entity beans, entity bean finder methods are inefficient. Another problem is that clients might not be capable of handling large results, and want the server to manage the results.
You have a remote client that wants to iterate over a large results list.
- Use a Value List Handler to search, cache the results, and allow the client to traverse and select items from the results.
- The Value List Handler provides the search and iteration functionality. To perform a search, the Value List Handler uses a Data Access Object to execute the query and retrieve the matching results from the database. This bypasses using the EJB finders for your applications where Business Objects are implemented as entity beans.
Participants and Collaborations
A Client is any client that needs to execute a query that returns a large set of results. The client can be a presentation-tier component that wants to display search results to a user. The client can also be a session bean that encapsulates the ValueListHandler.
A ValueListIterator provides an iteration mechanism with the following methods to iterate over the contents of the ValueList.
The ValueListHandler executes the search and obtains the query results, which it manages in a privately held collection represented by the ValueList object. The ValueListHandler creates and manipulates the ValueList collection typically using a Data Access Object. When the client requests the results, the ValueListHandler creates a sub-list from the original ValueList and sends it to the Client. Typically, a ValueListHandler manages a single ValueList. However,
ValueListHandler can manage more than one ValueList instances in case it has to combine and handle multiple search results.
The ValueListHandler uses the DataAccessObject to access the data source, execute the query, and retrieve the results.
The ValueList is a collection that holds the results of the query. Typically, you might use a List implementation from the Java Collections API or implement your own custom List based on your needs.
The Value represents a result data object from the search.
- POJO Strategy
- Session Façade
- Value List from Data Access Object Strategy
|Example for Value List Handler|