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 110465 - SPI to permit Stop Build and Re-run Build actions to be pluggable
Summary: SPI to permit Stop Build and Re-run Build actions to be pluggable
Status: RESOLVED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Generic Infrastructure (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Milos Kleint
URL:
Keywords: API, API_REVIEW_FAST
: 109745 (view as bug list)
Depends on:
Blocks: 132165
  Show dependency tree
 
Reported: 2007-07-20 19:55 UTC by Jesse Glick
Modified: 2009-02-19 22:56 UTC (History)
5 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
api and generic impl patch (44.95 KB, patch)
2008-10-16 13:03 UTC, Milos Kleint
Details | Diff
ant module rewrite (39.17 KB, patch)
2008-10-16 13:04 UTC, Milos Kleint
Details | Diff
maven module rewrite (7.61 KB, patch)
2008-10-16 13:05 UTC, Milos Kleint
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2007-07-20 19:55:42 UTC
Currently these actions are implemented in the Ant module. It would be desirable to let the Maven core module also hook
into them. Would need some kind of generic stub actions in the projectui module with an SPI in projectuiapi. An impl
should probably be able to list running builds (with a listener), each of which could be stop()'d or rerun()'d.
Comment 1 Jesse Glick 2007-08-10 03:52:27 UTC
*** Issue 109745 has been marked as a duplicate of this issue. ***
Comment 2 Jan Lahoda 2008-04-25 12:05:06 UTC
Are there any plans on this? It is possible we will need this to implement issue #132165.
Comment 3 Milos Kleint 2008-04-25 12:18:32 UTC
ok, I'll see what can be done. It should not be hard to do, just requires some API changes..
Comment 4 Milos Kleint 2008-10-16 13:03:58 UTC
Created attachment 71962 [details]
api and generic impl patch
Comment 5 Milos Kleint 2008-10-16 13:04:55 UTC
Created attachment 71964 [details]
ant module rewrite
Comment 6 Milos Kleint 2008-10-16 13:05:25 UTC
Created attachment 71965 [details]
maven module rewrite
Comment 7 Milos Kleint 2008-10-16 13:07:37 UTC
please review the following minor api change that allows the plugging of Rerun/Stop build actions.
Comment 8 Jesse Glick 2008-10-16 16:10:33 UTC
Generally looks good.


[JG01] Casting the result of lookup to an impl class is fragile. Rather make runningItems, lastFinishedItem,
register*Item, listeners, add/removeChangeListener static. Keep a WeakSet of instances of the class, and have fireChange
use this set to fire to all.


[JG02] RunLastBuildAction should perhaps not be using AntIcon.gif any more. Also check its Javadoc, and fix
Utilities.loadImage.


[JG03] org-netbeans-modules-project-ui-actions.StopBuildingAction.instance should be
org-netbeans-modules-project-ui-actions-StopBuildingAction.instance. The second occurrence should be a .shadow to the first.
Comment 9 Milos Kleint 2008-10-21 10:46:47 UTC
JG02, JG03 - done.

JG01 - I don't agree with your assesment of stability. If I make the methods static and avoid the cast, I cannot
avoiding someone registering a different impl, but then the actions will fail to work anyway as they will listen and get
t heir data from this instance. Therefore the eventuall ClassCastException is IMHO good early warning of something being
messed up.
Comment 10 Jesse Glick 2008-10-21 22:31:40 UTC
To JG01 - there would be no such risk (all the state would be static and the actions would work with any instance of
BuildExecutionSupportImpl interchangeably); but then again I think the situation cannot occur to begin with, as the only
point where a BuildExecutionSupportImpl would be created is by calling lookup on BuildExecutionSupportImplementation and
this interface is not visible publicly. If the SPI interface were made visible publicly then the cast could really fail
under legitimate use cases, e.g. in case some other impl were registered first but some client iterated all impls. The
safest idiom for that general case would actually be to remove the getInstance() method, and then from actions write e.g.

public boolean isEnabled() {
  for (BuildExecutionSupportImplementation impl :
      Lookup.getDefault().lookupAll(BuildExecutionSupportImplementation.class)) {
    if (i instanceof BuildExecutionSupportImpl) {
      return ((BuildExecutionSupportImpl) i).getLastItem() != null;
    }
  }
  return false;
}
Comment 11 Milos Kleint 2008-10-22 09:45:28 UTC
JG01: 
well, since the BESImplementation interface is effectively private and can only be implemented by a module that has
implementation dependency on projectuiapi, I've added the 2 methods that were the cause for the class cast into the
interface.
Comment 12 Milos Kleint 2008-10-23 12:40:43 UTC
pushed to main. implemented for ant and maven projects. Other project types should consider using the new api as well.
Comment 13 Quality Engineering 2008-10-24 04:19:22 UTC
Integrated into 'main-golden', will be available in build *200810240201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/c3194bac610e
User: Milos Kleint <mkleint@netbeans.org>
Log: #110465 add api and impl for plugging into the Rerun build/Stop build actions. Move the actions from ant module to a more general area.