This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 213640
Collapse All | Expand All

(-)a/glassfish.common/src/org/netbeans/modules/glassfish/common/Bundle.properties (-1 / +1 lines)
Lines 84-90 Link Here
84
MSG_ServerCmdRunning={0} running on {1}
84
MSG_ServerCmdRunning={0} running on {1}
85
MSG_ServerCmdCompleted={0} completed on {1}
85
MSG_ServerCmdCompleted={0} completed on {1}
86
MSG_ServerCmdFailed={0} failed on {1} \n {2}
86
MSG_ServerCmdFailed={0} failed on {1} \n {2}
87
MSG_ServerCmdFailedIncorrectInstance={0} failed. Instance is not {1}.
87
MSG_ServerCmdFailedIncorrectInstance={0} failed. Instance is not {1} or it is not running.
88
MSG_AuthorizationFailed=Authorization failed for {0} on {1}.  Bad password?
88
MSG_AuthorizationFailed=Authorization failed for {0} on {1}.  Bad password?
89
MSG_AuthorizationFailedRemote=Authorization failed for {0} on {1}.  Have you run the enable-secure-admin command?
89
MSG_AuthorizationFailedRemote=Authorization failed for {0} on {1}.  Have you run the enable-secure-admin command?
90
MSG_Exception={0}
90
MSG_Exception={0}
(-)a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/ServerInstance.java (-27 / +36 lines)
Lines 72-77 Link Here
72
import java.util.concurrent.ScheduledExecutorService;
72
import java.util.concurrent.ScheduledExecutorService;
73
import java.util.concurrent.TimeUnit;
73
import java.util.concurrent.TimeUnit;
74
import java.util.concurrent.TimeoutException;
74
import java.util.concurrent.TimeoutException;
75
import java.util.concurrent.atomic.AtomicReference;
75
import java.util.logging.Level;
76
import java.util.logging.Level;
76
import java.util.logging.Logger;
77
import java.util.logging.Logger;
77
import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
78
import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
Lines 181-187 Link Here
181
    
182
    
182
    private final ChangeSupport managerChangeSupport = new ChangeSupport(this);
183
    private final ChangeSupport managerChangeSupport = new ChangeSupport(this);
183
    
184
    
184
    private volatile static ServerInstance profiledServerInstance;
185
    private static AtomicReference<ServerInstance> profiledServerInstance = new AtomicReference<ServerInstance>();
185
    
186
    
186
    private final DebuggerStateListener debuggerStateListener;
187
    private final DebuggerStateListener debuggerStateListener;
187
    
188
    
