SlideShare a Scribd company logo
Date:
Time:
Duration:
Hashtag on Twitter:
Jakarta EE:
The First Parts
Introduction to Prime Jakarta EE APIs
HASUNUMA Kenji @khasunuma
7th November 2020
40 minutes
#jjug_ccc
Today’s Speaker
HASUNUMA Kenji
Service Engineer
@khasunuma
Table of Contents
1. Where's main method of Jakarta EE application?
2. Jakarta REST
3. Jakarta CDI
4. MicroProfile Config (See Example)
Examples: https://github.com/khasunuma/jee-first-parts
HASUNUMA Kenji @khasunuma
Introduction
Where's main method of Jakarta EE application?
HASUNUMA Kenji @khasunuma
Jakarta EE Architecture
HASUNUMA Kenji @khasunuma
Jakarta EE Architecture
HASUNUMA Kenji @khasunuma
Jakarta EE Architecture
HASUNUMA Kenji @khasunuma
Jakarta EE Architecture
HASUNUMA Kenji @khasunuma
Jakarta EE Architecture
HASUNUMA Kenji @khasunuma
Jakarta EE Architecture
HASUNUMA Kenji @khasunuma
Dependency of Jakarta EE Platform
HASUNUMA Kenji @khasunuma
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>8.0.0</version>
<scope>provided</scope>
</dependency>
Jakarta REST
Where we and Jakarta EE meet
HASUNUMA Kenji @khasunuma
What’s Jakarta REST
Jakarta REST (Jakarta RESTful Web Services) is a technology to
handle each HTTP requests:
• Easy to use
• Intuitive, Flexible and Expandable
• In most cases, better alternative of Servlets
HASUNUMA Kenji @khasunuma
What’s REST
• Primitive idea for Web Applications
• See in detail: Fielding, T., “Architectural Styles and Design of Network-
based Software Architectures”, 2000
The 3 elements of REST:
• Resource – What (HTML, XML, JSON, Image, etc.)
• URL – Where
• Method – How (GET, POST, PUT, DELETE, etc.)
HASUNUMA Kenji @khasunuma
URL syntax – in case of Jakarta EE
HASUNUMA Kenji @khasunuma
http://hostname:8080/context-root/path?query
Protocol
“http” / “https”
Port Number
(Omissible)
The path element
to identify
which application
Parameters
(Omissible)
How to send and receive HTTP GET
HASUNUMA Kenji @khasunuma
How to send and receive HTTP POST
HASUNUMA Kenji @khasunuma
Register Jakarta REST
HASUNUMA Kenji @khasunuma
@ApplicationPath(“app”)
public class MyApplication extends Application {
}
Resource Class
HASUNUMA Kenji @khasunuma
@Path(“some”)
public class SomeResource {
@GET
@Consumes(“application/x-www-form-urlencoded”)
@Produces(“text/html”)
public String handle(@QueryParam(“id”) String id) {
… // Create a response
}
}
<< URL: “/context-root/app/some” >>
<< Request >>
<< Response >>
<< Mapping >>
<< Mapping >>
<< Method >>
Handle GET method
HASUNUMA Kenji @khasunuma
@GET
@Consumes(“application/x-www-form-urlencoded”)
@Produces(“text/html”)
public String handle(@QueryParam(“id”) String id) {
// 1. Query Parameter (“id”) -> Argument (“id”) [0..N]
// 2. Create a response
// 3. Return value (String) -> Response (HTML)
...
}
Handle POST method
HASUNUMA Kenji @khasunuma
@POST
@Consumes(“application/x-www-form-urlencoded”)
@Produces(“text/html”)
public String handle(@FormParam(“data”) String data) {
// 1. Form Parameter (“data”) -> Argument (“data”) [1..N]
// 2. Create a response
// 3. Return value (String) -> Response (HTML)
...
}
Basic Error Handling
Throw the following exception if an error is occurred:
• WebApplicationException – specified HTTP Status
• NotFoundException (HTTP 404)
• InternalServerErrorException (HTTP 500)
• etc.
No exception, then respond successfully (HTTP 200)
HASUNUMA Kenji @khasunuma
Other Jakarta REST Features
• XML / JSON Binding Integration – for Web Services
• HTTP Client API
• Server Sent Events
• Use ServletContext – for low-level access
• Extensions of each implementation (Not standard)
HASUNUMA Kenji @khasunuma
Jakarta CDI
How to divide a complex thing to simple parts
HASUNUMA Kenji @khasunuma
What’s Jakarta CDI
Jakarta CDI is a technology that couples each components:
• View / User Interface
• Compute / Business Logic
• External Interface (e.g. Database, Messaging)
• Structure Value (e.g. Session Object)
etc.
HASUNUMA Kenji @khasunuma
Benefits of Jakarta CDI
• Split components as suitable size
• Choose “Alternative” (additional configuration is required)
• e.g. stub for test environment
• Combine components with different lifecycles (“Scope”)
• @RequestScoped – created for each request
• @SessionScoped – created and kept between a HTTP session
• @ApplicationScoped – created and kept until end of the application
• Call implicitly pre-processes and post-processes (“Interceptor”)
• e.g. @Transactional – begin and commit/rollback transaction
HASUNUMA Kenji @khasunuma
Dependency Injection by CDI
HASUNUMA Kenji @khasunuma
@Named // Qualifier
@RequestScoped // Scope
public class CdiBean1 {
@Inject // Injection Point
private CdiBean2 bean2;
public void compute() {
bean2.execute();
}
}
@Named // Qualifier
@RequestScoped // Scope
public class CdiBean2 {
public void execute() {
...
}
}
Inject an instance
CDI Bean
CDI Bean
Integration REST with CDI
HASUNUMA Kenji @khasunuma
@Path(“some”)
@RequestScoped // Scope
public class SomeResource {
@Inject // Injection Point
private Bean bean;
@get
@Produces(“text/html”)
public String handle() {
return bean.execute();
}
}
@Named // Qualifier
@RequestScoped // Scope
public class Bean {
public String execute() {
...
}
}
Inject an instance
CDI Bean
Resource / CDI Bean
Next Steps
• Jakarta EE provides various APIs for your applications:
• Jakarta Persistence – Database Access
• Jakarta Messaging – Message Queue Access
• Jakarta Mail – Connection to Mail Servers
• Jakarta Server Faces – Framework for creating Rich UI
• Jakarta Security – Security Features
• How to learn Jakarta EE APIs?
• Each application only uses some part of Jakarta EE
• You may learn when it is needed for you
HASUNUMA Kenji
We’ll Support You With:
Let us help you spread the word about our open source software. Join the Reef!
• Event, JUG, conference sponsorship
• Freebies, swag, handouts, speakers
• Promotion and advertising of events and articles
• Community forum
Learn More:
www.payara.fish/reef
Payara Reef: Community Growth Program
Download the open source software:
https://payara.fish/downloads
Need support for the Payara Platform?
https://payara.fish/support

