Lines 69-74
Link Here
|
69 |
import javax.enterprise.deploy.spi.status.ProgressListener; |
69 |
import javax.enterprise.deploy.spi.status.ProgressListener; |
70 |
import javax.enterprise.deploy.spi.status.ProgressObject; |
70 |
import javax.enterprise.deploy.spi.status.ProgressObject; |
71 |
import org.netbeans.api.java.platform.JavaPlatform; |
71 |
import org.netbeans.api.java.platform.JavaPlatform; |
|
|
72 |
import org.netbeans.api.server.StartupArguments; |
73 |
import org.netbeans.modules.j2ee.deployment.plugins.api.CommonServerBridge; |
72 |
import org.netbeans.modules.tomcat5.progress.ProgressEventSupport; |
74 |
import org.netbeans.modules.tomcat5.progress.ProgressEventSupport; |
73 |
import org.netbeans.modules.tomcat5.progress.Status; |
75 |
import org.netbeans.modules.tomcat5.progress.Status; |
74 |
import org.netbeans.modules.tomcat5.util.LogManager; |
76 |
import org.netbeans.modules.tomcat5.util.LogManager; |
Lines 78-84
Link Here
|
78 |
import org.openide.util.RequestProcessor; |
80 |
import org.openide.util.RequestProcessor; |
79 |
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerDebugInfo; |
81 |
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerDebugInfo; |
80 |
import org.netbeans.modules.j2ee.deployment.plugins.spi.StartServer; |
82 |
import org.netbeans.modules.j2ee.deployment.plugins.spi.StartServer; |
81 |
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerServerSettings; |
|
|
82 |
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerSupport; |
83 |
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerSupport; |
83 |
import org.netbeans.modules.tomcat5.TomcatManager; |
84 |
import org.netbeans.modules.tomcat5.TomcatManager; |
84 |
import org.netbeans.modules.tomcat5.util.TomcatProperties; |
85 |
import org.netbeans.modules.tomcat5.util.TomcatProperties; |
Lines 164-170
Link Here
|
164 |
public ProgressObject startDeploymentManager () { |
165 |
public ProgressObject startDeploymentManager () { |
165 |
LOGGER.log(Level.FINE, "StartTomcat.startDeploymentManager called on " + tm); // NOI18N |
166 |
LOGGER.log(Level.FINE, "StartTomcat.startDeploymentManager called on " + tm); // NOI18N |
166 |
pes.fireHandleProgressEvent (null, new Status (ActionType.EXECUTE, CommandType.START, "", StateType.RUNNING)); |
167 |
pes.fireHandleProgressEvent (null, new Status (ActionType.EXECUTE, CommandType.START, "", StateType.RUNNING)); |
167 |
SERVER_CONTROL_RP.post(new StartRunnable(MODE_RUN, CommandType.START, null), |
168 |
SERVER_CONTROL_RP.post(new StartRunnable(MODE_RUN, CommandType.START), |
168 |
0, Thread.NORM_PRIORITY); |
169 |
0, Thread.NORM_PRIORITY); |
169 |
isDebugModeUri.remove(tm.getUri()); |
170 |
isDebugModeUri.remove(tm.getUri()); |
170 |
return this; |
171 |
return this; |
Lines 227-233
Link Here
|
227 |
public ProgressObject stopDeploymentManager() { |
228 |
public ProgressObject stopDeploymentManager() { |
228 |
LOGGER.log(Level.FINE, "StartTomcat.stopDeploymentManager called on " + tm); // NOI18N |
229 |
LOGGER.log(Level.FINE, "StartTomcat.stopDeploymentManager called on " + tm); // NOI18N |
229 |
pes.fireHandleProgressEvent (null, new Status (ActionType.EXECUTE, CommandType.STOP, "", StateType.RUNNING)); |
230 |
pes.fireHandleProgressEvent (null, new Status (ActionType.EXECUTE, CommandType.STOP, "", StateType.RUNNING)); |
230 |
SERVER_CONTROL_RP.post(new StartRunnable(MODE_RUN, CommandType.STOP, null), |
231 |
SERVER_CONTROL_RP.post(new StartRunnable(MODE_RUN, CommandType.STOP), |
231 |
0, Thread.NORM_PRIORITY); |
232 |
0, Thread.NORM_PRIORITY); |
232 |
isDebugModeUri.remove(tm.getUri()); |
233 |
isDebugModeUri.remove(tm.getUri()); |
233 |
return this; |
234 |
return this; |
Lines 243-261
Link Here
|
243 |
public ProgressObject startDebugging(Target target) { |
244 |
public ProgressObject startDebugging(Target target) { |
244 |
LOGGER.log(Level.FINE, "StartTomcat.startDebugging called on " + tm); // NOI18N |
245 |
LOGGER.log(Level.FINE, "StartTomcat.startDebugging called on " + tm); // NOI18N |
245 |
pes.fireHandleProgressEvent (null, new Status (ActionType.EXECUTE, CommandType.START, "", StateType.RUNNING)); |
246 |
pes.fireHandleProgressEvent (null, new Status (ActionType.EXECUTE, CommandType.START, "", StateType.RUNNING)); |
246 |
SERVER_CONTROL_RP.post(new StartRunnable(MODE_DEBUG, CommandType.START, null), |
247 |
SERVER_CONTROL_RP.post(new StartRunnable(MODE_DEBUG, CommandType.START), |
247 |
0, Thread.NORM_PRIORITY); |
248 |
0, Thread.NORM_PRIORITY); |
248 |
return this; |
249 |
return this; |
249 |
} |
250 |
} |
250 |
|
251 |
|
251 |
public ProgressObject startProfiling(Target target, ProfilerServerSettings settings) { |
252 |
public ProgressObject startProfiling(Target target) { |
252 |
LOGGER.log(Level.FINE, "StartTomcat.startProfiling called on " + tm); // NOI18N |
253 |
LOGGER.log(Level.FINE, "StartTomcat.startProfiling called on " + tm); // NOI18N |
253 |
pes.fireHandleProgressEvent(null, new Status( |
254 |
pes.fireHandleProgressEvent(null, new Status( |
254 |
ActionType.EXECUTE, |
255 |
ActionType.EXECUTE, |
255 |
CommandType.START, |
256 |
CommandType.START, |
256 |
"", // NOI18N |
257 |
"", // NOI18N |
257 |
StateType.RUNNING)); |
258 |
StateType.RUNNING)); |
258 |
SERVER_CONTROL_RP.post(new StartRunnable(MODE_PROFILE, CommandType.START, settings), |
259 |
SERVER_CONTROL_RP.post(new StartRunnable(MODE_PROFILE, CommandType.START), |
259 |
0, Thread.NORM_PRIORITY); |
260 |
0, Thread.NORM_PRIORITY); |
260 |
return this; |
261 |
return this; |
261 |
} |
262 |
} |
Lines 275-286
Link Here
|
275 |
|
276 |
|
276 |
private int mode; |
277 |
private int mode; |
277 |
private CommandType command = CommandType.START; |
278 |
private CommandType command = CommandType.START; |
278 |
private ProfilerServerSettings profilerSettings; |
|
|
279 |
|
279 |
|
280 |
public StartRunnable(int mode, CommandType command, ProfilerServerSettings profilerSettings) { |
280 |
public StartRunnable(int mode, CommandType command) { |
281 |
this.mode = mode; |
281 |
this.mode = mode; |
282 |
this.command = command; |
282 |
this.command = command; |
283 |
this.profilerSettings = profilerSettings; |
|
|
284 |
} |
283 |
} |
285 |
|
284 |
|
286 |
public synchronized void run () { |
285 |
public synchronized void run () { |
Lines 398-408
Link Here
|
398 |
} |
397 |
} |
399 |
} |
398 |
} |
400 |
} |
399 |
} |
|
|
400 |
|
401 |
|
402 |
for (StartupArguments args : StartupArguments.getStartupArguments( |
403 |
CommonServerBridge.getCommonInstance(tm.getUri()), getMode(mode))) { |
404 |
for (String singleArg : args.getArguments()) { |
405 |
sb.append(' ').append(singleArg); |
406 |
} |
407 |
} |
401 |
javaOpts = sb.toString(); |
408 |
javaOpts = sb.toString(); |
402 |
} |
409 |
} |
403 |
|
410 |
|
404 |
JavaPlatform platform = mode == MODE_PROFILE ? profilerSettings.getJavaPlatform() |
411 |
JavaPlatform platform = getJavaPlatform(); |
405 |
: getJavaPlatform(); |
|
|
406 |
String jdkVersion = platform.getSpecification().getVersion().toString(); |
412 |
String jdkVersion = platform.getSpecification().getVersion().toString(); |
407 |
|
413 |
|
408 |
if (tm.isBundledTomcat()) { |
414 |
if (tm.isBundledTomcat()) { |
Lines 460-513
Link Here
|
460 |
startupScript.getAbsolutePath(), StateType.FAILED); |
466 |
startupScript.getAbsolutePath(), StateType.FAILED); |
461 |
return; |
467 |
return; |
462 |
} |
468 |
} |
463 |
} else if ((mode == MODE_PROFILE) && (command == CommandType.START)) { |
|
|
464 |
NbProcessDescriptor pd = null; |
465 |
if (tp.getSecManager()) { |
466 |
pd = defaultExecDesc(TAG_EXEC_CMD, TAG_EXEC_STARTUP, TAG_SECURITY_OPT); |
467 |
} else { |
468 |
pd = defaultExecDesc(TAG_EXEC_CMD, TAG_EXEC_STARTUP); |
469 |
} |
470 |
try { |
471 |
fireCmdExecProgressEvent("MSG_StartingInProfileMode", StateType.RUNNING); |
472 |
Process p = null; |
473 |
|
474 |
String[] profJvmArgs = profilerSettings.getJvmArgs(); |
475 |
// TODO solve conflicts between profiler and tomcat vm args |
476 |
StringBuffer catalinaOpts = new StringBuffer(); |
477 |
for (int i = 0; i < profJvmArgs.length; i++) { |
478 |
catalinaOpts.append(profJvmArgs[i]).append(" "); // NOI18N |
479 |
} |
480 |
String[] defaultEnv = new String[] { |
481 |
"JAVA_HOME=" + getJavaHome(platform), // NOI18N |
482 |
"JRE_HOME=", // NOI18N ensure that JRE_HOME system property won't be used instead of JAVA_HOME |
483 |
"JAVA_OPTS=" + javaOpts, // NOI18N |
484 |
"CATALINA_OPTS=" + catalinaOpts.toString(), // NOI18N |
485 |
"CATALINA_HOME=" + homeDir.getAbsolutePath(), // NOI18N |
486 |
"CATALINA_BASE=" + baseDir.getAbsolutePath(), // NOI18N |
487 |
// this is used in the setclasspath.sb/bat script for work-arounding |
488 |
// problems caused by the compatibility pack when running on 1.5 |
489 |
"NB_TOMCAT_JDK=" + jdkVersion, // NOI18N |
490 |
TomcatManager.KEY_UUID + "=" + tm.getUri() |
491 |
}; |
492 |
String[] profEnv = profilerSettings.getEnv(); |
493 |
// merge Tomcat and profiler env properties |
494 |
String[] envp = new String[defaultEnv.length + profEnv.length]; |
495 |
System.arraycopy(profEnv, 0, envp, 0, profEnv.length); |
496 |
System.arraycopy(defaultEnv, 0, envp, profEnv.length, defaultEnv.length); |
497 |
p = pd.exec( |
498 |
new TomcatFormat(startupScript, homeDir), |
499 |
envp, |
500 |
true, |
501 |
new File(homeDir, "bin") // NOI18N |
502 |
); |
503 |
tm.setTomcatProcess(p); |
504 |
openLogs(); |
505 |
} catch (java.io.IOException ioe) { |
506 |
LOGGER.log(Level.FINE, null, ioe); |
507 |
fireCmdExecProgressEvent(command == CommandType.START ? "MSG_StartFailedIOE" : "MSG_StopFailedIOE", |
508 |
startupScript.getAbsolutePath(), StateType.FAILED); |
509 |
return; |
510 |
} |
511 |
} else { |
469 |
} else { |
512 |
NbProcessDescriptor pd = null; |
470 |
NbProcessDescriptor pd = null; |
513 |
if (command == CommandType.START) { |
471 |
if (command == CommandType.START) { |
Lines 573-579
Link Here
|
573 |
StateType.FAILED); |
531 |
StateType.FAILED); |
574 |
} |
532 |
} |
575 |
} |
533 |
} |
576 |
|
534 |
|
|
|
535 |
private StartupArguments.StartMode getMode(int mode) { |
536 |
switch (mode) { |
537 |
case MODE_PROFILE: |
538 |
return StartupArguments.StartMode.PROFILE; |
539 |
case MODE_DEBUG: |
540 |
return StartupArguments.StartMode.DEBUG; |
541 |
default: |
542 |
return StartupArguments.StartMode.NORMAL; |
543 |
} |
544 |
} |
545 |
|
577 |
/** Open JULI log and server output */ |
546 |
/** Open JULI log and server output */ |
578 |
private void openLogs() { |
547 |
private void openLogs() { |
579 |
LogManager logManager = tm.logManager(); |
548 |
LogManager logManager = tm.logManager(); |