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

(-)a/core.startup/apichanges.xml (+16 lines)
Lines 56-61 Link Here
56
<!-- ACTUAL CHANGES BEGIN HERE: -->
56
<!-- ACTUAL CHANGES BEGIN HERE: -->
57
57
58
  <changes>
58
  <changes>
59
     <change id="cli.exit">
60
        <api name="exec-property"/>
61
        <summary>Exit when CLI options are not processed</summary>
62
        <version major="1" minor="30"/>
63
        <date day="1" month="3" year="2011"/>
64
        <author login="jtulach"/>
65
        <compatibility addition="yes" binary="compatible" semantic="compatible" />
66
        <description>
67
        <p>
68
            Applications built on top of NetBeans platform can now exit
69
            immediately when some CLI cannot be processed. See the 
70
            <a href="@TOP@/architecture-summary.html#usecase-cli-exit">usecase</a>.
71
        </p>
72
        </description>
73
        <issue number="196052"/>
74
    </change>
59
     <change id="netbeans.bootdelegation">
75
     <change id="netbeans.bootdelegation">
60
        <api name="exec-property"/>
76
        <api name="exec-property"/>
61
        <summary>netbeans.bootdelegation property</summary>
77
        <summary>netbeans.bootdelegation property</summary>
(-)a/core.startup/arch.xml (-1 / +26 lines)
Lines 111-117 Link Here
111
-->
111
-->
112
 <answer id="arch-usecases">
112
 <answer id="arch-usecases">
113
  <p>
113
  <p>
114
   XXX no answer for arch-usecases
114
      <usecase id="cli-exit" name="Exit on wrong CLI Options">
115
      <p>
116
          <api category="devel" group="property" name="cli-exit" type="export" url="@TOP@/architecture-summary.html#usecase-cli-exit">
117
          There is a special API that allows applications built on top of NetBeans platform
118
          exit immediately if certain command line options cannot be processed.
119
          </api>
120
      </p>
121
      <p> <a name="usecase-cli-exit">How does it work?</a>
122
          First of all you need to define your own 
123
          <a href="@org-netbeans-modules-sendopts@/org/netbeans/spi/sendopts/OptionProcessor.html">OptionProcessor</a>
124
          (very likely processing the 
125
          <a href="@org-netbeans-modules-sendopts@/org/netbeans/spi/sendopts/Option.html#always()">always()</a>
126
          option too). When its <code>process</code> method is called, verify
127
          the options and if they are not OK, throw
128
          <a href="@org-netbeans-modules-sendopts@/org/netbeans/api/sendopts/CommandException.html">CommandException</a>.
129
      </p>
130
      
131
      <p>
132
          To make sure the above also exits the application create a branding
133
          <code>branding/core/core.jar/org/netbeans/core/startup/Bundle.properties</code>
134
          and put there following line <code>ON_CLI_ERROR=exit</code>. This will
135
          tell the system to exit in response to 
136
          <a href="@org-netbeans-modules-sendopts@/org/netbeans/api/sendopts/CommandException.html">CommandException</a>.
137
      </p>
138
      
139
      </usecase>
115
  </p>
140
  </p>
116
 </answer>
141
 </answer>
117
142
(-)a/core.startup/manifest.mf (-1 / +1 lines)
Lines 3-7 Link Here
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/core/startup/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/core/startup/Bundle.properties
4
OpenIDE-Module-Layer: org/netbeans/core/startup/layer.xml
4
OpenIDE-Module-Layer: org/netbeans/core/startup/layer.xml
5
OpenIDE-Module-Provides: org.openide.modules.InstalledFileLocator
5
OpenIDE-Module-Provides: org.openide.modules.InstalledFileLocator
6
OpenIDE-Module-Specification-Version: 1.29
6
OpenIDE-Module-Specification-Version: 1.30
7
7
(-)a/core.startup/nbproject/project.xml (-1 / +1 lines)
Lines 55-61 Link Here
55
                    <compile-dependency/>
55
                    <compile-dependency/>
56
                    <run-dependency>
56
                    <run-dependency>
57
                        <release-version>1</release-version>
57
                        <release-version>1</release-version>
58
                        <specification-version>2.32</specification-version>
58
                        <specification-version>2.40</specification-version>
59
                    </run-dependency>
59
                    </run-dependency>
60
                </dependency>
60
                </dependency>
61
                <dependency>
61
                <dependency>
(-)a/core.startup/src/org/netbeans/core/startup/Bundle.properties (+3 lines)
Lines 97-102 Link Here
97
SplashProgressBarEdgeColor=0xC5646F
97
SplashProgressBarEdgeColor=0xC5646F
98
#NOI18N
98
#NOI18N
99
SplashProgressBarCornerColor=0xB4A2B5
99
SplashProgressBarCornerColor=0xB4A2B5
100
#NOI18N
101
# acceptable values: "warn", "exit"
102
ON_CLI_ERROR=warn
100
###################
103
###################
101
104
102
105
(-)a/core.startup/src/org/netbeans/core/startup/Main.java (-1 / +2 lines)
Lines 311-317 Link Here
311
    CoreBridge.getDefault().registerPropertyEditors();
311
    CoreBridge.getDefault().registerPropertyEditors();
312
    StartLog.logProgress ("PropertyEditors registered"); // NOI18N
312
    StartLog.logProgress ("PropertyEditors registered"); // NOI18N
313
313
314
    org.netbeans.Main.finishInitialization();