More Related Content

Similar to Jakarta EE : The First Parts

RESTEasy
RESTEasyRESTEasy
Cloud native programming model comparison
Cloud native programming model comparisonCloud native programming model comparison
Cloud native programming model comparison
Emily Jiang
 
May 2010 - RestEasy
May 2010 - RestEasyMay 2010 - RestEasy
May 2010 - RestEasy
JBug Italy
 
Codemotion appengine
Codemotion appengineCodemotion appengine
Codemotion appengine
Ignacio Coloma
 
Overview of RESTful web services
Overview of RESTful web servicesOverview of RESTful web services
Overview of RESTful web services
nbuddharaju
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2Hugo Hamon
 
Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017
Matt Raible
 
Implement Service Broker with Spring Boot #cf_tokyo
Implement Service Broker with Spring Boot #cf_tokyoImplement Service Broker with Spring Boot #cf_tokyo
Implement Service Broker with Spring Boot #cf_tokyo
Toshiaki Maki
 
VRaptor 4 - JavaOne
VRaptor 4 - JavaOneVRaptor 4 - JavaOne
VRaptor 4 - JavaOne
Rodrigo Turini
 
Ant vs Phing
Ant vs PhingAnt vs Phing
Ant vs Phing
Manuel Baldassarri
 
Spring 4 Web App
Spring 4 Web AppSpring 4 Web App
Spring 4 Web App
Rossen Stoyanchev
 
