Please disable your adblock and script blockers to view this page

Search this blog

Friday, 12 May 2017

Understanding Nested Application Modules in Oracle ADF


Application Module acts as a 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 enterprise applications using lots of business components, regions, dynamic regions and with each used application module there is an 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 the 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>
    <variableIterator id="variables"/>
    <iterator Binds="DepartmentsVO1" RangeSize="25" DataControl="DeptAMDataControl" id="DepartmentsVO1Iterator"/>
    <iterator Binds="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>
        <variableIterator id="variables"/>
        <iterator Binds="DeptAM1.DepartmentsVO1" DataControl="rootAmDataControl" RangeSize="25"
                  id="DepartmentsVO1Iterator"/>
        <iterator Binds="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 learned that this can be used when we import multiple application modules (reusable) in one app using application library (Jar files), In that scenario, We can create a root AM to avoid multiple DB connections

Cheers :) Happy Learning

7 comments :

  1. Thanks for this, Your posts are very easy to understand

    ReplyDelete
  2. thanks for this interesting post
    but i didnot understand the last statement

    "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"

    what do u mean by import multiple application modules ? u mean to deploy the application to a jar file and import it in another application and then put its Application module nested under the another application 'application module' ?

    ReplyDelete
    Replies
    1. Hi Mosta

      You got it right, Suppose you have multiple small apps and you need to use them in a larger MIS kind of app then we can create JARs and add it to main application under a root AM
      This post of andrejus talks about this use case in detail
      ADF Regions and Nested Application Modules to Improve Performance

      Ashish

      Delete
  3. Hi Ashish,
    How does the commit operation work here, if the nested AM is committed then will the rootAM also gets committed or is it the vice versa?

    Thanks,
    Jitu.

    ReplyDelete
    Replies
    1. Yes commit works for all AM Under nested AM when using AM on same page and if nested AM is used on a region then it commits only that AM

      Ashish

      Delete