|
Chapter 11 |
Replacement libraries can be very beneficial when you have multiple libraries that contain the same tables with similar sets of data. A primary example would be test data versus production data. Sometimes, different users have their own libraries, all containing the same files (tables). When a SQL is run, WOW checks to see if there has been a replacement library specified for the library the SQL is about to be run against. If so, the original library in the SQL is switched with a new replacement library.
For example:
Let’s say there is a replacement library defined to replace LIBRARY1 with TESTLIBRARY1. In addition, we have an SQL statement set to query LIBRARY1 (SELECT * FROM LIBRARY1.TABLE1). With the replacement library defined, the final SQL that is run will actually be SELECT * FROM TESTLIBRARY1.TABLE1. Underneath the covers WOW switches out replacement libraries before executing the SQL
WOW based - these replacement libraries take affect for any SQL that is run within the current running WOW instance
To configure, add a servlet initialization parameter called PJ_REPLACEMENT_LIBRARIES (similar to all the other WOW initialization parameters). Servlets that can be accessed by the public are defined in the web application's web.xml file. In this file, you can also define initialization parameters for the servlet. These are parameters that may be used by the servlet when it is initialized. The format for each key value pair is <library to be replace> = <replacement library>, etc.
For Example:
<init-param id="WOW_Replacement_Libraries">
<param-name>PJ_REPLACEMENT_LIBRARIES</param-name>
<param-value>LIBRARY1=REPLACEMENTLIBRARY32, LIBRARY3=REPLACEMENTLIBRARY2</param-value>
</init-param>
Application based - these replacement libraries take affect for any SQL that is run within the current application
To configure, add a "Config" property group to the application's properties. Edit the application. Add the Config property group in the properties text area. The format for the library replacement sting value is that same as the other library replacement support implementations <library to replace>=<replacement library>, etc.
For Example:
Config {
replacement libraries: LIBRARY1=TESTLIBRARY4,LIBRARY2=REPLACEMENTLIBRARY31;
}
User based - these replacement libraries take affect for any SQL that is run by current signed in user (for any application the user signs into).
User based replacement libraries take a little more work to configure but can be very useful when dealing with multiple users who have different libraries with similar tables. There are just a couple steps needed to configure user replacement libraries.
1. The SQLOperation used to sign on the application should contain a column that is to be used for replacement libraries. The format for this columns value should be same format as other library replacement support implementations <library to replace>=<replacement library>, etc.
2. The field descriptor for the “replacement libraries” column from the sign on needs to have a usage id set to denote it is a replacement libraries field. The usage id to denote a replacement library field is -165.
For Example:
Let's say that we have a users file containing the user id, password, and replacement libraries column. In this file there are two records with the following values:
Record 1
--------
User Id: USER1
Password: PASSWORD
Replacement Libraries: LIBRARY1=LIBRARY4
Record 2
--------
User Id: USER2
Password: PASSWORD
Replacement Libraries: LIBRARY1=LIBRARY3, LIBRARY6=REPLACEMENTLIBRARY2
The field descriptor for "replacement libraries” in this file is set with a usage id of -165.
When USER1 signs in and runs any SQL against LIBRARY1, the actual SQL is run against LIBRARY4. On the other hand, if USER2 signs into the same application, any SQL they run against LIBRARY1 will be actually against LIBRARY3
URL based - these replacement libraries take affect on any SQL that is run for the current user's environment only. Once the browser window is closed, the replacement libraries are no longer used.
To configure, add a request parameter on the URL call to the application when initially starting the application. This will set and remember the specified replacement libraries for the duration of the use of the application within the current browser session. The format for the library replacement sting value is that same as the other library replacement support implementations <library to replace>=<replacement library>, etc.
For Example:
The following URL would open application with the id of 1 and use the specified replacement libraries when running SQLs within that application for any user.
http://www.planetjavainc.com/wow63/runApp?id=1&_pj_replace_libs=LIBRARY1=TESTLIBRARY3,LIBRARY5=REPLACEMENTLIBRARY1
11.2.4 > 11.2.3 > 11.2.4 >11.2.1... In other words if a replacement library is specified on the URL, it will override any other replacement library setting for that library. If specified as a user property, it will override application and WOW global replacement libraries. And finally, application replacement libraries will override WOW global specified replacement libraries.
For Example:
Lets say the application was run with a URL parameter _pj_replace_libs=LIBRARY1=REPLACEMNTLIBRARY2. In addition, we'll say that there is a replacement library specified on the application being run. (Config {replacement libraries: LIBRARY1=REPLACEMENTLIBRARY4 ;}).
When an SQL is run, replacementtable2 would be used because URL replacement libraries take precedence over application replacement libraries.