Play framework
Play frameworkPlay framework
Play framework
Keshaw Kumar
 
Object Graph Mapping with Spring Data Neo4j 3 - Nicki Watt & Michael Hunger @...
Object Graph Mapping with Spring Data Neo4j 3 - Nicki Watt & Michael Hunger @...Object Graph Mapping with Spring Data Neo4j 3 - Nicki Watt & Michael Hunger @...
Object Graph Mapping with Spring Data Neo4j 3 - Nicki Watt & Michael Hunger @...
Neo4j
 
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディングXitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
scalaconfjp
 
Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014
Ngoc Dao
 
REST easy with API Platform
REST easy with API PlatformREST easy with API Platform
REST easy with API Platform
Antonio Peric-Mazar
 
Java Technology
Java TechnologyJava Technology
Java Technologyifnu bima
 
JDD 2016 - Jakub Kubrynski - Jpa - beyond copy-paste
JDD 2016 - Jakub Kubrynski - Jpa - beyond copy-pasteJDD 2016 - Jakub Kubrynski - Jpa - beyond copy-paste
JDD 2016 - Jakub Kubrynski - Jpa - beyond copy-paste
PROIDEA
 
REST made simple with Java
REST made simple with JavaREST made simple with Java
REST made simple with Java
Niklas Gustavsson
 

Similar to Jakarta EE : The First Parts (20)

RESTEasy
RESTEasyRESTEasy
RESTEasy
 
Cloud native programming model comparison
Cloud native programming model comparisonCloud native programming model comparison
Cloud native programming model comparison
 
May 2010 - RestEasy
May 2010 - RestEasyMay 2010 - RestEasy
May 2010 - RestEasy
 
Codemotion appengine
Codemotion appengineCodemotion appengine
Codemotion appengine
 
Overview of RESTful web services
Overview of RESTful web servicesOverview of RESTful web services
Overview of RESTful web services
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2
 
Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017
 
Implement Service Broker with Spring Boot #cf_tokyo
Implement Service Broker with Spring Boot #cf_tokyoImplement Service Broker with Spring Boot #cf_tokyo
Implement Service Broker with Spring Boot #cf_tokyo
 
VRaptor 4 - JavaOne
VRaptor 4 - JavaOneVRaptor 4 - JavaOne
VRaptor 4 - JavaOne
 
Ant vs Phing
Ant vs PhingAnt vs Phing
Ant vs Phing
 
Spring 4 Web App
Spring 4 Web AppSpring 4 Web App
Spring 4 Web App
 
Play framework
Play frameworkPlay framework
Play framework
 
Object Graph Mapping with Spring Data Neo4j 3 - Nicki Watt & Michael Hunger @...
Object Graph Mapping with Spring Data Neo4j 3 - Nicki Watt & Michael Hunger @...Object Graph Mapping with Spring Data Neo4j 3 - Nicki Watt & Michael Hunger @...
Object Graph Mapping with Spring Data Neo4j 3 - Nicki Watt & Michael Hunger @...
 
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディングXitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
 
Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014
 
REST easy with API Platform
REST easy with API PlatformREST easy with API Platform
REST easy with API Platform
 
Java Technology
Java TechnologyJava Technology
Java Technology
 
Jersey
JerseyJersey
Jersey
 
