Customizing templates Part 2
By Acshorten-Oracle on Feb 25, 2010
In an earlier posting I mentioned a new facility to implement changes to templates in OUAF V2.2. To recap, the product ships with configuration templates. These are used by the product utilities to build and maintain key configuration files for the product and related software (like the Web Application Server).
The templates have what you need in most cases, but sometimes you want to alter the configuration file manually to add some advanced settings or take advanatage of key facilities. In the past, to do this you had to alter the template directly, as whenever you regenerated the configuration files it reverted to the template, essentially overwriting your manual changes. If you did not alter the template and manually changed the file you had to remember to keep a copy of the file to reapply your changes. If you manually altered the template then when we ship a new improved template it overwrote the edited template unless you back it up first. We usually discouraged changes to base templates for this reason.
So it was a case of no matter which way you custmoizred you may run into upgrade issues, if you were not careful. The enhancement mentioned in "Customizing Product Templates" fixes this by allowing you to specify your own site specific template in place of the base one.
The basic process is as follows:
- Find the template you want to change.
- Copy the template to cm.templatename where templatename is the name of the template file to copy. Ensure it is in the same directory as the template
- Make your changes to template to suit your needs.
- When you next run initialSetup the custom template is used instead of the base one.
Lets illustrate this with a few examples.
One of the changes I always like to do on my laptop version of the product (yes, I have a copy of the product running on my laptop) is to disable preloading. This means my startup is faster as I am not worried about performance of calls to each screen as I am really the only user on my laptop. This setting that controls this is disablePreload which is hardcoded to false (to enable Preloading). This is not a setting we expect implementations to change as it really is a development setting not a production one. Now this setting is contained in the web.xml used by the online application (it is located at %SPLEBASE%\etc\conf\WEB-INF\web.xml). Prior to the implementation of this fix, I would edit this file directly (setting disablePreload to true) and then run genupdatewar to put the new change into the WAR/EAR file. I run Oracle WebLogic so that is all I have to do; If I ran IBM WebSphere then there are additonal steps to redeploy the file to WebSphere.
With the template override fix in place, the new way of making this change is to take copy of %SPLEBASE%\etc\web.xml.template and call it %SPLEBASE%\etc\cm.web.xml.template (notice I put it in same place as the original template - very imortant). I make the change to the disablePreload in cm.web.xml.template. Now everytime I run initialSetup it would use my custom template not the base one. I would not lose my changes.
Now another example, abiet not as detailed as above (but the process is the same). One of our customers is using the template enhancement to support clustering. In Oracle Weblogic, definitions of the cluster and other advanced settings are stored in a config.xml file. This file is essentialy maintained by the Oracle WebLogic console. Our product generates a default config.xml for use with basic settings. To implement advanced settings the customer changed the config,xml using the console and then took a copy of the product provided template config.xml.template (the custom one is called cm.config.xml). They then manually altered the cm.config.xml.template file to add the advanced settings they implemented using the config.xml as a guide. Now anytime they need to run initialSetup to implement a fix or as part of a reconfiguration they get their advanced features. This protects their upgrades.
This same technique applies to ANY configuration file generated using a template.
There is one catch to this enhancement you should be aware of. If we alter the base template for any reason you must manually change your custom template to reflect that change. Just remember to check the base templates on a regular basis for any changes and you should be able to catch any new feaures as they are added.