Monday, 25 September 2017

Nested Application Module in Oracle ADF

Introduction: Application modules support the ability to create software components that mimic the modularity of our use cases, for which our higher-level functions might reuse a "subfunction" that is common to several business work flows. We can implement this modularity by defining composite application modules that we assemble using instances of other application modules. This task is referred to as application module nesting. That is, an application module can contain logically one or more other application modules, as well as view objects. The outermost containing application module is referred to as the root application module.
Any application module can be used as a root application module, but it would usually be one that maps to a more complex use case. When a root application module contains other nested application modules, they all participate in the root application module’s transaction and share the same database connection and a single set of entity caches. This sharing is handled for us automatically by the root application module and its Transaction object.
When we nest an instance of one application module inside another, we trigger not only the view objects in its data model, but also any service methods it defines. This feature of nesting, or reusing, an instance of one application module inside of another application module is one of the most powerful design aspects for implementing larger-scale, real-world application systems.
Demonstration:  For demonstration purpose we will use the HR schema of the Oracle Database XE 11g. To create the sample application follow the steps as shown below:
Step 1: Create an Oracle ADF Fusion Web Application named as NestedAMDemo.
Step 2: Create an ADF Business components for tables (only EOs and VOs) from the EMPLOYEES and DEPARTMENTS table. Note: Don’t create Application Module at this point.
Step 3: Let us create two application modules: EmployeesAM containing the instance of EmployeesVO, and DepartmentsAM containing the instance of DepartmentsVO.
Step 4: Create a demo.jspx page. Drag and drop EmployeesVO1 and DepartmentsVO1 from the Data Control as a table on the demo.jspx page as shown below.
Step 5: Open demoPageDef.xml file. We can see that it uses or shows two different DataControl: DepartmentsAMDataControl and EmployeesAMDataControl.
Step 6: Now run the demo.jspx page and check connections in Web Logic Server Administration Console (Servers à DefaultServer à Monitoring à JDBC). It shows two Database connections (one for each Application Modules).
Step 7: Now let see what happens when we use Nested Application Module concept. Let us create a new application module and name it as RootAM and include both the EmployeesAM and DepartmentsAM inside RootAM as shown below:
Thus the screen shot of the Data Control is as below:
Step 8: Now let us look at the demoPageDef.xml file. We can see that it uses or shows only one DataControl: RootAMDataControl.
Step 9: Now run the demo.jspx page and check connections in Web Logic Server Administration Console (Servers à DefaultServer à Monitoring à JDBC). It will show only one Database connection that is used by the Root Application Module.
Thus, the main purpose of using Nested Application Module is to avoid multiple database connection. Hence, the solution to our requirement.
If you like the post, please comment, share the post and do like me on Facebook.

Thanks & Regards,
Susanto Paul