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.
- opening/closing components - prevent deadlocks: rules for what can be accessed in which time
Must-have features for milestone3, have impact on APIs (at least potential).
Here's the API for initialization and shutdown hooks: listen to the projectManager's PROP_PROJECT_OPEN property and PROP_PROJECT_CLOSING property. PROP_PROJECT_OPEN will be fired AFTER a project has been fully opened by the projects system. No locks are held when it is announced (no project system locks that is.) Modules may not assume anything about the order in which other modules are notified of project open; therefore, if you depend on the initialization performed by another module you have to negotiate a contract with that module such that it provides its own notification of when its initialization is done. PROP_PROJECT_CLOSING will be fired BEFORE a project's closing process is started (but after user confirmation). Thus, you can perform project shutdown procedures and utility all the project contents. As with PROPECT_OPEN no project system locks are held. (Note - not only is the property change fired when the project is about to be closed, but it is deliberately fired before the final project save prior to closure; thus you can modify the project contents and expect it to be reflected in the project file.) PROP_PROJECT_CLOSED is called after the project has been closed.
Sounds good for listeners "outside" of project, but it would be useful to allow similar notification for "inside" project stuff (e.g. Containers). The primary motivation for this was the implementation of Container which maintains list of subprojects. Since subprojects are deffered for PM4 this can be probably resolved later (until there isn't other requirement which I don't know about).
Can you be more specific? Are you suggesting creating an SPI so modules can listen to container additions/removals? (This wouldn't be tied to initialization/shutdown, right?) Or something else?
Imagine that you write Container (some DataObject in ProjectFileSystem, /Containers folder) which maintains the list of subprojects. You need to open those subropjects when the parent project is being open and close them when the parent project is closed. Right now, there is no way how the Container could be notified about the project open event. It can't register listener to ProjectManager beacause it doesn't exist prior opening the project which contains this Container. So, I just wanted to remember that events on ProjectManger are useful for listeners "outside" of the project, which exist independently on the project system and can hook the ProjectManager at the begining of their live cycle. It would be useful to have some initialization/shitdown support for the "inside-project" components like Containers, etc. I don't say that we have to do it right now. Subprojects has been deffered for milestone 4 and I don't know any other reason why this support would be neccessary
Ok - this would be like a "Startup" folder in the project where components can place themselves and be called during startup. I agree that we should add this later if a usage comes up. For example, to solve the subprojects-open problem the module providing subprojects could listen (not an object in the project itself but rather a "subprojects manager" object) to the ProjectManager for notification of project open, and when a project is open it could check to see if it's a superproject and then go and open other projects as necessary. So I believe we should avoid adding additional APIs in this area until we have more definite requirements. Most likely subprojects will be implemented inside the projects infrastructure so it won't need an exposed API.
Another possibility which comes to my mind is to place the open/close methods in the NatureInstall introduced by David. Since the project is getting more complicated with more possible stuff registered by natures, delegating to NatureInstalle would provide better flexibility for the future.
Feel free to extend NatureInstall as you need. The class was inspired by openide's ModuleInstall class, but I intentially put there only methods I really needed.
Vito, what is the status of this issue? There is a number of comments that were added after this was marked as resolved/fixed.
I think this is still TBD (at least some parts of it). Adding correct keywords.
As described in http://www.netbeans.org/servlets/ReadMsg?msgId=619519&listName=nbdiscuss the current work on projects prototype has been stopped.
--> VERIFIED