Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 319918 - [API] Clients need the ability to choose preferred module delegate
Summary: [API] Clients need the ability to choose preferred module delegate
Status: RESOLVED FIXED
Alias: None
Product: WTP Java EE Tools
Classification: WebTools
Component: jst.j2ee (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2.1   Edit
Assignee: Jason Peterson CLA
QA Contact: Chuck Bridgham CLA
URL:
Whiteboard: PMC_approved
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-14 16:40 EDT by Jason Peterson CLA
Modified: 2010-07-20 11:22 EDT (History)
4 users (show)

See Also:
david_williams: pmc_approved+
cbridgha: pmc_approved? (raghunathan.srinivasan)
cbridgha: pmc_approved? (naci.dai)
deboer: pmc_approved+
cbridgha: pmc_approved? (neil.hauge)
cbridgha: pmc_approved? (kaloyan)
cbridgha: review+


Attachments
patch (4.52 KB, patch)
2010-07-14 16:40 EDT, Jason Peterson CLA
no flags Details | Diff
updated_patch (4.55 KB, patch)
2010-07-14 16:45 EDT, Jason Peterson CLA
ccc: iplog+
Details | Diff
j2ee plugin now requires a newer wst.web plugin (930 bytes, patch)
2010-07-15 11:18 EDT, Carl Anderson CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Peterson CLA 2010-07-14 16:40:35 EDT
Created attachment 174344 [details]
patch

An adopter product has created their own module delegate for a Java EE utility project.  In this case the project is a simple PDE project.  As a result two different module delegates are created.  Currently, the FlatComponentDeployable code just chooses the first one when multiple exist.  Usually, only one would exist because delegate creation is based on the component. It is a J2EEModuleVirtualComponent in this case.

The solution is to create a new method that extenders can override to specify a preferred delegate.  The default would be to continue to return the first one found.
Comment 1 Jason Peterson CLA 2010-07-14 16:45:13 EDT
Created attachment 174345 [details]
updated_patch
Comment 2 Jason Peterson CLA 2010-07-14 17:13:11 EDT
* Explain why you believe this is a stop-ship defect. Or, if it is a
"hotbug" (requested by an adopter) please document it as such. 
 
A scenario has been found where two different module delegates are created for the same component.  The current code just chooses the first delegate found.  
    
* Is there a work-around? If so, why do you believe the work-around is
insufficient? 

No workaround exists

    * How has the fix been tested? Is there a test case attached to the
bugzilla record? Has a JUnit Test been added? 

Fix has been tested in the UI.

    * Give a brief technical overview. Who has reviewed this fix? 

A new method was created that extenders can override if they wish to control which delegate is returned.  The default is still to return the first found.

Chuck has reviewed this fix.

    * What is the risk associated with this fix? 

minimal - the default behavior still exists for any extenders that do not override the new method.
Comment 3 Chuck Bridgham CLA 2010-07-14 17:17:47 EDT
approved - Additive api for extenders only.  default behavior still applies
Comment 4 Tim deBoer CLA 2010-07-14 17:34:32 EDT
+1. Agreed, picking the 'first' module is inherently broken and will eventually cause problems as it has here. You may want to think about whether there is some default behaviour that the JEE components should be doing in WTP in the future, e.g. filtering by module type.
Comment 5 David Williams CLA 2010-07-15 11:00:04 EDT
I'm fine approving this, since sounds important for adopter, but ... you are saying adopter has to extend 
org.eclipse.wst.web.internal.deployables.FlatComponentDeployable
right? 
From the package name, doesn't sound like an API. Is it? One of those APIs that has "internal" in the name? 

Thanks,
Comment 6 Carl Anderson CLA 2010-07-15 11:18:20 EDT
Created attachment 174407 [details]
j2ee plugin now requires a newer wst.web plugin

One minor (but important) additional change- we need to raise the org.eclipse.jst.j2ee prereq of org.eclipse.wst.web, since it calls/overrides the method added there.
Comment 7 Carl Anderson CLA 2010-07-15 11:35:31 EDT
Committed to HEAD for WTP 3.2.1 and WTP 3.3

Unfortunately, I was reviewing another bug, and copied the header for that bug, so the commit comment was:
[319935] Null Pointer Exception when Importing UtilityJar