ADF for High Availability

 

  1. In order for an ADF application to support High Availability in clustered environment with server fail over. The below steps must be followed in developing an ADF application.
  • All Manage Beans must implement Serializable.
  • UI component bindings must be declared in a bean with shorter scope (backing bean scope or request scope).
  • If it needs to be declared in Manage Bean with PageFlowScope (Not recommended), please ensure you declare the binding as transient.
  • Any objects that are declared as an attribute in Manage Bean must be Serialized.
  • Ensure that all managed beans with a life span longer than one request are serializable (that is, they implement the java.io.Serializable interface). Specifically, beans stored in session scope, page flow scope, and view scope must be serializable.
  • Verify that Oracle ADF is aware of changes to managed beans stored in ADF scopes (view scope and page flow scope) and enable tracking changes to ADF memory scopes.
  • When you modify a value within a managed bean in either view scope or page flow scope, the application must notify Oracle ADF so that it can ensure the bean’s new value is replicated.

Example – Map<String, Object> viewScope =    AdfFacesContext.getCurrentInstance().getViewScope();MyObject obj = (MyObject)viewScope.get(“myObjectName”);Obj.setFoo(“newValue”);

Without additional code, Oracle ADF will be unaware of this change and will not know that a new value must replicate within the cluster. To inform Oracle ADF of the change and need for replication, use the markScopeDirty() method shown below. The markScopeDirty() method accepts only viewScopeand pageFlowScope as parameters.

controllerContext ctx = ControllerContext.getInstance();ctx.markScopeDirty(viewScope);

 

  • ADF component bindings can not support the Serializable.To make them support HA use the following code for component binding,getters and setters in pageFlowScope bean.

      ex. Normal ADF code for binding,getters and setters will be as follows

       Private RichSelectOneChoice partySelect 

          public void setPartySelect(RichSelectOneChoice partySelect) {
                this.partySelect = partySelect;
               }
         public RichSelectOneChoice getPartySelect() {
                  return partySelect;
        }

    Change this to following code in your pageFlowScope bean to support HA.

import org.apache.myfaces.trinidad.util.ComponentReference;
Private ComponentReference partySelect; 
      
public void setPartySelect(RichSelectOneChoice partySelect) {
      this.partySelect =ComponentReference.newUIComponentReference(partySelect);
}
public RichSelectOneChoice getPartySelect() {
       if(partySelect !=null){
           return (RichSelectOneChoice)partySelect.getComponent();
       }
     return null;
}

 

The following files must be modified to make an ADF application High Available in clustered environment.

 

  1. adf-config.xml


    <adf-controller-config xmlns=”http://xmlns.oracle.com/adf/controller/config“>

<adf-scope-ha-support>true</adf-scope-ha-support>
</adf-controller-config>

 

  1. Trinidad.xml

 

org.apache.myfaces.trinidad.CHECK_FILE_MODIFICATION = false

  1. weblogic.xml


    In the file, add the persistent-store-typedefinition to the session-descriptor element:

<weblogic-web-app>

    <session-descriptor>

    <persistent-store-type>

    replicated_if_clustered

    </persistent-store-type>

    </session-descriptor>

</weblogic-web-app>

 

  1. For testing, please add the below parameter in your weblogic domain 

setDomainEnv.cmd

-Dorg.apache.myfaces.trinidad.CHECK_STATE_SERIALIZATION=all

 

  1. Run each use case in UI application. Verify that you don’t see below highlighted errors in Domain console log.

 

[2012-02-22T13:29:25.383-06:00] [manageserver1] [ERROR] [] [oracle.adfinternal.controller.state.SessionBasedScopeMap] 

  1. io.NotSerializableException: com.ram.mytest.manage.TestMB
Advertisements

2 comments

  1. Thanks for your post ..

    Can you please let me know where to call the below code to inform Oracle ADF of the bean change and need for replication :

    controllerContext ctx = ControllerContext.getInstance();ctx.markScopeDirty(viewScope);

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s