// set config name (which is retrieved from domain.xml) into System properties to be used for path resolution
System.setProperty(SystemPropertyConstants.CONFIG_NAME_PROPERTY, configRef);
systemProperties.put(SystemPropertyConstants.CONFIG_NAME_PROPERTY, configRef);
// get javaconfig for server that is being started
JavaConfig javaConfig=config.getJavaConfig();
// derive and add java command to Command
String jvmCmd=javaConfig.getJavaHome() + File.separator + "bin"
+ File.separator + "java";
command.setJavaCommand(jvmCmd);
// fix for bug# 6323645
// Do not add options which are not applicable for stop action.
// For ex. debug options and profiler options.
// In other words add the following options ony when the action
// is other than stop.
Profiler profiler=javaConfig.getProfiler();
String profilerClasspath=null;
if (!action.equals(LAUNCHER_STOP_ACTION)) {
// The debug options including the debug port would be added
// to the command when the action is start.
// If the action is stop adding the same port to the java command
// would stack up the ports and block until the port assigned for
// start action is released. To avoid this we check for stop action.
// If the stop action needs to be debugged then one work around is to
// copy the java command from server.log, change the debug settings and
// run the command.
// debug options
if ((javaConfig.isDebugEnabled() || isDebugEnabled())) {
// add debug statements
addDebugOptions(command, javaConfig.getDebugOptions());
}
// add profiler properties & jvm args
if (profiler != null && profiler.isEnabled()) {
// add config properties
addElementProperties(profiler.getElementProperty(), systemProperties);
String [] jvmOptions=profiler.getJvmOptions();
addJvmOptions(command, jvmOptions, action);
profilerClasspath=profiler.getClasspath();
}
}
// set the default locale specified in domain.xml config file
String locale=domain.getLocale();
if (locale == null || locale.equals("")) {
// if not specified in domain try system
locale=System.getProperty(SystemPropertyConstants.DEFAULT_LOCALE_PROPERTY);
}
// make sure locale is specified before setting it
if (locale != null && !locale.equals("")) {
command.addSystemVariable("-D" + SystemPropertyConstants.DEFAULT_LOCALE_PROPERTY + "=" + locale);
}
//
// add jvm args, look for combined jvm options
String[] jvmOptions=javaConfig.getJvmOptions();
addJvmOptions(command, jvmOptions, action);
//
// add config system properties
addSystemProperties(config.getSystemProperty(), systemProperties);
//
// add cluster system properties if the server instance is clustered
if (ServerHelper.isServerClustered(configCtxt, server)) {
Cluster cluster = ClusterHelper.getClusterForInstance(configCtxt,
server.getName());
addSystemProperties(cluster.getSystemProperty(), systemProperties);
}
//
// add server system properties
addSystemProperties(server.getSystemProperty(), systemProperties);
//
// add classpath
// check to see if jvmCmd starts with same as processLauncher jvm.
// if so, use the system property java-version to determine jvm version
if(OS.isWindows()) {
// make sure all delimeters are the same
jvmCmd=jvmCmd.replace('/', '\\');
}
if (jvmCmd.startsWith(System.getProperty(SystemPropertyConstants.JAVA_ROOT_PROPERTY))) {
// jvm command are the same, so use processLauncher jvm version
jvmCmd=null;
}
String classpath=deriveClasspath(plConfig, jvmCmd, javaConfig, profilerClasspath);
getLogger().log(Level.FINE, "Complete process classpath = " + classpath);
command.setClasspath(classpath);
//
//add main class
command.setMainClass(plConfig.getMainClass());
//
// native library path to java path and system properties
deriveNativeClasspath(command, javaConfig, profiler, systemProperties);
//
// add all system properties to command as jvm args
Iterator it=systemProperties.keySet().iterator();
String key=null;
String property=null, value=null;;
while(it.hasNext()) {
key=(String)it.next();
value=systemProperties.getProperty(key);
// take care of vm arg that are sent in via the processlauncher.xml file
if (key.startsWith("-")) {
property = key;
if (value != null && !value.equals("")) {
property += "=" + value;
}
command.addJvmOption(property);
getLogger().log(Level.FINE, "JVM Option: " + property);
} else {
// regular system property
property = "-D" + key + "=" + value;
command.addSystemVariable(property);
getLogger().log(Level.FINE, "System Property: " + property);
}
}
//Add prefix and suffix for AS9Profile
if (getProcessLauncherProfile().equals(AS9_INTERNAL_SERVER_PROFILE)) {
String classpathPrefix=javaConfig.getClasspathPrefix();
String classpathSuffix=javaConfig.getClasspathSuffix();
String serverClasspath=javaConfig.getServerClasspath();
getLogger().log(Level.FINE, " prefix :: " + classpathPrefix
+ " suffix :: " + classpathSuffix);
if (classpathPrefix == null) classpathPrefix = "";
command.addSystemVariable("-D" + CLASSPATH_PREFIX_PROPERTY + "=" + classpathPrefix);
if (classpathSuffix == null) classpathSuffix = "";