SlideShare a Scribd company logo
Rapid Development Tools for
Java EE 8
Mert Çalışkan, Gaurav Gupta
JavaOne 2017
Mert Çalışkan
Payara Developer
Java EE / Spring Consultant
Author of PrimeFaces Cookbook
Author of Beginning Spring book
Part-time Lecturer
@mertcal
Gaurav Gupta
Payara Developer
NetBeans Dream Team
Jeddict Creator ( jeddict.github.io )
@jGauravGupta , @ImJeddict
Agenda
- What’s new with Java EE 8? : Quick overview
- Java EE 8 application generation w/ Jeddict
- Java EE Tools : To boost your productivity
- Q&A
@jGauravGupta
What’s new with Java EE8?
Java EE8 is released on Sep 24, 2017.
● JAX-RS 2.1 (Jersey 2.26)
● CDI 2.0 (Weld 3.0.0.Final)
● Bean Validation 2.0 (Hibernate Validator 6.0.2.Final)
● JSON-B (Yasson 1.0)
● JPA 2.2 (EclipseLink 2.7.0)
● Java Security API 1.0 (Soteria 1.0)
Checkout https://github.com/javaee-samples/javaee8-samples for details on the
examples
@mertcal
● Reactive Client API
● JSON-B support
● Server Sent Events (SSE)
JAX-RS 2.1 (JSR 370)
@mertcal
● With JAX-RS 2.0, we had asynchronous invoker approach as:
Client client = ClientBuilder.newClient();
WebTarget target = client.target("http://localhost:8080/service-url");
Invocation.Builder builder = target.request();
Future<MyClass> futureResult = builder.async().get(MyClass.class);
System.out.println(futureResult.get());
client.close();
Previously on JAX-RS 2.0
@mertcal
● Previous scenario can also be implemented with InvocationCallback<T>
but…
Client client = ClientBuilder. newClient();
WebTarget target = client.target( "http://localhost:8080/service-url");
Invocation.Builder builder = target.request();
builder.async().get( new InvocationCallback<MyClass>() {
@Override
public void completed(MyClass t) {}
@Override
public void failed(Throwable throwable) {}
});
Previously on JAX-RS 2.0
@mertcal
● Reactive Client API to the rescue.
Client client = ClientBuilder.newClient();
WebTarget target = client.target("http://localhost:8080/service-url");
Invocation.Builder builder = target.request();
CompletionStage<Response> response = builder.rx().get();
response.thenAcceptAsync(res -> {
MyClass t = res.readEntity(MyClass.class);
System.out.println(t);
});
JerseyCompletionStageRxInvoker
CompletionStage<Response>
With JAX-RS 2.1
@mertcal
● 3rd Party Reactive Framework Support
○ RxJava
Client client = ClientBuilder.newClient().register(RxFlowableInvokerProvider.class);
WebTarget target = client.target("http://localhost:8080/service-url");
Invocation.Builder builder = target.request();
Flowable<Response> flowable = builder.rx(RxFlowableInvoker.class).get();
flowable.subscribe(res -> {
MyClass t = res.readEntity(MyClass.class);
System.out.println(t);
});
reactive invoker specialized
for io.reactivex.Flowable
JAX-RS 2.1
@mertcal
Client client = ClientBuilder.newClient().target("http://localhost:8080/service-url")
.request()
.get();
Client client = ClientBuilder.newClient().target("http://localhost:8080/service-url")
.request()
.async()
.get();
Client client = ClientBuilder.newClient().target("http://localhost:8080/service-url")
.request()
.rx()
.get();
JAX-RS 2.1
@mertcal
● Server Sent Events (SSE) is a mechanism that allows server to
asynchronously push data from the server to client once the client-server
connection is established by the client.
● It’s mostly like Long-Pooling but it’s not :) and it’s not WebSockets either.
● Implementations already provided it with JAX-RS 2.0 but there was no standard
API. With JAX-RS 2.1, API is created under javax.ws.rs.sse
JAX-RS 2.1
@mertcal
@Path("/temperature")
public class TemperatureResource {
private final OutboundSseEvent.Builder sseEventBuilder;
public TemperatureResource( @Context Sse sse) {
this.sseEventBuilder = sse.newEventBuilder();
}
@GET
@Path("/{city}")
@Produces(MediaType.SERVER_SENT_EVENTS)
public void getCurrentTemperatureStream( @Context SseEventSink eventSink) {
while (true) {
eventSink.send( sseEventBuilder.data(temperature)
.mediaType(MediaType. APPLICATION_JSON_TYPE).build());
Thread. sleep(1000);
}
}
}
"text/event-stream"
1
2
3
4
JAX-RS 2.1
@mertcal
CDI 2.0 (JSR 365)
- SE Support - It’s possible to use CDI outside of Java EE
- Ordering of CDI events - @Priority helps ordering observers
void receive(@Observes @Priority(APPLICATION + 200) String greet) {
this.greet += greet + "2";
}
void receive2(@Observes @Priority(APPLICATION) String greet) {
this.greet = greet + "1";
}
For send(“Welcome”) output will be:
Welcome1Welcome2
@Inject
private Event<String> event;
public void send(String message) {
event.fire(message);
}
@mertcal
CompletableStage<MyEvent> eventSent = event.fireAsync( new MyEvent(),
NotificationOptions.ofExecutor(executor));
- Exception in async observer doesn’t break the observer invocation chain.
callMe(@Observes payload) callMe(@ObservesAsync payload)
event.fire(payload) Sync call Not Notified
event.fireAsync(payload) Not Notified Async call
- Long awaited Asynchronous Events Support
- Fire Sync → Observer Sync / Fire Async → Observer Async
CDI 2.0
@mertcal
● Java 8 Date and Time API Support
@Past(message = "must be a past date")
private java.time.Year yearOfBirth;
● Type Annotations
private List<@NotNull @Email String> emails;
private String @NotNull @Email[] emails;
private Map<@Valid Employee, @Valid Address> addressMap = new HashMap<>();
@mertcal
Bean Validation 2 (JSR 380)
● java.util.Optional Support
private Optional<@Past LocalDate> marriageAnniversary;
private Optional<@Size(max = 20) String> name;
● Repeating Annotations
@Max(value = 2000, groups = Default.class)
@Max(value = 5000, groups = GoldCustomer.class)
private long withdrawalAmount;
@mertcal
Bean Validation 2
Bean Validation 2
● Introduces new constraints
○ @Email
○ @NotBlank
○ @NotEmpty
○ @PastOrPresent
○ @FutureOrPresent
○ @Negative
○ @NegativeOrZero
○ @Positive
○ @PositiveOrZero
@mertcal
JSON-B (JSR 367)
● Standard solution like JAXB
● Default mapping between classes and JSON
● Customizable
a. Compile time
■ Property naming @JsonbProperty
■ Property ignoring @JsonbTransient
■ Null handling @JsonbNillable
■ Property ordering @JsonbPropertyOrder
■ Date and Number Format @JsonbDateFormat/@JsonbNumberFormat
■ Adapter @JsonbTypeAdapter
b. Runtime configration
■ Configuration builder JsonbConfig
@jGauravGupta
JSON-B - Default mapping
class Employee {
private String name;
private String pin;
private String email;
}
{
"name": "Gaurav",
"pin": "J1-Secret",
"email": "gaurav.gupta@payara.fish",
}
@jGauravGupta
JSON-B - Custom mapping
@JsonbPropertyOrder({"email", "name"})
class Employee {
@JsonbProperty("empName")
private String name;
@JsonbTransient
private String pin;
private String email;
}
{
"email": "gaurav.gupta@payara.fish",
"empName": "Gaurav"
}
@jGauravGupta
JPA 2.2 (JSR 338)
● @Repeatable annotations
● Support Java 8 Date and Time API
● Ability to return stream of query result
● CDI Injection in AttributeConverters
@jGauravGupta
JPA 2.1
Container annotation required
@Entity
@NamedQueries({
@NamedQuery(name = "Employee.findAll",
query = "SELECT e FROM Employee e"),
@NamedQuery(name = "Employee.findByName",
query = "SELECT e FROM Employee e WHERE e.name = :name")
})
class Employee {
@Convert(converter=LocalDateConverter.class)
private LocalDate dateOfBirth;
} AttributeConverter
implementation @jGauravGupta
JPA 2.2
Container annotation not required
@Entity
@NamedQueries({
@NamedQuery(name = "Employee.findAll",
query = "SELECT e FROM Employee e"),
@NamedQuery(name = "Employee.findByName",
query = "SELECT e FROM Employee e WHERE e.name = :name")
})
class Employee {
@Convert(converter=LocalDateConverter.class)
private LocalDate dateOfBirth;
}
AttributeConverter not required @jGauravGupta
JPA 2.2
@Entity
@NamedQuery(name = "Employee.findAll",
query = "SELECT e FROM Employee e")
@NamedQuery(name = "Employee.findByName",
query = "SELECT e FROM Employee e WHERE e.name = :name")
class Employee {
private LocalDate dateOfBirth;
}
@jGauravGupta
JPA 2.2
● Stream query results
Stream<Employee> employees =
em.createQuery(“SELECT e FROM Employee”, Employee.class)
.getResultStream();
@jGauravGupta
Security API 1.0 (JSR 375)
● Simplify the existing solution
● Enhance the portability
● New APIs
○ HTTPAuthenticationMechanism
○ IdentityStore
○ SecurityContext
@jGauravGupta
Security API 1.0 (JSR 375)
● HTTP Authentication Mechanism
○ validateRequest(request, response, httpMessageContext)
○ secureResponse(request, response, httpMessageContext)
○ cleanSubject(request, response, httpMessageContext)
● Identity Store
○ validate(credential)
○ getCallerGroups(credentialValidationResult)
● Security Context
○ getCallerPrincipal()
○ isCallerInRole(role)
○ … … …
@jGauravGupta
@ApplicationScoped
public class MyAuthMechanism implements HttpAuthenticationMechanism {
@Override
public AuthenticationStatus validateRequest(HttpServletRequest request,
HttpServletResponse response, HttpMessageContext context) {
}
}
Security API 1.0
@jGauravGupta
@ApplicationScoped
public class MyAuthMechanism implements HttpAuthenticationMechanism {
@Inject
private IdentityStoreHandler identityStoreHandler;
@Override
public AuthenticationStatus validateRequest(HttpServletRequest request,
HttpServletResponse response, HttpMessageContext context) {
………
identityStoreHandler.validate(credential);
………
}
}
Security API 1.0
@jGauravGupta
@ApplicationScoped
public class MyAuthMechanism implements HttpAuthenticationMechanism {
@Inject
private IdentityStoreHandler identityStoreHandler;
@Override
public AuthenticationStatus validateRequest (HttpServletRequest request,
HttpServletResponse response, HttpMessageContext context) {
………
identityStoreHandler.validate(credential);
………
}
}
Security API 1.0
@jGauravGupta
Java EE 8 App generation w/
jeddict.github.io
@Email
@JsonbProperty
("fName")
@JsonbTransient
java.time.LocalDate
@NamedQuery(name = "findAll")
@NamedQuery(name = "findByFirstName")
@NamedQuery(name = "findByEmail")
@JsonbProperty
("number")
@NotEmpty
@JsonbProperty
("lName")
OpenERP Domain model
@jGauravGupta
npm install
Java EE Tools : To boost your productivity
● Jeddict modeler
● Dynamic Code Evolution Virtual Machine
● Payara Fish in NetBeans IDE
● Payara CDI Dev Mode
● Payara AsAdmin Recorder
● Maven Plugin
@jGauravGupta
● Supports any relational database (JDBC compliant)
● Relationship mapping
○ JoinColumn to JoinTable converter and vice versa
○ java.util.Collection, java.util.Map
● Embeddable
● Inheritance
● Query Builder / Executor / Generator (JPQL, SQL, Stored Procedure, Entity Graph)
● JAXB / JSON-B
● Bean Validation
● more… Fluent API, java.util.Optional, Reverse Engineering etc.
Jeddict modeler
@jGauravGupta
JPA 2.2 modeler - Relationship
Self reference
Many-to-One
One-to-One
Many-to-Many
@jGauravGupta
JPA 2.2 modeler - Embedded
Nested Embeddable
Embedded Collection Multiple Embedded fields @jGauravGupta
JPA 2.2 modeler - Entity Inheritance
Nested Inheritance
@jGauravGupta
● Supports any relational database (JDBC compliant)
● Relationship mapping
○ JoinColumn to JoinTable converter and vice versa
○ java.util.Collection, java.util.Map
● Embeddable
● Inheritance
● Query Builder / Executor / Generator (JPQL, SQL, Stored Procedure, Entity Graph)
● Bean Validation
● JAXB / JSON-B
● more… Fluent API, java.util.Optional, Reverse Engineering etc.
Jeddict modeler
@jGauravGupta
● JRE Patch
● Update the code instantly
● DCEVM Dynamic Code Evolution VM http://dcevm.github.io/
STEP-1 : Java installation with the DCEVM engine
STEP-2 : Connect with the Payara Server
STEP-3 : Turn off redeployment of the application on save
STEP-4 : Turn on compile and apply code changes on save
Dynamic Code Evolution
@jGauravGupta
● Bean Archives
● Beans and their properties
○ such as qualifiers, stereotypes and name
● Invocation Trees
● Observers and producers declared by beans
● Interceptors and decorators
● Extensions
● Fired events
Payara CDI Dev Mode : to inspect
@jGauravGupta
● Graph of bean dependency
Payara CDI Dev Mode : to inspect
@jGauravGupta
● Graph of bean archives
Payara CDI Dev Mode : to inspect
@jGauravGupta
● Trace the admin console actions
● Create automation scripts easily
● Helps to investigate
Payara AsAdmin Recorder
@jGauravGupta
● payara-micro-maven-plugin incorporates payara-micro with produced
artifact.
● Offers 3 mojos
○ bundle
○ start
○ stop
● Plugin is available on Maven Central
<groupId>fish.payara.maven.plugins</groupId>
<artifactId>payara-micro-maven-plugin</artifactId>
<version>1.0.0</version>
Maven Plugin
@mertcal
<configuration>
<customJars>
<artifactItem>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>6.0</version>
</artifactItem>
</customJars>
</configuration>
<configuration>
<startClass>
my.custom.start.class.Main
</startClass>
<deployArtifacts>
<artifactItem>
<groupId>org.mycompany</groupId>
<artifactId>my-project</artifactId>
<version>1.0</version>
<type>ear</type>
</artifactItem>
</deployArtifacts>
<configuration>
Maven Plugin - bundle mojo config
into MICRO-INF/deploy folder
into MICRO-INF/lib folder
@mertcal
<configuration>
<useUberJar>true</useUberJar>
<daemon>true</daemon>
<javaPath>/path/to/Java/Home</javaPath>
<payaraMicroAbsolutePath>/path/to/payara-micro.jar</payaraMicroAbsolutePath>
<artifactItem>
<groupId>fish.payara.extras</groupId>
<artifactId>payara-micro</artifactId>
<version>4.1.1.171</version>
</artifactItem>
<commandLineOptions>
<option>
<key>--autoBindHttp</key>
<value>true</value>
</option>
</commandLineOptions>
</configuration>
Maven Plugin - start mojo config
@mertcal
Thank you!
Any
Questions?
%50 on ebook - JE8MEK50
%15 on printed - JE8MPK15
valid until October 11

