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 148320 - Create API for common delegating Sources
Summary: Create API for common delegating Sources
Status: RESOLVED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Ant Project (show other bugs)
Version: 5.x
Hardware: All All
: P2 blocker (vote)
Assignee: Tomas Zezula
URL:
Keywords: API, API_REVIEW_FAST
Depends on:
Blocks:
 
Reported: 2008-09-25 09:04 UTC by Tomas Zezula
Modified: 2010-06-04 06:08 UTC (History)
5 users (show)

See Also:
Issue Type: TASK
Exception Reporter:


Attachments
The diff file (84.41 KB, patch)
2010-05-28 11:38 UTC, Tomas Zezula
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tomas Zezula 2008-09-25 09:04:50 UTC
There are several copies on the J2SESources class spreading through java, j2ee, ruby, python, j2me clusters. There should be a common version covering all 
these use cases.
Comment 1 mvfranz 2010-05-20 00:06:43 UTC
Can anyone expand on this?  Is this copies of J2SESources or is this classes that implement Sources that are copy/paste copies of J2SESources?
Comment 2 Jesse Glick 2010-05-20 17:06:12 UTC
(In reply to comment #1)
> Is this copies of J2SESources or is this classes
> that implement Sources that are copy/paste copies of J2SESources?

The latter, I think. SourceRoots covers some of the infrastructure but I imagine more could be shared. Are you interested in working on it?
Comment 3 Tomas Zezula 2010-05-20 19:18:37 UTC
Yes, it's an implementation of Sources which delegates to SourcesHelper. The class solves adding and removing of source roots and was introduced in NB 4.1 when adding support for multiple source roots. Th problem is that the API will require SPI class (org.netbeans.modules.java.api.common.SourceRoots) which is a part of the java.common.api but the API should belong to project.ant as the copies are also in PHP, Ruby, Python which cannot depend on java.common.api.

The API should look like something like:

public class SourcesFactory {
      private SourcesFactory(){}
     p s Sources createSources(Project p, APH aph, PE eval, Collection<? extends SourceRootsLike> src, String... nonSourceRootProps){ return new J2SESources(....);}
}
Comment 4 Tomas Zezula 2010-05-21 06:37:02 UTC
If it's good enough to solve just the "java" projects (no ruby or python) I can attach the API patch. J2SESources moved into j.c.a where the SourceRoots is available and factory method added into QuerySupport. I've fixed just a j2seproject to use it.
Comment 5 Jesse Glick 2010-05-24 16:25:22 UTC
You know more about this so you should probably review any patches.
Comment 6 Tomas Zezula 2010-05-28 11:38:56 UTC
Created attachment 99603 [details]
The diff file
Comment 7 Tomas Zezula 2010-05-28 11:46:44 UTC
I've added a factory method into the QuerySupport and fixed all usages in j2se, web, j2ee.
I will also fix the j2me + card before commit.
There is no nice solution how to remove the copy of *Sources as they are modified in projects and also have a custom method providing the SourceGroupModifierImplementaion.
Rather than adding a special subtype of Sources with a new method getSourceGroupModifier as it was done, the factory method returns a Sources instance which also implements the SGMI. Not very nice but seems better than a new type. I've also had to create a supertype of SourceRoots as the web project and j2eeproject have typed source roots which are not based on SourceRoots (project.xml + properties). The supertype is nicer than adding List of String[] into the factory method.
Comment 8 Tomas Zezula 2010-05-28 11:47:54 UTC
It would be good if someone from web team can look to the rewritten parts of web (j2ee).
Thanks
Comment 9 Jesse Glick 2010-05-28 22:06:50 UTC
LibrarySourceGroup_DisplayName bundle key may need to be moved.

Might need to add a change listener to sgmi & refire from SourcesImpl.

Are you still listening to changes in J2SEProjectProperties.{BUILD,DIST}_DIR?
Comment 10 Jesse Glick 2010-05-28 22:08:41 UTC
Consider also moving J2SESourcesTest and/or SourceRootsTest to java.api.common.
Comment 11 Tomas Zezula 2010-05-31 13:31:31 UTC
>LibrarySourceGroup_DisplayName bundle key may need to be moved.
Fixed.

>Might need to add a change listener to sgmi & refire from SourcesImpl.
Sgmi does not support listening and has no listeners.

>Are you still listening to changes in J2SEProjectProperties.{BUILD,DIST}_DIR?
This is what I am not sure about it. I've removed it as I think it was not needed, the {BUILD,DIST}_DIR are registered to SourcesHelper by addNonSourcesRoot. The Sources created by SourcesHelper fire ChangeEvent which is delegated when property changed. I will add a test.

>Consider also moving J2SESourcesTest and/or SourceRootsTest to java.api.common.
I've added a new SourcesImplTest instead of  moving the J2SESourcesTest as it's very j2seproject dependent. I will try to move the SourceRootsTest into java.api.common.

Thanks for the review.
Comment 12 Tomas Zezula 2010-06-01 11:06:56 UTC
I am going to integrate it.
Comment 13 Tomas Zezula 2010-06-01 13:17:26 UTC
Fixed a81f706cef4e
Comment 14 Quality Engineering 2010-06-04 06:08:27 UTC
Integrated into 'main-golden', will be available in build *201006040001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/a81f706cef4e
User: Tomas Zezula <tzezula@netbeans.org>
Log: #148320:Create API for common delegating Sources