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 230831 - Refactor EMGenStrategyResolverImpl and PersistenceProviderSupplierImpl
Summary: Refactor EMGenStrategyResolverImpl and PersistenceProviderSupplierImpl
Status: RESOLVED WONTFIX
Alias: None
Product: javaee
Classification: Unclassified
Component: Code (show other bugs)
Version: 7.4
Hardware: All All
: P3 normal (vote)
Assignee: Martin Janicek
URL:
Keywords:
Depends on: 230847
Blocks: 230820
  Show dependency tree
 
Reported: 2013-06-06 08:50 UTC by Martin Janicek
Modified: 2016-07-07 08:56 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Resolving EMGenStrategyResolverImpl (18.85 KB, patch)
2013-06-18 16:30 UTC, Martin Janicek
Details | Diff
Resolving EMGenStrategyResolverImpl - v2 (19.23 KB, patch)
2013-06-20 12:46 UTC, Martin Janicek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Janicek 2013-06-06 08:50:41 UTC
See subj.
Comment 1 Martin Janicek 2013-06-18 16:25:31 UTC
CCing David and Sergey. Some changes are in web.project and j2ee.persistence so feel free to comment on the patch (I'm going to attach it in a few minutes).
If there will be no objections, I'll integrate the patch tomorrow.
Comment 2 Martin Janicek 2013-06-18 16:30:54 UTC
Created attachment 135987 [details]
Resolving EMGenStrategyResolverImpl

In the patch I'm moving EMGenStrategyResolverImpl class from j2ee.common to the j2ee.persistence. In the persistence module I have created new api package (corresponding to the already existing spi) which contains only one factory class that returns default instance of EMGenStrategyResolverImpl.
Comment 3 Martin Janicek 2013-06-18 16:31:38 UTC
CCing also MartinF, I have made tiny changes in j2ee.ejbjarproject too.
Comment 4 Sergey Petrov 2013-06-18 20:23:07 UTC
changes may affect maven projects, may be in maven.persistence module but I'll check better tomorrow.
Comment 5 David Konecny 2013-06-19 00:11:22 UTC
Thanks Martin. Unsorted comments:

* j2ee.persistence already has two API packages named "entitygenerator" and "api.entity.generator". Adding third one named "api.entitymanagergenerator" sound suspicious. :-) I did not look though into existing packages and what's in them.

* spec version could be just 1.39 (instead of 1.39.1)

* new API method "createInstance" could be annotated in its Javadoc "@since 1.39"

Otherwise this looks good.

I was surprised to to discover "ContainerClassPathModifier" API class! It is first time I've ever seen it. It has a single impl in maven.j2ee and it looks it does nothing since EE6. I think even for EE5 it probably could be deleted as Maven dependencies are now handled via Ant libraries which have POM reference.
Comment 6 Martin Janicek 2013-06-19 07:14:23 UTC
(In reply to comment #5)
> Thanks Martin. Unsorted comments:
> 
> * j2ee.persistence already has two API packages named "entitygenerator" and
> "api.entity.generator". Adding third one named "api.entitymanagergenerator"
> sound suspicious. :-)

I would like to let the decision up to Sergey as the module owner. I created "api.entitymanagergenerator" because the related SPI class is placed in "spi.entitymanagergenerator" but not sure if such convention has to be respected.

> * spec version could be just 1.39 (instead of 1.39.1)
> 
> * new API method "createInstance" could be annotated in its Javadoc "@since
> 1.39"

Ok, I'll do that

> I was surprised to to discover "ContainerClassPathModifier" API class! It is
> first time I've ever seen it. It has a single impl in maven.j2ee and it looks
> it does nothing since EE6. I think even for EE5 it probably could be deleted as
> Maven dependencies are now handled via Ant libraries which have POM reference.

I'm a little bit confused. I guess this is unrelated, right? :) ..anyway I agree the implementation looks weird. I'll talk to Milos tomorrow.
Comment 7 Sergey Petrov 2013-06-19 10:59:50 UTC
entitymanagergenerator and entitygenerator even with similar naming should be different by meaning, also packages are on different level, and both contain a lot of classes, we do not have one-two class per package here. 
I'm ok with entitymanagergenerator package but api.entity.generator and entitygenerator packages may need some review/rename/refactor. Persistence may need spome cleanup from 1.4 support also.
Comment 8 Martin Janicek 2013-06-19 11:24:15 UTC
Thanks, I'll stay with current "api.entitymanagergenerator" in that case.
Comment 9 David Konecny 2013-06-19 21:28:04 UTC
> I'm a little bit confused. I guess this is unrelated, right? :) ..anyway I
> agree the implementation looks weird. I'll talk to Milos tomorrow.