More Related Content

What's hot (19)

PDF
Binding business data to vaadin components
Peter Lehto
 
PPTX
Jasig Cas High Availability - Yale University
Jasig CAS
 
PPTX
Apache Struts 2 Advance
Emprovise
 
PDF
React lecture
Christoffer Noring
 
PDF
Android development
Gregoire BARRET
 
PDF
Clustering your Application with Hazelcast
Hazelcast
 
PDF
Cassandra summit 2013 - DataStax Java Driver Unleashed!
Michaël Figuière
 
PDF
Quick start with React | DreamLab Academy #2
DreamLab
 
PPTX
Drools rule Concepts
RaviShankar Mishra
 
PDF
Build Widgets
scottw
 
PPTX
Apache Struts 2 Framework
Emprovise
 
PDF
BDD, ATDD, Page Objects: The Road to Sustainable Web Testing
John Ferguson Smart Limited
 
PPT
Struts2
Scott Stanlick
 
PDF
Reactивная тяга
Vitebsk Miniq
 
PDF
Enterprise Guice 20090217 Bejug
robbiev
 
PDF
Aggregation and Awareness or How to Reduce the Amount of your FrontEnd Code ...
ISS Art, LLC
 
PDF
Durable functions 2.0 (2019-10-10)
Paco de la Cruz
 
