public static synchronized GlassFish startGlassFish(String serverID, String installRoot,
String instanceRoot, String configFileURI,
boolean configFileReadOnly, int httpPort)
throws GlassFishException {
GlassFish glassfish = gfMap.get(serverID);
if (glassfish != null) {
return glassfish;
}
if (glassfishRuntime == null) {
BootstrapProperties bootstrapProperties = new BootstrapProperties();
if (installRoot != null) {
bootstrapProperties.setInstallRoot(installRoot);
}
glassfishRuntime = GlassFishRuntime.bootstrap(bootstrapProperties);
}
GlassFishProperties glassfishProperties = new GlassFishProperties();
if (instanceRoot != null) {
glassfishProperties.setInstanceRoot(instanceRoot);
}
if (configFileURI != null) {
glassfishProperties.setConfigFileURI(configFileURI);
glassfishProperties.setConfigFileReadOnly(configFileReadOnly);
}
if (httpPort != -1) {
glassfishProperties.setPort("http-listener", httpPort);
}
glassfish = glassfishRuntime.newGlassFish(glassfishProperties);
glassfish.start();
gfMap.put(serverID, glassfish);
System.out.println("Started GlassFish [" + serverID + "]");