JDD 2016 - Jakub Kubrynski - Jpa - beyond copy-paste
JDD 2016 - Jakub Kubrynski - Jpa - beyond copy-pasteJDD 2016 - Jakub Kubrynski - Jpa - beyond copy-paste
JDD 2016 - Jakub Kubrynski - Jpa - beyond copy-paste
 
REST made simple with Java
REST made simple with JavaREST made simple with Java
REST made simple with Java
 

More from Kenji HASUNUMA

oop-in-javaee
oop-in-javaeeoop-in-javaee
oop-in-javaee
Kenji HASUNUMA
 
Life of our small product
Life of our small productLife of our small product
Life of our small product
Kenji HASUNUMA
 
Overviewing Admin Console
Overviewing Admin ConsoleOverviewing Admin Console
Overviewing Admin Console
Kenji HASUNUMA
 
How to adapt MicroProfile API for Generic Web Applications
How to adapt MicroProfile API for Generic Web ApplicationsHow to adapt MicroProfile API for Generic Web Applications
How to adapt MicroProfile API for Generic Web Applications
Kenji HASUNUMA
 
Introduction to MicroProfile Metrics
Introduction to MicroProfile MetricsIntroduction to MicroProfile Metrics
Introduction to MicroProfile Metrics
Kenji HASUNUMA
 
Introduction to JCA and MDB
Introduction to JCA and MDBIntroduction to JCA and MDB
Introduction to JCA and MDB
Kenji HASUNUMA
 
Virtualization Fundamental
Virtualization FundamentalVirtualization Fundamental
Virtualization Fundamental
Kenji HASUNUMA
 
JLS myths
JLS mythsJLS myths
JLS myths
Kenji HASUNUMA
 
Introduction to Date and Time API 4
Introduction to Date and Time API 4Introduction to Date and Time API 4
Introduction to Date and Time API 4
Kenji HASUNUMA
 
Fundamental Java
Fundamental JavaFundamental Java
Fundamental Java
Kenji HASUNUMA
 
Collections Framework Begineers guide 2
Collections Framework Begineers guide 2Collections Framework Begineers guide 2
Collections Framework Begineers guide 2
Kenji HASUNUMA
 
Introduction to Date and Time API 3
Introduction to Date and Time API 3Introduction to Date and Time API 3
Introduction to Date and Time API 3
Kenji HASUNUMA
 
Introduction to JavaFX Dialogs
Introduction to JavaFX DialogsIntroduction to JavaFX Dialogs
Introduction to JavaFX Dialogs
Kenji HASUNUMA
 
Brand new Date and Time API
Brand new Date and Time APIBrand new Date and Time API
Brand new Date and Time API
Kenji HASUNUMA
 
Introduction to Date and Time API 2
Introduction to Date and Time API 2Introduction to Date and Time API 2
Introduction to Date and Time API 2
Kenji HASUNUMA
 
Introduction to Data and Time API
Introduction to Data and Time APIIntroduction to Data and Time API
Introduction to Data and Time API
Kenji HASUNUMA
 

More from Kenji HASUNUMA (16)

oop-in-javaee
oop-in-javaeeoop-in-javaee
oop-in-javaee
 
Life of our small product
Life of our small productLife of our small product
Life of our small product
 
Overviewing Admin Console
Overviewing Admin ConsoleOverviewing Admin Console
Overviewing Admin Console
 
How to adapt MicroProfile API for Generic Web Applications
How to adapt MicroProfile API for Generic Web ApplicationsHow to adapt MicroProfile API for Generic Web Applications
How to adapt MicroProfile API for Generic Web Applications
 
Introduction to MicroProfile Metrics
Introduction to MicroProfile MetricsIntroduction to MicroProfile Metrics
Introduction to MicroProfile Metrics
 
Introduction to JCA and MDB
Introduction to JCA and MDBIntroduction to JCA and MDB
Introduction to JCA and MDB
 