PDF
Speed up your GWT coding with gQuery
Manuel Carrasco Moñino
 
ODP
JPA Best Practices
Carol McDonald
 
Binding business data to vaadin components
Peter Lehto
 
Jasig Cas High Availability - Yale University
Jasig CAS
 
Apache Struts 2 Advance
Emprovise
 
React lecture
Christoffer Noring
 
Android development
Gregoire BARRET
 
Clustering your Application with Hazelcast
Hazelcast
 
Cassandra summit 2013 - DataStax Java Driver Unleashed!
Michaël Figuière
 
Quick start with React | DreamLab Academy #2
DreamLab
 
Drools rule Concepts
RaviShankar Mishra
 
Build Widgets
scottw
 
Apache Struts 2 Framework
Emprovise
 
BDD, ATDD, Page Objects: The Road to Sustainable Web Testing
John Ferguson Smart Limited
 
Reactивная тяга
Vitebsk Miniq
 
Enterprise Guice 20090217 Bejug
robbiev
 
Aggregation and Awareness or How to Reduce the Amount of your FrontEnd Code ...
ISS Art, LLC
 
Durable functions 2.0 (2019-10-10)
Paco de la Cruz
 
Speed up your GWT coding with gQuery
Manuel Carrasco Moñino
 
JPA Best Practices
Carol McDonald
 

