Chapter 16. Creating and testing layered applications

Hibernate is intended to be used in just about any architectural scenario imaginable. Hibernate may run inside a servlet container; you can use it with web application framework like Struts, WebWork, or Tapestry, or inside an EJB container, or to manage persistent data in a Java Swing application.

Even—perhaps especially—with all these options, it's often difficult to see exactly how Hibernate should be integrated into a particular Java-based architecture. Inevitably, you'll need to write infrastructural code to support your own application design. In this chapter, we describe common Java architectures and show how Hibernate can be integrated into each scenario.

We discuss how you design and create layers in a typical request/response based web application, and how you separate code by functionality. After this, we introduce Java EE services and EJBs and show how managed components can make your life easier and reduce the infrastructure coding that would otherwise be necessary.

Finally, we assume that you're also interested in testing your layered application, with or without managed components. Today, testing is one of the most important activities in a developer's work, and applying the right tools and strategies is essential for quick turnaround times and productivity (not to mention the quality of the software). We'll look at unit, functional, and integration testing with our current favorite testing framework, TestNG.

Let's start with a typical web application example.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.11.182