Scripting Websphere 6.1 configurations, Part 5

Configuring the JVM and setting Websphere Variables

A typical task when deploying and managing a Websphere application is to set a Websphere variable, for example; location of property files, or an file based database. You might also want to tweak the JVM properties. For our project, we add a couple locations to our classpath, and we also set this property to help with IIOP: These tasks can all be handled through scripting with Jython. Here are some examples:

def configureJVM(self, jvmProps, mode=””):

# See the previous posts on how to get the JVM ID, hint: use the AdminConfig.list() method
jvm = self.getJVMId();

genericVMArgStr = “”;
for o in jvmProps.otherJVMprops:
genericVMArgStr += ” ” + o;

classpathStr = “”;
for c in jvmProps.classpath:
if len(classpathStr) > 0:
classpathStr += “;”;
classpathStr += c;

params = WASConfigParams();
params.add(“classpath”, classpathStr);
params.add(“initialHeapSize”, jvmProps.initialHeapSize);
params.add(“maximumHeapSize”, jvmProps.maximumHeapSize);
params.add(“disableJIT”, jvmProps.disableJIT);
params.add(“genericJvmArguments”, genericVMArgStr);
AdminConfig.modify(jvm, params.asList());

The following is an example of a method that sets Websphere variables

def setVariable(self, varName, varValue, varDesc):
vmap = self.findConfigId(“VariableMap”);
params = WASConfigParams();
params.add(“symbolicName”, varName);
params.add(“value”, varValue);
params.add(“description”, varDesc);
v = AdminConfig.create(“VariableSubstitutionEntry”, vmap, params.asList());