# What Is an Application Module

An Application Module is a logical container for coordinated objects related to a particular task, with optional programming logic. Application Modules provide a simple runtime data connection model (one connection per Application Module) and a context for defining and executing transactions. The Business Components for Java framework provides an `oracle.jbo.common.ampool` package that clients can use to manage and share a pool of Application Modules. An Application Module provides the following functionality:

- Define a database session and a transaction boundary. See About Application Modules and Transactions.

- Control concurrent access to data. See About Transactions and Locks.

- Group related View Objects into a data model that clients can access in a single network roundtrip. See About Application Modules, View Objects, and Data Models.

- Store application-specific Java code in an object on the middle tier. See About Application Modules and Custom Code.

- Create read-only View Objects from SQL statements and clauses. See Using SQL with View Objects.

- Access utility methods for testing and debugging. See Using Application Module Utility Methods.

You can define an Application Module using wizards at design time, or clients can use a generic Application Module provided by the Business Components for Java framework. You don't need to write Java code unless you want to customize the Application Module or the View Objects it contains.

Application Modules can be nested. That is, an Application Module can (logically) contain one or more other Application Modules as well as View Objects. When Application Modules are nested, the outer-most (top-level) Application Module provides the transaction context for the others. The following figure shows two examples. In the first example, `amTwo` contains `amThree`, but it does not provide its transaction context because `amOne` is the outer-most Application Module. In the second example, the generic Application Module is outer-most, so it provides the transaction context for `amFour`.

## Useful Application Module Methods

The following methods are frequently used when working with Application Modules.

    createViewObject

    findViewObject

    createViewObjectFromQueryStmt

    findViewLink

    remove

You can deploy an Application Module to any supported platform. Client applications use different approaches to find an Application Module, depending on where it is deployed. For more information, see Loading an Application Module and Finding an Application Module.

## About Application Modules, View Objects, and Data Models

An Application Module provides a logical container for a data model represented by View Objects and View Links. Figure 1 shows an Application Module that contains four View Objects: `DeptView`, `EmpView`, `EmployeeList`, and `YearsInService`. The figure also shows the corresponding Entity Objects and the underlying tables in the database. A client application could access the four View Objects individually, but each access would require a separate trip across the network. The Application Module effectively groups or "wraps" the View Objects, enabling a client to access the entire data model (including information about the master-detail link between `DeptView` and `EmpView`) in one roundtrip.

#### Figure 1: An Application Module Lets Clients Access the Entire Data Model

Application Modules can be shared and reused by middle-tier components and client applications. Using Application Modules, you can build client frames as fully-functional stand-alone components. Each frame can have its own Application Module that describes its data model and provides any middle-tier, application-specific code and event handling the frame might require. Figure 2 shows two client frames. One frame uses an Application Module named `AMFoo`, the other uses `AMBar`. Each Application Module includes a data model (both data models use the View Object `VO-C`), and `AMFoo` provides some custom code.

#### Figure 2: A View Object Can Participate in Multiple Application Modules