314
    boolean exit = "exit".equals(NbBundle.getMessage(Main.class, "ON_CLI_ERROR")); // NOI18N
315
    org.netbeans.Main.finishInitialization(exit);
315
    StartLog.logProgress("Ran any delayed command-line options"); // NOI18N
316
    StartLog.logProgress("Ran any delayed command-line options"); // NOI18N
316
    
317
    
317
    for (RunLevel level : Lookup.getDefault().lookupAll(RunLevel.class)) {
318
    for (RunLevel level : Lookup.getDefault().lookupAll(RunLevel.class)) {
(-)a/o.n.bootstrap/manifest.mf (-1 / +1 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.bootstrap/1
2
OpenIDE-Module: org.netbeans.bootstrap/1
3
OpenIDE-Module-Specification-Version: 2.39
3
OpenIDE-Module-Specification-Version: 2.40
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/Bundle.properties
5
OpenIDE-Module-Recommends: org.netbeans.NetigsoFramework
5
OpenIDE-Module-Recommends: org.netbeans.NetigsoFramework
6
6
(-)a/o.n.bootstrap/src/org/netbeans/Main.java (-1 / +10 lines)
Lines 84-89 Link Here
84
     * delayed command-line options like -open FILE.
84
     * delayed command-line options like -open FILE.
85
     */
85
     */
86
    public static void finishInitialization() {
86
    public static void finishInitialization() {
87
        MainImpl.finishInitialization();
87
        finishInitialization(false);
88
    }
89
    /** 
90
     * Call when the system is up and running, to complete handling of
91
     * delayed command-line options like -open FILE.
92
     * @param exit true, if the system shall exit on error
93
     * @since 2.40
94
     */
95
    public static void finishInitialization(boolean exit) {
96
        MainImpl.finishInitialization(exit);
88
    }
97
    }
89
}
98
}
(-)a/o.n.bootstrap/src/org/netbeans/MainImpl.java (-4 / +8 lines)
Lines 67-72 Link Here
67
import java.util.StringTokenizer;
67
import java.util.StringTokenizer;
68
import java.util.concurrent.atomic.AtomicReference;
68
import java.util.concurrent.atomic.AtomicReference;
69
import org.openide.util.Lookup;
69
import org.openide.util.Lookup;
70
import org.openide.util.NbBundle;
70
import org.openide.util.lookup.Lookups;
71
import org.openide.util.lookup.Lookups;
71
72
72
/** Bootstrap main class.
73
/** Bootstrap main class.
Lines 225-236 Link Here
225
     * Call when the system is up and running, to complete handling of
226
     * Call when the system is up and running, to complete handling of
226
     * delayed command-line options like -open FILE.
227
     * delayed command-line options like -open FILE.
227
     */
228
     */
228
    public static void finishInitialization() {
229
    public static void finishInitialization(boolean exit) {
229
        int r = CLIHandler.finishInitialization (false);
230
        int r = CLIHandler.finishInitialization (false);
230
        if (r != 0) {
231
        if (r != 0) {
231
            // Not much to do about it.
232
            if (exit) {
232
            System.err.println ("Post-initialization command-line options could not be run."); // NOI18N
233
                TopSecurityManager.exit(r);
233
            //System.err.println("r=" + r + " args=" + java.util.Arrays.asList(args.getArguments()));
234
            } else {
235
                // Not much to do about it.
236
                System.err.println ("Post-initialization command-line options could not be run."); // NOI18N
237
            }
234
        }
238
        }
235
    }
239
    }
236
240
(-)a/sendopts/src/org/netbeans/modules/sendopts/Bundle.properties (+1 lines)
Lines 49-51 Link Here
49
OpenIDE-Module-Display-Category=Infrastructure
49
OpenIDE-Module-Display-Category=Infrastructure
50
50
51
MSG_OptionsHeader=\nAdditional Module(s) Option(s):\n
51
MSG_OptionsHeader=\nAdditional Module(s) Option(s):\n
52
MSG_Error=Cannot process command line option(s): {0}
(-)a/sendopts/src/org/netbeans/modules/sendopts/HandlerImpl.java (-4 / +7 lines)
Lines 44-49 Link Here
44
package org.netbeans.modules.sendopts;
44
package org.netbeans.modules.sendopts;
45
45
46
import java.io.File;
46
import java.io.File;
47
import java.io.IOException;
47
import java.io.InputStream;
48
import java.io.InputStream;
48
import java.io.OutputStream;
49
import java.io.OutputStream;
49
import java.io.PrintStream;
50
import java.io.PrintStream;
Lines 68-77 Link Here
68
            return 0;
69
            return 0;
69
        } catch (CommandException ex) {
70
        } catch (CommandException ex) {
70
            PrintStream ps = new PrintStream(err);
71
            PrintStream ps = new PrintStream(err);
71
            ps.println(ex.getLocalizedMessage());
72
            try {
72
            // XXX pst is not useful, only in verbose mode
73
                ps.println(NbBundle.getMessage(HandlerImpl.class, "MSG_Error", ex.getLocalizedMessage()));
73
            // the question is how to turn that mode on
74
                err.flush();
74
            // ex.printStackTrace(ps);
75
            } catch (IOException io) {
76
                io.printStackTrace(ps);
77
            }
75
            return ex.getExitCode();
78
            return ex.getExitCode();
76
        }
79
        }
77
    }
80
    }

Return to bug 196052