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 53010
Collapse All | Expand All

(-)apichanges.xml (+17 lines)
Lines 240-245 Link Here
240
            <class package="org.netbeans.modules.j2ee.deployment.devmodules.spi" name="J2eeModuleProvider"/>
240
            <class package="org.netbeans.modules.j2ee.deployment.devmodules.spi" name="J2eeModuleProvider"/>
241
            <class package="org.netbeans.modules.j2ee.deployment.devmodules.spi" name="OriginalMappingProvider"/>
241
            <class package="org.netbeans.modules.j2ee.deployment.devmodules.spi" name="OriginalMappingProvider"/>
242
         </change>
242
         </change>
243
        <change id="StartServer-Services-for-Target">
244
            <api name="plugins"/>
245
            <summary>StartServer methods call to manage states for target server instances</summary>
246
            <version major="1" minor="5"/>
247
            <date day="10" month="01" year="2005"/>
248
            <author login="nnguyen"/>
249
            <compatibility addition="yes"/>
250
            <description>
251
                <p>
252
                    J2eeserver should be able to start target managed server instances
253
		    which are not identical with admin server instance.
254
                    Methods supportsStartTarget, isRunning, startTarget, stopTarget
255
                    are added as optional to StartServer abstract class plugin SPI.
256
                </p>
257
            </description>
258
            <class package="org.netbeans.modules.j2ee.deployment.plugins.api" name="StartServer"/>
259
         </change>
243
    </changes>
260
    </changes>
244
261
245
    <!-- Now the surrounding HTML text and document structure: -->
262
    <!-- Now the surrounding HTML text and document structure: -->
(-)src/org/netbeans/modules/j2ee/deployment/config/DDFilesListener.java (-1 / +1 lines)
Lines 48-54 Link Here
48
        for (int i=0; i<pathNames.length; i++) {
48
        for (int i=0; i<pathNames.length; i++) {
49
            String fileName = pathNames[i];
49
            String fileName = pathNames[i];
50
            if (J2eeModule.WAR != provider.getJ2eeModule().getModuleType()) {
50
            if (J2eeModule.WAR != provider.getJ2eeModule().getModuleType()) {
51
                fileName = fileName.substring(pathNames[i].lastIndexOf('/')+1);
51
                fileName = fileName.substring(pathNames[i].lastIndexOf('/')+1); //always forward
52
            }
52
            }
53
            ddFiles[i] = new File(configFolder, fileName);
53
            ddFiles[i] = new File(configFolder, fileName);
54
        }
54
        }
(-)src/org/netbeans/modules/j2ee/deployment/impl/Bundle.properties (+2 lines)
Lines 122-124 Link Here
122
Services/J2EEServers=J2EE Servers
122
Services/J2EEServers=J2EE Servers
123
123
124
MSG_NoServerInstance=Cannot locate server instance {0} and there is no default instance.
124
MSG_NoServerInstance=Cannot locate server instance {0} and there is no default instance.
125
126
MSG_StartStopTargetNotSupported=Start or stop target server {0} is not supported.
(-)src/org/netbeans/modules/j2ee/deployment/impl/ServerInstance.java (-5 / +138 lines)
Lines 46-51 Link Here
46
    private J2eePlatformImpl j2eePlatformImpl;
46
    private J2eePlatformImpl j2eePlatformImpl;
47
    private StartServer startServer;
47
    private StartServer startServer;
48
    private FindJSPServlet findJSPServlet;
48
    private FindJSPServlet findJSPServlet;
49
    private final Set targetsStartedByIde = new HashSet(); // valued by target name
49
    private Map targets; // keyed by target name, valued by ServerTarget
50
    private Map targets; // keyed by target name, valued by ServerTarget
50
    private boolean managerStartedByIde = false;
51
    private boolean managerStartedByIde = false;
51
    private ServerTarget coTarget = null;
52
    private ServerTarget coTarget = null;
Lines 174-179 Link Here
174
        String title = NbBundle.getMessage(ServerInstance.class, "LBL_StopServerProgressMonitor", displayName);
