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 122655 - AntProjectHelper & copy-pasted UpdateHelper
Summary: AntProjectHelper & copy-pasted UpdateHelper
Status: RESOLVED WONTFIX
Alias: None
Product: projects
Classification: Unclassified
Component: Ant Project (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Tomas Stupka
URL:
Keywords: API
: 113895 (view as bug list)
Depends on:
Blocks: 83826
  Show dependency tree
 
Reported: 2007-11-23 17:07 UTC by Tomas Mysik
Modified: 2016-07-07 08:37 UTC (History)
6 users (show)

See Also:
Issue Type: TASK
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tomas Mysik 2007-11-23 17:07:32 UTC
I'm currently working on elimination of copy&pasted code in all the project types (Java, Java EE) - I have started 
with all the Queries (SourceLevelQueryImplementation etc.) but now I have a problem - in all the project types there's 
SourceRoots together with UpdateHelper (the first one is copy&pasted, the second one nearly as well) and I would like 
to solve this (these 2 classes are used in 4 *Queries, e.g. FileBuiltQuery). I can see probably 2 possibilities:

a) AntProjectHelper could implement interface that would be then implemented by UpdateHelper, or better

b) create UpdatableAntProjectHelper (maybe some better name would be needed) that would extend AntProjectHelper and:
	- add one or two methods:
		public boolean ensureUpdate() throws IOException and maybe
		public boolean isCurrent();
this UpdatableAntProjectHelper would need project type specific implementation of the update process itself (no idea 
about the correct name of the interface for it right now).

Please let me know what you think about it and/or if you see some better solution for this situation.

Thanks.
Comment 1 Tomas Mysik 2007-11-30 09:42:56 UTC
Update:
I have created module java/commonapi in which proposal of UpdateHelper and UpdateProject (interface mentioned in my 
previous post) can be found. UpdateHelper is now of course just proxy of AntProjectHelper.

All comments are welcome, thanks.
Comment 2 Jesse Glick 2007-11-30 20:50:40 UTC
1. UpdateHelper should not be in a Java-specific module. Probably it should not be a separate class at all; rather
enhance AntProjectHelper to cover this functionality.

2. The UH implementation in ant/freeform is I think superior as it automatically decides which schema to use when
writing: namely, the oldest schema against which the proposed XML validates (for best compatibility).

3. java/project is likely the proper place for the Java-specific helpers. Some are already there.
Comment 3 Tomas Zezula 2007-12-03 14:24:55 UTC
[jg3] The java/project is the correct place and the API will go there in NB 7.0 In NB 6.1 the code will be a friend API
to collect more feedback about it before making it public. I agree with Tomas M. about this.
Comment 4 Tomas Mysik 2007-12-03 19:52:51 UTC
> 1. UpdateHelper should not be in a Java-specific module.

Yes, you are right - I did so just to show how UpdateHelper and UpdateProject would look like so we could discuss it
better.

> Probably it should not be a separate class at all; rather enhance AntProjectHelper to cover
> this functionality.

Yes that's one possibility so if you think that I can do it so, I would probably implement it this way. The question
is how to "deliver" UpdateProject implementation to AntProjectHelper. I can think about these possibilities:
- during AntProjectHelper creation (some setter which can be called just once or better probably in
AntBasedProjectFactorySingleton.loadProject())
- put this implementation into project's lookup (probably not good idea at all)
- maybe utilize AntBasedProjectType?

I would prefer the first one but I don't know yet where's the best place to do it and how to do it. I will investigate
more and let you know. Jesse (or anybody else), if you have any idea please let me know, thanks.

>
> 2. The UH implementation in ant/freeform is I think superior as it
> automatically decides which schema to use when writing: namely, the oldest
> schema against which the proposed XML validates (for best compatibility).

Probably I don't know what you mean exactly but the project specific implementation of UpdateProject can behave so. I
guess that there should be some "typical" behaviour for project updating like to ask user if he/she wants to upgrade
project and so on, maybe some common implementation could be created - I will see later.

>
> 3. java/project is likely the proper place for the Java-specific helpers.
> Some are already there.

The motivation for this is exactly like Tomas Zezula wrote - all the classes should be moved to java/project later.
Comment 5 Jesse Glick 2007-12-03 20:16:58 UTC
I might suggest creating an extended interface AntBasedProjectType2 with some methods giving optional update
information. Then when using such a factory, your APH would automatically behave sensibly when reading/writing different
project schemas. TBD what the exact behavior should be.
Comment 6 Tomas Mysik 2007-12-04 10:14:41 UTC
> I might suggest creating an extended interface AntBasedProjectType2

Yes, I agree. I'm going to create branch for ant/project (code_duplicates_96425) module and implement this change. I 
will let you know, thanks.
Comment 7 Tomas Mysik 2007-12-05 14:56:52 UTC
At least 2 problems here:

1) AntBasedProjectType is staless and so UpdatableAntBasedProjectType has to be stateless as well - now (in the branch 
code_duplicates_96425) it's not, my mistake; I would fix it, probably:
- using another interface (UpdateImplementation probably) which would have all the methods that can be found now in 
UpdatableAntBasedProjectType; UpdatableAntBasedProjectType itself would have only "createUpdateImplementation()" 
method which would be called from APH (and the result cached there as well), or
- try to create stateless UpdatableAntBasedProjectType, each its method would take UpdateContext which would be 
just "holder" for all needed parameters/data

I prefer probably the 1st possibility just because of what AntBasedProjectType does now.

2) there can be "cyclic calls" (is it a correct term for it?)  between APH and UpdatableAntBasedProjectType 
(UpdateImplementation respectively), have a look into e.g. UpdateHelper.getProperties(String) in J2SE project; I can 
think of about 3 possible solutions but have no idea which one is the best:
	- create UpdatableAntProjectHelper - this problem should be solved but another would probably appear - where 
and how it should be created and used etc.
	- create some "flag" just to ensure that no cyclic calls will be done
	- provide all the needed data to UpdateImplementation while calling from APH (using UpdateContext, see above)

I would probably prefer the 3rd possibility.

If I'm missing something or I'm wrong in some case, please let me know.

Thanks a lot.
Comment 8 Tomas Mysik 2007-12-07 14:36:04 UTC
Andrei, David and me have been discussing this situation and this is the result/proposal:

I'll create public final class AntProjectHelper.UpdateContext which will provide methods for getting APH properties 
needed for project update etc. (for more info see UpdateHelper in J2SEProject) and this UpdateContext will be provided 
to all methods of UpdatableAntBasedProjectType or to UpdateImplementation (not decided yet what I'll implement, see  
my previous comment). This is probably the best solution of this situation because one can later add any method to 
UpdateContext without breaking any existing code.
Comment 9 Jesse Glick 2007-12-14 15:37:40 UTC
*** Issue 113895 has been marked as a duplicate of this issue. ***
Comment 10 Tomas Mysik 2008-01-15 10:54:58 UTC
I would like to complete this for NB 6.1.
Comment 11 Tomas Mysik 2008-02-25 12:45:16 UTC
Unfortunately not doable for NB 6.1.
Comment 12 Antonin Nebuzelsky 2009-04-10 09:30:03 UTC
Changing to TASK.
Comment 13 Martin Balin 2016-07-07 08:37:48 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss