Adam Bien's Weblog
p4j5: Source For The Paginator Java EE 5 Pattern Available
I even checked in the source code sample for the Paginator pattern. Paginator is a new name for the Value List Handler Pattern from the ancient J2EE 1.4 days :-). The name Value List Handler is no more appropriate, because Paginator is also able to return persistent JPA-Entities (they do not have necessarily to be attached, or Value Object). Paginator is able to iterate over a set of entities, so it is very similar to the [GoF] Iterator-Pattern.
The usage is very straight-forward - it works like an iterator:
CustomerQuery query = (CustomerQuery)PortableRemoteObject.narrow(remote,CustomerQuery.class);
while(query.hasNext()){
List<Customer> customers = query.next();
System.out.println("Size: " + customers.size());
for (Customer customer : customers) {
System.out.println("Customer: " +customer);
}
}
The Paginator is realized as a stateful EJB 3 which works with JPA's Entity Manager. The whole source is available in p4j5.
Posted at 12:09PM Aug 10, 2007 by Adam Bien in Java EE 5 Architectures | Comments[2]
[my tweets]
Rss My book: Real World Java EE - Rethinking Best Practices


Very nice... I love that it implements Iterator -- should be extremely intuitive to use, and hopefully by using an interface that everyone knows of and uses every day (well, before JSE 5), it will cause people to stop and think about how these patterns can be renewed with JEE 5... Nice work!
Posted by Matt Corey on August 10, 2007 at 06:49 PM CEST #
Matt,
thanks for your nice comment. Just check it out and use it :-). I'm going to check in the remaining patterns and utilities. They are mainly abstractions and best practices from my current projects.
thanks again
Posted by Adam Bien on August 10, 2007 at 07:28 PM CEST #