175
        String title = NbBundle.getMessage(ServerInstance.class, "LBL_StopServerProgressMonitor", displayName);
175
        DeployProgressUI ui = new DeployProgressMonitor(title, false, true);  // modeless with stop/cancel buttons
176
        DeployProgressUI ui = new DeployProgressMonitor(title, false, true);  // modeless with stop/cancel buttons
176
        
177
        
178
        for (Iterator i=targetsStartedByIde.iterator(); i.hasNext(); ){
179
            String targetName = (String) i.next();
180
            ServerTarget serverTarget = getServerTarget(targetName);
181
            if (serverTarget != null) {
182
                _stop(serverTarget.getTarget(), ui);
183
            }
184
        }
185
        
177
        stop(ui);
186
        stop(ui);
178
        ServerRegistry.getInstance().removeServerInstance(getUrl());
187
        ServerRegistry.getInstance().removeServerInstance(getUrl());
179
    }
188
    }
Lines 304-309 Link Here
304
        return managerStartedByIde;
313
        return managerStartedByIde;
305
    }
314
    }
306
    
315
    
316
    /**
317
     * Return set of ServerTarget's that have been started from inside IDE.
318
     * @return set of ServerTarget objects.
319
     */
320
    public Set getTargetsStartedByIde() {
321
        Set ret = new HashSet();
322
        for (Iterator i=targetsStartedByIde.iterator(); i.hasNext(); ) {
323
            String targetName = (String) i.next();
324
            ret.add(getServerTarget(targetName));
325
        }
326
        return ret;
327
    }
328
    
307
    //----------- State Transistion API's: ----------------------
329
    //----------- State Transistion API's: ----------------------
308
    // Note: configuration needs
330
    // Note: configuration needs
