Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 363551 - JavaTypeConstraintService
Summary: JavaTypeConstraintService
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Sapphire (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Konstantin Komissarchik CLA
QA Contact:
URL:
Whiteboard:
Keywords: plan
Depends on:
Blocks:
 
Reported: 2011-11-10 22:51 EST by Greg Amerson CLA
Modified: 2021-11-19 09:21 EST (History)
1 user (show)

See Also:


Attachments
Patch attempt #1 (9.77 KB, patch)
2011-11-10 22:54 EST, Greg Amerson CLA
no flags Details | Diff
Patch #2 (31.92 KB, patch)
2011-11-11 03:48 EST, Greg Amerson CLA
no flags Details | Diff
Patch v3 (37.85 KB, patch)
2011-11-13 23:09 EST, Greg Amerson CLA
konstantin: iplog+
Details | Diff
mylyn/context/zip (70.32 KB, application/octet-stream)
2011-11-13 23:09 EST, Greg Amerson CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Greg Amerson CLA 2011-11-10 22:51:29 EST
Lets say you have a property that is a JavaType target with a JavaTypeConstraint annotation specifying kind.  However, what if you want the type to be derived from the value of some model property at runtime.  In this case, it would be good to have a JavaTypeConstraintService where the type() info could be computed at runtime.  This way when the "create" action occurs, we could supply what baseType to use for the new class.
Comment 1 Greg Amerson CLA 2011-11-10 22:54:29 EST
Created attachment 206825 [details]
Patch attempt #1

This is my rough draft of a patch.  I just want to make sure I'm going in the right direction before I continue with it.
Comment 2 Konstantin Komissarchik CLA 2011-11-10 23:03:11 EST
Looks like you are on the right track. A few comments from a very rough review...

1. JavaTypeConstraintService methods should return collections rather than arrays.

2. Need to cover kind() and behavior() with service too.

3. Need to find all places where JavaTypeConstraint annotation is referenced and replace with references to the service.

4. For the service to be truly dynamic, some of the consumers of this metadata (such as JavaTypeValidationService) need to listen on JavaTypeValidationService. The Service API already includes listener API.
Comment 3 Konstantin Komissarchik CLA 2011-11-10 23:04:42 EST
I am being somewhat optimistic here since there is only a week left, but I will target this to 0.4 for now.
Comment 4 Greg Amerson CLA 2011-11-11 03:48:51 EST
Created attachment 206829 [details]
Patch #2

- completed the constraint service to have behavior() and kind()
- converted the lists to collections, although there are two places where it is assuming an order of the items in the collection which looks like a problem
- removed all references to JavaTypeConstaint with reference to the JavaTypeConstraintService, 
- switched to using element.service(property, JavaTypeConstraintService) instead of just property.service(..)
- tried to implement the listener for Facts and Validation serivce but I don't know if it is having the desired effect.
Comment 5 Greg Amerson CLA 2011-11-13 23:09:16 EST
Created attachment 206910 [details]
Patch v3

This patch is same as before but it includes documentation.
Comment 6 Greg Amerson CLA 2011-11-13 23:09:34 EST
Created attachment 206911 [details]
mylyn/context/zip
Comment 7 Konstantin Komissarchik CLA 2011-11-16 20:39:36 EST
Accepted Patch v3 with following changes:

1. Improved the API of JavaTypeConstraintService to be based on cache/refresh architecture similar to EnablementService.

2. Removed listener from JavaTypeConstraintFactsService. It isn't necessary since FactsService doesn't cache internally and refreshing the element doesn't draw on the FactsService. It's used on demand in other contexts.

3. JavaTypeValidationService does need to trigger property refresh when JavaTypeConstraintService changes, but the patch was refreshing the whole element (too much refresh).

4. JavaTypeValidationService was originally written to cache constraint information during init. This doesn't work if the constraint information is dynamic. Removed the caching.

5. In JavaTypeBrowseActionHandler, lookup of JavaTypeConstraintService was using property metamodel context instead of property instance context.

6. In JavaTypeCreateActionHandler, caching was removed with interpretation of constraint moved to the run method, except that it was still writing to member fields. Multiple invocations of run would surely result in amusing results. See the interfaces field, in particular. Changed the fields to local variables.

7. Moved analysis of the constraint in JavaTypeCreateActionHandler further down in the run method as there are some paths that abort early and there is no sense in analyzing the constraint in those cases.

8. Improved the documentation content.
Comment 8 Greg Amerson CLA 2011-11-16 22:00:43 EST
Thanks for pushing in this fix.  I have my downstream service working nicely now.  

Marking as Verified.
Comment 9 Konstantin Komissarchik CLA 2011-11-16 22:01:43 EST
Thanks for the verification. Closing.