Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 242635

Summary: Remove unnecessary UI dependencies from org.eclipse.jst.ws.consumption
Product: [WebTools] WTP Webservices Reporter: Troy Bishop <tjbishop>
Component: jst.wsAssignee: Mark Hutchinson <mahutch>
Status: CLOSED FIXED QA Contact: Kathy Chan <kathy>
Severity: enhancement    
Priority: P3 CC: kathy, keith.chong.ca
Version: 3.0Keywords: plan
Target Milestone: 3.1 M6   
Hardware: PC   
OS: Windows XP   
Whiteboard: other
Attachments:
Description Flags
proposed patch none

Description Troy Bishop CLA 2008-07-30 17:18:17 EDT
Build ID: WTP 3.0.1

Steps To Reproduce:
The plug-in org.eclipse.jst.ws.consumption is currently a "core" based plug-in however it has an optional dependency to org.eclipse.ui and (as a result of bug 242633) it has a direct dependency to jface.  This really shouldn't be required for a core plug-in (as it pulls in unnecessary plug-ins for headless based applications).

Both of these dependencies shouldn't be required (at all) however you will need to add org.eclipse.core.commands to fix compilation errors wherever a class extends or uses org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation.
As well, the code in the class FacetUtils should be revisted to remove the use of the org.eclipse.jface.operation.IRunnableWithProgress, org.eclipse.ui.PlatformUI, and org.eclipse.swt.widgets.Display classes.

More information:
Comment 1 Kathy Chan CLA 2008-07-31 07:26:12 EDT
We were using IRunnableWithProgress to call the facet API on a different thread to avoid possible deadlock issues.  We should look into another mechanism for achieving this. 

One possible alternative would be to use jobs or other mechanisms used by J2EE or server team
Comment 2 Keith Chong CLA 2009-02-25 11:58:57 EST
Over to you Mark.
Comment 3 Mark Hutchinson CLA 2009-02-25 12:03:45 EST
*** Bug 231928 has been marked as a duplicate of this bug. ***
Comment 4 Mark Hutchinson CLA 2009-03-03 14:51:38 EST
Created attachment 127371 [details]
proposed patch

The UI dependencies were originally added as part of a fix for bug 126757 as a way of running certain Facets API code in a different thread to avoid deadlocks.  The fix was to run the facets code in an IRunnableWithProgress that was run by an IProgressService.  This would create another thread and display a modal progress dialog while the thread was run.  Users could not perform other operations until the runnable completed and the modal dialog closed. (i.e. the facet operations are run synchronously)  IProgressService and IRunnableWithProgress come from UI plugins.

If no UI was present then the facet operations were run in the current thread.

Using another mechanism to create a new thread, such as a Job, is not appropriate since it is desirable to display progress to the user while the facet operation runs.  The facet operation can not be run asynchronously so we would have to join() the job immediately after scheduling it which could cause the UI thread to block.

To be able to use the Progress Service if a UI is present without adding UI dependencies to the org.eclipse.jst.ws.consumption plugin the UI specific code will be moved into the org.eclipse.consumption.ui plugin. This is done by defining a new extension point in the org.eclipse.jst.ws.consumption plugin that allows an IFacetOperationDelegate to be plugged in.

This extension point is called org.eclipse.jst.ws.consumption.internalFacetOperationDelegate.  If the FacetUtils class detects that a facetOperationDelegate extension has been plugged in then it will delegate certain operations to the facetOperationDelegate. If no extension is present, then the facet operation will be run in the current thread.

This extension point is internal and should not be implemented by adopters. 

The org.eclipse.jst.ws.consumption.ui plugin will provide a internalFacetOperationDelegate extension that implements IFacetOperationDelegate.  This will run the Facet code in a new thread in an IProgressService if the UI is present, otherwise it will run the operation in the current thread.  This is identical to what FacetUtils did before the UI dependencies were removed.
Comment 5 Keith Chong CLA 2009-03-03 17:12:49 EST
I've released the changes for 3.1 M6.
Comment 6 Mark Hutchinson CLA 2010-06-15 13:49:42 EDT
Verified and closed.