Similar to Rapid Development Tools for Java EE 8 [TUT2998] (20)

PPTX
TDC2018SP | Trilha Java - Java SE 8 for Java EE Developers
tdc-globalcode
 
PPT
Java EE 7 (Hamed Hatami)
Hamed Hatami
 
PDF
50 features of Java EE 7 in 50 minutes at JavaZone 2014
Arun Gupta
 
PDF
Rapid development tools for java ee 8 and micro profile [GIDS]
Payara
 
PDF
Jakarta EE Recipes
Josh Juneau
 
PPTX
JEE.next()
Jakub Marchwicki
 
PDF
JUG Berlin Brandenburg: What's new in Java EE 7?
gedoplan
 
PDF
Java EE 8: On the Horizon
Josh Juneau
 
PDF
Java EE 8 Recipes
Josh Juneau
 
PPTX
Java EE 7 - New Features and the WebSocket API
Marcus Schiesser
 
ODP
JUDCON India 2014 Java EE 7 talk
Vijay Nair
 
ODP
Javaee6 Overview
Carol McDonald
 
PDF
Java EE 7 for WebLogic 12c Developers
Bruno Borges
 
PDF
Fifty New Features of Java EE 7 in Fifty Minutes
Arun Gupta
 
PDF
Fifty Features of Java EE 7 in 50 Minutes
glassfish
 
