Skip to content
This repository was archived by the owner on Jan 30, 2019. It is now read-only.
This repository was archived by the owner on Jan 30, 2019. It is now read-only.

Adapt to Java SE 8 Repeating Annotations #36

@glassfishrobot

Description

@glassfishrobot

Java SE 8 introduces the capability of repeating annotations: http://docs.oracle.com/javase/tutorial/java/annotations/repeating.html. There are a number of existing Java EE annotations that could adapt to the feature (fortunately in a fairly backwards compatible fashion - the Java SE feature was clearly designed with backwards compatibility in mind).

The following is a list of annotations that are fairly clear candidates, in roughly priority order (keep in mind, it is possible I missed something - hopefully spec leads will do a far better job at identifying required changes):

  • EJB
    • javax.ejb.Schedule
  • Java EE/Common Annotations
    • javax.annotation.sql.DataSourceDefinition
  • JPA
    • javax.persistence.NamedQuery
    • javax.persistence.NamedNativeQuery
    • javax.persistence.SqlResultSetMapping
    • javax.persistence.NamedEntityGraph
    • javax.persistence.NamedStoredProcedureQuery
    • javax.persistence.SequenceGenerator
    • javax.persistence.TableGenerator
    • javax.persistence.PersistenceContext
    • javax.persistence.PersistenceUnit
    • (There may be others in JPA)
  • JMS
    • javax.jms.JMSDestinationDefinition
    • javax.jms.JMSConnectionFactoryDefinition
  • JavaMail
    • javax.mail.MailSessionDefinition
  • JSF
    • javax.faces.application.ResourceDependency
    • javax.faces.event.ListenerFor
  • JCA
    • javax.resource.AdministeredObjectDefinition
    • javax.resource.ConnectionFactoryDefinition
    • javax.resource.spi.ConnectionDefinition
    • (There may be others in JCA)
  • JAX-WS
    • javax.xml.ws.WebServiceRef
    • (There may be others in JAX-WS)

Other than the above, there are other annotations where the value proposition of the repeatable annotation semantics is less clear. It is highly subjective, but in these cases having an explicit containing annotation may add clarity since the repeating annotations are more logically grouped. On the other hand, it may be simpler for developers if repeating annotations are used consistently across the platform.

The following is a list, in roughly priority order (keep in mind, it is possible I missed something - hopefully spec leads will do a far better job at identifying required changes):

  • JPA
    • javax.persistence.SecondaryTable
    • javax.persistence.JoinColumn
    • javax.persistence.AttributeOverride
    • javax.persistence.AssociationOverride
    • javax.persistence.PrimaryKeyJoinColumn
    • javax.persistence.MapKeyJoinColumn
    • (There may be others in JPA)
  • Bean Validation
    • javax.validation.constraints.NotNull
    • javax.validation.constraints.Size
    • javax.validation.constraints.Min
    • javax.validation.constraints.Max
    • javax.validation.constraints.DecimalMin
    • javax.validation.constraints.DecimalMax
    • javax.validation.constraints.Pattern
    • javax.validation.constraints.Digits
    • javax.validation.constraints.Past
    • javax.validation.constraints.Future
    • javax.validation.constraints.AssertTrue
    • javax.validation.constraints.AssertFalse
    • javax.validation.constraints.Null
    • javax.validation.groups.ConvertGroup
    • javax.validation.OverridesAttribute
  • JAXB
    • javax.xml.bind.annotation.XmlElement
    • javax.xml.bind.annotation.XmlSchemaType
    • (there may be others in JAXB)

The repeating annotations feature also opens up some interesting possibilities such as overlapping @path annotations (effectively aliases), various @QueryParam, etc annotations mapping to the same Java method parameter and the like. The value in keeping things simple may override any compelling semantic benefit to be gained in such cases...

Do let me know if anything needs to be explained further - I am happy to help. I am also happy to disperse these JIRA issues across various projects if needed. Doing one JIRA for the platform was easier especially since this involves some older Java EE specifications.

Please note that these are purely my personal views and certainly not of Oracle's as a company.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions