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

Bug 317495

Summary: JPA facet needs runtime changed listener/handler
Product: [WebTools] Dali JPA Tools Reporter: Leonard Theivendra <theivend>
Component: GeneralAssignee: Paul Fullbright <paul.fullbright>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: gindik, jpitman, karenfbutzke, konstantin, neil.hauge, paul.fullbright
Version: unspecifiedFlags: neil.hauge: review+
Target Milestone: 2.3.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Patch to add a runtime changed listener to the JPA facet
none
patch
none
updated patch none

Description Leonard Theivendra CLA 2010-06-21 13:49:53 EDT
Build Identifier: WTP 3.2

When the runtime target is changed on an EJB project with the JPA facet in an adopting product, two classpath containers are set on the project (i.e. the new runtime's classpath container, and the old runtime's classpath container still remains)

From what I understand about the facet framework, when runtime targets are changed on a project, it iterates over the facets asking each one to detach itself in order to remove the classpath container.  Since the JPA facet does not have a runtime changed listener/handler, the framework assumes that the classpath container cannot be removed since it still sees the JPA facet "owning" the classpath container (who didn't take any action).

I'm attaching a patch implementing a runtime changed listener that solves this problem and hopefully will explain the problem further.  Note that the EJB facet has a similar listener too.

Can this be considered for WTP 3.2.1 please?

Reproducible: Always
Comment 1 Leonard Theivendra CLA 2010-06-21 13:50:53 EDT
Created attachment 172348 [details]
Patch to add a runtime changed listener to the JPA facet
Comment 2 Paul Fullbright CLA 2010-06-21 15:00:02 EDT
Konstantin, does this patch look right, or is this something that should be handled within the library provider framework?  Or are we not utilizing the library provider framework correctly within this context?
Comment 3 Konstantin Komissarchik CLA 2010-06-21 16:00:13 EDT
The facet should call into the library provider framework upon runtime change as the available libraries could be different in the new context, but the attached patch isn't the right way to do this. 

The attached patch is correct for facets that use the basic ClasspathHelper API (like the module facets), but for facets that use the library provider framework, the body of the listener needs to be different. It should look more like the version change action. You will need to create LibraryInstallDelegate and run it to let it do it's thing.
Comment 4 Paul Fullbright CLA 2010-06-24 16:42:08 EDT
Created attachment 172687 [details]
patch

Unfortunately, I don't really have any runtime definitions that provide libraries for JPA, so I can't test this patch out.  I don't have a way to set up a runtime library provider.

Konstantin, is this pretty much what you're talking about?

Len, does this solve your problem?
Comment 5 Konstantin Komissarchik CLA 2010-06-24 18:13:25 EDT
That looks about right.
Comment 6 Paul Fullbright CLA 2010-06-28 10:13:14 EDT
Leonard, can you verify that the patch addresses your problem?  I'd like to have something released soon.
Comment 7 Leonard Theivendra CLA 2010-06-28 10:44:31 EDT
(In reply to comment #6)
> Leonard, can you verify that the patch addresses your problem?  I'd like to
> have something released soon.

Hi Paul, I just tried the patch and it doesn't seem to work. In debugging, it does get into your new listener, but the following call returns null for the working copy so nothing is done: IFacetedProjectWorkingCopy fpwc = facetedProjectEvent.getWorkingCopy();
Comment 8 Paul Fullbright CLA 2010-06-28 11:15:17 EDT
Created attachment 172915 [details]
updated patch

Ah, hadn't tested the situation where the faceted project wasn't actually being changed.

Can you try the updated patch?
Comment 9 Leonard Theivendra CLA 2010-06-28 12:02:28 EDT
(In reply to comment #8)
> Created an attachment (id=172915) [details]
> updated patch
> Ah, hadn't tested the situation where the faceted project wasn't actually being
> changed.
> Can you try the updated patch?

OK that seems to work just fine. Thanks.
Comment 10 Paul Fullbright CLA 2010-06-28 13:24:53 EDT
Committed to head.

Please reopen if there are further issues.