Application Module act as container for view Object and view Link business components that are used in a specific task. It provides data model and data control to show required information and perform action for the client
An application module represents a single transaction and owns one database connection that's why commit and rollback works for all view Objects inside an application module
In ADF we develop large enterprize applications using lots of business components , regions , dynamic regions and with each used application module there is a increment in connection count
We can handle it using nested application modules where ever possible
An application module can contain other application modules, Nested application modules are used where an AM can be used again for another transaction. The important thing about nested application modules is transaction and connection sharing, All nested application modules use same transaction as the root application module
Here I am not taking any practical use case just showing how use of nested application modules decrease DB connection count
Created a Fusion Web Application using Departments and Employees table of HR Schema and prepared two application module - DeptAM and EmpAM
DeptAM- It has Departments View Object
EmpAM- It has Employees View Object
Now created a page and dropped both view Object as af:table on page
see pageDef source that shows two different data controls
<executables>
<variableIteratorid="variables"/>
<iteratorBinds="DepartmentsVO1"RangeSize="25"DataControl="DeptAMDataControl"id="DepartmentsVO1Iterator"/>
<iteratorBinds="EmployeesVO1"RangeSize="25"DataControl="EmpAmDataControl"id="EmployeesVO1Iterator"/>
</executables>
Now run and check connections in Weblogic Server Administration console, It shows 2 DB connections (one for each AM)
Now see what happens when we use nested application modules,
Create a new Application Module , name it as rootAm and add both application modules to it
You can see it appears under application data controls, Now drop both view Object on page from rootAmDataControl
and look at pagedef , both view Objects are of different application module but shares same data control that is of root application module
<executables>
<variableIteratorid="variables"/>
<iteratorBinds="DeptAM1.DepartmentsVO1"DataControl="rootAmDataControl"RangeSize="25"
id="DepartmentsVO1Iterator"/>
<iteratorBinds="EmpAm1.EmployeesVO1"DataControl="rootAmDataControl"RangeSize="25"id="EmployeesVO1Iterator"/>
</executables>
Run application and check connection count again, It shows 1 DB connection that is used by root application module
So here we learnt that we can import multiple application module (reusable) in one app using application library (Jar files) and create a root AM to avoid multiple DB connections
Cheers :) Happy Learning