Nesting Application Modules at Runtime

You can nest application module on the fly. Following code snippet illustrates the APIs for nesting application module at runtime. Note that nested AM shares same transaction context with the calling AM.

 //In application module implementation class  
 public void nestAMIfRequiredAndInvokeMethod() {  
      ApplicationModuleImpl hrAM = null;  
      boolean generatedLocally = false;  
      try {  
           //Check whether the HRAppModule is already nested
           hrAM =(ApplicationModuleImpl)getDBTransaction().getRootApplicationModule().findApplicationModule("HRAppModule");  
           //create a new instance of the HRAppModule, if not nested already
           if (hrAM == null) {  
                hrAM = (ApplicationModuleImpl)this.getDBTransaction().createApplicationModule("demo.HRAppModule");  
                generatedLocally = true;  
           }  
           //Invoke business methods  
           if (hrAM != null) {  
                hrAM.doSomething();  
           }  
      } catch (Exception e) {  
           e.printStackTrace();  
      } finally {  
           //Remove locally created AM here itself 
           //or you can defer this till you finish you work with this AM
           if (generatedLocally && hrAM != null) {  
                hrAM.remove();  
           }  
      }  
 }  

Learn More ...

There are a lot more points like this. If  you are curious to learn the internals of the ADF Business Components and ADF Binding Layer,  the following book is for you - Oracle ADF Real World Developer’s Guide.
More details about this book can be found in this post- http://jobinesh.blogspot.in/2012/07/pre-order-your-copy-of-oracle-adf-real.html

Comments

Disclaimer

The views expressed on this blog are my own and do not necessarily reflect the views of my employer.