404 IBM Express Runtime V2.1
The SamplePDC.java file
Example C-4 shows the source code for the SamplePDC class.
Example: C-4 Source of SamplePDC.java
* Created on Mar 10, 2005
* This sample program demonstrates how to create a wrapper.
* Based on your knowledge of your application,
* use this code as an example to develop a custom wrapper.
package com.ibm.flght400;
import java.io.File;
import com.ibm.as400.access.AS400;
import com.ibm.as400.resource.RSoftwareResource;
import com.ibm.jsdt.support.SupportOS400Base;
import com.ibm.jsdt.support.SupportOS400Helper;
* This is a sample class, created as part of the Redbook example.
public class SamplePDC extends SupportOS400Base {
private String ivWASProfileDir = null;
private String ivAppName = null;
private String ivWASServerName = null;
private String ivWasProfileName = null;
private String ivHttpServerName = null;
private String ivScriptsDir = null;
private SupportOS400Helper ivHelper = null;
private String ivDB2AdminUserId = null;
private String ivBaseRelease = null;
public SamplePDC(){
* Initialize the object.
* Retrieve input parameter
* parm#0 = The response file name.
* parm#1 = The minimul release that the sample can be installed on.
public int init(String[] args)
ivHelper = (SupportOS400Helper) getHelper();
if (args.length != 2) {
logMessage(getResourceString(SampleNLSkeys.BAD_NUMBER_PGM_ARGS, new String []{"SamplePDC", "2",
return FAILURE;
return SUCCESS;
Appendix C. Source code for Flght400 user programs and script files on OS/400 405
* The sample application requires WAS and HTTP to be install,
* and the WAS and HTTP servers instances to be configured. This PDC will
* - check to see if WAS is installed. (version specified in the properties file)
* - check to see if HTTP is installed.
* - check to see if the HTTP server name is configured.
* - check to see if the WAS profile is configured.
* - check to see if the OS release is equal or later than the base release
* - check to see if the application is installed
private int check()
logMessage ("We are in PDC.check method");
// get the values set in the properties file, properties file is mandatory
if (getResponseFileName() == null || getResponseFileName().trim().equals("")) {
return FAILURE;
} else {
if (getProperties() == FAILURE) return FAILURE;
logMessage ("Checking the OS level");
//check to make sure the release is at the correct level
if (isCurReleaseEqualOrGreater(getBaseRelease()) == false) {
logMessage(getResourceString(SampleNLSkeys.INVALID_OS_RELEASE, new
return FAILURE;
//check to make sure HTTP is installed
logMessage ("Checking if HTTP installed");
AS400 as400 = new AS400();
if (SampleCommon.isProductInstall(as400, SampleCommon.HTTP_PRODUCT_ID,
RSoftwareResource.PRODUCT_OPTION_BASE) == false) {
logMessage(getResourceString(SampleNLSkeys.HTTP_NOT_INSTALLED, new
return FAILURE;
//check to make sure WAS is installed
logMessage ("Checking if WAS installed");
if (SampleCommon.isProductInstall(as400, SampleCommon.WAS_PRODUCT_ID,
SampleCommon.WAS_PRODUCT_OPTION) == false) {
logMessage(getResourceString(SampleNLSkeys.WAS_NOT_INSTALLED, new
return FAILURE;
//check to see if HTTP server is configured.
logMessage ("Checking if HTTP configured");
if (isHTTPServerConfigured() == false) {
logMessage(getResourceString(SampleNLSkeys.HTTP_SERVER_NOT_CONFIG, new
return FAILURE;
406 IBM Express Runtime V2.1
//check to see if WAS server is configured.
logMessage ("Checking if WAS configured");
if (isWASServerConfigured() == false) {
logMessage(getResourceString(SampleNLSkeys.WAS_SERVER_NOT_EXIST, new
return FAILURE;
/* Don't need this
//check to see if DB2 Admin Id Exists
logMessage ("Checking if DB2 user exist");
setUserName (getDb2AdminUserId());
if ( ivHelper.doesUserExist (this) == false) {
logMessage(getResourceString(SampleNLSkeys.NO_USER_PROF, getDb2AdminUserId()));
return FAILURE;
//The next if should be in Main program. Access to the script file is not available yet.
//check to see if the application is installed.
logMessage ("Checking if application installed");
if (isApplicationInstalled() == true) {
return PDC_EXISTS;
* Get values from the properties file
private int getProperties()
int rc = SUCCESS;
// The properties file name was set in the constructor
// Log the contents of the properties file
// get the values specified in the properties file that are needed by this PDC
setKey(SampleCommon.SERVER_NAME_KEY); // server name to use to determine the application path
if (getServerName() == null || getServerName().equals("")) {
logMessage(getResourceString(SampleNLSkeys.NO_PROPERTY, SampleCommon.SERVER_NAME_KEY));
setKey(SampleCommon.WAS_PROFILE_KEY); // WAS profile name
if (getWasProfileName() == null || getWasProfileName().equals("")) {
if (getServerName() == null || getServerName().equals("")) {
logMessage(getResourceString(SampleNLSkeys.NO_PROPERTY, SampleCommon.WAS_PROFILE_KEY));
} else {

Get IBM Express Runtime V2.1 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.