1. Java EE 7 – New
Features?
Presenter: Shahzad Badar
2. Agenda
Who am I?
Java EE 7 – New Features?
Pakistan Java User Group
3. Who am I?
A programmer working on java since
2002
Spent most of the time in Islamabad
Leading Pakistan Java User Group
Working in Royal Cyber
Pakistan Java User Group
7. Java EE 6 - Achievements
50,000,000 + downloads
#1 choice for enterprise developers
#1 application development platform
Fastest adoptions of any Java EE release – 18 complaint
servers
Pakistan Java User Group
8. Java EE 6 – Main Features
Web Profile
EJB packaged in war
Optional web.xml
Type-safe dependency injection
CDI Events
JSF standardizing on facelets
@Schedule
Pakistan Java User Group
11. Active JSRs
JSR 342: Java EE 7 Platform
JSR 338: Java API for RESTful Web Services 2.0
JSR 339: Java Persistence API 2.1
JSR 340: Servlet 3.1
JSR 341: Expression Language 3.0
JSR 343: Java Message Service 2.0
JSR 344: JavaServer Faces 2.2
JSR 345: Enteprise JavaBeans 3.2
JSR 346: Contexts and Dependency Injection 1.1
JSR 349: Bean Validation 1.1
JSR 236: Concurrency Utilities for Java EE 1.0
JSR 352: Batch Applications for the Java Platform 1.0
JSR 353: Java API for JSON Processing 1.0
JSR 356: Java API for WebSocket 1.0
Pakistan Java User Group
12. Concurrency and Java EE
Managing your own threads within a Java EE container is
not recommended
Using java.util.concurrent API in a Java EE application
component such as EJB or Servlet are problematic since the
container and server have no knowledge of these resource
Provides simple, safe API for concurrency in Java EE
Builds on Java SE concurrency
java.util.concurrent.ExecutorService
Pakistan Java User Group
14. Batch Applications for the Java
Platform
Batch processing is execution of series of "jobs"
that is suitable for non-interactive, bulk-oriented
and long-running tasks.
no standard Java programming model existed for
batch applications.
Pakistan Java User Group
16. Java EE Web Profile Enhancements
The Java Enterprise Edition Web Profile was introduced
in Java EE 6
Most Web applications have significant requirements
in the areas of transaction management, security, and
persistence.
but are not supported by standalone servlet containers
Web Profile is provided with pre-installed, pre-
integrated, fully tested Web infrastructure features.
The Java EE 7 Web Profile adds support for HTML5
with WebSockets, JSON, JAX-RS 2.0, and more.
Pakistan Java User Group
17. Bean Validation 1.1
Method constraints
Bean Validation artifacts injectable
Fixes, clarifications and enhancements
Pakistan Java User Group
18. Bean Validation 1.1
Method Level Constraints
Pakistan Java User Group
public void placeOrder( @NotNull String productName,
@NotNull @Max(“10”) Integer quantity,
@Customer String customer) {
. . .
}
@Future
public Date getAppointment() {
. . .
}
19. JSF 2.2
HTML5 Support
@FlowScoped
@ViewScoped for CDI
Managed beans deprecated/CDI alignment
File upload component
View actions
Multi-templating
Security
Fixes and enhancements
Pakistan Java User Group
20. JSON Processing Support
JSON (JavaScript Object Notation) is a lightweight data-interchange
format. It is easy for humans to read and write.
It is easy for machines to parse and generate.
It is based on a subset of the JavaScript Programming
Language, Standard ECMA-262 3rd Edition - December 1999.
JSON is a text format that is completely language independent but uses
conventions that are familiar to programmers
Pakistan Java User Group
{
“employee": [
{ "firstName":"John" , "lastName":"Doe" },
{ "firstName":"Anna" , "lastName":"Smith" },
{ "firstName":"Peter" , "lastName":"Jones" }
]
}
JSON Example
21. JSON Implementations for Java
org.json.
org.json.me.
Jackson JSON Processor.
Json-lib.
JSON Tools.
Stringtree.
SOJO.
Jettison.
json-taglib.
XStream.
Flexjson.
JON tools.
Argo.
jsonij.
fastjson.
mjson.
jjson.
json-simple.
json-io.
JsonMarshaller.
google-gson.
Json-smart.
FOSS Nova JSON.
Corn CONVERTER.
Pakistan Java User Group
a lot of implementations for other languages
22. Why we need another API?
Pakistan Java User Group
• JSON has become a defacto data transfer standard specially for
RESTful Web Services.
• Java applications use different implementations to consume and
process JSON data
• There should be standardized Java API for JSON so that
applications do not need to bundle the implementation libraries
23. JSON Processing Support
API to parse and generate JSON
Streaming API
Low level efficient way to parse/generate JSON
Provide pluggability for parser/generator
Object Model
Simple, Easy-to-use high-level API
Implemented on top of Streaming API
Pakistan Java User Group
24. Java API for JSON Processing
Writing JSON (Object Model API)
Pakistan Java User Group
“employees": [
{ “firstName": “Asif", “lastName": ”Naveed” },
{ “firstName": “Khalid", “lastName": ”Ali” }
]
JsonObject jsonObject =
new JsonBuilder() .beginArray(“employees")
.beginObject() .add(“firstName", “Asif")
.add(“lastName", “Naveed") .endObject()
.beginObject () .add(“firstName", “Khalid")
.add(“lastName", “Ali").endObject()
.endArray() .build();
26. Web Socket Support
In age of Web 2.0 / 3.0 , We need interactive websites
Pakistan Java User Group
but
In the standard HTTP model, a server cannot initiate a connection
with a client nor send an unrequested HTTP response to a client;
thus, the server cannot push asynchronous events to clients.
27. Why WebSocket?
HTTP is half duplex
HTTP is verbose
Hacks for Server Push
Polling
Long Polling
Comet/Ajax
Complex, Wasteful, Inefficient
Pakistan Java User Group
32. WebSocket to rescue
TCP based, bi-directional, full-duplex messaging
Capable of sending both UTF-8 string and binary
frames in any direction at the same time
Operating from a single socket across the web
As part of HTML5, the application of the client
interface will become native to all modern browsers
To establish a Web Socket connection, the browser or
client simply makes a request to the server for an
upgrade from HTTP to a Web Socket
Pakistan Java User Group
34. Pakistan Java User Group
“Reducing kilobytes of data to 2
bytes…and reducing latency from
150ms to 50ms is far more than
marginal. In fact, these two factors
alone are enough to make Web Sockets
seriously interesting to Google.”
36. WebSocket API
Connection Life Cycle
@Singleton
@WebSocketEndpoint(path=”/chat”)
public class ChatServer {
Set<Session> peers = ...
@WebSocketOpen
public void onOpen(Session peer) { peers.add(session);
}
@WebSocketClose
public void onClose(Session session) {
peers.remove(session);
}
...
Pakistan Java User Group
37. WebSocket API
WebSocket Communication
. . .
@WebSocketMessage
public void message(String message, Session client)
throws IOException {
for (Session session : peers) {
if (!session.equals(client)) {
session.getRemote().sendObject(message);
}
}
}
}
Pakistan Java User Group
38. JPA 2.1 – New Features
The first spec to include new features is the JPA 2.1. The new
features can be described with the following short list:
Multi-Tenancy (Table discriminator)
Stored Procedures
Custom types and transformation methods - Query
by Example
Dynamic PU Definition
Schema Generation (Additional mapping metadata
to provide better standardization)
Pakistan Java User Group
39. Servlet 3.1 – New Features
NIO.2 async I/O
Leverage Java EE concurrency
Security improvements
Web Sockets support
Ease-of-Development
Pakistan Java User Group
40. Enteprise JavaBeans 3.2 – New
Features
The scope of EJB 3.2 is intended to be relatively
constrained in focusing on these goals.
Incremental factorization (Interceptors)
Further use of annotations to simplify the EJB
programming model
Proposed Optional: BMP/CMP
Proposed Optional: Web Services invocation using
RPC
Pakistan Java User Group
41. Java EE 8 Plan
JSON-B
JCache
More CDI/EJB alignment
Cloud, PaaS, multitenancy/SaaS
JMS.next()?
JAX-RS.next()?
Modularity?
NoSQL?
Action-oriented Web framework/HTML 5?
Configuration API?
Security?
Pakistan Java User Group