Jump to content

Jakarta Annotations

From Alfawiki
Jakarta Annotations
Company typeSpecification
IndustrySoftware development
PredecessorCommon Annotations for the Java Platform (JSR 250)
Founded2006-05-11
ProductsJava annotations for Jakarta EE and Java SE

Jakarta Annotations (abbreviated as CA; previously known as Common Annotations for the Java Platform or JSR 250) constitutes a component of Jakarta EE. Its development aimed at creating Java annotations that represent universal semantic concepts applicable to both Java SE and Java EE environments, thereby fostering a declarative approach to programming. This harmonization enhances the coherence among Java EE component JSRs and ensures alignment between Java EE and Java SE standards.

Description and purpose

The Java Specification Request JSR 250 establishes annotations that encapsulate shared semantic ideas intended for widespread use across various Java EE and SE modules, minimizing duplication of annotation definitions. Officially released on 11 May 2006, its significance has increased alongside the rise of declarative, annotation-driven configurations in frameworks such as Spring, which extensively utilize annotations to enable flexible configuration.

Dependencies

JSR 250 requires the presence of JSR 175 and Java SE version 5.0 to function properly.

List of annotations

The following annotations have transitioned from the javax.annotation namespace to jakarta.annotation.

Annotation Description
Generated Identifies source code that has been generated automatically
Resource Specifies a reference to external resources such as databases
Resources Acts as a container for multiple Resource annotations
PostConstruct Marks methods that are invoked after dependency injection for initialization purposes
PreDestroy Designates methods executed prior to container-managed instance removal
Priority Denotes execution precedence, often used in interceptors to manage invocation order
RunAs Defines the security role an application assumes during execution within a Java EE container
RolesAllowed Lists security roles authorized to access particular methods
PermitAll Grants access to all security roles for annotated methods or classes
DenyAll Restricts access for all security roles on specified methods
DeclareRoles Enumerates application-specific security roles
DataSourceDefinition Specifies and registers a container-managed DataSource via JNDI, with configurable annotation attributes
ManagedBean Declares Managed Beans—objects controlled by the container that support resource injection, lifecycle callbacks, and interceptors

Implementation

Annotations from JSR 250 not tied to Java EE were integrated into Java SE 6 (including Generated, PostConstruct, PreDestroy, Resource, Resources) under the javax.annotation package. These annotations became deprecated in Java SE 9 and were removed entirely in Java SE 11; however, they persist under the new jakarta.annotation package starting with Jakarta EE 9.

References