Friday, September 19, 2014

Customization Classes for MDS in Oracle ADF

In last blog posts Seeded Customizations using MDS in Oracle ADF & Personalization using MDS in Oracle ADF Personalization and Customizations were described using power of MDS framework. The most important part in configuring/implementing Customizations which we can say is heart are Customization Classes. So it becomes very important to know and have a clear concept about what Customization classes are , what they do and how to implement them for use cases.

Customization Classes

First we need to understand what are Customization Classes. Customization classes provide a layer of customization. This is a very common technical definition for MDS Customization classes. In very simple terms, they return a single/multiple values for which different customizations are applied to the base document.
This means suppose while configuring/designing customizations, developer configured ABC changes (Customizations) for X value, then at the runtime when the Customization class method(will the method later in article) will return X value, ABC Changes will be applied on the document. Thus Customization classes return values and changes stored in MDS are applied to the base document based on these Classes.



Customization Classes provided by Oracle ADF Framework

There are some Customization classes which are provided by framework itself. These are layer values which are required and are very common in implementation of MDS Customizations and Personalizations. Below are the common Customization classes already there in ADF :


  • UserCC - Returns Authenticated user names.
  • SiteCC  -  Returns a single value “site” and allows developers to customize an application for a point of installation.
  • ADFRoleCC - Returns the roles the authenticated user is a member of

These Customization layer classes provides default layer values.
UserCC returns the current user. This customization class is used mostly for User Customizations or Personalizations. Since it returns current logged in user, it goes to MDS and fetches all the customizations for that particular user name from the MDS and applies it to the base document.

On Similar terms ADFRoleCC class reads Role from SecurityContext and returns the role to which current logged in user belongs to.


Custom Customization Classes for MDS

Above mentioned classes comes default with the framework and can be used for most of the use cases. But there are requirements where customization layers have to return some custom values. For this, custom class is implemented.

Every Custom Class needs to extend oracle.mds.cust.CustomizationClass and needs to override below three methods.


  • public CacheHint getCacheHint()
  • public String getName() 
  • public String[] getValue(RestrictedSession restrictedSession,MetadataObject metadataObject)


getCacheHint() - The cache hint information provides information about how long a change definition read fromthe MDS repository should be kept in memory and whether, or not, internally it should be cached for multiple users.
Valid values which can be returned by getCacheHint are


  • ALL_USERS -  Customizations are applied to all users of application.
  • MULTI_USERS - Customizations are applied to only group of users of application.
  • USER - Customizations are applied to only individual user.
  • REQUEST - Customization is applied to single request only and is not persisted.
Example : 

public CacheHint getCacheHint() {
return CacheHint.ALL_USERS;
}


getName() - This is the name by which Customization Layers are identified. It defines a name for customization layers like user for UserCC layer.

Example :

public String getName() {
return "powerUserCC";
}

getValue() - This is the most important method to be implemented while implementing Custom Customization class. This method actually returns the value of Customization Layer according to which changes and customizations defined/stored in MDS needs to be applied. Values returned by the getValue method is the part that influences the visual appearance and behavior of an application.

Now there are multiple ways getValue() method can be implemented according to the needs. Since getValue() needs to return a specific value at the runtime for which customizations are defined/store, it needs to read these values from configuration files which have these values which are specific to client or use case.

One way getValue() method can be implemented to read values from properties file. This is very well explained in oracle documentation http://docs.oracle.com/cd/E16764_01/web.1111/b31974/customize.htm#BABJADGG

Another way which is very useful is to read Context Parameter from Web.xml file. Using this approach, the customization layer value is being defined as value for context parameter in Web.xml and in the getValue() method of Customization class, this parameter is read and returned. This means once getValue() method is implemented to read values of context parameter, only context parameter needs to be changed for different values of customization layers. Below is example for this.



And below is how value for ClientName context parameter is set in Web.xml






So at runtime, the code in getValue() will read the value of ClientName parameter and return the same as value of customization layer. After this customizations specific to this value will be applied over the Base Document.


Well thats it. As we saw Customization classes are the heart of Customizations in ADF and they are very powerful as one can create custom classes in addition to the default classes provided by the framework.

12 comments:

  1. I like this article as I have been wondering how to leverage MDS customizations. However, I thought the whole point of MDS was that it had it's own data store? So, if a user had some preferences for a table layout, those preferences would be stored in the MDS repository.

    Lastly, how would you leverage this class in the actual ADF application?

    ReplyDelete
  2. Yes Brad, MDS store data, but framework needs to know how to apply that stored data and under which conditions.
    For leverage these classes, please refer earlier posts on Personalization and Seeded Customizations.
    http://rohanwalia.blogspot.in/2014/08/seeded-customizations-using-mds-in.html
    http://rohanwalia.blogspot.in/2014/08/personalization-using-mds-in-oracle-adf.html

    Thanks

    ReplyDelete
  3. Rohan, I don't understand the param clientname? What if I have 100 users in my application? What exactly it does?

    ReplyDelete
  4. Sfti,
    clientName paramater is key for the clientName. At designtime, developer does customizations for values. Values can be client names. This client name is set in web.xml as context param. At runtime, it returns the name of client (value which is set in context param) and then gets all the defined customizations from MDS and applys on it.

    For users you can use in built UserCC class as your customization layer.

    Thanks

    ReplyDelete
  5. Oracle ADF Online Training, ONLINE TRAINING – IT SUPPORT – CORPORATE TRAINING http://www.21cssindia.com/courses/oracle-adf-online-training-122.html The 21st Century Software Solutions of India offers one of the Largest conglomerations of Software Training, IT Support, Corporate Training institute in India - +919000444287 - +917386622889 - Visakhapatnam,Hyderabad Oracle ADF Online Training, Oracle ADF Training, Oracle ADF, Oracle ADF Online Training| Oracle ADF Training| Oracle ADF| "Courses at 21st Century Software Solutions
    Talend Online Training -Hyperion Online Training - IBM Unica Online Training - Siteminder Online Training - SharePoint Online Training - Informatica Online Training - SalesForce Online Training - Many more… | Call Us +917386622889 - +919000444287 - contact@21cssindia.com
    Visit: http://www.21cssindia.com/courses.html"

    ReplyDelete
  6. Thank you for sharing your thoughts. I really appreciate your efforts
    and I will be waiting for your next write ups thanks once again.
    Qlikview Training | Informatica Online training

    ReplyDelete
  7. I am following your blog from the beginning, it was so distinct & I had a chance to collect conglomeration of information that helps me a lot to improvise myself. I hope this will help many readers who are in need of this vital piece of information. Thanks for sharing & keep your blog updated.
    S&M consultants

    ReplyDelete
  8. excellent piece of information, I had come to know about your website from my friend kishore, pune,i have read atleast 8 posts of yours by now, and let me tell you, your site gives the best and the most interesting information. This is just the kind of information that i had been looking for, i'm already your rss reader now and i would regularly watch out for the new posts, once again hats off to you! Thanx a lot once again, Regards, obiee training in hyderabad,informatica training in hyderabad

    ReplyDelete
  9. Thanks for posting this useful information,
    It is very useful to who are searching for oracle adf online training.

    ReplyDelete

  10. hi your blog Article is very nice & thanks for sharing the information.

    oracle adf online coaching in hyderabad

    ReplyDelete

  11. I appreciate what you folks are as a rule up as well. This kind of astute work and scope! Keep up the brilliant works folks I've added you all to my blog roll.

    Oracle adf online training in Hyderabad

    ReplyDelete