Virtualization Fundamental
Virtualization FundamentalVirtualization Fundamental
Virtualization Fundamental
 
JLS myths
JLS mythsJLS myths
JLS myths
 
Introduction to Date and Time API 4
Introduction to Date and Time API 4Introduction to Date and Time API 4
Introduction to Date and Time API 4
 
Fundamental Java
Fundamental JavaFundamental Java
Fundamental Java
 
Collections Framework Begineers guide 2
Collections Framework Begineers guide 2Collections Framework Begineers guide 2
Collections Framework Begineers guide 2
 
Introduction to Date and Time API 3
Introduction to Date and Time API 3Introduction to Date and Time API 3
Introduction to Date and Time API 3
 
Introduction to JavaFX Dialogs
Introduction to JavaFX DialogsIntroduction to JavaFX Dialogs
Introduction to JavaFX Dialogs
 
Brand new Date and Time API
Brand new Date and Time APIBrand new Date and Time API
Brand new Date and Time API
 
Introduction to Date and Time API 2
Introduction to Date and Time API 2Introduction to Date and Time API 2
Introduction to Date and Time API 2
 
Introduction to Data and Time API
Introduction to Data and Time APIIntroduction to Data and Time API
Introduction to Data and Time API
 

Recently uploaded

GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 

Recently uploaded (20)

GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 