Lines 376-382 Link Here
376
                try {
377
                try {
377
                    int oldState = getServerState();
378
                    int oldState = getServerState();
378
                    setServerState(STATE_WAITING);
379
                    setServerState(STATE_WAITING);
379
                    if (ServerInstance.this == profiledServerInstance) {
380
                    if (ServerInstance.this == profiledServerInstance.get()) {
380
                        updateStateFromProfiler();
381
                        updateStateFromProfiler();
381
                        return;
382
                        return;
382
                    }
383
                    }
Lines 1107-1113 Link Here
1107
    throws ServerException {
1108
    throws ServerException {
1108
        // check whether another server not already running in profile mode
1109
        // check whether another server not already running in profile mode
1109
        // and ask whether it is ok to stop it
1110
        // and ask whether it is ok to stop it
1110
        ServerInstance tmpProfiledServerInstance = profiledServerInstance;
1111
        ServerInstance tmpProfiledServerInstance = profiledServerInstance.get();
1111
        if (tmpProfiledServerInstance != null && tmpProfiledServerInstance != this) {
1112
        if (tmpProfiledServerInstance != null && tmpProfiledServerInstance != this) {
1112
            String msg = NbBundle.getMessage(
1113
            String msg = NbBundle.getMessage(
1113
                                    ServerInstance.class,
1114
                                    ServerInstance.class,
Lines 1138-1144 Link Here
1138
        try {
1139
        try {
1139
            setServerState(STATE_WAITING);
1140
            setServerState(STATE_WAITING);
1140
            boolean inDebug = isDebuggable(null);
1141
            boolean inDebug = isDebuggable(null);
1141
            boolean inProfile = profiledServerInstance == this;
1142
            boolean inProfile = profiledServerInstance.get() == this;
1142
            boolean stopped = true;
1143
            boolean stopped = true;
1143
            
1144
            
1144
            if (inProfile || isReallyRunning() || isSuspended()) {
1145
            if (inProfile || isReallyRunning() || isSuspended()) {
Lines 1166-1172 Link Here
1166
    public void stop(ProgressUI ui) throws ServerException {
1167
    public void stop(ProgressUI ui) throws ServerException {
1167
        try {
1168
        try {
1168
            setServerState(STATE_WAITING);
1169
            setServerState(STATE_WAITING);
1169
            if (profiledServerInstance == this || isReallyRunning() || isSuspended()) {
1170
            if (profiledServerInstance.get() == this || isReallyRunning() || isSuspended()) {
1170
                _stop(ui);
1171
                _stop(ui);
1171
            }
1172
            }
1172
            debugInfo.clear();
1173
            debugInfo.clear();
Lines 1488-1506 Link Here
1488
                                    Target target, 
1489
                                    Target target, 
1489
                                    boolean forceRestart,
1490
                                    boolean forceRestart,
1490
                                    ProgressUI ui) throws ServerException {
1491
                                    ProgressUI ui) throws ServerException {
1491
        ServerInstance tmpProfiledServerInstance = profiledServerInstance;
1492
        ServerInstance tmpProfiledServerInstance = profiledServerInstance.get();
1492
        if (tmpProfiledServerInstance == this && !forceRestart) {
1493
        if (tmpProfiledServerInstance == this && !forceRestart) {
1493
            return; // server is already runnning in profile mode, no need to restart the server
1494
            return; // server is already runnning in profile mode, no need to restart the server
1494
        }
1495
        }
1495
        if (tmpProfiledServerInstance != null && tmpProfiledServerInstance != this) {
1496
        if (tmpProfiledServerInstance != null && tmpProfiledServerInstance != this) {
1496
            // another server currently running in profiler mode
1497
            // another server currently running in profiler mode
1497
            tmpProfiledServerInstance.stop(ui);
1498
            tmpProfiledServerInstance.stop(ui);
1498
            profiledServerInstance = null;
1499
            boolean done = profiledServerInstance.compareAndSet(tmpProfiledServerInstance, null);
1500
            assert done : "Unxpected profiled instance " + profiledServerInstance.get();
1499
        }
1501
        }
1500
        if (profiledServerInstance == this || isReallyRunning() || isDebuggable(target)) {
1502
        if (profiledServerInstance.get() == this || isReallyRunning() || isDebuggable(target)) {
1501
            _stop(ui);
1503
            _stop(ui);
1502
            debugInfo.clear();
1504
            debugInfo.clear();
1503
            profiledServerInstance = null;
1505
            //profiledServerInstance = null;
1504
        }
1506
        }
1505
        
1507
        
1506
        final Profiler profiler = ServerRegistry.getProfiler();
1508
        final Profiler profiler = ServerRegistry.getProfiler();
Lines 1510-1515 Link Here
1510
        }
1512
        }
1511
        
1513
        
1512
        final ScheduledExecutorService statusUpdater = Executors.newSingleThreadScheduledExecutor();
1514
        final ScheduledExecutorService statusUpdater = Executors.newSingleThreadScheduledExecutor();
1515
        
1516
        final StateListener l = new StateListener() {
1517
1518
            @Override
1519
            public void stateChanged(int oldState, int newState) {
1520
                if (oldState != newState && newState == STATE_STOPPED) {
1521
                    ServerInstance.this.removeStateListener(this);
1522
                    statusUpdater.shutdownNow();
1523
                    ServerInstance.this.refresh();
1524
                    boolean done = profiledServerInstance.compareAndSet(ServerInstance.this, null);
1525
                    assert done : "Unxpected profiled instance " + profiledServerInstance.get();
1526
                }
1527
            }
1528
        };
1529
        
1530
        this.addStateListener(l);
1531
        profiler.notifyStarting();
1532
        
1513
        statusUpdater.scheduleAtFixedRate(new Runnable() {
1533
        statusUpdater.scheduleAtFixedRate(new Runnable() {
1514
1534
1515
            @Override
1535
            @Override
Lines 1518-1538 Link Here
1518
            }
1538
            }
1519
        }, 50, 100, TimeUnit.MILLISECONDS);
1539
        }, 50, 100, TimeUnit.MILLISECONDS);
1520
        
1540
        
1521
        final StateListener l = new StateListener() {
1522
1523
            @Override
1524
            public void stateChanged(int oldState, int newState) {
1525
                if (oldState != newState && newState == STATE_STOPPED) {
1526
                    ServerInstance.this.removeStateListener(this);
1527
                    statusUpdater.shutdownNow();
1528
                    profiledServerInstance = null;
1529
                }
1530
            }
1531
        };
1532
        
1533
        this.addStateListener(l);
1534
        
1535
        profiler.notifyStarting();
1536
        ProgressObject po = getStartServer().startProfiling(target);
1541
        ProgressObject po = getStartServer().startProfiling(target);
1537
        try {
1542
        try {
1538
            boolean completedSuccessfully = ProgressObjectUtil.trackProgressObject(ui, po, DEFAULT_TIMEOUT);
1543
            boolean completedSuccessfully = ProgressObjectUtil.trackProgressObject(ui, po, DEFAULT_TIMEOUT);
Lines 1543-1549 Link Here
1543
            String msg = NbBundle.getMessage(ServerInstance.class, "MSG_StartProfileTimeout", getDisplayName());
1548
            String msg = NbBundle.getMessage(ServerInstance.class, "MSG_StartProfileTimeout", getDisplayName());
1544
            throw new ServerException(msg);
1549
            throw new ServerException(msg);
1545
        }
1550
        }
1546
        profiledServerInstance = this;
1551
        profiledServerInstance.set(this);
1547
        synchronized (this) {
1552
        synchronized (this) {
1548
            managerStartedByIde = true;
1553
            managerStartedByIde = true;
1549
//            coTarget = null;
1554
//            coTarget = null;
Lines 1573-1581 Link Here
1573
    // stopDeploymentManager
1578
    // stopDeploymentManager
1574
    private void _stop(ProgressUI ui) throws ServerException {
1579
    private void _stop(ProgressUI ui) throws ServerException {
1575
        // if the server is started in profile mode, deattach profiler first
1580
        // if the server is started in profile mode, deattach profiler first
1576
        if (profiledServerInstance == this) {
1581
        if (profiledServerInstance.get() == this) {
1577
            shutdownProfiler(ui);
1582
            shutdownProfiler(ui);
1578
            profiledServerInstance = null;
1583
            boolean done = profiledServerInstance.compareAndSet(this, null);
1584
            assert done : "Unxpected profiled instance " + profiledServerInstance.get();
1579
        }
1585
        }
1580
        synchronized (this) {
1586
        synchronized (this) {
1581
            // if the server is suspended, the debug session has to be terminated first
1587
            // if the server is suspended, the debug session has to be terminated first
Lines 1728-1733 Link Here
1728
    }
1734
    }
1729
    
1735
    
1730
    private void fireStateChanged(int oldState, int newState) {
1736
    private void fireStateChanged(int oldState, int newState) {
1737
        if (oldState == newState) {
1738
            return;
1739
        }
1731
        StateListener[] listeners;
1740
        StateListener[] listeners;
1732
        synchronized (stateListeners) {
1741
        synchronized (stateListeners) {
1733
            listeners = (StateListener[])stateListeners.toArray(new StateListener[stateListeners.size()]);
1742
            listeners = (StateListener[])stateListeners.toArray(new StateListener[stateListeners.size()]);

Return to bug 213640