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 206093

Summary: Need explicit marker for eager action registration
Product: platform Reporter: Jesse Glick <jglick>
Component: ActionsAssignee: Jesse Glick <jglick>
Status: RESOLVED FIXED    
Severity: normal CC: apireviews, jtulach
Priority: P3 Keywords: API, API_REVIEW_FAST
Version: 7.1   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Bug Depends on:    
Bug Blocks: 183794, 206089    
Attachments: Proposed patch

Description Jesse Glick 2011-12-07 15:28:37 UTC
Continuation of JG04 from bug #183794. In practice there are some actions which simply cannot be registered using lazy factories, and convincing the action processor to use a traditional eager registration for them is cumbersome and error-prone: you have to know to implement a special interface like ContextAwareAction and then somehow implement it without changing semantics.

While my original preference was for a separate annotation for such actions, an attribute lazy=false (with default being true) in @ActionRegistration would suffice. When lazy=false, the processor would create a traditional registration rather than using an Actions factory method.

Attempting to use lazy=false would result in an error when only a factory method could make sense, e.g. the class implements only ActionListener and not Action, or it has a context constructor.

For compatibility, existing (implicitly lazy=true) registrations on classes which implement ContextAwareAction, Presenter.*, or DynamicMenuContent would continue to processed as eager, but a warning should be issued. (To use a lazy factory, specify lazy=true explicitly; the processor can use AnnotationMirror.getElementValues to distinguish this case. Of course such registrations will not generally work as intended, but there might be reasons to do it.)
Comment 1 Jesse Glick 2011-12-07 18:30:12 UTC
Created attachment 113935 [details]
Proposed patch

Includes API and processor impl; and updates to various existing registrations to specify lazy=false (in some cases removing dummy implementations of marker interfaces which existed solely to force this style).
Comment 2 Jesse Glick 2011-12-07 18:30:53 UTC
Please review.
Comment 3 Jesse Glick 2011-12-07 18:40:04 UTC
Will also add apichanges.xml entry of course.
Comment 4 Jesse Glick 2011-12-14 17:01:13 UTC
core-main #316ede293415
Comment 5 Quality Engineering 2011-12-15 12:45:01 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/316ede293415
User: Jesse Glick <jglick@netbeans.org>
Log: #206093: allow an @ActionRegistration to be explicitly marked lazy or eager.