Thursday, July 26, 2012

Multiple Root Application Module to One Root Application Module

Was quite busy in AM pooling and database connections issue.. but interesting issue..

3 years back somebody designed my application with 7 root AM's and its working fine with few users... but in next few months we are going to have 300+ concurrent users..

We don't want to..
 - take 2100 database connections..
 - have frequent activation and passivation..
 - change the application design to have one main taskflow and let all other task flow to share the transaction...

And we just got 4 weeks to fix this... What is the option I left with.. Create a new root application module and make existing 7 AM's nested.. but we got more than 200 pageDef.. I need atleast 4 months to change everything declaratively and test it thoroughly.. not enough time to do this..


So what I have done is.. Created a new sample application with one root AM and one nested AM.. created a task flow and a page with all kinds of bindings declaratively... closely observed the patterns in pageDef files.. Just following the pattern and wrote a small piece of java code which will replace all the pageDef root AM references to use nested AM references.. And yes it worked out.. Just one day coding and 3 weeks testing.. Now on average 1 User 1 DB Connection... I think the best way would be xslt but I'm not familiar with that and I don't have much time to experiment that.. So went with my favorite java code..


I'm sure the same situation will be faced by other developers also.. So I'm sharing my code here.. Just follow the below steps:


1. Create a new Application Module (Say TestRootAM) and make all your existing AM's as nested of RootAM.


2. Create a datacontrol usage in DataBindings.cpx for the new AM. (Simple way is to drag and drop an attribute from a nested AM which will create this entry automatically) Also remove all other datacontrol usages from DataBindings.cpx


3. Download my java code and set proper value for variables
ROOT_AM_NAME (new AM name TestRootAM ) and 
ROOT_DIR (root directory of pageDef files) 
and then run it.. It will replace all root AM references to use nested AM references.

4. Test your application and make sure everything works fine.

Do not forget to change the new AM configurations..

That's it now my application code/design looks same as if it would have been implemented declaratively via jdeveloper with one root AM and multiple nested AM.

In future if you don't want to make any other AM's as root AM then hide all nested AM data controls as per my earlier post.

Also this script will fix Oracle ADF Bug 13837650 which I mentioned in my earlier post.

Good luck and incase if you find any issues in my script please put your comments so that I will modify it. 

Note : Please note that I'm just sharing the code for reference and its your responsibility to use this and test your application thoroughly.

Thiru

11 comments:

  1. Great post i must say.. One thing i want to understand. If the concurrent user in application is more.so should we always make one root application module.Is it the standard way for desiging application. Please clarify when we should use Nested AM and when root AM

    ReplyDelete
    Replies
    1. It depends on your application. In my case when the user logs in almost all the AM's will be used hence I kept one root AM. In case if I have application where the users are restricted(both technically or functionally) to only few pages then I will have different root AM's. Also if your entire application is started with one Bounded Task Flow then you can share the transaction to share the db connection.

      Delete
  2. Goodmorning Thirumalaisamy ,
    this post is very important to resolve one my big problem with much of my viewcontrollers jarlibrary.
    if is possible can you give me an example workspace application for study,
    i'm only a entry level adf programmer .

    thank you in advance

    Giovanni

    ReplyDelete
    Replies
    1. I would suggest you to have a look on Order demo application which comes with Oracle ADF tutorial.

      Delete
    2. thank you for your response,
      can you give me the url where i can find the tutorial

      Delete
    3. Hello,

      Sorry for delayed reply. Please find the Oracle Fusion Order Demo Application in the below link:
      http://www.oracle.com/technetwork/developer-tools/jdev/index-095536.html

      Thiru

      Delete
  3. I read your post and I found this is amazing. Your thought process is wonderful. The way you express yourself is awesome.
    Custom Precision Manufacturer

    ReplyDelete
  4. Thanks you, Thanks you, Thanks you! It works like a champ!
    Thiru, you save me a lot of work :D
    I have modifyed a bit your java code in order to exclude some DataControls (EJB and others Models) from the replacement.

    https://dl.dropboxusercontent.com/u/2329711/ReplaceRootAm.java

    Alex

    ReplyDelete
    Replies
    1. You are welcome Alex. That's fine. Hope your issue resolved.

      Delete
  5. Hi Thirumalaisamy,
    I am facing problem when converting seperated AM into nested AM.Let say I have a jspx page with 2 region, and both the taskflow as start new transation behaviour enabled.In that case I am getting exception.

    ReplyDelete
  6. i cant down the code please send my email 417464169@qq.com ! thanks

    ReplyDelete