PDF
Java EE 7, what's in it for me?
Alex Soto
 
PPTX
JAX-RS 2.0 and OData
Anil Allewar
 
PDF
50 features of Java EE 7 in 50 minutes at Geecon 2014
Arun Gupta
 
PDF
112815 java ee8_davidd
Takashi Ito
 
PPT
Don't Wait! Develop responsive applications with Java EE7 instead
Erin Schnabel
 
TDC2018SP | Trilha Java - Java SE 8 for Java EE Developers
tdc-globalcode
 
Java EE 7 (Hamed Hatami)
Hamed Hatami
 
50 features of Java EE 7 in 50 minutes at JavaZone 2014
Arun Gupta
 
Rapid development tools for java ee 8 and micro profile [GIDS]
Payara
 
Jakarta EE Recipes
Josh Juneau
 
JEE.next()
Jakub Marchwicki
 
JUG Berlin Brandenburg: What's new in Java EE 7?
gedoplan
 
Java EE 8: On the Horizon
Josh Juneau
 
Java EE 8 Recipes
Josh Juneau
 
Java EE 7 - New Features and the WebSocket API
Marcus Schiesser
 
JUDCON India 2014 Java EE 7 talk
Vijay Nair
 
Javaee6 Overview
Carol McDonald
 
Java EE 7 for WebLogic 12c Developers
Bruno Borges
 
Fifty New Features of Java EE 7 in Fifty Minutes
Arun Gupta
 
Fifty Features of Java EE 7 in 50 Minutes
glassfish
 
Java EE 7, what's in it for me?
Alex Soto
 
JAX-RS 2.0 and OData
Anil Allewar
 
50 features of Java EE 7 in 50 minutes at Geecon 2014
Arun Gupta
 
112815 java ee8_davidd
Takashi Ito
 
Don't Wait! Develop responsive applications with Java EE7 instead
Erin Schnabel
 
Ad

Recently uploaded (20)

PDF
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
July Patch Tuesday
Ivanti
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
July Patch Tuesday
Ivanti
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Ad