Jakarta EE : The First Parts

  • 1. Date: Time: Duration: Hashtag on Twitter: Jakarta EE: The First Parts Introduction to Prime Jakarta EE APIs HASUNUMA Kenji @khasunuma 7th November 2020 40 minutes #jjug_ccc
  • 3. Table of Contents 1. Where's main method of Jakarta EE application? 2. Jakarta REST 3. Jakarta CDI 4. MicroProfile Config (See Example) Examples: https://github.com/khasunuma/jee-first-parts HASUNUMA Kenji @khasunuma
  • 4. Introduction Where's main method of Jakarta EE application? HASUNUMA Kenji @khasunuma
  • 11. Dependency of Jakarta EE Platform HASUNUMA Kenji @khasunuma <dependency> <groupId>jakarta.platform</groupId> <artifactId>jakarta.jakartaee-api</artifactId> <version>8.0.0</version> <scope>provided</scope> </dependency>
  • 12. Jakarta REST Where we and Jakarta EE meet HASUNUMA Kenji @khasunuma
  • 13. What’s Jakarta REST Jakarta REST (Jakarta RESTful Web Services) is a technology to handle each HTTP requests: • Easy to use • Intuitive, Flexible and Expandable • In most cases, better alternative of Servlets HASUNUMA Kenji @khasunuma
  • 14. What’s REST • Primitive idea for Web Applications • See in detail: Fielding, T., “Architectural Styles and Design of Network- based Software Architectures”, 2000 The 3 elements of REST: • Resource – What (HTML, XML, JSON, Image, etc.) • URL – Where • Method – How (GET, POST, PUT, DELETE, etc.) HASUNUMA Kenji @khasunuma
  • 15. URL syntax – in case of Jakarta EE HASUNUMA Kenji @khasunuma http://hostname:8080/context-root/path?query Protocol “http” / “https” Port Number (Omissible) The path element to identify which application Parameters (Omissible)
  • 16. How to send and receive HTTP GET HASUNUMA Kenji @khasunuma
  • 17. How to send and receive HTTP POST HASUNUMA Kenji @khasunuma
  • 18. Register Jakarta REST HASUNUMA Kenji @khasunuma @ApplicationPath(“app”) public class MyApplication extends Application { }
  • 19. Resource Class HASUNUMA Kenji @khasunuma @Path(“some”) public class SomeResource { @GET @Consumes(“application/x-www-form-urlencoded”) @Produces(“text/html”) public String handle(@QueryParam(“id”) String id) { … // Create a response } } << URL: “/context-root/app/some” >> << Request >> << Response >> << Mapping >> << Mapping >> << Method >>
  • 20. Handle GET method HASUNUMA Kenji @khasunuma @GET @Consumes(“application/x-www-form-urlencoded”) @Produces(“text/html”) public String handle(@QueryParam(“id”) String id) { // 1. Query Parameter (“id”) -> Argument (“id”) [0..N] // 2. Create a response // 3. Return value (String) -> Response (HTML) ... }
  • 21. Handle POST method HASUNUMA Kenji @khasunuma @POST @Consumes(“application/x-www-form-urlencoded”) @Produces(“text/html”) public String handle(@FormParam(“data”) String data) { // 1. Form Parameter (“data”) -> Argument (“data”) [1..N] // 2. Create a response // 3. Return value (String) -> Response (HTML) ... }
  • 22. Basic Error Handling Throw the following exception if an error is occurred: • WebApplicationException – specified HTTP Status • NotFoundException (HTTP 404) • InternalServerErrorException (HTTP 500) • etc. No exception, then respond successfully (HTTP 200) HASUNUMA Kenji @khasunuma
  • 23. Other Jakarta REST Features • XML / JSON Binding Integration – for Web Services • HTTP Client API • Server Sent Events • Use ServletContext – for low-level access • Extensions of each implementation (Not standard) HASUNUMA Kenji @khasunuma
  • 24. Jakarta CDI How to divide a complex thing to simple parts HASUNUMA Kenji @khasunuma
  • 25. What’s Jakarta CDI Jakarta CDI is a technology that couples each components: • View / User Interface • Compute / Business Logic • External Interface (e.g. Database, Messaging) • Structure Value (e.g. Session Object) etc. HASUNUMA Kenji @khasunuma
  • 26. Benefits of Jakarta CDI • Split components as suitable size • Choose “Alternative” (additional configuration is required) • e.g. stub for test environment • Combine components with different lifecycles (“Scope”) • @RequestScoped – created for each request • @SessionScoped – created and kept between a HTTP session • @ApplicationScoped – created and kept until end of the application • Call implicitly pre-processes and post-processes (“Interceptor”) • e.g. @Transactional – begin and commit/rollback transaction HASUNUMA Kenji @khasunuma
  • 27. Dependency Injection by CDI HASUNUMA Kenji @khasunuma @Named // Qualifier @RequestScoped // Scope public class CdiBean1 { @Inject // Injection Point private CdiBean2 bean2; public void compute() { bean2.execute(); } } @Named // Qualifier @RequestScoped // Scope public class CdiBean2 { public void execute() { ... } } Inject an instance CDI Bean CDI Bean
  • 28. Integration REST with CDI HASUNUMA Kenji @khasunuma @Path(“some”) @RequestScoped // Scope public class SomeResource { @Inject // Injection Point private Bean bean; @get @Produces(“text/html”) public String handle() { return bean.execute(); } } @Named // Qualifier @RequestScoped // Scope public class Bean { public String execute() { ... } } Inject an instance CDI Bean Resource / CDI Bean
  • 29. Next Steps • Jakarta EE provides various APIs for your applications: • Jakarta Persistence – Database Access • Jakarta Messaging – Message Queue Access • Jakarta Mail – Connection to Mail Servers • Jakarta Server Faces – Framework for creating Rich UI • Jakarta Security – Security Features • How to learn Jakarta EE APIs? • Each application only uses some part of Jakarta EE • You may learn when it is needed for you HASUNUMA Kenji
  • 30. We’ll Support You With: Let us help you spread the word about our open source software. Join the Reef! • Event, JUG, conference sponsorship • Freebies, swag, handouts, speakers • Promotion and advertising of events and articles • Community forum Learn More: www.payara.fish/reef Payara Reef: Community Growth Program
  • 31. Download the open source software: https://payara.fish/downloads Need support for the Payara Platform? https://payara.fish/support