Lines 64-69
Link Here
|
64 |
import org.netbeans.modules.j2ee.deployment.plugins.spi.JDBCDriverDeployer; |
64 |
import org.netbeans.modules.j2ee.deployment.plugins.spi.JDBCDriverDeployer; |
65 |
import org.openide.filesystems.*; |
65 |
import org.openide.filesystems.*; |
66 |
import java.util.*; |
66 |
import java.util.*; |
|
|
67 |
import java.util.concurrent.atomic.AtomicReference; |
67 |
import java.util.logging.Level; |
68 |
import java.util.logging.Level; |
68 |
import java.util.logging.Logger; |
69 |
import java.util.logging.Logger; |
69 |
import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException; |
70 |
import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException; |
Lines 86-93
Link Here
|
86 |
import org.netbeans.modules.j2ee.deployment.plugins.spi.MessageDestinationDeployment; |
87 |
import org.netbeans.modules.j2ee.deployment.plugins.spi.MessageDestinationDeployment; |
87 |
import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerInstanceDescriptor; |
88 |
import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerInstanceDescriptor; |
88 |
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerServerSettings; |
89 |
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerServerSettings; |
89 |
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerSupport; |
90 |
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerStateEvent; |
90 |
import org.netbeans.modules.j2ee.deployment.profiler.spi.Profiler; |
91 |
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerStateListener; |
|
|
92 |
import org.netbeans.modules.j2ee.deployment.profiler.spi.ProfilerProvider; |
93 |
import org.netbeans.modules.j2ee.deployment.profiler.spi.ProfilerSession; |
91 |
import org.openide.nodes.Node; |
94 |
import org.openide.nodes.Node; |
92 |
import org.openide.util.NbBundle; |
95 |
import org.openide.util.NbBundle; |
93 |
import org.openide.NotifyDescriptor; |
96 |
import org.openide.NotifyDescriptor; |
Lines 99-105
Link Here
|
99 |
import org.openide.windows.InputOutput; |
102 |
import org.openide.windows.InputOutput; |
100 |
|
103 |
|
101 |
|
104 |
|
102 |
public class ServerInstance implements Node.Cookie, Comparable { |
105 |
|
|
|
106 |
public class ServerInstance implements Node.Cookie, Comparable, ProfilerStateListener { |
103 |
|
107 |
|
104 |
/** Server state is being checked or state changes is in progress */ |
108 |
/** Server state is being checked or state changes is in progress */ |
105 |
public static final int STATE_WAITING = 1; |
109 |
public static final int STATE_WAITING = 1; |
Lines 161-168
Link Here
|
161 |
|
165 |
|
162 |
private final ChangeSupport managerChangeSupport = new ChangeSupport(this); |
166 |
private final ChangeSupport managerChangeSupport = new ChangeSupport(this); |
163 |
|
167 |
|
164 |
private volatile static ServerInstance profiledServerInstance; |
168 |
private AtomicReference<ProfilerSession> mySession; |
165 |
private ProfilerServerSettings profilerSettings; |
169 |
private ThreadLocal<ProgressUI> myProfilerStopUI; |
|
|
170 |
private Object myLock; |
166 |
|
171 |
|
167 |
private final DebuggerStateListener debuggerStateListener; |
172 |
private final DebuggerStateListener debuggerStateListener; |
168 |
|
173 |
|
Lines 175-180
Link Here
|
175 |
// listen to debugger changes so that we can update server status accordingly |
180 |
// listen to debugger changes so that we can update server status accordingly |
176 |
debuggerStateListener = new DebuggerStateListener(); |
181 |
debuggerStateListener = new DebuggerStateListener(); |
177 |
DebuggerManager.getDebuggerManager().addDebuggerListener(debuggerStateListener); |
182 |
DebuggerManager.getDebuggerManager().addDebuggerListener(debuggerStateListener); |
|
|
183 |
mySession = new AtomicReference<ProfilerSession>(); |
184 |
myProfilerStopUI = new ThreadLocal<ProgressUI>(); |
185 |
myLock = new Object(); |
178 |
} |
186 |
} |
179 |
|
187 |
|
180 |
/** Return this server instance InstanceProperties. */ |
188 |
/** Return this server instance InstanceProperties. */ |
Lines 349-373
Link Here
|
349 |
public void refresh() { |
357 |
public void refresh() { |
350 |
RequestProcessor.getDefault().post(new Runnable() { |
358 |
RequestProcessor.getDefault().post(new Runnable() { |
351 |
public void run() { |
359 |
public void run() { |
|
|
360 |
synchronized( myLock ){ |
352 |
try { |
361 |
try { |
353 |
int oldState = getServerState(); |
362 |
int oldState = getServerState(); |
354 |
setServerState(STATE_WAITING); |
363 |
setServerState(STATE_WAITING); |
355 |
if (ServerInstance.this == profiledServerInstance) { |
364 |
ProfilerSession session = getProfilerSession(); |
356 |
int profState = ProfilerSupport.getState(); |
365 |
if (session != null) { |
357 |
if (profState == ProfilerSupport.STATE_STARTING) { |
366 |
int profState = session.getState(); |
|
|
367 |
if (profState == ProfilerSession.STATE_STARTING) { |
358 |
setServerState(ServerInstance.STATE_PROFILER_STARTING); |
368 |
setServerState(ServerInstance.STATE_PROFILER_STARTING); |
359 |
return; |
369 |
return; |
360 |
} else if (profState == ProfilerSupport.STATE_BLOCKING) { |
370 |
} else if (profState == ProfilerSession.STATE_BLOCKING) { |
361 |
setServerState(ServerInstance.STATE_PROFILER_BLOCKING); |
371 |
setServerState(ServerInstance.STATE_PROFILER_BLOCKING); |
362 |
return; |
372 |
return; |
363 |
} else if (profState == ProfilerSupport.STATE_PROFILING |
373 |
} else if (profState == ProfilerSession.STATE_PROFILING |
364 |
|| profState == ProfilerSupport.STATE_RUNNING) { |
374 |
|| profState == ProfilerSession.STATE_RUNNING) { |
365 |
initCoTarget(); |
375 |
initCoTarget(); |
366 |
setServerState(ServerInstance.STATE_PROFILING); |
376 |
setServerState(ServerInstance.STATE_PROFILING); |
367 |
return; |
377 |
return; |
368 |
} else { |
378 |
} else if ( profState == ProfilerSession.STATE_STOPPING ){ |
|
|
379 |
reset(); |
380 |
setServerState(ServerInstance.STATE_STOPPED); |
369 |
// profiler is inactive - has been shutdown |
381 |
// profiler is inactive - has been shutdown |
370 |
profiledServerInstance = null; |
382 |
mySession.set( null ); |
|
|
383 |
return; |
384 |
} |
385 |
else if (profState == ProfilerSession.STATE_INACTIVE) |
386 |
{ |
387 |
// profiler is inactive - has been shutdown |
388 |
mySession.set( null ); |
371 |
} |
389 |
} |
372 |
} |
390 |
} |
373 |
if (isSuspended()) { |
391 |
if (isSuspended()) { |
Lines 395-400
Link Here
|
395 |
} |
413 |
} |
396 |
} |
414 |
} |
397 |
} |
415 |
} |
|
|
416 |
} |
398 |
}); |
417 |
}); |
399 |
} |
418 |
} |
400 |
|
419 |
|
Lines 523-535
Link Here
|
523 |
// TODO revert the Glassfish /w profiler related workaround |
542 |
// TODO revert the Glassfish /w profiler related workaround |
524 |
// once profiling uses the same startup sequence as debugging eg. |
543 |
// once profiling uses the same startup sequence as debugging eg. |
525 |
try { |
544 |
try { |
|
|
545 |
ProfilerSession session = getProfilerSession(); |
526 |
if (! isRunning() && startServer != null && startServer.needsStartForTargetList()) { |
546 |
if (! isRunning() && startServer != null && startServer.needsStartForTargetList()) { |
527 |
// GF workaround |
547 |
// GF workaround |
528 |
// the guard condition introduced |
548 |
// the guard condition introduced |
529 |
// *** original line |
549 |
// *** original line |
530 |
// start(); |
550 |
// start(); |
531 |
// *** |
551 |
// *** |
532 |
if (ProfilerSupport.getState() == ProfilerSupport.STATE_INACTIVE) { |
552 |
if (session == null || |
|
|
553 |
session.getState() == ProfilerSession.STATE_INACTIVE) |
554 |
{ |
533 |
start(); |
555 |
start(); |
534 |
} |
556 |
} |
535 |
// end of GF workaround |
557 |
// end of GF workaround |
Lines 541-554
Link Here
|
541 |
// *** |
563 |
// *** |
542 |
do { |
564 |
do { |
543 |
targs = getDeploymentManager().getTargets(); |
565 |
targs = getDeploymentManager().getTargets(); |
544 |
if (targs == null && ProfilerSupport.getState() == ProfilerSupport.STATE_PROFILING) { |
566 |
session = getProfilerSession(); |
|
|
567 |
if (targs == null && session!= null && |
568 |
session.getState() == ProfilerSession.STATE_PROFILING) |
569 |
{ |
545 |
try { |
570 |
try { |
546 |
Thread.sleep(500); |
571 |
Thread.sleep(500); |
547 |
} catch (InterruptedException ex) { |
572 |
} catch (InterruptedException ex) { |
548 |
Thread.currentThread().interrupt(); |
573 |
Thread.currentThread().interrupt(); |
549 |
} |
574 |
} |
550 |
} |
575 |
} |
551 |
} while (targs == null && ProfilerSupport.getState() == ProfilerSupport.STATE_PROFILING); |
576 |
} while (targs == null && session!=null && |
|
|
577 |
session.getState() == ProfilerSession.STATE_PROFILING); |
552 |
// end of GF workaround |
578 |
// end of GF workaround |
553 |
} catch(IllegalStateException e) { |
579 |
} catch(IllegalStateException e) { |
554 |
LOGGER.log(Level.INFO, null, e); |
580 |
LOGGER.log(Level.INFO, null, e); |
Lines 944-950
Link Here
|
944 |
* not also the target server. |
970 |
* not also the target server. |
945 |
*/ |
971 |
*/ |
946 |
public boolean isProfileSupported() { |
972 |
public boolean isProfileSupported() { |
947 |
Profiler profiler = ServerRegistry.getProfiler(); |
973 |
ProfilerProvider profiler = ServerRegistry.getProfilerProvider(); |
948 |
if (profiler == null) { |
974 |
if (profiler == null) { |
949 |
return false; |
975 |
return false; |
950 |
} |
976 |
} |
Lines 1000-1034
Link Here
|
1000 |
} |
1026 |
} |
1001 |
} |
1027 |
} |
1002 |
|
1028 |
|
|
|
1029 |
/* (non-Javadoc) |
1030 |
* @see org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerStateListener#stateChanged() |
1031 |
*/ |
1032 |
@Override |
1033 |
public void stateChanged( ProfilerStateEvent event ) { |
1034 |
int fromState = event.getOldState(); |
1035 |
ProfilerSession session = getProfilerSession(); |
1036 |
if ( session == null ){ |
1037 |
return; |
1038 |
} |
1039 |
if ( session.getState() == ProfilerSession.STATE_STOPPING ){ |
1040 |
session.removeProfilerStateListener( this ); |
1041 |
} |
1042 |
if ( (getStartServer().supportsProfilerStop() || |
1043 |
(fromState == ProfilerSession.STATE_RUNNING|| |
1044 |
fromState == ProfilerSession.STATE_PROFILING)) |
1045 |
&& session.getState() == ProfilerSession.STATE_STOPPING ) |
1046 |
{ |
1047 |
ProgressUI progressUI = myProfilerStopUI.get(); |
1048 |
if ( progressUI == null ){ |
1049 |
progressUI = new ProgressUI(NbBundle.getMessage( |
1050 |
ServerInstance.class, "MSG_StoppingProfiler", |
1051 |
getDisplayName()), false); |
1052 |
} |
1053 |
try { |
1054 |
doStopServer(progressUI); |
1055 |
} catch (ServerException ex) { |
1056 |
String msg = ex.getLocalizedMessage(); |
1057 |
NotifyDescriptor desc = new NotifyDescriptor.Message(msg, |
1058 |
NotifyDescriptor.ERROR_MESSAGE); |
1059 |
DialogDisplayer.getDefault().notify(desc); |
1060 |
} |
1061 |
} |
1062 |
else { |
1063 |
refresh(); |
1064 |
} |
1065 |
} |
1066 |
|
1003 |
/** Start the admin server in the profile mode. Show UI feedback. |
1067 |
/** Start the admin server in the profile mode. Show UI feedback. |
1004 |
* @param settings settings that will be used to start the server |
1068 |
* @param session profiler session |
1005 |
* |
1069 |
* |
1006 |
* @throws ServerException if the server cannot be started. |
1070 |
* @throws ServerException if the server cannot be started. |
1007 |
*/ |
1071 |
*/ |
1008 |
public void startProfile(ProfilerServerSettings settings, boolean forceRestart, ProgressUI ui) |
1072 |
public void startProfile(ProfilerSession session, boolean forceRestart, |
1009 |
throws ServerException { |
1073 |
ProgressUI ui) throws ServerException |
1010 |
// check whether another server not already running in profile mode |
1074 |
{ |
1011 |
// and ask whether it is ok to stop it |
1075 |
synchronized (myLock) { |
1012 |
ServerInstance tmpProfiledServerInstance = profiledServerInstance; |
1076 |
// check whether another server not already running in profile mode |
1013 |
if (tmpProfiledServerInstance != null && tmpProfiledServerInstance != this) { |
1077 |
// and ask whether it is ok to stop it |
1014 |
String msg = NbBundle.getMessage( |
1078 |
synchronized (session.getProvider()) { |
|
|
1079 |
if (!session.getProvider().canConfigure(session)) { |
1080 |
ServerInstance[] serverInstances = ServerRegistry |
1081 |
.getInstance().getServerInstances(); |
1082 |
StringBuilder builder = new StringBuilder(); |
1083 |
for (ServerInstance serverInstance : serverInstances) { |
1084 |
ProfilerSession profiler = serverInstance |
1085 |
.getProfilerSession(); |
1086 |
if (profiler != null |
1087 |
&& profiler.getProvider() == session |
1088 |
.getProvider()) |
1089 |
{ |
1090 |
builder.append(serverInstance.getDisplayName()); |
1091 |
builder.append(", "); // NOI18N |
1092 |
} |
1093 |
} |
1094 |
if (builder.length() > 0) { |
1095 |
builder = builder.delete(builder.length() - 2, builder |
1096 |
.length()); |
1097 |
String msg = NbBundle.getMessage(ServerInstance.class, |
1098 |
"MSG_AnotherServerProfiling", // NOI18N |
1099 |
builder.toString()); |
1100 |
NotifyDescriptor nd = new NotifyDescriptor.Confirmation( |
1101 |
msg, NotifyDescriptor.OK_CANCEL_OPTION); |
1102 |
if (DialogDisplayer.getDefault().notify(nd) == NotifyDescriptor.CANCEL_OPTION) |
1103 |
{ |
1104 |
// start in profile mode has been cancelled |
1105 |
String err = NbBundle.getMessage( |
1015 |
ServerInstance.class, |
1106 |
ServerInstance.class, |
1016 |
"MSG_AnotherServerProfiling", |
1107 |
"MSG_ProfilingCancelled", // NOI18N |
1017 |
tmpProfiledServerInstance.getDisplayName()); |
1108 |
getDisplayName()); |
1018 |
NotifyDescriptor nd = new NotifyDescriptor.Confirmation(msg, NotifyDescriptor.OK_CANCEL_OPTION); |
1109 |
throw new ServerException(err); |
1019 |
if (DialogDisplayer.getDefault().notify(nd) == NotifyDescriptor.CANCEL_OPTION) { |
1110 |
} |
1020 |
// start in profile mode has been cancelled |
1111 |
} |
1021 |
String err = NbBundle.getMessage(ServerInstance.class, "MSG_ProfilingCancelled", getDisplayName()); |
1112 |
} |
1022 |
throw new ServerException(err); |
1113 |
try { |
|
|
1114 |
setServerState(STATE_WAITING); |
1115 |
// target == null - admin server |
1116 |
_startProfile(null, session, forceRestart, ui); |
1117 |
} |
1118 |
finally { |
1119 |
refresh(); |
1120 |
} |
1023 |
} |
1121 |
} |
1024 |
} |
1122 |
} |
1025 |
try { |
|
|
1026 |
setServerState(STATE_WAITING); |
1027 |
// target == null - admin server |
1028 |
_startProfile(null, settings, forceRestart, ui); |
1029 |
} finally { |
1030 |
refresh(); |
1031 |
} |
1032 |
} |
1123 |
} |
1033 |
|
1124 |
|
1034 |
/** Restart the admin server in the mode the server was running in before. |
1125 |
/** Restart the admin server in the mode the server was running in before. |
Lines 1039-1046
Link Here
|
1039 |
public void restart(ProgressUI ui) throws ServerException { |
1130 |
public void restart(ProgressUI ui) throws ServerException { |
1040 |
try { |
1131 |
try { |
1041 |
setServerState(STATE_WAITING); |
1132 |
setServerState(STATE_WAITING); |
|
|
1133 |
ProfilerSession session = mySession.get(); |
1042 |
boolean inDebug = isDebuggable(null); |
1134 |
boolean inDebug = isDebuggable(null); |
1043 |
boolean inProfile = profiledServerInstance == this; |
1135 |
boolean inProfile = session!=null; |
1044 |
boolean stopped = true; |
1136 |
boolean stopped = true; |
1045 |
|
1137 |
|
1046 |
if (inProfile || isReallyRunning() || isSuspended()) { |
1138 |
if (inProfile || isReallyRunning() || isSuspended()) { |
Lines 1049-1055
Link Here
|
1049 |
if (stopped) { |
1141 |
if (stopped) { |
1050 |
// restart in the mode the server was running in before |
1142 |
// restart in the mode the server was running in before |
1051 |
if (inProfile) { |
1143 |
if (inProfile) { |
1052 |
_startProfile(null, profilerSettings, true, ui); |
1144 |
_startProfile(null, session, true, ui); |
1053 |
} else if (inDebug) { |
1145 |
} else if (inDebug) { |
1054 |
startDebugTarget(null, ui); |
1146 |
startDebugTarget(null, ui); |
1055 |
} else { |
1147 |
} else { |
Lines 1068-1074
Link Here
|
1068 |
public void stop(ProgressUI ui) throws ServerException { |
1160 |
public void stop(ProgressUI ui) throws ServerException { |
1069 |
try { |
1161 |
try { |
1070 |
setServerState(STATE_WAITING); |
1162 |
setServerState(STATE_WAITING); |
1071 |
if (profiledServerInstance == this || isReallyRunning() || isSuspended()) { |
1163 |
if (getProfilerSession()!=null || isReallyRunning() || isSuspended()) { |
1072 |
_stop(ui); |
1164 |
_stop(ui); |
1073 |
} |
1165 |
} |
1074 |
debugInfo.clear(); |
1166 |
debugInfo.clear(); |
Lines 1155-1166
Link Here
|
1155 |
* |
1247 |
* |
1156 |
* @throws ServerException if the server cannot be started. |
1248 |
* @throws ServerException if the server cannot be started. |
1157 |
*/ |
1249 |
*/ |
1158 |
public boolean startProfile(final ProfilerServerSettings settings, boolean forceRestart, Deployment.Logger logger) { |
1250 |
public boolean startProfile(final ProfilerSession session , |
1159 |
String title = NbBundle.getMessage(ServerInstance.class, "LBL_StartServerInProfileMode", getDisplayName()); |
1251 |
boolean forceRestart, Deployment.Logger logger) |
|
|
1252 |
{ |
1253 |
String title = NbBundle.getMessage(ServerInstance.class, |
1254 |
"LBL_StartServerInProfileMode", getDisplayName()); // NOI18N |
1160 |
ProgressUI ui = new ProgressUI(title, false, logger); |
1255 |
ProgressUI ui = new ProgressUI(title, false, logger); |
1161 |
try { |
1256 |
try { |
1162 |
ui.start(); |
1257 |
ui.start(); |
1163 |
startProfile(settings, forceRestart, ui); |
1258 |
startProfile(session, forceRestart, ui); |
1164 |
return true; |
1259 |
return true; |
1165 |
} catch (ServerException ex) { |
1260 |
} catch (ServerException ex) { |
1166 |
return false; |
1261 |
return false; |
Lines 1385-1434
Link Here
|
1385 |
} |
1480 |
} |
1386 |
} |
1481 |
} |
1387 |
|
1482 |
|
1388 |
/** start server in the profile mode */ |
1483 |
/* start server in the profile mode |
1389 |
private void _startProfile( |
1484 |
* |
1390 |
Target target, |
1485 |
* This method suppose to be called under session.getProvider() lock |
1391 |
ProfilerServerSettings settings, |
1486 |
*/ |
1392 |
boolean forceRestart, |
1487 |
private void _startProfile(Target target, ProfilerSession session, |
1393 |
ProgressUI ui) throws ServerException { |
1488 |
boolean forceRestart,ProgressUI ui) throws ServerException |
1394 |
ProfilerServerSettings tmpProfilerSettings; |
1489 |
{ |
1395 |
synchronized (this) { |
1490 |
ProfilerSession currentSession = mySession.get(); |
1396 |
tmpProfilerSettings = profilerSettings; |
1491 |
|
|
|
1492 |
if (session == null) { |
1493 |
// this should not occur, but better make sure |
1494 |
throw new ServerException(NbBundle.getMessage(ServerInstance.class, |
1495 |
"MSG_ProfilerNotRegistered")); // NOI18N |
1397 |
} |
1496 |
} |
1398 |
ServerInstance tmpProfiledServerInstance = profiledServerInstance; |
1497 |
|
1399 |
if (tmpProfiledServerInstance == this && !forceRestart && settings.equals(tmpProfilerSettings)) { |
1498 |
if ( !forceRestart && session.equals( currentSession )) |
|
|
1499 |
{ |
1400 |
return; // server is already runnning in profile mode, no need to restart the server |
1500 |
return; // server is already runnning in profile mode, no need to restart the server |
1401 |
} |
1501 |
} |
1402 |
if (tmpProfiledServerInstance != null && tmpProfiledServerInstance != this) { |
1502 |
|
1403 |
// another server currently running in profiler mode |
1503 |
if( !session.getProvider().canConfigure(session) ) |
1404 |
tmpProfiledServerInstance.stop(ui); |
1504 |
{ |
1405 |
profiledServerInstance = null; |
1505 |
ServerInstance[] serverInstances = ServerRegistry.getInstance() |
1406 |
} |
1506 |
.getServerInstances(); |
1407 |
if (profiledServerInstance == this || isReallyRunning() || isDebuggable(target)) { |
1507 |
for (ServerInstance serverInstance : serverInstances) { |
1408 |
_stop(ui); |
1508 |
ProfilerSession profiler = serverInstance |
1409 |
debugInfo.clear(); |
1509 |
.getProfilerSession(); |
1410 |
profiledServerInstance = null; |
1510 |
if (profiler != null && profiler.getProvider() == |
|
|
1511 |
session.getProvider()) |
1512 |
{ |
1513 |
serverInstance._stop(ui); |
1514 |
if ( session.getProvider().canConfigure(session) ){ |
1515 |
break; |
1516 |
} |
1517 |
} |
1518 |
} |
1411 |
} |
1519 |
} |
1412 |
|
1520 |
|
1413 |
Profiler profiler = ServerRegistry.getProfiler(); |
1521 |
if ( !session.getProvider().canConfigure( session )){ |
1414 |
if (profiler == null) { |
1522 |
throw new ServerException(NbBundle.getMessage(ServerInstance.class, |
1415 |
// this should not occur, but better make sure |
1523 |
"MSG_ProfilerNoNewSession")); // NOI18N |
1416 |
throw new ServerException(NbBundle.getMessage(ServerInstance.class, "MSG_ProfilerNotRegistered")); |
|
|
1417 |
} |
1524 |
} |
1418 |
profiler.notifyStarting(); |
1525 |
|
1419 |
ProgressObject po = getStartServer().startProfiling(target, settings); |
1526 |
ProfilerServerSettings settings = session.configureSession(); |
|
|
1527 |
session.addProfilerStateListener( this ); |
1528 |
session.notifyStarting(); |
1529 |
ProgressObject po = getStartServer().startProfiling(target, settings, |
1530 |
session); |
1420 |
try { |
1531 |
try { |
1421 |
boolean completedSuccessfully = ProgressObjectUtil.trackProgressObject(ui, po, DEFAULT_TIMEOUT); |
1532 |
boolean completedSuccessfully = ProgressObjectUtil. |
|
|
1533 |
trackProgressObject(ui, po, DEFAULT_TIMEOUT); |
1422 |
if (!completedSuccessfully) { |
1534 |
if (!completedSuccessfully) { |
1423 |
throw new ServerException(po.getDeploymentStatus().getMessage()); |
1535 |
throw new ServerException(po.getDeploymentStatus().getMessage()); |
1424 |
} |
1536 |
} |
1425 |
} catch (TimedOutException e) { |
1537 |
} catch (TimedOutException e) { |
1426 |
String msg = NbBundle.getMessage(ServerInstance.class, "MSG_StartProfileTimeout", getDisplayName()); |
1538 |
String msg = NbBundle.getMessage(ServerInstance.class, |
|
|
1539 |
"MSG_StartProfileTimeout", getDisplayName()); |
1427 |
throw new ServerException(msg); |
1540 |
throw new ServerException(msg); |
1428 |
} |
1541 |
} |
1429 |
profiledServerInstance = this; |
1542 |
mySession.set( session ); |
1430 |
synchronized (this) { |
1543 |
synchronized (this) { |
1431 |
profilerSettings = settings; |
|
|
1432 |
managerStartedByIde = true; |
1544 |
managerStartedByIde = true; |
1433 |
// coTarget = null; |
1545 |
// coTarget = null; |
1434 |
// targets = null; |
1546 |
// targets = null; |
Lines 1437-1454
Link Here
|
1437 |
} |
1549 |
} |
1438 |
|
1550 |
|
1439 |
/** Tell the profiler to shutdown */ |
1551 |
/** Tell the profiler to shutdown */ |
1440 |
private void shutdownProfiler(ProgressUI ui) throws ServerException { |
1552 |
private void shutdownProfiler(ProfilerSession session , ProgressUI ui) |
1441 |
ui.progress(NbBundle.getMessage(ServerInstance.class, "MSG_StoppingProfiler")); |
1553 |
throws ServerException |
1442 |
Profiler profiler = ServerRegistry.getProfiler(); |
1554 |
{ |
1443 |
if (profiler != null) { |
1555 |
ui.progress(NbBundle.getMessage(ServerInstance.class, |
1444 |
ProgressObject po = profiler.shutdown(); |
1556 |
"MSG_StoppingProfiler")); // NOI18N |
|
|
1557 |
if (session != null) { |
1558 |
ProgressObject po = session.notifyStop(); |
1445 |
try { |
1559 |
try { |
1446 |
boolean completedSuccessfully = ProgressObjectUtil.trackProgressObject(ui, po, getShutdownTimeout()); |
1560 |
boolean completedSuccessfully = ProgressObjectUtil. |
|
|
1561 |
trackProgressObject(ui, po, getShutdownTimeout()); |
1447 |
if (!completedSuccessfully) { |
1562 |
if (!completedSuccessfully) { |
1448 |
throw new ServerException(po.getDeploymentStatus().getMessage()); |
1563 |
throw new ServerException(po.getDeploymentStatus().getMessage()); |
1449 |
} |
1564 |
} |
1450 |
} catch (TimedOutException e) { |
1565 |
} catch (TimedOutException e) { |
1451 |
String msg = NbBundle.getMessage(ServerInstance.class, "MSG_ProfilerShutdownTimeout"); |
1566 |
String msg = NbBundle.getMessage(ServerInstance.class, |
|
|
1567 |
"MSG_ProfilerShutdownTimeout"); // NOI18N |
1452 |
throw new ServerException(msg); |
1568 |
throw new ServerException(msg); |
1453 |
} |
1569 |
} |
1454 |
} |
1570 |
} |
Lines 1457-1508
Link Here
|
1457 |
// stopDeploymentManager |
1573 |
// stopDeploymentManager |
1458 |
private void _stop(ProgressUI ui) throws ServerException { |
1574 |
private void _stop(ProgressUI ui) throws ServerException { |
1459 |
// if the server is started in profile mode, deattach profiler first |
1575 |
// if the server is started in profile mode, deattach profiler first |
1460 |
if (profiledServerInstance == this) { |
1576 |
ProfilerSession session = getProfilerSession(); |
1461 |
shutdownProfiler(ui); |
1577 |
if (session != null) { |
1462 |
profiledServerInstance = null; |
1578 |
myProfilerStopUI.set( ui ); |
|
|
1579 |
shutdownProfiler(session, ui); |
1580 |
mySession.set(null); |
1581 |
myProfilerStopUI.set( null ); |
1582 |
return; |
1463 |
} |
1583 |
} |
1464 |
synchronized (this) { |
1584 |
doStopServer(ui); |
1465 |
// if the server is suspended, the debug session has to be terminated first |
1585 |
} |
1466 |
if (isSuspended()) { |
1586 |
|
1467 |
Target target = _retrieveTarget(null); |
1587 |
private void doStopServer( ProgressUI ui ) throws ServerException { |
1468 |
ServerDebugInfo sdi = getServerDebugInfo(target); |
1588 |
synchronized (myLock) { |
1469 |
Session[] sessions = DebuggerManager.getDebuggerManager().getSessions(); |
1589 |
// if the server is suspended, the debug session has to be |
1470 |
for (int i = 0; i < sessions.length; i++) { |
1590 |
// terminated first |
1471 |
Session s = sessions[i]; |
1591 |
synchronized (this) { |
1472 |
if (s != null) { |
1592 |
if (isSuspended()) { |
1473 |
AttachingDICookie attCookie = (AttachingDICookie)s.lookupFirst(null, AttachingDICookie.class); |
1593 |
Target target = _retrieveTarget(null); |
1474 |
if (attCookie != null) { |
1594 |
ServerDebugInfo sdi = getServerDebugInfo(target); |
1475 |
if (sdi.getTransport().equals(ServerDebugInfo.TRANSPORT_SHMEM)) { |
1595 |
Session[] sessions = DebuggerManager.getDebuggerManager() |
1476 |
String shmem = attCookie.getSharedMemoryName(); |
1596 |
.getSessions(); |
1477 |
if (shmem != null && shmem.equalsIgnoreCase(sdi.getShmemName())) { |
1597 |
for (int i = 0; i < sessions.length; i++) { |
1478 |
s.kill(); |
1598 |
Session s = sessions[i]; |
|
|
1599 |
if (s != null) { |
1600 |
AttachingDICookie attCookie = (AttachingDICookie) s |
1601 |
.lookupFirst(null, AttachingDICookie.class); |
1602 |
if (attCookie != null) { |
1603 |
if (sdi.getTransport().equals( |
1604 |
ServerDebugInfo.TRANSPORT_SHMEM)) |
1605 |
{ |
1606 |
String shmem = attCookie |
1607 |
.getSharedMemoryName(); |
1608 |
if (shmem != null |
1609 |
&& shmem.equalsIgnoreCase(sdi |
1610 |
.getShmemName())) |
1611 |
{ |
1612 |
s.kill(); |
1613 |
} |
1479 |
} |
1614 |
} |
1480 |
} else { |
1615 |
else { |
1481 |
String host = attCookie.getHostName(); |
1616 |
String host = attCookie.getHostName(); |
1482 |
if (host != null && isSameHost(host, sdi.getHost()) |
1617 |
if (host != null |
1483 |
&& attCookie.getPortNumber() == sdi.getPort()) { |
1618 |
&& isSameHost(host, sdi.getHost()) |
1484 |
s.kill(); |
1619 |
&& attCookie.getPortNumber() == sdi |
|
|
1620 |
.getPort()) |
1621 |
{ |
1622 |
s.kill(); |
1623 |
} |
1485 |
} |
1624 |
} |
1486 |
} |
1625 |
} |
1487 |
} |
1626 |
} |
1488 |
} |
1627 |
} |
1489 |
} |
1628 |
} |
1490 |
} |
1629 |
} |
|
|
1630 |
ProgressObject po = getStartServer().stopDeploymentManager(); |
1631 |
try { |
1632 |
boolean completedSuccessfully = ProgressObjectUtil |
1633 |
.trackProgressObject(ui, po, getShutdownTimeout()); |
1634 |
if (!completedSuccessfully) { |
1635 |
throw new ServerException(po.getDeploymentStatus() |
1636 |
.getMessage()); |
1637 |
} |
1638 |
} |
1639 |
catch (TimedOutException e) { |
1640 |
String msg = NbBundle.getMessage(ServerInstance.class, |
1641 |
"MSG_StopServerTimeout", getDisplayName()); // NOI18N |
1642 |
throw new ServerException(msg); |
1643 |
} |
1644 |
synchronized ( this ) { |
1645 |
managerStartedByIde = false; |
1646 |
} |
1647 |
refresh(); |
1648 |
reset(); |
1491 |
} |
1649 |
} |
1492 |
ProgressObject po = getStartServer().stopDeploymentManager(); |
|
|
1493 |
try { |
1494 |
boolean completedSuccessfully = ProgressObjectUtil.trackProgressObject(ui, po, getShutdownTimeout()); |
1495 |
if (!completedSuccessfully) { |
1496 |
throw new ServerException(po.getDeploymentStatus().getMessage()); |
1497 |
} |
1498 |
} catch (TimedOutException e) { |
1499 |
String msg = NbBundle.getMessage(ServerInstance.class, "MSG_StopServerTimeout", getDisplayName()); |
1500 |
throw new ServerException(msg); |
1501 |
} |
1502 |
synchronized (this) { |
1503 |
managerStartedByIde = false; |
1504 |
} |
1505 |
reset(); |
1506 |
} |
1650 |
} |
1507 |
|
1651 |
|
1508 |
private void _start(Target target, ProgressUI ui) throws ServerException { |
1652 |
private void _start(Target target, ProgressUI ui) throws ServerException { |
Lines 1672-1677
Link Here
|
1672 |
return sdi; |
1816 |
return sdi; |
1673 |
} |
1817 |
} |
1674 |
|
1818 |
|
|
|
1819 |
private ProfilerSession getProfilerSession(){ |
1820 |
return mySession.get(); |
1821 |
} |
1822 |
|
1675 |
private Target _retrieveTarget(Target target) { |
1823 |
private Target _retrieveTarget(Target target) { |
1676 |
StartServer ss = getStartServer(); |
1824 |
StartServer ss = getStartServer(); |
1677 |
if (ss == null) { |
1825 |
if (ss == null) { |