Yeah sorry it is unrelated. :-) I noticed the class while looking at your diff and was surprised I've never seen it before.
Comment 10 Martin Janicek 2013-06-20 08:46:03 UTC
(In reply to comment #8)
> Thanks, I'll stay with current "api.entitymanagergenerator" in that case.

After discussion with PetrH (considering him as one of the most experienced API designer in our team;)), I'll move the Factory class directly to the SPI package "spi.entitymanagergenerator". Feel free to comment if you don't think it's a good idea
Comment 11 Martin Janicek 2013-06-20 12:46:29 UTC
Created attachment 136080 [details]
Resolving EMGenStrategyResolverImpl - v2

- @since annotation added
- Factory class moved to SPI package
- spec. version changed to 1.39
Comment 12 David Konecny 2013-06-20 21:38:06 UTC
> I'll move the Factory class directly to the SPI
> package "spi.entitymanagergenerator".

That's a very good idea.
Comment 13 Martin Janicek 2013-06-24 12:00:34 UTC
First part fix in: web-main #6f7a6d2eba46
Plus I had to move javaee.injection into the J2SE cluster (web-main #130cceb8ef54) because j2ee.persistence lies there and depends on it.
Comment 14 David Konecny 2013-06-24 22:38:55 UTC
> Plus I had to move javaee.injection into the J2SE cluster

It's a detail, but when you have to do something like that it is usually an indicator that we are doing something wrong. Unfortunately. :-)

Sorry I did not pick up on it earlier - I keep forgetting that persistence APIs are defined in J2SE cluster.

On one hand we could leave everything as is. On the other hand if you look at the purpose of javaee.injection and who implements it and how then you can see that nobody will ever use it in J2SE cluster. Similarly if you look at EntityManagerGenerationStrategyResolverFactory.EMGenStrategyResolverImpl and what the javaee.injection is used there for you can see that this implementation makes sense only in Web/EE project types and nobody in J2SE cluster will actually use it. So, inevitable conclusion is that EntityManagerGenerationStrategyResolverFactory.EMGenStrategyResolverImpl does not belong to J2SE cluster. Such problem is fixed usually in two ways:

#1) either keep EntityManagerGenerationStrategyResolverFactory in the J2SE but lookup its implementation via a global lookup; implementation would be then provided via some java ee cluster module (and javaee.injection can go back to ee cluster too); EntityManagerGenerationStrategyResolverFactory fallbacks on some dummy impl if lookup is empty (which would be "use ApplicationManagedResourceTransactionInJ2SE.class strategy"); or

#2) move EntityManagerGenerationStrategyResolverFactory into EE cluster (eg. into javaee.project module which we will create soon)
Comment 15 Quality Engineering 2013-06-25 02:45:28 UTC
Integrated into 'main-golden', will be available in build *201306242301* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/6f7a6d2eba46
User: Martin Janicek <mjanicek@netbeans.org>
Log: #230831 - Refactor EMGenStrategyResolverImpl and PersistenceProviderSupplierImpl
Comment 16 Martin Janicek 2013-06-25 06:26:22 UTC
(In reply to comment #14)
> So, inevitable conclusion is that
> EntityManagerGenerationStrategyResolverFactory.EMGenStrategyResolverImpl does
> not belong to J2SE cluster.

I agree with you but on the other hand I think this is not a problem of EntityManagerGenerationStrategyResolverFactory but rather the part of the j2ee.persistence which is in SE cluster but does not have anything in common with SE. For example most of the classes from spi.entitymanagergenerator package ends up with -EJB or -Web suffix and obviously doesn't belong to SE.
Comment 17 Sergey Petrov 2013-06-25 12:47:00 UTC
"good"  design may be to have separate modules for general jpa and jpa-ee, but it may hit user experience to update/configure/enable-disable two separate modules but it may not be a problem. But may require some more work for redesign.
Comment 18 David Konecny 2013-06-25 21:56:20 UTC
I agree that perhaps persistence should have had J2SE and J2EE parts. That might be non-trivial to do now though.
Comment 19 Martin Balin 2016-07-07 08:56:10 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