309
    /**
331
    /**
Lines 442-454 Link Here
442
                if (ss.isDebuggable(target)) {
464
                if (ss.isDebuggable(target)) {
443
                    return true;
465
                    return true;
444
                }
466
                }
445
                //if (! _stop(target, ui)) {
467
                if (! _stop(target, ui)) {
446
                //    return false;
468
                    return false;
447
                //}
469
                }
448
                return _startDebug(target, ui);
470
                return _startDebug(target, ui);
449
            } else {
471
            } else {
450
                //return _start(target, ui);
472
                return _start(target, ui);
451
                return true;
452
            }
473
            }
453
        }
474
        }
454
    }
475
    }
Lines 608-613 Link Here
608
            managerStartedByIde = false;
629
            managerStartedByIde = false;
609
            refresh(ServerState.STOPPED);
630
            refresh(ServerState.STOPPED);
610
            return true;
631
            return true;
632
            
633
        } finally {
634
            if (ui != null) {
635
                ui.removeCancelHandler(ch);
636
                ui.setProgressObject(null);
637
            }
638
            if (po != null) {
639
                po.removeProgressListener(handler);
640
            }
641
        }
642
    }
643
    
644
    private boolean _start(Target target, DeployProgressUI ui) {
645
        ServerTarget serverTarget = getServerTarget(target.getName());
646
        if (serverTarget.isRunning())
647
            return true;
648
        
649
        String displayName = target.getName();
650
        output(ui, NbBundle.getMessage(ServerInstance.class, "MSG_StartingServer", displayName));
651
        DeployProgressUI.CancelHandler ch = getCancelHandler();
652
        StartProgressHandler handler = new StartProgressHandler();
653
        ProgressObject po = null;
654
        if (ui != null) {
655
            ui.addCancelHandler(ch);
656
        }
657
        
658
        try {
659
            setCommandSucceeded(false);
660
            po = serverTarget.start();
661
            if (ui != null) {
662
                ui.setProgressObject(po);
663
            }
664
            po.addProgressListener(handler);
665
            
666
            String error = null;
667
            if (isProgressing(po)) {
668
                // wait until done or cancelled
669
                boolean done = sleep();
670
                if (! done) {
671
                    error = NbBundle.getMessage(ServerInstance.class, "MSG_StartServerTimeout", displayName);
672
                } else if (ui != null && ui.checkCancelled()) {
673
                    error = NbBundle.getMessage(ServerInstance.class, "MSG_StartServerCancelled", displayName);
674
                } else if (! hasCommandSucceeded()) {
675
                    return false;
676
                }
677
            } else if (hasFailed(po)) {
678
                return false;
679
            }
680
            
681
            if (error != null) {
682
                outputError(ui, error);
683
                return false;
684
            } else {
685
                targetsStartedByIde.add(serverTarget.getName());
686
                return true;
687
            }
688
            
689
        } finally {
690
            if (ui != null) {
691
                ui.removeCancelHandler(ch);
692
                ui.setProgressObject(null);
693
            }
694
            if (po != null) {
695
                po.removeProgressListener(handler);
696
            }
697
        }
698
    }
699
    
700
    private boolean _stop(Target target, DeployProgressUI ui) {
701
        ServerTarget serverTarget = getServerTarget(target.getName());
702
        if (serverTarget.isRunning())
703
            return true;
704
        
705
        String displayName = target.getName();
706
        output(ui, NbBundle.getMessage(ServerInstance.class, "MSG_StoppingServer", displayName));
707
        DeployProgressUI.CancelHandler ch = getCancelHandler();
708
        StartProgressHandler handler = new StartProgressHandler();
709
        ProgressObject po = null;
710
        if (ui != null) {
711
            ui.addCancelHandler(ch);
712
        }
713
        
714
        try {
715
            setCommandSucceeded(false);
716
            po = serverTarget.stop();
717
            if (ui != null) {
718
                ui.setProgressObject(po);
719
            }
720
            po.addProgressListener(handler);
721
            
722
            String error = null;
723
            if (isProgressing(po)) {
724
                // wait until done or cancelled
725
                boolean done = sleep();
726
                if (! done) {
727
                    error = NbBundle.getMessage(ServerInstance.class, "MSG_StopServerTimeout", displayName);
728
                } else if (ui != null && ui.checkCancelled()) {
729
                    error = NbBundle.getMessage(ServerInstance.class, "MSG_StopServerCancelled", displayName);
730
                } else if (! hasCommandSucceeded()) {
731
                    return false;
732
                }
733
            } else if (hasFailed(po)) {
734
                return false;
735
            }
736
            
737
            if (error != null) {
738
                outputError(ui, error);
739
                return false;
740
            } else {
741
                targetsStartedByIde.remove(serverTarget.getName());
742
                return true;
743
            }
611
            
744
            
612
        } finally {
745
        } finally {
613
            if (ui != null) {
746
            if (ui != null) {
(-)src/org/netbeans/modules/j2ee/deployment/impl/ServerTarget.java (+32 lines)
Lines 14-19 Link Here
14
14
15
package org.netbeans.modules.j2ee.deployment.impl;
15
package org.netbeans.modules.j2ee.deployment.impl;
16
16
17
import javax.enterprise.deploy.spi.status.ProgressObject;
17
import org.openide.nodes.Node;
18
import org.openide.nodes.Node;
18
import javax.enterprise.deploy.spi.Target;
19
import javax.enterprise.deploy.spi.Target;
19
//import javax.management.ObjectName;
20
//import javax.management.ObjectName;
Lines 68-73 Link Here
68
    public boolean isRunning() {
69
    public boolean isRunning() {
69
        if (isAlsoServerInstance())
70
        if (isAlsoServerInstance())
70
            return instance.isRunning();
71
            return instance.isRunning();
72
        
73
        StartServer ss = instance.getStartServer();
74
        if (ss != null) {
75
            return ss.isRunning(target);
76
        }
71
        return false;
77
        return false;
78
    }
79
    
80
    public ProgressObject start() {
81
        StartServer ss = instance.getStartServer();
82
        if (ss != null && ss.supportsStartTarget(target)) {
83
            ProgressObject po = ss.startTarget(target);
84
            if (po != null) {
85
                return po;
86
            }
87
        }
88
        String name = target == null ? "null" : target.getName(); //NOI18N
89
        String msg = NbBundle.getMessage(ServerTarget.class, "MSG_StartStopTargetNotSupported", name);
90
        throw new UnsupportedOperationException(msg);
91
    }
92
    
93
    public ProgressObject stop() {
94
        StartServer ss = instance.getStartServer();
95
        if (ss != null && ss.supportsStartTarget(target)) {
96
            ProgressObject po = ss.stopTarget(target);
97
            if (po != null) {
98
                return po;
99
            }
100
        }
101
        String name = target == null ? "null" : target.getName(); //NOI18N
102
        String msg = NbBundle.getMessage(ServerTarget.class, "MSG_StartStopTargetNotSupported", name);
103
        throw new UnsupportedOperationException(msg);
72
    }
104
    }
73
}
105
}
(-)src/org/netbeans/modules/j2ee/deployment/plugins/api/StartServer.java (+55 lines)
Lines 43-48 Link Here
43
     */
43
     */
44
    public abstract boolean supportsStartDeploymentManager();
44
    public abstract boolean supportsStartDeploymentManager();
45
    
45
    
46
    /**
47
     * Returns if the plugin can start/stop single target servers.
48
     * This should be overwritten as needed.
49
     * @param target the target server in question, could be null in which
50
     * case the answer should probably be false.
51
     * @return true if this plugin can currently handle state management for 
52
     * the specific target.
53
     */
54
    public boolean supportsStartTarget(Target target) {
55
        return false;
56
    }
46
    
57
    
47
    /**
58
    /**
48
     * Starts the admin server. Note that this means that the DeploymentManager
59
     * Starts the admin server. Note that this means that the DeploymentManager
Lines 85-94 Link Here
85
    public abstract boolean isRunning();
96
    public abstract boolean isRunning();
86
    
97
    
87
    /**
98
    /**
99
     * Returns the running state of a specific target. This should be
100
     * overwritten by plugins which support multiple target servers via
101
     * one admin server.
102
     * @param target the target server in question; null value implies 
103
     * the query is against the admin server.
104
     * @return true if the server is question is running.
105
     */
106
    public boolean isRunning(Target target) {
107
        if (target == null || isAlsoTargetServer(target)) {
108
            return isRunning();
109
        }
110
        
111
        return false;
112
    }
113
    
114
    /**
88
     * Returns true if the given target is in debug mode.
115
     * Returns true if the given target is in debug mode.
89
     */
116
     */
90
    public abstract boolean isDebuggable(Target target);
117
    public abstract boolean isDebuggable(Target target);
91
    
118
    
119
    /**
120
     * Starts the target server asynchronously and reports the status
121
     * through the returned <code>ProgressObject</code>. This should be
122
     * overwritten by plugins which support the state management of
123
     * different target servers.
124
     * @param target a non-null target server to be started
125
     * @return a ProgressObject which is used to communicate the
126
     * progess/state of this action.  Should not be null when supportsStartTarget 
127
     * returns true on same target.
128
     */
129
    public ProgressObject startTarget(Target target) {
130
        return null;
131
    }
132
    
133
    /**
134
     * Stops the target server asynchronously and reports the status
135
     * through the returned <code>ProgressObject</code>. This should be
136
     * overwritten by plugins which support the state management of
137
     * different target servers.
138
     * @param target a non-null target server to be stopped
139
     * @return a ProgressObject which is used to communicate the
140
     * progess/state of this action.  Should not be null when supportsStartTarget 
141
     * return true on the same target.
142
     */
143
    public ProgressObject stopTarget(Target target) {
144
        return null;
145
    }
146
92
    /**
147
    /**
93
     * Start or restart the target in debug mode.
148
     * Start or restart the target in debug mode.
94
     * If target is also domain admin, the amdin is restarted in debug mode.
149
     * If target is also domain admin, the amdin is restarted in debug mode.

Return to bug 53010