Q: What is the seeded customization of an application?

A:“Seeded customization of an application is the process of taking a generalized application and making modifications to suit the needs of a particular group, such as a specific industry or site. Seeded customizations exist as part of the deployed application, and endure for the life of a given deployment.”  —http://download.oracle.com/docs/cd/E17904_01/web.1111/b31974/customize.htm#BABEGABC

In order to customize a base application, one or more customization layers need to be created. The customizations are stored in a repository by MDS. At runtime, MDS retrieves the customizations which are then merged with the base application.

For the purposes of this demo I created a simple model using HR schema, having only two view objects. The Departments view object as the master and the Employees as the detail. They are associated by the Department Id column.

Create a new jspx pag. Drag and drop the departments data source to the page as an updateable form and the employees datasource as an updateable table.

 

Departments and Employees are updateable, and navigation through the Departments refreshes the Employees table so that the correct records are displayed.

 

Created above is our base application. Now imagine that this application is sold to two new clients. Blue Inc and Red Inc. They both have new requirements for this page. Blue wants Departments not to be updateable and the Phone Number to be required. He also wants the background of the Departments form to be… blue. Red on the other hand wants Departments to be updateable, Salary column not to be visible and, obviously, the background to be red.

To implement these new requirements without affecting the existing functionality that might be used by existing customers, MDS seeded customizations is the perfect solution.
To enable seeded customizations right-click the view project and choose Project Properties. In the Project Properties dialog, click ADF View and select the “Enable Seeded Customizations” checkbox.

 

Next we need to create a customization class in the View project. The customization class is the interface that MDS uses to define which customization applies. This class will be used to determine whether the user is Blue or Red. There are many ways to distinguish between the two clients. In our case we will use a property file which will be different for the two clients.

package model;
import java.io.IOException;
 import java.io.InputStream;
 import java.util.Properties;
 import oracle.mds.core.MetadataObject;
 import oracle.mds.core.RestrictedSession;
 import oracle.mds.cust.CacheHint;
 import oracle.mds.cust.CustomizationClass;
public class ClientCustomizationClass extends CustomizationClass {
 public ClientCustomizationClass() {
 super();
 }
public CacheHint getCacheHint() {
 return CacheHint.ALL_USERS;
 }
public String getName() {
 return "client";
 }
//retrieve the “client” value from the properties file
 public String[] getValue(RestrictedSession sess, MetadataObject mo) {
 Properties props = new Properties();
 String value = null;
 Class cls = ClientCustomizationClass.class;
 //the properties file used to save whether the client is Red, Blue or someone else
 InputStream inStream = cls.getResourceAsStream("/client.properties");
 if (inStream != null){
 try {
 props.load(inStream);
 String clientValue = props.getProperty(getName());
 if (clientValue != null){
 value = clientValue;
 }
 } catch (IOException e) {
 e.printStackTrace();
 }
 finally {
 try {
 inStream.close();
 } catch (IOException e) {
 e.printStackTrace();
 }
 }
 }
 return new String[] {value};
 }
 }
The getValue() method “decides” which customizations will be used when the application is ran.
Then create the property file which will have a different value depending on the customer. The contents of the client.properties file can be the following:
# Key used to distinguish between clients value can be “Red” or “Blue”
client=”Blue”

For customizations to work, the adf-config.xml file must have the cust-config tag in the mds-config section. In this tag the customization classes need to be defined. Go to MDS Configuration section and click “+” find and select the customization class you created.

 

For customization development to be possible we must specify customization layers and the corresponding values in the CustomizationLayerValues.xml file so that JDeveloper “sees” them. You can find this file in the jdev folder of your jdeveloper installation.

The following tag needs to be added:

<cust-layer name=”client” id-prefix=”c”>
      <cust-layer-value value=”Blue” display-name=”Blue” id-prefix=”1″ />
      <cust-layer-value value=”Red” display-name=”Red” id-prefix=”2″ />
  </cust-layer>

We are one step away from being able to develop customizations. The customization class needs to be deployed in a jar somewhere for jdeveloper to see when it starts up.
Right click on the project were the customization class was created and create a new deployment profile (archive type must be jar).

 

In Jar Options make sure that the jar file is saved in the patches folder under jdev_installation/jdev/libs/patches

 

In the filters section make sure that only the customization class is selected to be included in the jar

 

Now deploy the jar.

After the jar is deployed we can begin developing customizations. To do this we must open jdeveloper using the Customization User role. Under Preferences/Roles choose the Customization Role and restart Jdeveloper.

 

When Jdeveloper restarts, the “Customization Context” panel is visible. Value “Blue” is selected by default. While “Blue” is selected, any changes made will only affect the specific client.

 

As mentioned before client Blue wants the Departments form to be read only. To do this open the Departments view object, in the Entity Objects tab select the Departments entity object and uncheck the “updateable” property checkbox.

 

When this change is done a new file is created DepartmentsView.xml.xml which contains the changes made in DepartmentsView.xml for client “Blue”.  If you open this file you will see the following code:

 

 

 

 

 

 

This xml defines the modifications made in the specific file for client Blue.

Blue also wants the Phone Number attribute in the EmployeesView view object to be required and the background of the departments form to be blue. Both of these requirements will be implemented in the jspx file. Open the MDSDemo.jspx file and using the property inspector change the required property of the PhoneNumber field to ”true”. Also select the Departments panelFormLayout and using the property inspector change the InlineStyle propery to “background-color:rgb(130,148,255);”

MDSDemo.jspx.xml is created after these changes and the page looks something like this

 

These are all the customizations Blue requested.

To begin customizations for Red, in the “Customization Context” panel of JDeveloper, for the “client” layer select “Red” from the choice list. All customizations implemented after this will only affect client Red.

Red wants the Salary to be non-visible in the Employees table of the page, and the Departments background to be red. Open the jspx and through the property inspector panel, change the visible property of “Salary” to false. Select the Departments panelFormLayout and set inlineStyle=”background-color:rgb(255,91,91);”

 

Notice that a new MDSDemo.jspx.xml has been created under folder “red”.

We are ready to test the application. Change the User Role back to default (under Tools/Preferences/Roles) and restart jdeveloper.

In the client.properties file make sure that client=”Blue” value exists and run the application.

As you can see the Departments form is not updateable, its background is blue and the PhoneNumber column is required.

 

In the client.properties file make sure that client=”Red” value exists and run the application.

For Red, the Departments form is updateable, its background is red, PhoneNumber is not required and the Salary column is not visible.

 

When the client value in the client.properties file does not contain one of the two values (Blue or Red) then the default application is run without applying the customizations done for the two new clients.

The demo source code and all required files can be found here.

Further reading about MSD Seeded Customizations:

http://download.oracle.com/docs/cd/E17904_01/web.1111/b31974/customize.htm#BABEGABC

http://www.oracle.com/technetwork/developer-tools/jdev/adfmds-128339.pdf

http://community.oraclepressbooks.com/downloads/S316901-customization.pdf

http://www.oracle.com/technetwork/developer-tools/adf/learnmore/31-mds-sample-169173.pdf

 






Comments

Name (required)

Email (required)

Website

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Share your wisdom