jakartaee / platform

The Jakarta EE Platform project produces the Jakarta EE platform specification, which is an umbrella specification that aggregates all other Jakarta EE specifications.
https://jakartaee.github.io/platform/
Eclipse Public License 2.0
197 stars 65 forks source link

Provide library with an API spec projects can reuse #405

Open lukasj opened 3 years ago

lukasj commented 3 years ago

Is your feature request related to a problem? Please describe. GenericType class defined by the JAXRS spec is an example of a class, which other specs may wish to reuse. Right now the only option for that is to either "depend" on JAXRS - not everyone wants or needs to do that - or "copy&paste" this class to his project.

I think that by deeper inspection of existing specs, more "utility"-like/common stuff which does not necessarily belong to the given spec's API and may be useful to others can be found.

The artifact could also provide EE platform extensions to SE classes - for example extended ServiceLoader handling provider's priority,..

Describe the solution you'd like The Platform project provides an artifact, let's say jakarta.platform:jakarta.commons with a package jakarta.commons.util- with common functionality other spec projects or implementations can reuse to guarantee consistent behavior across the platform and avoid duplicating the functionality.

Spec projects should not be required to use this artifact, they should be able to opt-in/opt-out to use it at any time if they want to.

Describe alternatives you've considered

Additional context depending on the output related to semantic versioning and usage of OSGi annotations - there may be a need to support these annotation but it is not desirable to bring 3rd-party non-Jakarta based dependency to the spec projects; an artifact like this could have the package ie jakarta.commons.osgi with annotations from the OSGi

tomas-langer commented 3 years ago

GenericType - the same is javax.enterprise.util.TypeLiteral in CDI. This would also be very useful in Config (to request a generic type), and probably would find its use in any specification that needs to handle types in API, as Class<?> is limited to non-generic types.

tomas-langer commented 3 years ago

I think the following utilities would be useful as well (ideas to be discussed):

Ladicek commented 3 years ago

My personal opinion is that 1. the "commons" projects tend to become dumping grounds, so they should be really minimal and have a high bar for entry; 2. there's already Common Annotations, so that should be repurposed to host utility classes, because why have more than one "commons" projects?

Emily-Jiang commented 3 years ago

We need to first review the current annotations to see whether they are still in use. If not, deprecate them. The other issue is to ensure there are sufficient tests to cover the common apis. There should be a strategy how to ensure these apis are still in use and still useful.

keilw commented 3 years ago

Builder is certainly something pattern specific, but so IMO are other patterns like Repository. They may be a little more specific to CRUD type operations, but go beyond JPA or NoSQL, especially Config is another great example where this could be handy.

On the other hand the likes of Entity, Column, etc. those are probably subject to a "persistence-common" kind of spec that would benefit at least SQL and NoSQL specs under Jakarta EE.

tomas-langer commented 2 years ago

I have created a proposal here: https://docs.google.com/document/d/19eN3pQxtoMNoiqEKasPzbuTjUcYBC4pS0TGT12lVE3Y/edit?usp=sharing Please comment - I will open a discussion in an e-mail thread and on Jakarta platform meeting.

Ladicek commented 2 years ago

Since the document doesn't allow comments, I'll add mine here.

Also, I think the proposal (and later a "project charter" or what would be the best place?) should spell out explicitly the rules for acceptance into "commons". And those rules should not be very lax. Something like 2 (3? 4?) specification projects agreeing on usefulness, and no specification objecting.

[1] I guess one benefit is that the interface could do the annoying self type emulation once and for all. Something like this?

interface Builder<T, THIS extends Builder<T, THIS>> {
    T build();

    @SuppressWarnings("unchecked")
    default THIS self() {
        return (THIS) this;
    }
}

From a quick experiment, this seems to add little value. Also, I've seen many people getting confused by declarations such as this, because they (rightfully so!) don't care WTH F-bounded type polymorphism is.

tomas-langer commented 2 years ago

I have enabled comments in the document. I will update it with yours