Jakarta
my-jakarta-project/
├── pom.xml # Maven configuration file, containing dependencies and build instructions
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ └── example
│ │ │ ├── controller
│ │ │ │ └── PhysicianResource.java # REST controller
│ │ │ ├── model
│ │ │ │ └── Physician.java # JPA entity class
│ │ │ ├── service
│ │ │ │ └── PhysicianService.java # Business service class
│ │ │ ├── repository
│ │ │ │ └── PhysicianRepository.java # Database access class
│ │ │ └── cdi
│ │ │ └── AppProducer.java # CDI producer class for injecting beans
│ │ ├── resources
│ │ │ ├── META-INF
│ │ │ │ └── persistence.xml # JPA persistence configuration file
│ │ │ ├── application.properties # Application configuration file
│ │ │ └── logback.xml # Logging configuration file
│ │ ├── webapp
│ │ ├── WEB-INF
│ │ │ ├── web.xml # Web application configuration file
│ │ │ └── beans.xml # CDI configuration file
│ │ ├── index.jsp # Web application homepage (JSP)
│ │ └── static
│ │ ├── js # Directory for JavaScript files
│ │ └── css # Directory for CSS files
│ └── test
│ ├── java
│ │ └── com
│ │ └── example
│ │ └── PhysicianResourceTest.java # REST service test
Java / Jakarta EE Architecture¶
Java Naming and Directory Interface(JNDI)¶
CDI:¶
Payara¶
Presentation Layer¶
- Model:
- VIEW:
- CONTROLLER:
Java Servlets¶
run in a container
-
life cycle methods of a servelt
- init() -> service() -> destory()
JSP¶
JSTL¶
Jakarta EE Presentation Technologies¶
Annotations¶
- RESTful Services (JAX-RS) Annotations
- @Path: Defines the relative path for a resource class or method.
- @GET: Indicates that a method responds to HTTP GET requests.
- @POST: Indicates that a method responds to HTTP POST requests.
- @Produces: Defines the media types that the methods of a resource can produce.
- @Consumes: Defines the media types that the methods of a resource can accept.
- @PathParam: Binds a method parameter to a URI path segment.
- JPA (Java Persistence API) Annotations
- @Entity: Specifies that a class is an entity and is mapped to a database table.
- @Table: Specifies the table in the database that the entity is mapped to.
- @Id: Specifies the primary key of an entity.
- @GeneratedValue: Specifies the generation strategy for the values of primary keys.
- @Column: Specifies the mapped column for a persistent property or field.
- @OneToMany, @ManyToOne, @OneToOne, @ManyToMany: Define relationships between entities.
-
CDI (Contexts and Dependency Injection) Annotations
- • @Inject: Specifies that a dependency should be injected.
- • @Named: Defines a name for a CDI bean, which can be used in EL (Expression Language) in JSP or JSF.
- • @Produces: Used to create producer methods, which are used to inject custom objects.
- • @RequestScoped, @SessionScoped, @ApplicationScoped: Define the scope of a CDI bean.
-
EJB (Enterprise JavaBeans) Annotations
- @Stateless: Defines a stateless session bean, which does not maintain a conversational state with clients.
- @Stateful: Defines a stateful session bean, which maintains a state with the client across multiple method calls.
- @Singleton: Defines a singleton session bean, which maintains a single instance throughout the application.
- @Schedule: Defines a timer method for scheduling tasks.
- @Asynchronous: Specifies that a method should be invoked asynchronously.
- Jakarta Security Annotations
- @RolesAllowed: Specifies that only users with certain roles can access the annotated method or class.
- @RolesAllowed("ADMIN")
- @PermitAll: Allows access to everyone.
- • @DenyAll: Denies access to everyone.
- JSF
- Maven
- JPA Hibernate MyBatis Comparison