Rapid Development Tools for Java EE 8 [TUT2998]

  • 1. Rapid Development Tools for Java EE 8 Mert Çalışkan, Gaurav Gupta JavaOne 2017
  • 2. Mert Çalışkan Payara Developer Java EE / Spring Consultant Author of PrimeFaces Cookbook Author of Beginning Spring book Part-time Lecturer @mertcal Gaurav Gupta Payara Developer NetBeans Dream Team Jeddict Creator ( jeddict.github.io ) @jGauravGupta , @ImJeddict
  • 3. Agenda - What’s new with Java EE 8? : Quick overview - Java EE 8 application generation w/ Jeddict - Java EE Tools : To boost your productivity - Q&A @jGauravGupta
  • 4. What’s new with Java EE8? Java EE8 is released on Sep 24, 2017. ● JAX-RS 2.1 (Jersey 2.26) ● CDI 2.0 (Weld 3.0.0.Final) ● Bean Validation 2.0 (Hibernate Validator 6.0.2.Final) ● JSON-B (Yasson 1.0) ● JPA 2.2 (EclipseLink 2.7.0) ● Java Security API 1.0 (Soteria 1.0) Checkout https://github.com/javaee-samples/javaee8-samples for details on the examples @mertcal
  • 5. ● Reactive Client API ● JSON-B support ● Server Sent Events (SSE) JAX-RS 2.1 (JSR 370) @mertcal
  • 6. ● With JAX-RS 2.0, we had asynchronous invoker approach as: Client client = ClientBuilder.newClient(); WebTarget target = client.target("http://localhost:8080/service-url"); Invocation.Builder builder = target.request(); Future<MyClass> futureResult = builder.async().get(MyClass.class); System.out.println(futureResult.get()); client.close(); Previously on JAX-RS 2.0 @mertcal
  • 7. ● Previous scenario can also be implemented with InvocationCallback<T> but… Client client = ClientBuilder. newClient(); WebTarget target = client.target( "http://localhost:8080/service-url"); Invocation.Builder builder = target.request(); builder.async().get( new InvocationCallback<MyClass>() { @Override public void completed(MyClass t) {} @Override public void failed(Throwable throwable) {} }); Previously on JAX-RS 2.0 @mertcal
  • 8. ● Reactive Client API to the rescue. Client client = ClientBuilder.newClient(); WebTarget target = client.target("http://localhost:8080/service-url"); Invocation.Builder builder = target.request(); CompletionStage<Response> response = builder.rx().get(); response.thenAcceptAsync(res -> { MyClass t = res.readEntity(MyClass.class); System.out.println(t); }); JerseyCompletionStageRxInvoker CompletionStage<Response> With JAX-RS 2.1 @mertcal
  • 9. ● 3rd Party Reactive Framework Support ○ RxJava Client client = ClientBuilder.newClient().register(RxFlowableInvokerProvider.class); WebTarget target = client.target("http://localhost:8080/service-url"); Invocation.Builder builder = target.request(); Flowable<Response> flowable = builder.rx(RxFlowableInvoker.class).get(); flowable.subscribe(res -> { MyClass t = res.readEntity(MyClass.class); System.out.println(t); }); reactive invoker specialized for io.reactivex.Flowable JAX-RS 2.1 @mertcal
  • 10. Client client = ClientBuilder.newClient().target("http://localhost:8080/service-url") .request() .get(); Client client = ClientBuilder.newClient().target("http://localhost:8080/service-url") .request() .async() .get(); Client client = ClientBuilder.newClient().target("http://localhost:8080/service-url") .request() .rx() .get(); JAX-RS 2.1 @mertcal
  • 11. ● Server Sent Events (SSE) is a mechanism that allows server to asynchronously push data from the server to client once the client-server connection is established by the client. ● It’s mostly like Long-Pooling but it’s not :) and it’s not WebSockets either. ● Implementations already provided it with JAX-RS 2.0 but there was no standard API. With JAX-RS 2.1, API is created under javax.ws.rs.sse JAX-RS 2.1 @mertcal
  • 12. @Path("/temperature") public class TemperatureResource { private final OutboundSseEvent.Builder sseEventBuilder; public TemperatureResource( @Context Sse sse) { this.sseEventBuilder = sse.newEventBuilder(); } @GET @Path("/{city}") @Produces(MediaType.SERVER_SENT_EVENTS) public void getCurrentTemperatureStream( @Context SseEventSink eventSink) { while (true) { eventSink.send( sseEventBuilder.data(temperature) .mediaType(MediaType. APPLICATION_JSON_TYPE).build()); Thread. sleep(1000); } } } "text/event-stream" 1 2 3 4 JAX-RS 2.1 @mertcal
  • 13. CDI 2.0 (JSR 365) - SE Support - It’s possible to use CDI outside of Java EE - Ordering of CDI events - @Priority helps ordering observers void receive(@Observes @Priority(APPLICATION + 200) String greet) { this.greet += greet + "2"; } void receive2(@Observes @Priority(APPLICATION) String greet) { this.greet = greet + "1"; } For send(“Welcome”) output will be: Welcome1Welcome2 @Inject private Event<String> event; public void send(String message) { event.fire(message); } @mertcal
  • 14. CompletableStage<MyEvent> eventSent = event.fireAsync( new MyEvent(), NotificationOptions.ofExecutor(executor)); - Exception in async observer doesn’t break the observer invocation chain. callMe(@Observes payload) callMe(@ObservesAsync payload) event.fire(payload) Sync call Not Notified event.fireAsync(payload) Not Notified Async call - Long awaited Asynchronous Events Support - Fire Sync → Observer Sync / Fire Async → Observer Async CDI 2.0 @mertcal
  • 15. ● Java 8 Date and Time API Support @Past(message = "must be a past date") private java.time.Year yearOfBirth; ● Type Annotations private List<@NotNull @Email String> emails; private String @NotNull @Email[] emails; private Map<@Valid Employee, @Valid Address> addressMap = new HashMap<>(); @mertcal Bean Validation 2 (JSR 380)
  • 16. ● java.util.Optional Support private Optional<@Past LocalDate> marriageAnniversary; private Optional<@Size(max = 20) String> name; ● Repeating Annotations @Max(value = 2000, groups = Default.class) @Max(value = 5000, groups = GoldCustomer.class) private long withdrawalAmount; @mertcal Bean Validation 2
  • 17. Bean Validation 2 ● Introduces new constraints ○ @Email ○ @NotBlank ○ @NotEmpty ○ @PastOrPresent ○ @FutureOrPresent ○ @Negative ○ @NegativeOrZero ○ @Positive ○ @PositiveOrZero @mertcal
  • 18. JSON-B (JSR 367) ● Standard solution like JAXB ● Default mapping between classes and JSON ● Customizable a. Compile time ■ Property naming @JsonbProperty ■ Property ignoring @JsonbTransient ■ Null handling @JsonbNillable ■ Property ordering @JsonbPropertyOrder ■ Date and Number Format @JsonbDateFormat/@JsonbNumberFormat ■ Adapter @JsonbTypeAdapter b. Runtime configration ■ Configuration builder JsonbConfig @jGauravGupta
  • 19. JSON-B - Default mapping class Employee { private String name; private String pin; private String email; } { "name": "Gaurav", "pin": "J1-Secret", "email": "[email protected]", } @jGauravGupta
  • 20. JSON-B - Custom mapping @JsonbPropertyOrder({"email", "name"}) class Employee { @JsonbProperty("empName") private String name; @JsonbTransient private String pin; private String email; } { "email": "[email protected]", "empName": "Gaurav" } @jGauravGupta
  • 21. JPA 2.2 (JSR 338) ● @Repeatable annotations ● Support Java 8 Date and Time API ● Ability to return stream of query result ● CDI Injection in AttributeConverters @jGauravGupta
  • 22. JPA 2.1 Container annotation required @Entity @NamedQueries({ @NamedQuery(name = "Employee.findAll", query = "SELECT e FROM Employee e"), @NamedQuery(name = "Employee.findByName", query = "SELECT e FROM Employee e WHERE e.name = :name") }) class Employee { @Convert(converter=LocalDateConverter.class) private LocalDate dateOfBirth; } AttributeConverter implementation @jGauravGupta
  • 23. JPA 2.2 Container annotation not required @Entity @NamedQueries({ @NamedQuery(name = "Employee.findAll", query = "SELECT e FROM Employee e"), @NamedQuery(name = "Employee.findByName", query = "SELECT e FROM Employee e WHERE e.name = :name") }) class Employee { @Convert(converter=LocalDateConverter.class) private LocalDate dateOfBirth; } AttributeConverter not required @jGauravGupta
  • 24. JPA 2.2 @Entity @NamedQuery(name = "Employee.findAll", query = "SELECT e FROM Employee e") @NamedQuery(name = "Employee.findByName", query = "SELECT e FROM Employee e WHERE e.name = :name") class Employee { private LocalDate dateOfBirth; } @jGauravGupta
  • 25. JPA 2.2 ● Stream query results Stream<Employee> employees = em.createQuery(“SELECT e FROM Employee”, Employee.class) .getResultStream(); @jGauravGupta
  • 26. Security API 1.0 (JSR 375) ● Simplify the existing solution ● Enhance the portability ● New APIs ○ HTTPAuthenticationMechanism ○ IdentityStore ○ SecurityContext @jGauravGupta
  • 27. Security API 1.0 (JSR 375) ● HTTP Authentication Mechanism ○ validateRequest(request, response, httpMessageContext) ○ secureResponse(request, response, httpMessageContext) ○ cleanSubject(request, response, httpMessageContext) ● Identity Store ○ validate(credential) ○ getCallerGroups(credentialValidationResult) ● Security Context ○ getCallerPrincipal() ○ isCallerInRole(role) ○ … … … @jGauravGupta
  • 28. @ApplicationScoped public class MyAuthMechanism implements HttpAuthenticationMechanism { @Override public AuthenticationStatus validateRequest(HttpServletRequest request, HttpServletResponse response, HttpMessageContext context) { } } Security API 1.0 @jGauravGupta
  • 29. @ApplicationScoped public class MyAuthMechanism implements HttpAuthenticationMechanism { @Inject private IdentityStoreHandler identityStoreHandler; @Override public AuthenticationStatus validateRequest(HttpServletRequest request, HttpServletResponse response, HttpMessageContext context) { ……… identityStoreHandler.validate(credential); ……… } } Security API 1.0 @jGauravGupta
  • 30. @ApplicationScoped public class MyAuthMechanism implements HttpAuthenticationMechanism { @Inject private IdentityStoreHandler identityStoreHandler; @Override public AuthenticationStatus validateRequest (HttpServletRequest request, HttpServletResponse response, HttpMessageContext context) { ……… identityStoreHandler.validate(credential); ……… } } Security API 1.0 @jGauravGupta
  • 31. Java EE 8 App generation w/ jeddict.github.io @Email @JsonbProperty ("fName") @JsonbTransient java.time.LocalDate @NamedQuery(name = "findAll") @NamedQuery(name = "findByFirstName") @NamedQuery(name = "findByEmail") @JsonbProperty ("number") @NotEmpty @JsonbProperty ("lName") OpenERP Domain model
  • 33. Java EE Tools : To boost your productivity ● Jeddict modeler ● Dynamic Code Evolution Virtual Machine ● Payara Fish in NetBeans IDE ● Payara CDI Dev Mode ● Payara AsAdmin Recorder ● Maven Plugin @jGauravGupta
  • 34. ● Supports any relational database (JDBC compliant) ● Relationship mapping ○ JoinColumn to JoinTable converter and vice versa ○ java.util.Collection, java.util.Map ● Embeddable ● Inheritance ● Query Builder / Executor / Generator (JPQL, SQL, Stored Procedure, Entity Graph) ● JAXB / JSON-B ● Bean Validation ● more… Fluent API, java.util.Optional, Reverse Engineering etc. Jeddict modeler @jGauravGupta
  • 35. JPA 2.2 modeler - Relationship Self reference Many-to-One One-to-One Many-to-Many @jGauravGupta
  • 36. JPA 2.2 modeler - Embedded Nested Embeddable Embedded Collection Multiple Embedded fields @jGauravGupta
  • 37. JPA 2.2 modeler - Entity Inheritance Nested Inheritance @jGauravGupta
  • 38. ● Supports any relational database (JDBC compliant) ● Relationship mapping ○ JoinColumn to JoinTable converter and vice versa ○ java.util.Collection, java.util.Map ● Embeddable ● Inheritance ● Query Builder / Executor / Generator (JPQL, SQL, Stored Procedure, Entity Graph) ● Bean Validation ● JAXB / JSON-B ● more… Fluent API, java.util.Optional, Reverse Engineering etc. Jeddict modeler @jGauravGupta
  • 39. ● JRE Patch ● Update the code instantly ● DCEVM Dynamic Code Evolution VM http://dcevm.github.io/ STEP-1 : Java installation with the DCEVM engine STEP-2 : Connect with the Payara Server STEP-3 : Turn off redeployment of the application on save STEP-4 : Turn on compile and apply code changes on save Dynamic Code Evolution @jGauravGupta
  • 40. ● Bean Archives ● Beans and their properties ○ such as qualifiers, stereotypes and name ● Invocation Trees ● Observers and producers declared by beans ● Interceptors and decorators ● Extensions ● Fired events Payara CDI Dev Mode : to inspect @jGauravGupta
  • 41. ● Graph of bean dependency Payara CDI Dev Mode : to inspect @jGauravGupta
  • 42. ● Graph of bean archives Payara CDI Dev Mode : to inspect @jGauravGupta
  • 43. ● Trace the admin console actions ● Create automation scripts easily ● Helps to investigate Payara AsAdmin Recorder @jGauravGupta
  • 44. ● payara-micro-maven-plugin incorporates payara-micro with produced artifact. ● Offers 3 mojos ○ bundle ○ start ○ stop ● Plugin is available on Maven Central <groupId>fish.payara.maven.plugins</groupId> <artifactId>payara-micro-maven-plugin</artifactId> <version>1.0.0</version> Maven Plugin @mertcal
  • 47. Thank you! Any Questions? %50 on ebook - JE8MEK50 %15 on printed - JE8MPK15 valid until October 11