Java EE8 - by Kito Mann
-
Upload
kile-niklawski -
Category
Technology
-
view
70 -
download
1
Transcript of Java EE8 - by Kito Mann
Kito D. Mann@kito99
• Principal Consultant at Virtua (http://virtua.tech)
• Training, consulting, architecture, mentoring
• PrimeFaces, JSF, Java EE, Polymer, Web Components, Liferay, etc.
• Official US PrimeFaces partner
• Author, JavaServer Faces in Action
• Founder, JSF Central (http://www.jsfcentral.com)
Kito D. Mann@kito99
•Co-host, Enterprise Java Newscast
•http://enterprisejavanews.com
• Internationally recognized speaker
• JavaOne, JavaZone, Devoxx, Devnexus, NFJS, etc.
• JCP Member
• JSF, MVC, JSF Portlet Bridge, Portlets
Agenda• Overview of the specifications that are part
of Java EE 8, provide current status
• Examples of Proposed Enhancements and New Features
• What the current status of Java EE 8 progress is and what you can do to help
The Importance of Java EE to the Ecosystem
https://javaee-guardians.io/java-ee-adoption-surveys
Java EEPast, Present, Future
J2EE 1.2
Servlet, JSP, EJB, JMS, RMI
J2EE 1.3
CMP,JCA
J2EE 1.4
Web Services,
Mgmt, Deplymnt
Java EE 5
Ease of Use,
EJB 3, JPA, JSF,
JAXB,JAX-WS
Java EE 6
Pruning,Ease of Use,
JAX-RS,CDI,
Bean-Validation
Servlet 3,EJB 3.1 Lite
Java EE 7
JMS 2, Batch, TX,
Concurrency,Web-Sockets,
JSON
Java EE 8
SERVLET 4, JSON-B,
JSON-P 1.1, JSF 2.3, CDI
2.0, JAX-RS 2.1,
SECURITY, MVC,
MANAGEMENT
Java EE Past, Present, & Future
J2EE 1.3
CMP,JCA
J2EE 1.4
Web Services,
Mgmt, Deplymnt
Java EE 5
Ease of Use,
EJB 3, JPA, JSF,
JAXB,JAX-WS
Java EE 6
Pruning,Ease of
Use,JAX-RS,
CDI,Bean-
Validation
Servlet 3,EJB 3.1
Lite
Java EE 7
JMS 2, Batch, TX, Concurr,
Web-Sockets,
JSON
JAX-RS 2
JAX-RPC, CMP/ BMP, JSR 88
J2EE 1.2
Servlet, JSP, EJB, JMS, RMI
Java EE Past, Present, & Future
Java EE 5
Ease of Use,
EJB 3, JPA, JSF,
JAXB,JAX-WS
Java EE 6
Pruning,Ease of
Use,JAX-RS,
CDI,Bean-
Validation
Web Profile
Servlet 3,EJB 3.1
Lite
Java EE 7
JMS 2, Batch, TX, Concurr,
Web-Sockets,
JSON
Web Profile
JAX-RS 2
JAX-RPC, CMP/ BMP, JSR 88
J2EE 1.3
CMP,JCA
J2EE 1.4
Web Services,
Mgmt, Deplymnt
J2EE 1.2
Servlet, JSP, EJB, JMS, RMI
Java EE Past, Present, & Future
J2EE 1.3
CMP,JCA
J2EE 1.4
Web Services,
Mgmt, Deplymnt
Java EE 5
Ease of Use,
EJB 3, JPA, JSF,
JAXB,JAX-WS
Java EE 6
Pruning,Ease of
Use,JAX-RS,
CDI,Bean-
Validation
Web Profile
Servlet 3,EJB 3.1
Lite
Java EE 7
JMS 2, Batch, TX, Concurr,
Web-Sockets,
JSON
JAX-RS 2
JAX-RPC, CMP/ BMP, JSR 88
J2EE 1.2
Servlet, JSP, EJB, JMS, RMI
Java EE Past, Present, & Future
J2EE 1.3
CMP,JCA
J2EE 1.4
Web Services,
Mgmt, Deplymnt
Java EE 5
Ease of Use,
EJB 3, JPA, JSF,
JAXB,JAX-WS
Java EE 6
Pruning,Ease of
Use,JAX-RS,
CDI,Bean-
Validation
Web Profile
Servlet 3,EJB 3.1
Lite
Java EE 7
JMS 2, Batch, TX, Concurr,
Web-Sockets,
JSON
Web Profile
JAX-RS 2
JAX-RPC, CMP/ BMP, JSR 88
J2EE 1.2
Servlet, JSP, EJB, JMS, RMI
Java EE 8 Community Survey
https://java.net/downloads/javaee-spec/JavaEE8_Community_Survey_Results.pdf
https://blogs.oracle.com/ldemichiel/entry/results_from_the_java_ee
Java EE 8: Original Plan
• Continued Enhancements for Web Standards Alignment•HTTP2, JSON Binding, JSON-P, MVC
•Cloud enhancements•Security, RESTful Management API
•CDI Programming Model•Ease of use, EJB via CDI
•Smaller, but Important Features•Caching, Better Messaging
•Alignment with Java SE 8
Java EE 8Original Overview
• JMS 2.1• JAX-RS 2.1• JSF 2.3• CDI 2.0• JSON-P 1.1• Servlet 4.0
• JCache 1.0
• JSON-B 1.0
• MVC 1.0
• Java EE Security1.0
• Java EE Management 2.0
Java EE 8: New Proposal
Expected release: Q4 2017• JMS 2.1• JAX-RS 2.1• JSF 2.3• CDI 2.0• JSON-P 1.1• Servlet 4.0
• JCache 1.0
• JSON-B 1.0
• MVC 1.0
• Java EE Security 1.0
• Java EE Management 2.0●Health Checking●Configuration
Java EE 9: New Proposal
Expected release: Q4 2018• Increased focus on microservices and cloud
• Proposed new features:
• Multi-tenancy
• Circuit-breaker
• Reactive programming support
Servlet 4.0• Principal goal to support HTTP 2
• Modernization of internet protocol
• Boost web performance
• Early Draft has been published
• Join mailing list or follow expert group (JSR 369)
• Keep tabs on Ed Burns’ presentations, although not anything new since JavaOne 2015
Servlet 4.0• HTTP 2 Support -> Major Update
• Why do we need HTTP 2?
• Problems with HTTP 1.1
• Head-of-Line Blocking
•HTTP Pipelining, File Concatenation, & Image Sprites
Servlet 4.0HTTP 2
• Request/Response Multiplexing
• Binary Framing
• Socket Optimization
• Upgrade from HTTP 1.1
Servlet 4.0Exposing HTTP 2
• Stream Prioritization
• New class Priority
• Enhance HttpServletRequest and HttpServletResponse to accommodate
• Server Push
• Not replacing WebSockets
Servlet 4.0Newer HttpClient API (Java
SE 9)
• Plans to provide easy to use API
• Support both HTTP/1.1 and 2
• Builds on existing Java API Classes
JMS 2.1(Proposed for Removal)
• JSR 368 - In early stages
• No builds available for testing, as yet.
• Planning: https://java.net/projects/jms-spec/pages/JMS21Planning
JMS 2.1• JMS 2.0 was a major overhaul• Continuation of API Modernization• Declarative Message Listeners
• Alternative to MDB• More Powerful Features• Available to all Beans
JMS 2.1
• JMS Provider Portability Improvements• Dead Message Queues
• Redelivery Behavior on JMS MDB Rollback (delays, max # consecutive)
JMS 2.1Asynchronous Batches
• In JMS 2.0, messages delivered asynchronously by calling: javax.jms.MessageListener onMessage(Message message)
• Define new: javax.jms.BatchMessageListener onMessages(Message[] messages)
JMS 2.1Declarative JMS Listeners
@ApplicationScoped@MaxConcurrency(10)public class HandlingEventRegistrationAttemptConsumer { @JmsListener( destinationLookup="jms/HandlingEventRegistrationAttemptQueue", selector="source = 'mobile'", batchSize=10, retry=5, retryDelay=7000, orderBy=TIMESTAMP) @Transactional public void onEventRegistrationAttempt( HandlingEventRegistrationAttempt... attempts) {
... }}
JAX-RS 2.1
• JSR 370 - In Early Stages
• No builds available for testing
• Follow JSR-370 EG and Mailing Lists
JAX-RS 2.1• Hypermedia API
• Reactive API
• Security API
• Support for SSE (Server Sent Events)
• Improved CDI Integration
• Support for Non-Blocking IO in Providers
JSF 2.3
• JSR 372 - in active progress
• Milestones available for testing
• Read, Test, Supply Feedback
JSF 2.3• Enhanced CDI Integration
• Lifecycle Enhancements
• PostRenderViewEvent
• EL API Enhancements
• Configuration Enhancements
• AJAX Enhancements
JSF 2.3Enhanced CDI Integration
• Injection of Resources@Inject FacesContext facesContext;
@ApplicationMap @Inject Map applicationMap;
JSF 2.3Enhanced CDI Integration
• Wider Support of Injection into JSF Artifacts
• javax.faces.convert.Converter
• javax.faces.validator.Validator
• javax.faces.component.behavior.Behavior
• Upgraded to CDI qualifiers
CDI 2.0
• JSR 365 - in active progress
• Test Releases of Reference Implementation (Weld 3.0.0 Alphas)
• http://weld.cdi-spec.org/news/
• Follow the Expert Group
CDI 2.0• Java SE Bootstrap• XML Configuration• Asynchronous Events@S@tar• @Startup for CDI Beans•Portable Extension SPI Simplification•Small features and enhancements
CDI 2.0Event System Enhancements
• Asynchronous Events
•Call to event.fireAsync() returns immediately
@Injectprivate ExperimentalEvent<Configuration> event;
…
event.fireAsync(new Configuration());
CDI 2.0@Schedule Outside EJB
@ApplicationScopedpublic class MyScheduledBean { ... @Schedule(...) public void myScheduledTask() { ... }}
@ApplicationScoped@Stereotype@Retention(RUNTIME)@Target(TYPE)@Schedule(...)public @interface MonthlyTask {}
JSON-P 1.1
• JSR 374 - In Early Draft Review
• More Information:
• https://json-processing-spec.java.net/
• Sources: https://java.net/projects/jsonp
JSON-P 1.1• Updates to new API in Java EE 7
• New JSON Standards
• JSON-Pointer and JSON-Patch
• Editing Operations on JSON objects and arrays
• Helper Classes and Enhanced Java SE 8 support
JSON-P 1.1Java SE 8 Support
• Stream SupportJsonArray persons;persons.getValuesAs(JsonObject.class).stream() .filter(x->x.getString(“age”) >= 65) .forEach(System.out.println(x.getString(“name”)));
JSON-P 1.1JSON-Patch
public void shouldBuildJsonPatchExpressionUsingJsonPatchBuilder() { JsonPatchBuilder patchBuilder = new JsonPatchBuilder();
JsonObject result = patchBuilder.add("/email”,"[email protected]").replace("/age", 30) .remove("/phoneNumber”) .test("/firstName", "John”) .copy("/address/lastName", "/lastName”) .apply(buildPerson());}
Java EE Management API 2.0
(Proposed for Removal)
• Currently working on Early Draft
• Join mailing list of JSR 373
Java EE Management API 2.0
• REST Based Interface to Supersede EJB Management APIs of JSR 77
• Monitoring and deployment as well
• SSE for Event Support (WebSockets also under consideration)
MVC(Proposed for Removal)
• Model - View - Controller
• JSR 371
• Active Progress…download milestones
• Ozark: https://ozark.java.net/
MVC• Action-Based Web Framework for Java EE
• Follows suit of Spring MVC or Apache Struts
• Does Not Replace JSF
• Model: CDI, Bean Validation, JPA
• View: Facelets, JSP (Extensible)
• Controller: Layered on top of JAX-RS
MVCController Example
@Controller@Path("/customers")@View("my-view.jsp")public class CustomerController { @Inject private Models models; @GET public String getItems(){ ... return “customers.jsp”;}
MVCView Example
<c:forEach var="customer" items="${customers}"> <tr> <td class="text-left">${customer.name}</td> <td class="text-center"> <form action="${pageContext.request.contextPath}/r/customers/edit" method="POST"> <input type="hidden" name="id" value="${item.id}"/> <button type="submit"> Edit </button> </form> </td> </tr></c:forEach>
JSON-B
• Java API for JSON Binding
• JSR 367 - Public Review
• Read the spec, start testing: https://java.net/projects/jsonb-spec/pages/Home
JSON-B• Standardize means of converting JSON to
Java objects and vice versa
• Default mapping algorithm for converting Java classes
• Draw from best of breed ideas in existing JSON binding solutions
• Provide JAX-RS a standard way to support “application/json” for POJOs
• JAX-RS currently supports JSON-P
JSON-BMapping
@Entity public class Person {
@Id String name;
String gender;
@ElementCollection
Map<String, String> phones;
...
}
Person duke = new Person();
duke.setName("Duke");
duke.setGender("Male");
phones = new HashMap<>();
phones.put("home", "650-123-4567");
phones.put("mobile",
"650-234-5678");
duke.setPhones(phones);
{
"name":"Duke",
"gender":"Male",
"phones":{
"home":"650-123-4567",
"mobile":"650-234-5678"
}
}
JSON-BProposed API - Custom
Mapping• Utilization of annotations to map fields to JSON
Document Elements{ poolType : “Inground”,}
@JsonProperty(“poolType”)
public String poolType;
{ poolType : “Inground”, shape : “Rectangle”}
@JsonPropertyOrder(“poolType”,
”shape”)
public class Pool(){
public String poolType;
public String shape;
…
}
Java EE Security• JSR 365
• Early Draft Development
• Improve Java EE platform by ensuring that the security API is useful in the modern cloud/PaaS paradigm
• Simplify, standardize, modernize
• Promotes modern concepts (EL and CDI)
Java EE Security
• Simple security providers
• Easy pluggability and mapping
• Enabling Existing Security Annotations for all beans
Java EE SecurityProposed Security Provider
@SecurityProvider
public class MySecurityProvider {
@Inject UserService userService;
@OnAuthentication
// The parameters could suit the credentials mechanism being used.
public Principal getPrincipal(String username, String password) {
// Construct the principal using the user service.
}
@OnAuthorization
public String[] getRoles (Principal principal) {
// Construct an array of roles using the principal and user service.
}
}
Java EE Security
• Proposed Idea Examples:
• https://github.com/javaee-security-spec/javaee-security-proposals
JCache• Java Temporary Caching API
• JSR 107 - Started in 2001
• Finished in 2014
• Provides a common way for Java applications to create, access, update, and remove entries from caches
JCache• Provide applications with caching
functionality…particularly the ability to cache Java objects
• Define common set of caching concepts & facilities
• Minimize learning curve• Maximize portability• Support in-process and distributed cache
implementations
JCache
• Unknown status...not mentioned in the Oracle update
• Make use of JCache with some application servers now with CDI
Health Checking• Newly proposed specification, geared
towards monitoring the health of microservices
• Client-side standard• Automatic, periodic, and self-monitoring• Possibly statistics
Configuration• Standard for externalizing configuration• Aimed at cloud based environments• Provide the ability to change one or more
configurations that are independent/decoupled of apps...multiple configuration files
• Unified API for accessing configuration in many different environments
• Layering and Overrides
Java EE 8 Timeline
Q4 2014Expert Groups
Q4 2015 Early Draft
Q1 2016Public
Review
Q3 2016 Proposed
FinalDraft
H2 2017? Final
Release
Java EE.Next
Java EE 8: Take Action
• Start working with Java EE 8 today
• Tools:
• GlassFish v4.1, Payara 5 Branch
• Milestones
• Examples and Specification Docs
Adopt-A-JSR
• Started in 2007, easy way for JUGs to get involved
• What you can do depends upon what you want to do & what spec leads are looking for
Share
Feedback
Follow Expert Groups
Read early
drafts/javadoc
Test early
versions
Write or speak about the technology!