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.

Bug 217418 - ArgsProcessor execution
Summary: ArgsProcessor execution
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Launchers&CLI (show other bugs)
Version: 7.2
Hardware: PC Windows 7
: P2 normal (vote)
Assignee: Jiri Rechtacek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-26 12:31 UTC by pjdm
Modified: 2012-09-15 02:09 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description pjdm 2012-08-26 12:31:53 UTC
I'm using an ArsgProcessor class to execute code at startup (in combination with --nosplash --nogui). The code is effectively running a script and exiting.

In the IDE, ArgsProcessor.process() is called after "[org.netbeans.core.startup.NbEvents]: Turning on modules", which seems to be the correct place for application code to run. However, I don't know if this is guaranteed to happen, or is just a coincidence: the javadoc doesn't say.

Please update the javadoc to specify which stage ArgsProcessor.process() is called().

If it isn't called at a stage suitable for running application code, please document a way to run application code after NetBeans has finished starting up (in the same way that WindowManager.invokeWhenUIReady() allows code to be executed when NetBeans is ready, but for use when "--nosplash --nogui" has been specified).
Comment 1 Jiri Rechtacek 2012-09-05 14:03:48 UTC
I think that this is the right way - look at
http://bits.netbeans.org/dev/javadoc/org-openide-modules/org/openide/modules/OnStart.html
Comment 2 pjdm 2012-09-06 08:04:39 UTC
The OnStart doc specifically states that it does the opposite of what I want. It is for code "to be instantiated and invoked on start of your module" and "It is guaranteed that execution of all runnables is finished before the startup sequence is claimed over."

I want to run my entire application headless ("--nosplash --nogui"). I don't want to run initialisation code for an individual module, nor do I want run code that executes before the startup sequence is over.

I want to invoke NetBeans from a command line with no GUI, wait for the startup sequence to finish (so all modules are loaded and initialised), then execute the code in my application as specified by command line options via ArgsProcessor.

The OnStart doc says "Some modules may want to invoke code when the UI is initialized. In such case consider using @OnShowing annotation." Presumably by the time the UI is initialised, NetBeans has finished starting. I would like the --nogui equivalent of invoking code when headless NetBeans is initialised.

ModuleInstall.restored() says "modules should avoid doing anything here that is not strictly necessary - often by moving initialization code into the place where the initialization is actually first required (if ever)", so that doesn't seem to be the correct place to run an application either.

Thanks.
Comment 3 Jaroslav Tulach 2012-09-07 09:50:55 UTC
You'd like to "finish the startup by running something when the startup is finished" - that seems like a self denying request to me.

Anyway CLI options should really be processed after @OnStart is finished. As far as I can tell CLI options processing is the last step in the boot sequence of headless NetBeans application.

If you want to invoke something at this stage, you should register the Option.always() or is Args equivalent. If you feel this info should be in javadoc, attache patch and reopen.
Comment 4 pjdm 2012-09-07 11:15:08 UTC
I'm not sure how you concluded that I'd like to "finish the startup by running something when the startup is finished". I do want to run something after the (headless) startup is finished: I don't want to run anything before the startup is finished. If "last step in the boot sequence" is close enough to make no difference, that's fine.

Proposed documentation patch to be added to the org.netbeans.spi.sendopts.ArgsProcessor javadoc:

<javadoc>
For headless NetBeans applications: command line argument processing is the last step in the boot sequence; services and classes offered by the platform have been initialized at this point. Application code in process() can safely use the platform.
</javadoc>
Comment 5 Jaroslav Tulach 2012-09-07 20:12:02 UTC
ergonomics#0960c04aec61
Comment 6 Quality Engineering 2012-09-15 02:09:53 UTC
Integrated into 'main-golden', will be available in build *201209150001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/0960c04aec61
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #217418: Javadoc improved by pjdm