SlideShare a Scribd company logo
What’s New in the Java EE Platform
Alpes JUG - March 2014
!
David Delabassee
@delabassee
Software Evangelist - Oracle
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!2
Program Agenda
A look at some of the important
new features of Java EE 7
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!3
Java EE 7 Momentum
ACTIVEPROJECTS
26
Active and
transparent
mailing lists
JSRsADOPTED
22
JUGs
19
Adopt a JSR
PROMOTEDBUILDS
89
GlassFish
YOU
187
COMPANIES
32
EXPERTS
SPECLEADS
16
ACTIVEJSRs
14
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!4
Java EE 7 Momentum
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!5
Java EE 7 Themes
ENTERPRISE
EDITION
▪ Batch
▪ Concurrency
▪ Simplified JMS
▪ More annotated POJOs
▪ Less boilerplate code
▪ Cohesive integrated 

platform
DEVELOPER
PRODUCTIVITY
▪ WebSockets
▪ JSON
▪ Servlet 3.1 NIO
▪ REST
MEETING 

ENTERPRISE
DEMANDS
Java EE 7
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Java EE 7 JSRs

New or Updated
▪ JPA 2.1
▪ JAX-RS 2.0
▪ EJB 3.2
▪ JMS 2.0
▪ Servlet 3.1
▪ EL 3.0
▪ JSF 2.2
▪ CDI 1.1
▪ Bean Validation 1.1
▪ WebSocket 1.0
▪ JSON 1.0
▪ Batch Applications 1.0
▪ Concurrency Utilities 1.0
!6
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Java EE 7 Maintenance Releases
▪ Common Annotations 1.2
▪ JTA 1.2
▪ Interceptors 1.2
▪ Connector 1.7
▪ JSP 2.3
▪ JASPIC 1.2
▪ JACC 1.4
▪ JavaMail 1.5
▪ Web Services 1.4
!7
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!8
JSON Processing 1.0
▪ API to parse and generate JSON
▪ Streaming API (javax.json.stream)
– Low-level, efficient way to parse/generate JSON
– Similar to StAX API in XML world
▪ Object model API (javax.json)
– Simple, easy to use high-level API
– Similar to DOM API in XML world
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!9
JSON Processing 1.0
▪ Created using
– Json.createParser(…)!
– Json.createParserFactory().createParser(…)!
▪ Parses JSON in streaming way from input sources
Event event = parser.next(); // START_OBJECT!
event = parser.next(); // KEY_NAME!
event = parser.next(); // VALUE_STRING!
▪ Parser state events
– START_OBJECT, END_OBJECT, START_ARRAY, END_ARRAY,
KEY_NAME, VALUE_STRING, VALUE_NUMBER, …
Streaming API: Parsing
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!10
JSON Processing 1.0
{!
“firstName”:“John”,“lastName”: “Smith”,“age”: 25,!
“phoneNumber”: [!
{“type”: “home”, “number”: “212 555-1234” },!
{“type”: “fax”, “number”: “646 555-4567” }!
]!
}
Streaming Parser
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!11
JSON Processing 1.0
{!
“firstName”:“John”,“lastName”: “Smith”,“age”: 25,!
“phoneNumber”: [!
{“type”: “home”, “number”: “212 555-1234” },!
{“type”: “fax”, “number”: “646 555-4567” }!
]!
}
Streaming Parser
START_OBJECT
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!12
JSON Processing 1.0
{!
“firstName”:“John”,“lastName”: “Smith”,“age”: 25,!
“phoneNumber”: [!
{“type”: “home”, “number”: “212 555-1234” },!
{“type”: “fax”, “number”: “646 555-4567” }!
]!
}
Streaming Parser
KEY_NAME
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!13
JSON Processing 1.0
{!
“firstName”:“John”,“lastName”: “Smith”,“age”: 25,!
“phoneNumber”: [!
{“type”: “home”, “number”: “212 555-1234” },!
{“type”: “fax”, “number”: “646 555-4567” }!
]!
}
Streaming Parser
VALUE_STRING
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!14
JSON Processing 1.0
{!
“firstName”:“John”,“lastName”: “Smith”,“age”: 25,!
“phoneNumber”: [!
{“type”: “home”, “number”: “212 555-1234” },!
{“type”: “fax”, “number”: “646 555-4567” }!
]!
}
Streaming Parser
VALUE_NUMBER
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!15
JSON Processing 1.0
{!
“firstName”:“John”,“lastName”: “Smith”,“age”: 25,!
“phoneNumber”: [!
{“type”: “home”, “number”: “212 555-1234” },!
{“type”: “fax”, “number”: “646 555-4567” }!
]!
}
Streaming Parser
START_ARRAY
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!16
JSON Processing 1.0
{!
“firstName”:“John”,“lastName”: “Smith”,“age”: 25,!
“phoneNumber”: [!
{“type”: “home”, “number”: “212 555-1234” },!
{“type”: “fax”, “number”: “646 555-4567” }!
]!
}
Streaming Parser
END_ARRAY
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
JSON Processing 1.0
JsonGenerator gen = Json.createGenerator…!
.writeStartObject()!
.write("firstName", "John") !
.write("lastName", "Smith") !
.write("age", 25) !
.writeStartArray(“phones”)!
.writeStartObject()!
!! .write(“type",“home") !
.write(“number”, “222…”)!
.writeEnd()!
.writeStartObject() …!
.writeEnd()!
.writeEnd()!
.writeEnd();!
!
Using Streaming API to generate JSON
!
{ “firstName”:“John”,!
“lastName”:”Smith”,!
“age”:25, !
“phones”:[ !
{“type”:“home”,“number”:“…”},!
{“type”:“fax”,“number”:“…”} ]!
}
!17
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!18
Interactive Web Sites
• Flavors of Server Push
• Polling
• Long polling
• AJAX
!
!
• Complex, inefficient, wasteful
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!19
WebSockets to the rescue
▪ Bidirectional full-duplex messaging
– Over a single TCP connection
▪ IETF defined protocol: RFC 6455
▪ Part of HTML5
▪ W3C defined JavaScript API
▪ Adoption
▪ http://caniuse.com/websockets
Bring interactivity to the Web
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!20
WebSockets
Handshake Request
Http Request!
GET /mychat HTTP/1.1!
Host: server.example.com!
Upgrade: websocket!
Connection: Upgrade!
Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==!
Sec-WebSocket-Protocol: megachat, chat!
Sec-WebSocket-Extensions : compress, mux!
Sec-WebSocket-Version: 13!
Origin: http://example.com
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!21
WebSockets
Handshake Response
Http Response!
HTTP/1.1 101 Switching Protocols!
Upgrade: websocket!
Connection: Upgrade!
Sec-WebSocket-Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk=!
Sec-WebSocket-Protocol: chat!
Sec-WebSocket-Extensions: compress, mux
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!22
Java API for WebSocket 1.0
▪ WebSocket Java client & server API
▪ Part of Java EE 7
▪ Annotation-based & interface-based programming model
▪ Under consideration for Java SE 9
▪ Reference Implementation
▪ http://tyrus.java.net
▪ Supported in GlassFish 4.0
JSR 356
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!23
Java API for WebSocket 1.0
▪ Establish a WebSocket connection
▪ Send messages backwards and forwards
▪ End the connection
What’s the basic idea?
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!24
Java API for WebSocket 1.0
▪ Session
– Represents the active conversation
▪ Endpoint
– Intercepts websocket lifecycle events
▪ RemoteEndpoint
– Represents the other end of the conversation
▪ MessageHandler
– Handles incoming messages for endpoint
Main API classes
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!25
WebSocket Endpoints
public class MyClient extends Endpoint {!
public void onOpen(Session session, EndpointConfig ec) {!
session.addMessageHandler(new MessageHandler.Whole<String>() {!
public void onMessage(String payload) {!
System.out.println("From the server : " + payload);!
}!
}!
session.getBasicRemote().sendText("Hello!");!
}!
!
public void onClose(Session session, CloseReason closeReason) {!
super.onClose(session, closeReason);!
}!
}
Programmatic API
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!26
WebSocket Endpoints as POJOs
@ClientEndpoint!
public class MyClient { !
@OnOpen!
public void onOpen(Session session) {!
session.getBasicRemote().sendText(“Hello”);!
}!
@OnMessage!
public void onMessage(String payload, Session session) { !
System.out.println("From the server : " + payload);!
} !
}
Annotated client endpoint
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!27
WebSocket Endpoints as POJOs
@ServerEndpoint(“/chat")!
public class ChatServer { !!
static Set<Session> peers = Collections.synchronizedSet(…);!!!
! ! ! @OnOpen!
!!! public void onOpen(Session peer) {!
peers.add(peer);!
}!
!
@OnMessage!
!!! public void onMessage (String message, Session client) { !
for (Session peer : peers) {!
peer.getBasicRemote().sendObject(message);!
} !
}!
!
@OnClose!
!!! public void onClose(Session peer) {!
peers.remove(peer);!
}!
}
Annotated server endpoint
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!28
Java API for WebSocket 1.0
▪ Payload
▪ Text
▪ Binary
▪ Ping-Pong
▪ Synchronous / Asynchronous
▪ Whole message / Sequence of partial messages
▪ No delivery guarantee
Messaging
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!29
Java API for WebSocket 1.0
▪ Use Session’s RemoteEndpoint interface
mySession.getBasicRemote().sendText(”Hello”);
!
▪ Return a value from @OnMessage method
@OnMessage!
public String echo(String incomingMessage) {!
return(“Hello”);!
}
Sending messages
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!30
Java API for WebSocket 1.0
Means of sending RemoteEndpoint method to use
as whole string sendText(String message)
as binary data sendBinary(ByteBuffer message)
in string fragments sendText(String part, boolean last)
in binary data fragments sendBinary(ByteBuffer part, boolean last)
as a blocking stream of text Writer getSendWriter())
as a blocking stream of binary data OutputStream getSendStream()
as a custom object of type T sendObject(T customObject)
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!31
Java API for WebSocket 1.0
▪ Annotation - @onMessage
@OnMessage!
public void whenGettingText(String message)…!
!
▪ Implement a MessageHandler, add it to the Session
MyMessageHandler implements MessageHandler.Whole<String>!
…!
session.addMessageHandler( new MyMessageHandler() );
Receiving messages
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!32
Java API for WebSocket 1.0
▪ Encoder
▪ Object to Binary: Encoder.Binary<T>, Encoder.BinaryStream<T>!
▪ Object to Text: Encoder.Text<T>, Encoder.TextStream<T>!
▪ Decoder
▪ Text to Object: Decoder.Text<T>, Decoder.TextStream<T>!
▪ Binary to Object: Decoder.Binary<T>, Decoder.BinaryStream<T>!
▪ Lifecycle
▪ init() and destroy() methods
▪ willDecode()
Custom payload
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!33
Java API for RESTful Web Services (JAX-RS) 2.0
▪ Client API
▪ Filters and Interceptors
▪ Asynchronous Processing
▪ Hypermedia
▪ Validation
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!34
JAX-RS 1.1
URL url = new URL("http://. . ./atm/balance"); !
HttpURLConnection conn = (HttpURLConnection) url.openConnection();!
conn.setDoInput(true); !
conn.setDoOutput(false); !
conn.setRequestMethod("GET"); !
BufferedReader br = new BufferedReader(new!
!!! ! ! ! ! ! ! ! ! InputStreamReader(conn.getInputStream())); !
String line; !
while ((line = br.readLine()) != null) {    !
//. . . !
}
Previous Client API
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!35
JAX-RS 2.0
Client client = ClientFactory.newClient();!
!
String name = client.target("http://.../orders/{orderId}/customer")!
.resolveTemplate(“orderId”, “10”)!
.request()!
.get(String.class);
JAX-RS 2.0 Client API
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!36
Client client = ClientFactory.newClient();!
…!
WebTarget target = client.target(“http://…/orders/{orderId}/customer”)!
! ! .register(LoggingFilter.class);!
!
String name = target.resolveTemplate(“orderId”, “10”)!
!! !! ! ! ! .request()!
!! !! ! ! ! .get(String.class);
JAX-RS 2.0
JAX-RS 2.0 Client API
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!37
JAX-RS 2.0
@Path("/")!
class MyResourceClass {!
!
@POST!
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)!
public void registerUser(!
@NotNull @FormParam("firstName") String firstName,!
@NotNull @FormParam("lastName") String lastName,!
@Email @FormParam("email") String email) {!
... }!
…!
}
Bean Validation
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!38
Servlet 3.1
▪ Protocol Upgrade
▪ Non-blocking I/O
▪ Miscellaneous
▪ Security
▪ Upload
▪ …
JSR 340
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!39
Alignment and Simplification of Managed Beans
▪ CDI is core component model
▪ CDI enabled by default
▪ Expanded use of CDI Interceptors
– Transactional interceptors
– Method-level validation interceptors
▪ New CDI scopes: @TransactionScoped, @FlowScoped
Cohesive, integrated model
Java EE 7
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!40
Managed Bean Alignment
▪ CDI injection and CDI interceptors apply to all Java EE components
and related managed classes when CDI is enabled
▪ CDI is enabled by default in implicit bean archives
– Use of CDI bean-defining annotations (@SessionScoped,
@Dependent,…) and session beans result in implicit bean archives
▪ Library jars, EJB jars, WEB-INF/classes
– beans.xml not required
Expanded use of CDI
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!41
Transactional Interceptors
@Transactional(rollbackOn={SQLException.class},!
dontRollbackOn={SQLWarning.class})!
public class ShoppingCart {…}!
…!
!
@Inherited!
@InterceptorBinding!
@Target({TYPE, METHOD}) @Retention(RUNTIME)!
public @interface Transactional {!
TxType value() default TxType.REQUIRED;!
Class[] rollbackOn() default {};!
Class[] dontRollbackOn() default {};!
}
Annotations and semantics defined in JTA 1.2
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!42
Bean Validation 1.1

Method-level Validation
@Stateless!
public class OrderService {!
…!
@ValidOrder!
public Order placeOrder(!
@NotNull String productName,!
@Max(10) int quantity,!
@NotNull String customerName,!
@Address String customerAddress) {!
…!
}!
}
Via CDI Interceptors
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!43
Interceptor Ordering
▪ Interceptor.Priority.PLATFORM_BEFORE = 0
– Platform-defined interceptors to be executed at beginning of interceptor chain
– Transactional interceptors: Interceptor.Priority.PLATFORM_BEFORE+200
▪ Interceptor.Priority.LIBRARY_BEFORE = 1000
– Intended for use by extension libraries
▪ Interceptor.Priority.APPLICATION = 2000
– Intended for application-defined interceptors
▪ Interceptor.Priority.LIBRARY_AFTER = 3000
▪ Interceptor.Priority.PLATFORM_AFTER = 4000
– Bean Validation defined interceptors: Interceptor.Priority.PLATFORM_AFTER+800
Well-defined priority ordering
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!44
Resource Definition Metadata
▪ Specifies resources needed by application
– Enhances configurability in Java EE 7 apps
– Facilitates provisioning in cloud environments
– Java EE 6 introduced DataSourceDefinition
!
@DataSourceDefinition (!
name=“java:app/jdbc/myDB”,!
className=“oracle.jdbc.pool.OracleDataSource”,!
isolationLevel=TRANSACTION_REPEATABLE_READ, initialPoolSize=5)!
!
@Stateless public class MySessionBean {!
@Resource(lookup=“java:app/jdbc/myDB”) DataSource my DB;!
…!
}
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!45
Resource Definition Metadata
▪ Java EE 7 adds:
– JMSConnectionFactoryDefinition!
– JMSDestinationDefinition!
– MailSessionDefinition!
– ConnectionFactoryDefinition!
– AdministeredObjectDefinition
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!46
Default Resources
▪ JDBC/JPA
– java:comp/DefaultDataSource!
▪ JMS
– java:comp/DefaultJMSConnectionFactory!
▪ Concurrency Utilities
– java:comp/DefaultManagedExecutorService!
– java:comp/DefaultManagedScheduledExecutorService!
– java:comp/DefaultManagedThreadFactory!
– java:comp/DefaultManagedContextService
Preconfigured resources for use by application
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!47
Simplification through Pruning
▪ Process defined in Java EE 6
– Platform version N defines feature as “Proposed Optional”
– Platform version N+1 determines whether to make feature Optional
▪ Optional APIs as of Java EE 7
– EJB Entity Beans (CMP, BMP, EJB QL)
– JAX-RPC
– JAXR
– Deployment (JSR 88)
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!48
Java Message Service 2.0
▪ Less code, less boilerplate
▪ Fewer objects to manage
▪ Increased developer productivity
▪ “Classic API” has also been improved
New JMS Simplified API targeted at ease of development
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!49
JMS 2.0
▪ New JMSContext interface
▪ Use of CDI injection; new TransactionScope
▪ AutoCloseable JMSContext, Connection, Session, …
▪ Use of runtime exceptions
▪ Method chaining on JMSProducer
▪ Simplified message sending
Simplifications include….
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!50
JMS 1.1
@Resource(lookup = “java:global/jms/myConnectionFactory”)!
ConnectionFactory connectionFactory; !
!
@Resource(lookup = “java:global/jms/myQueue”)!
Queue queue; !
!
public void sendMessage(String text) { !
try {!
Connection connection = connectionFactory.createConnection();!
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);!
MessageProducer messageProducer = session.createProducer(queue);!
TextMessage textMessage = session.createTextMessage(text);!
messageProducer.send(textMessage);!
} finally {!
connection.close();!
} catch (JMSException ex) { … }!
}!
Sending a message in the JMS 1.1 “classic” API
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!51
JMS 2.0
@Resource(lookup = “java:global/jms/myConnectionFactory”)!
ConnectionFactory connectionFactory; !
!
@Resource(lookup = “java:global/jms/myQueue”)!
Queue queue; !
!
public void sendMessage(String text) { !
try (JMSContext context = connectionFactory.createContext();) {!
context.createProducer().send(queue, text);!
} catch (JMSRuntimeException ex) {!
…!
}!
}
Sending a message using Simplified API and JMSContext
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!52
JMS 2.0
@Inject !
@JMSConnectionFactory(“java:global/jms/myConnectionFactory”)!
JMSContext context;!
!
@Resource(lookup = “java:global/jms/myQueue”)!
Queue queue; !
!
public void sendMessage(String text) { !
context.createProducer().send(queue, text);!
}
Even simpler….
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!53
JMS 2.0
@Inject !
JMSContext context;!
!
@Resource(lookup = “java:global/jms/myQueue”)!
Queue queue; !
!
public void sendMessage(String text) { !
context.createProducer().send(queue, text);!
}
Even simpler still….
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!54
Concurrency Utilities for Java EE 1.0
▪ Extension of Java SE Concurrency Utilities API
▪ Provides managed objects for submitting tasks and obtaining
managed threads
– ManagedExecutorService!
– ManagedScheduledExecutorService!
– ManagedThreadFactory!
– ContextService
Provides asynchronous capabilities to Java EE components
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!55
Concurrency Utilities for Java EE 1.0
public class AccountTask implements Callable {!
...!
public AccountInfo call() {!
// task logic!
}!
...!
}!
!
//in calling component:!
@Resource!
ManagedExecutorService mes;!
...!
Future<AccountInfo> acctFuture = mes.submit(new AccountTask(...));!
AccountInfo accountInfo = acctFuture.get(); // Wait for the results.!
...!
// Process the results!
...
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!56
Batch Applications for the Java Platform 1.0
▪ Designed for non-interactive, bulk-oriented and long-running tasks
▪ Sequential, parallel, and/or decision-based batch execution
▪ Processing styles
– Item-oriented (“chunked”)
– Task-oriented (“batchlet”)
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!57
Batch 1.0
▪ Job : Entire batch process
– Defined through XML Job Specification Language
▪ Step : Independent, sequential phase of a job
▪ JobOperator : Interface for managing job processing
▪ JobRepository : Information about past and present jobs
Key concepts
Job Repository
Job Operator Job Step
ItemReader
ItemWriter
ItemProcessor
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!58
Batch 1.0
▪ Chunked : Item-oriented processing
– ItemReader/ItemProcessor/ItemWriter pattern
– Configurable checkpointing and transactions
▪ Batchlet : Task-oriented processing
– Roll-your-own batch pattern
– Runs to completion and exits
▪ Job can include both types of steps
Job steps
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!59
Batch Applications
▪ Read and Process one item
▪ Do the above ‘n’ times (‘commit interval’)
▪ Write the ‘n’ processed items
▪ Commit the transaction
Primary Processing Style
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!60
Batch 1.0
<job id="myJob" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.0">!
<step id="step1" next="step2">!
<chunk item-count="3">!
<reader ref="myItemReader"></reader> !
<processor ref="myItemProcessor"></processor>!
<writer ref="myItemWriter"></writer> !
</chunk>!!
</step>!
<step id="step2" next=“step3”>!
<batchlet ref="myBatchlet"/>!
</step>!
<step id="step3" >!
<chunk item-count="3">!
<reader ref="myOtherItemReader"></reader> !
<processor ref="myOtherItemProcessor"></processor>!
<writer ref="myOtherItemWriter"></writer> !
</chunk>!!
</step>!
</job>
Job specification language
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!61
Batch 1.0
<step id=”sendStatements”>!
<chunk item-count=“3”>

<reader ref=”accountReader”/>!
<processor ref=”accountProcessor”/>

<writer ref=”myWriter”/>!
</step>
…implements ItemReader {

public Object readItem() {

// read account using JPA
}
…implements ItemProcessor {!
Public Object processItems(Object account) {

// read Account, return Statement!
}!
…implements ItemWriter {!
public void writeItems(List accounts) {

// use JavaMail to send email or save on disk!
}!
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!62
Batch 1.0
<step id=”transferFile”>!
<batchlet ref=“MyFileTransfer” />!
</step>
@Dependent!
@Named("MyFileTransfer")!
public class MyBatchlet implements javax.batch.api.chunk.Batchlet {!
@Inject!
private JobContext jobCtx;!!
@Override!
public void process() throws Exception {!
String fName = jobCtx.getProperties().getProperty("out_file");!
// transfer file!
}!
}!
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!63
Batch 1.0
Interface Abstract Classes
JobListener AbstractJobListener
StepListener AbstractStepListener
ChunkListener AbstractChunkListener
ItemRead/Write/ProcessListener AbstractItemRead/Write/ProcessListener
SkipRead/Write/ProcessListener AbstractSkipRead/Write/ProcessListener
RetryRead/Write/ProcessListener AbstractRetryRead/Write/ProcessListener
Listeners
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!64
Batch 1.0
JobOperator
private long startNewBatchJob() throws Exception { !
! ! JobOperator jobOperator = BatchRuntime.getJobOperator(); !
! ! Properties props = new Properties(); !
! ! props.setProperty(”someInputFileName", someInputFileName); !
! ! return jobOperator.start(JOB_NAME, props); !
}
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!65
And more…
▪ Servlet 3.1
▪ JPA 2.1
▪ JSF 2.2
▪ EJB 3.2
▪ EL 3.0
▪ JCA 1.7
▪ …
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!66
Java EE 7 Summary
ENTERPRISE
EDITION
▪ Batch
▪ Concurrency
▪ Simplified JMS
▪ More annotated POJOs
▪ Less boilerplate code
▪ Cohesive integrated 

platform
DEVELOPER
PRODUCTIVITY
▪ WebSockets
▪ JSON
▪ Servlet 3.1 NIO
▪ REST
MEETING 

ENTERPRISE
DEMANDS
Java EE 7
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!67
Transparency in JSR processes
▪ java.net used for all Oracle-led JSRs
– http://java.net/projects/javaee-spec/pages/Home
▪ Publicly viewable Expert Group mailing archives
▪ Users observer lists get copies of all Expert Group emails
▪ Public download areas, JIRAs
▪ Wikis, source repositories, etc. at the group discretion
▪ Commitment to JCP 2.8/2.9 processes
All Java EE JSRs run with high level of transparency
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!68
DOWNLOAD
Java EE 7 SDK
oracle.com/javaee
!
GlassFish 4.0
Full Platform or Web Profile
glassfish.org
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!69
WebLogic Server 12.1.3
WebLogic Server
12.1.3
Clients
HTML5
clients
ADF Mobile
Proxies
HTTP/S, JSON/XML
WebSocket, Server-Sent
Events, Long polling
OTD
Apache
OHS
Web Sockets (JSR 356)
TopLink Data Services
Server-Sent Events
JAX-RS 2.0
Avatar (post-GA)
HTML5client
emulation
JPA
Change

Notification
Database
• Server-Sent Events
• JAX-RS 2.0
• WebSocket – JSR 356
• JPA 2.1, JSON-P
• WebSocket Client Emulation
• Avatar
• Maven improvements
• Classloader Analysis Tool
updates
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!70
Program Agenda
Java EE 8 and beyond
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!71
Java EE 8
▪ New JSRs
▪ JCACHE (JSR 107)
▪ Data Grid API (JSR 347)
▪ State Management API (JSR 350)
▪ Identity API (JSR 351)
▪ Java API for JSON Binding
▪ Java EE Configuration
▪ …
▪ Profiles & Pruning
Ideas… just ideas!
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!72
Java EE 8
▪ HTML 5
▪ Server-sent events?
▪ JavaScript on the server?
▪ Something else?
▪ User Interface
▪ MVC?
▪ Client API for TSA?
▪ Templating? Facelet?
Ideas (cont.)
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!73
Java EE 8
▪ CDI
▪ NoSQL ?
▪ Cloud
▪ PaaS, SaaS, Multi-tenancy ?
▪ Logging
▪ Security
▪ Testability
▪ Deployment, Management, Monitoring
▪ ???
Ideas (cont.)
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!74
https://glassfish.org/survey
Java EE 8 Survey
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!75
Merci!
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12!76
Graphic Section Divider

More Related Content

PDF
Java EE 7 et ensuite pourquoi pas JavaScript sur le serveur!
PDF
HTTP/2 comes to Java
PDF
Java EE 8 - Work in progress
PDF
Java EE 8 - February 2017 update
PDF
JavaOne 2014 BOF4241 What's Next for JSF?
PDF
HTTP/2 comes to Java (Dec. 2015 version)
PDF
Java API for WebSocket 1.0: Java EE 7 and GlassFish
PDF
XML and Web Services with Groovy
Java EE 7 et ensuite pourquoi pas JavaScript sur le serveur!
HTTP/2 comes to Java
Java EE 8 - Work in progress
Java EE 8 - February 2017 update
JavaOne 2014 BOF4241 What's Next for JSF?
HTTP/2 comes to Java (Dec. 2015 version)
Java API for WebSocket 1.0: Java EE 7 and GlassFish
XML and Web Services with Groovy

What's hot (20)

PPTX
Servlet 4.0 at GeekOut 2015
PDF
MVC 1.0 / JSR 371
PDF
Server Side JavaScript on the JVM - Project Avatar - QCon London March 2014
PDF
JavaCro'15 - Java EE 8 - An instant snapshot - David Delabassee
PDF
JavaCro'15 - HTTP2 Comes to Java! - David Delabassee
PDF
Java EE 8 Overview (Japanese)
PDF
JavaCro'15 - Everything a Java EE Developer needs to know about the JavaScrip...
PPT
Reactive Java EE - Let Me Count the Ways!
PDF
Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0
PDF
JavaCro'15 - Java Certification – in theory and practice - Branko Mihaljević,...
PDF
WebSockets in Enterprise Applications
PDF
WebSockets - Realtime em Mundo Conectado
PDF
Oracle Cloud: Anything as a Service
PPTX
HTTP/2 comes to Java. What Servlet 4.0 means to you. DevNexus 2015
PDF
What's Coming in Java EE 8
PPT
GlassFish BOF
PDF
Supercharge your Code to get optimal Database Performance
PDF
Tweet4Beer - Beertap powered by Java goes IoT and JavaFX
PDF
JavaCro'15 - HUJAKing – Expansion of Java Community - Branko Mihaljević, Alek...
PDF
Another compilation method in java - AOT (Ahead of Time) compilation
Servlet 4.0 at GeekOut 2015
MVC 1.0 / JSR 371
Server Side JavaScript on the JVM - Project Avatar - QCon London March 2014
JavaCro'15 - Java EE 8 - An instant snapshot - David Delabassee
JavaCro'15 - HTTP2 Comes to Java! - David Delabassee
Java EE 8 Overview (Japanese)
JavaCro'15 - Everything a Java EE Developer needs to know about the JavaScrip...
Reactive Java EE - Let Me Count the Ways!
Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0
JavaCro'15 - Java Certification – in theory and practice - Branko Mihaljević,...
WebSockets in Enterprise Applications
WebSockets - Realtime em Mundo Conectado
Oracle Cloud: Anything as a Service
HTTP/2 comes to Java. What Servlet 4.0 means to you. DevNexus 2015
What's Coming in Java EE 8
GlassFish BOF
Supercharge your Code to get optimal Database Performance
Tweet4Beer - Beertap powered by Java goes IoT and JavaFX
JavaCro'15 - HUJAKing – Expansion of Java Community - Branko Mihaljević, Alek...
Another compilation method in java - AOT (Ahead of Time) compilation
Ad

Similar to Java EE 7 (Lyon JUG & Alpes JUG - March 2014) (20)

PDF
Project Avatar (Lyon JUG & Alpes JUG - March 2014)
PDF
Avatar 2.0
PDF
JAX-RS.next
PPTX
Construindo aplicações com HTML5, WebSockets, e Java EE 7
PDF
Server Side JavaScript on the Java Platform - David Delabassee
PDF
Automated infrastructure is on the menu
PDF
Getting Started with WebSocket and Server-Sent Events using Java by Arun Gupta
PDF
HTTP/2 Comes to Java - What Servlet 4.0 Means to You
PDF
Getting started with Websocket and Server-sent Events using Java - Arun Gupta
PDF
Tweet4Beer (atualizada): Torneira de Chopp Controlada por Java, JavaFX, IoT ...
PDF
Pushing JavaEE outside of the enterprise: Home Automation & IoT - David Delab...
PDF
WSO2Con Asia 2014 - WSO2 AppDev Platform for the Connected Business
PDF
WSO2 AppDev platform
PPTX
REST Enabling your Oracle Database (2018 Update)
PDF
Leverage integration cloud_service_for_ebs_
PDF
GeekAustin DevOps
PDF
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
PDF
Kick Start your Application Development and Management Strategy
PDF
Big Data Web applications for Interactive Hadoop by ENRICO BERTI at Big Data...
PDF
Getting Started with WebSocket and Server-Sent Events in Java
Project Avatar (Lyon JUG & Alpes JUG - March 2014)
Avatar 2.0
JAX-RS.next
Construindo aplicações com HTML5, WebSockets, e Java EE 7
Server Side JavaScript on the Java Platform - David Delabassee
Automated infrastructure is on the menu
Getting Started with WebSocket and Server-Sent Events using Java by Arun Gupta
HTTP/2 Comes to Java - What Servlet 4.0 Means to You
Getting started with Websocket and Server-sent Events using Java - Arun Gupta
Tweet4Beer (atualizada): Torneira de Chopp Controlada por Java, JavaFX, IoT ...
Pushing JavaEE outside of the enterprise: Home Automation & IoT - David Delab...
WSO2Con Asia 2014 - WSO2 AppDev Platform for the Connected Business
WSO2 AppDev platform
REST Enabling your Oracle Database (2018 Update)
Leverage integration cloud_service_for_ebs_
GeekAustin DevOps
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
Kick Start your Application Development and Management Strategy
Big Data Web applications for Interactive Hadoop by ENRICO BERTI at Big Data...
Getting Started with WebSocket and Server-Sent Events in Java
Ad

More from David Delabassee (19)

PDF
JVMs in Containers - Best Practices
PDF
JVMs in Containers
PDF
Serverless Java Challenges & Triumphs
PDF
Serverless Java - Challenges and Triumphs
PDF
Randstad Docker meetup - Serverless
PDF
Java Serverless in Action - Voxxed Banff
PPTX
Serverless Kotlin
PDF
REST in an Async World
PDF
JAX-RS 2.1 Reloaded
PDF
Java EE Next
PDF
Java EE Next - BeJUG JavaOne Afterglow 2016
PDF
EJB and CDI - Alignment and Strategy
PDF
HTTP/2 Comes to Java
PDF
Java EE 8 - What’s new on the Web front
PDF
HTTP/2 Comes to Java
PDF
What's coming in Java EE 8
PDF
Java EE 8 - An instant snapshot
PDF
Java EE 8 - An instant snapshot
PDF
Pushing Java EE outside of the Enterprise - Home Automation
JVMs in Containers - Best Practices
JVMs in Containers
Serverless Java Challenges & Triumphs
Serverless Java - Challenges and Triumphs
Randstad Docker meetup - Serverless
Java Serverless in Action - Voxxed Banff
Serverless Kotlin
REST in an Async World
JAX-RS 2.1 Reloaded
Java EE Next
Java EE Next - BeJUG JavaOne Afterglow 2016
EJB and CDI - Alignment and Strategy
HTTP/2 Comes to Java
Java EE 8 - What’s new on the Web front
HTTP/2 Comes to Java
What's coming in Java EE 8
Java EE 8 - An instant snapshot
Java EE 8 - An instant snapshot
Pushing Java EE outside of the Enterprise - Home Automation

Recently uploaded (20)

PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Cloud computing and distributed systems.
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Empathic Computing: Creating Shared Understanding
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Approach and Philosophy of On baking technology
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Machine learning based COVID-19 study performance prediction
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Spectroscopy.pptx food analysis technology
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
MIND Revenue Release Quarter 2 2025 Press Release
Cloud computing and distributed systems.
Per capita expenditure prediction using model stacking based on satellite ima...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Programs and apps: productivity, graphics, security and other tools
Review of recent advances in non-invasive hemoglobin estimation
NewMind AI Weekly Chronicles - August'25 Week I
Empathic Computing: Creating Shared Understanding
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
20250228 LYD VKU AI Blended-Learning.pptx
Spectral efficient network and resource selection model in 5G networks
Approach and Philosophy of On baking technology
Mobile App Security Testing_ A Comprehensive Guide.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Machine learning based COVID-19 study performance prediction
The AUB Centre for AI in Media Proposal.docx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Spectroscopy.pptx food analysis technology
Agricultural_Statistics_at_a_Glance_2022_0.pdf

Java EE 7 (Lyon JUG & Alpes JUG - March 2014)

  • 1. What’s New in the Java EE Platform Alpes JUG - March 2014 ! David Delabassee @delabassee Software Evangelist - Oracle
  • 2. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!2 Program Agenda A look at some of the important new features of Java EE 7
  • 3. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!3 Java EE 7 Momentum ACTIVEPROJECTS 26 Active and transparent mailing lists JSRsADOPTED 22 JUGs 19 Adopt a JSR PROMOTEDBUILDS 89 GlassFish YOU 187 COMPANIES 32 EXPERTS SPECLEADS 16 ACTIVEJSRs 14
  • 4. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!4 Java EE 7 Momentum
  • 5. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!5 Java EE 7 Themes ENTERPRISE EDITION ▪ Batch ▪ Concurrency ▪ Simplified JMS ▪ More annotated POJOs ▪ Less boilerplate code ▪ Cohesive integrated 
 platform DEVELOPER PRODUCTIVITY ▪ WebSockets ▪ JSON ▪ Servlet 3.1 NIO ▪ REST MEETING 
 ENTERPRISE DEMANDS Java EE 7
  • 6. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Java EE 7 JSRs
 New or Updated ▪ JPA 2.1 ▪ JAX-RS 2.0 ▪ EJB 3.2 ▪ JMS 2.0 ▪ Servlet 3.1 ▪ EL 3.0 ▪ JSF 2.2 ▪ CDI 1.1 ▪ Bean Validation 1.1 ▪ WebSocket 1.0 ▪ JSON 1.0 ▪ Batch Applications 1.0 ▪ Concurrency Utilities 1.0 !6
  • 7. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Java EE 7 Maintenance Releases ▪ Common Annotations 1.2 ▪ JTA 1.2 ▪ Interceptors 1.2 ▪ Connector 1.7 ▪ JSP 2.3 ▪ JASPIC 1.2 ▪ JACC 1.4 ▪ JavaMail 1.5 ▪ Web Services 1.4 !7
  • 8. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!8 JSON Processing 1.0 ▪ API to parse and generate JSON ▪ Streaming API (javax.json.stream) – Low-level, efficient way to parse/generate JSON – Similar to StAX API in XML world ▪ Object model API (javax.json) – Simple, easy to use high-level API – Similar to DOM API in XML world
  • 9. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!9 JSON Processing 1.0 ▪ Created using – Json.createParser(…)! – Json.createParserFactory().createParser(…)! ▪ Parses JSON in streaming way from input sources Event event = parser.next(); // START_OBJECT! event = parser.next(); // KEY_NAME! event = parser.next(); // VALUE_STRING! ▪ Parser state events – START_OBJECT, END_OBJECT, START_ARRAY, END_ARRAY, KEY_NAME, VALUE_STRING, VALUE_NUMBER, … Streaming API: Parsing
  • 10. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!10 JSON Processing 1.0 {! “firstName”:“John”,“lastName”: “Smith”,“age”: 25,! “phoneNumber”: [! {“type”: “home”, “number”: “212 555-1234” },! {“type”: “fax”, “number”: “646 555-4567” }! ]! } Streaming Parser
  • 11. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!11 JSON Processing 1.0 {! “firstName”:“John”,“lastName”: “Smith”,“age”: 25,! “phoneNumber”: [! {“type”: “home”, “number”: “212 555-1234” },! {“type”: “fax”, “number”: “646 555-4567” }! ]! } Streaming Parser START_OBJECT
  • 12. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!12 JSON Processing 1.0 {! “firstName”:“John”,“lastName”: “Smith”,“age”: 25,! “phoneNumber”: [! {“type”: “home”, “number”: “212 555-1234” },! {“type”: “fax”, “number”: “646 555-4567” }! ]! } Streaming Parser KEY_NAME
  • 13. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!13 JSON Processing 1.0 {! “firstName”:“John”,“lastName”: “Smith”,“age”: 25,! “phoneNumber”: [! {“type”: “home”, “number”: “212 555-1234” },! {“type”: “fax”, “number”: “646 555-4567” }! ]! } Streaming Parser VALUE_STRING
  • 14. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!14 JSON Processing 1.0 {! “firstName”:“John”,“lastName”: “Smith”,“age”: 25,! “phoneNumber”: [! {“type”: “home”, “number”: “212 555-1234” },! {“type”: “fax”, “number”: “646 555-4567” }! ]! } Streaming Parser VALUE_NUMBER
  • 15. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!15 JSON Processing 1.0 {! “firstName”:“John”,“lastName”: “Smith”,“age”: 25,! “phoneNumber”: [! {“type”: “home”, “number”: “212 555-1234” },! {“type”: “fax”, “number”: “646 555-4567” }! ]! } Streaming Parser START_ARRAY
  • 16. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!16 JSON Processing 1.0 {! “firstName”:“John”,“lastName”: “Smith”,“age”: 25,! “phoneNumber”: [! {“type”: “home”, “number”: “212 555-1234” },! {“type”: “fax”, “number”: “646 555-4567” }! ]! } Streaming Parser END_ARRAY
  • 17. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. JSON Processing 1.0 JsonGenerator gen = Json.createGenerator…! .writeStartObject()! .write("firstName", "John") ! .write("lastName", "Smith") ! .write("age", 25) ! .writeStartArray(“phones”)! .writeStartObject()! !! .write(“type",“home") ! .write(“number”, “222…”)! .writeEnd()! .writeStartObject() …! .writeEnd()! .writeEnd()! .writeEnd();! ! Using Streaming API to generate JSON ! { “firstName”:“John”,! “lastName”:”Smith”,! “age”:25, ! “phones”:[ ! {“type”:“home”,“number”:“…”},! {“type”:“fax”,“number”:“…”} ]! } !17
  • 18. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!18 Interactive Web Sites • Flavors of Server Push • Polling • Long polling • AJAX ! ! • Complex, inefficient, wasteful
  • 19. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!19 WebSockets to the rescue ▪ Bidirectional full-duplex messaging – Over a single TCP connection ▪ IETF defined protocol: RFC 6455 ▪ Part of HTML5 ▪ W3C defined JavaScript API ▪ Adoption ▪ http://caniuse.com/websockets Bring interactivity to the Web
  • 20. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!20 WebSockets Handshake Request Http Request! GET /mychat HTTP/1.1! Host: server.example.com! Upgrade: websocket! Connection: Upgrade! Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==! Sec-WebSocket-Protocol: megachat, chat! Sec-WebSocket-Extensions : compress, mux! Sec-WebSocket-Version: 13! Origin: http://example.com
  • 21. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!21 WebSockets Handshake Response Http Response! HTTP/1.1 101 Switching Protocols! Upgrade: websocket! Connection: Upgrade! Sec-WebSocket-Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk=! Sec-WebSocket-Protocol: chat! Sec-WebSocket-Extensions: compress, mux
  • 22. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!22 Java API for WebSocket 1.0 ▪ WebSocket Java client & server API ▪ Part of Java EE 7 ▪ Annotation-based & interface-based programming model ▪ Under consideration for Java SE 9 ▪ Reference Implementation ▪ http://tyrus.java.net ▪ Supported in GlassFish 4.0 JSR 356
  • 23. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!23 Java API for WebSocket 1.0 ▪ Establish a WebSocket connection ▪ Send messages backwards and forwards ▪ End the connection What’s the basic idea?
  • 24. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!24 Java API for WebSocket 1.0 ▪ Session – Represents the active conversation ▪ Endpoint – Intercepts websocket lifecycle events ▪ RemoteEndpoint – Represents the other end of the conversation ▪ MessageHandler – Handles incoming messages for endpoint Main API classes
  • 25. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!25 WebSocket Endpoints public class MyClient extends Endpoint {! public void onOpen(Session session, EndpointConfig ec) {! session.addMessageHandler(new MessageHandler.Whole<String>() {! public void onMessage(String payload) {! System.out.println("From the server : " + payload);! }! }! session.getBasicRemote().sendText("Hello!");! }! ! public void onClose(Session session, CloseReason closeReason) {! super.onClose(session, closeReason);! }! } Programmatic API
  • 26. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!26 WebSocket Endpoints as POJOs @ClientEndpoint! public class MyClient { ! @OnOpen! public void onOpen(Session session) {! session.getBasicRemote().sendText(“Hello”);! }! @OnMessage! public void onMessage(String payload, Session session) { ! System.out.println("From the server : " + payload);! } ! } Annotated client endpoint
  • 27. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!27 WebSocket Endpoints as POJOs @ServerEndpoint(“/chat")! public class ChatServer { !! static Set<Session> peers = Collections.synchronizedSet(…);!!! ! ! ! @OnOpen! !!! public void onOpen(Session peer) {! peers.add(peer);! }! ! @OnMessage! !!! public void onMessage (String message, Session client) { ! for (Session peer : peers) {! peer.getBasicRemote().sendObject(message);! } ! }! ! @OnClose! !!! public void onClose(Session peer) {! peers.remove(peer);! }! } Annotated server endpoint
  • 28. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!28 Java API for WebSocket 1.0 ▪ Payload ▪ Text ▪ Binary ▪ Ping-Pong ▪ Synchronous / Asynchronous ▪ Whole message / Sequence of partial messages ▪ No delivery guarantee Messaging
  • 29. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!29 Java API for WebSocket 1.0 ▪ Use Session’s RemoteEndpoint interface mySession.getBasicRemote().sendText(”Hello”); ! ▪ Return a value from @OnMessage method @OnMessage! public String echo(String incomingMessage) {! return(“Hello”);! } Sending messages
  • 30. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!30 Java API for WebSocket 1.0 Means of sending RemoteEndpoint method to use as whole string sendText(String message) as binary data sendBinary(ByteBuffer message) in string fragments sendText(String part, boolean last) in binary data fragments sendBinary(ByteBuffer part, boolean last) as a blocking stream of text Writer getSendWriter()) as a blocking stream of binary data OutputStream getSendStream() as a custom object of type T sendObject(T customObject)
  • 31. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!31 Java API for WebSocket 1.0 ▪ Annotation - @onMessage @OnMessage! public void whenGettingText(String message)…! ! ▪ Implement a MessageHandler, add it to the Session MyMessageHandler implements MessageHandler.Whole<String>! …! session.addMessageHandler( new MyMessageHandler() ); Receiving messages
  • 32. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!32 Java API for WebSocket 1.0 ▪ Encoder ▪ Object to Binary: Encoder.Binary<T>, Encoder.BinaryStream<T>! ▪ Object to Text: Encoder.Text<T>, Encoder.TextStream<T>! ▪ Decoder ▪ Text to Object: Decoder.Text<T>, Decoder.TextStream<T>! ▪ Binary to Object: Decoder.Binary<T>, Decoder.BinaryStream<T>! ▪ Lifecycle ▪ init() and destroy() methods ▪ willDecode() Custom payload
  • 33. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!33 Java API for RESTful Web Services (JAX-RS) 2.0 ▪ Client API ▪ Filters and Interceptors ▪ Asynchronous Processing ▪ Hypermedia ▪ Validation
  • 34. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!34 JAX-RS 1.1 URL url = new URL("http://. . ./atm/balance"); ! HttpURLConnection conn = (HttpURLConnection) url.openConnection();! conn.setDoInput(true); ! conn.setDoOutput(false); ! conn.setRequestMethod("GET"); ! BufferedReader br = new BufferedReader(new! !!! ! ! ! ! ! ! ! ! InputStreamReader(conn.getInputStream())); ! String line; ! while ((line = br.readLine()) != null) {    ! //. . . ! } Previous Client API
  • 35. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!35 JAX-RS 2.0 Client client = ClientFactory.newClient();! ! String name = client.target("http://.../orders/{orderId}/customer")! .resolveTemplate(“orderId”, “10”)! .request()! .get(String.class); JAX-RS 2.0 Client API
  • 36. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!36 Client client = ClientFactory.newClient();! …! WebTarget target = client.target(“http://…/orders/{orderId}/customer”)! ! ! .register(LoggingFilter.class);! ! String name = target.resolveTemplate(“orderId”, “10”)! !! !! ! ! ! .request()! !! !! ! ! ! .get(String.class); JAX-RS 2.0 JAX-RS 2.0 Client API
  • 37. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!37 JAX-RS 2.0 @Path("/")! class MyResourceClass {! ! @POST! @Consumes(MediaType.APPLICATION_FORM_URLENCODED)! public void registerUser(! @NotNull @FormParam("firstName") String firstName,! @NotNull @FormParam("lastName") String lastName,! @Email @FormParam("email") String email) {! ... }! …! } Bean Validation
  • 38. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!38 Servlet 3.1 ▪ Protocol Upgrade ▪ Non-blocking I/O ▪ Miscellaneous ▪ Security ▪ Upload ▪ … JSR 340
  • 39. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!39 Alignment and Simplification of Managed Beans ▪ CDI is core component model ▪ CDI enabled by default ▪ Expanded use of CDI Interceptors – Transactional interceptors – Method-level validation interceptors ▪ New CDI scopes: @TransactionScoped, @FlowScoped Cohesive, integrated model Java EE 7
  • 40. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!40 Managed Bean Alignment ▪ CDI injection and CDI interceptors apply to all Java EE components and related managed classes when CDI is enabled ▪ CDI is enabled by default in implicit bean archives – Use of CDI bean-defining annotations (@SessionScoped, @Dependent,…) and session beans result in implicit bean archives ▪ Library jars, EJB jars, WEB-INF/classes – beans.xml not required Expanded use of CDI
  • 41. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!41 Transactional Interceptors @Transactional(rollbackOn={SQLException.class},! dontRollbackOn={SQLWarning.class})! public class ShoppingCart {…}! …! ! @Inherited! @InterceptorBinding! @Target({TYPE, METHOD}) @Retention(RUNTIME)! public @interface Transactional {! TxType value() default TxType.REQUIRED;! Class[] rollbackOn() default {};! Class[] dontRollbackOn() default {};! } Annotations and semantics defined in JTA 1.2
  • 42. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!42 Bean Validation 1.1
 Method-level Validation @Stateless! public class OrderService {! …! @ValidOrder! public Order placeOrder(! @NotNull String productName,! @Max(10) int quantity,! @NotNull String customerName,! @Address String customerAddress) {! …! }! } Via CDI Interceptors
  • 43. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!43 Interceptor Ordering ▪ Interceptor.Priority.PLATFORM_BEFORE = 0 – Platform-defined interceptors to be executed at beginning of interceptor chain – Transactional interceptors: Interceptor.Priority.PLATFORM_BEFORE+200 ▪ Interceptor.Priority.LIBRARY_BEFORE = 1000 – Intended for use by extension libraries ▪ Interceptor.Priority.APPLICATION = 2000 – Intended for application-defined interceptors ▪ Interceptor.Priority.LIBRARY_AFTER = 3000 ▪ Interceptor.Priority.PLATFORM_AFTER = 4000 – Bean Validation defined interceptors: Interceptor.Priority.PLATFORM_AFTER+800 Well-defined priority ordering
  • 44. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!44 Resource Definition Metadata ▪ Specifies resources needed by application – Enhances configurability in Java EE 7 apps – Facilitates provisioning in cloud environments – Java EE 6 introduced DataSourceDefinition ! @DataSourceDefinition (! name=“java:app/jdbc/myDB”,! className=“oracle.jdbc.pool.OracleDataSource”,! isolationLevel=TRANSACTION_REPEATABLE_READ, initialPoolSize=5)! ! @Stateless public class MySessionBean {! @Resource(lookup=“java:app/jdbc/myDB”) DataSource my DB;! …! }
  • 45. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!45 Resource Definition Metadata ▪ Java EE 7 adds: – JMSConnectionFactoryDefinition! – JMSDestinationDefinition! – MailSessionDefinition! – ConnectionFactoryDefinition! – AdministeredObjectDefinition
  • 46. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!46 Default Resources ▪ JDBC/JPA – java:comp/DefaultDataSource! ▪ JMS – java:comp/DefaultJMSConnectionFactory! ▪ Concurrency Utilities – java:comp/DefaultManagedExecutorService! – java:comp/DefaultManagedScheduledExecutorService! – java:comp/DefaultManagedThreadFactory! – java:comp/DefaultManagedContextService Preconfigured resources for use by application
  • 47. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!47 Simplification through Pruning ▪ Process defined in Java EE 6 – Platform version N defines feature as “Proposed Optional” – Platform version N+1 determines whether to make feature Optional ▪ Optional APIs as of Java EE 7 – EJB Entity Beans (CMP, BMP, EJB QL) – JAX-RPC – JAXR – Deployment (JSR 88)
  • 48. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!48 Java Message Service 2.0 ▪ Less code, less boilerplate ▪ Fewer objects to manage ▪ Increased developer productivity ▪ “Classic API” has also been improved New JMS Simplified API targeted at ease of development
  • 49. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!49 JMS 2.0 ▪ New JMSContext interface ▪ Use of CDI injection; new TransactionScope ▪ AutoCloseable JMSContext, Connection, Session, … ▪ Use of runtime exceptions ▪ Method chaining on JMSProducer ▪ Simplified message sending Simplifications include….
  • 50. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!50 JMS 1.1 @Resource(lookup = “java:global/jms/myConnectionFactory”)! ConnectionFactory connectionFactory; ! ! @Resource(lookup = “java:global/jms/myQueue”)! Queue queue; ! ! public void sendMessage(String text) { ! try {! Connection connection = connectionFactory.createConnection();! Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);! MessageProducer messageProducer = session.createProducer(queue);! TextMessage textMessage = session.createTextMessage(text);! messageProducer.send(textMessage);! } finally {! connection.close();! } catch (JMSException ex) { … }! }! Sending a message in the JMS 1.1 “classic” API
  • 51. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!51 JMS 2.0 @Resource(lookup = “java:global/jms/myConnectionFactory”)! ConnectionFactory connectionFactory; ! ! @Resource(lookup = “java:global/jms/myQueue”)! Queue queue; ! ! public void sendMessage(String text) { ! try (JMSContext context = connectionFactory.createContext();) {! context.createProducer().send(queue, text);! } catch (JMSRuntimeException ex) {! …! }! } Sending a message using Simplified API and JMSContext
  • 52. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!52 JMS 2.0 @Inject ! @JMSConnectionFactory(“java:global/jms/myConnectionFactory”)! JMSContext context;! ! @Resource(lookup = “java:global/jms/myQueue”)! Queue queue; ! ! public void sendMessage(String text) { ! context.createProducer().send(queue, text);! } Even simpler….
  • 53. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!53 JMS 2.0 @Inject ! JMSContext context;! ! @Resource(lookup = “java:global/jms/myQueue”)! Queue queue; ! ! public void sendMessage(String text) { ! context.createProducer().send(queue, text);! } Even simpler still….
  • 54. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!54 Concurrency Utilities for Java EE 1.0 ▪ Extension of Java SE Concurrency Utilities API ▪ Provides managed objects for submitting tasks and obtaining managed threads – ManagedExecutorService! – ManagedScheduledExecutorService! – ManagedThreadFactory! – ContextService Provides asynchronous capabilities to Java EE components
  • 55. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!55 Concurrency Utilities for Java EE 1.0 public class AccountTask implements Callable {! ...! public AccountInfo call() {! // task logic! }! ...! }! ! //in calling component:! @Resource! ManagedExecutorService mes;! ...! Future<AccountInfo> acctFuture = mes.submit(new AccountTask(...));! AccountInfo accountInfo = acctFuture.get(); // Wait for the results.! ...! // Process the results! ...
  • 56. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!56 Batch Applications for the Java Platform 1.0 ▪ Designed for non-interactive, bulk-oriented and long-running tasks ▪ Sequential, parallel, and/or decision-based batch execution ▪ Processing styles – Item-oriented (“chunked”) – Task-oriented (“batchlet”)
  • 57. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!57 Batch 1.0 ▪ Job : Entire batch process – Defined through XML Job Specification Language ▪ Step : Independent, sequential phase of a job ▪ JobOperator : Interface for managing job processing ▪ JobRepository : Information about past and present jobs Key concepts Job Repository Job Operator Job Step ItemReader ItemWriter ItemProcessor
  • 58. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!58 Batch 1.0 ▪ Chunked : Item-oriented processing – ItemReader/ItemProcessor/ItemWriter pattern – Configurable checkpointing and transactions ▪ Batchlet : Task-oriented processing – Roll-your-own batch pattern – Runs to completion and exits ▪ Job can include both types of steps Job steps
  • 59. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!59 Batch Applications ▪ Read and Process one item ▪ Do the above ‘n’ times (‘commit interval’) ▪ Write the ‘n’ processed items ▪ Commit the transaction Primary Processing Style
  • 60. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!60 Batch 1.0 <job id="myJob" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.0">! <step id="step1" next="step2">! <chunk item-count="3">! <reader ref="myItemReader"></reader> ! <processor ref="myItemProcessor"></processor>! <writer ref="myItemWriter"></writer> ! </chunk>!! </step>! <step id="step2" next=“step3”>! <batchlet ref="myBatchlet"/>! </step>! <step id="step3" >! <chunk item-count="3">! <reader ref="myOtherItemReader"></reader> ! <processor ref="myOtherItemProcessor"></processor>! <writer ref="myOtherItemWriter"></writer> ! </chunk>!! </step>! </job> Job specification language
  • 61. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!61 Batch 1.0 <step id=”sendStatements”>! <chunk item-count=“3”>
 <reader ref=”accountReader”/>! <processor ref=”accountProcessor”/>
 <writer ref=”myWriter”/>! </step> …implements ItemReader {
 public Object readItem() {
 // read account using JPA } …implements ItemProcessor {! Public Object processItems(Object account) {
 // read Account, return Statement! }! …implements ItemWriter {! public void writeItems(List accounts) {
 // use JavaMail to send email or save on disk! }!
  • 62. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!62 Batch 1.0 <step id=”transferFile”>! <batchlet ref=“MyFileTransfer” />! </step> @Dependent! @Named("MyFileTransfer")! public class MyBatchlet implements javax.batch.api.chunk.Batchlet {! @Inject! private JobContext jobCtx;!! @Override! public void process() throws Exception {! String fName = jobCtx.getProperties().getProperty("out_file");! // transfer file! }! }!
  • 63. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!63 Batch 1.0 Interface Abstract Classes JobListener AbstractJobListener StepListener AbstractStepListener ChunkListener AbstractChunkListener ItemRead/Write/ProcessListener AbstractItemRead/Write/ProcessListener SkipRead/Write/ProcessListener AbstractSkipRead/Write/ProcessListener RetryRead/Write/ProcessListener AbstractRetryRead/Write/ProcessListener Listeners
  • 64. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!64 Batch 1.0 JobOperator private long startNewBatchJob() throws Exception { ! ! ! JobOperator jobOperator = BatchRuntime.getJobOperator(); ! ! ! Properties props = new Properties(); ! ! ! props.setProperty(”someInputFileName", someInputFileName); ! ! ! return jobOperator.start(JOB_NAME, props); ! }
  • 65. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!65 And more… ▪ Servlet 3.1 ▪ JPA 2.1 ▪ JSF 2.2 ▪ EJB 3.2 ▪ EL 3.0 ▪ JCA 1.7 ▪ …
  • 66. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!66 Java EE 7 Summary ENTERPRISE EDITION ▪ Batch ▪ Concurrency ▪ Simplified JMS ▪ More annotated POJOs ▪ Less boilerplate code ▪ Cohesive integrated 
 platform DEVELOPER PRODUCTIVITY ▪ WebSockets ▪ JSON ▪ Servlet 3.1 NIO ▪ REST MEETING 
 ENTERPRISE DEMANDS Java EE 7
  • 67. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!67 Transparency in JSR processes ▪ java.net used for all Oracle-led JSRs – http://java.net/projects/javaee-spec/pages/Home ▪ Publicly viewable Expert Group mailing archives ▪ Users observer lists get copies of all Expert Group emails ▪ Public download areas, JIRAs ▪ Wikis, source repositories, etc. at the group discretion ▪ Commitment to JCP 2.8/2.9 processes All Java EE JSRs run with high level of transparency
  • 68. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!68 DOWNLOAD Java EE 7 SDK oracle.com/javaee ! GlassFish 4.0 Full Platform or Web Profile glassfish.org
  • 69. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!69 WebLogic Server 12.1.3 WebLogic Server 12.1.3 Clients HTML5 clients ADF Mobile Proxies HTTP/S, JSON/XML WebSocket, Server-Sent Events, Long polling OTD Apache OHS Web Sockets (JSR 356) TopLink Data Services Server-Sent Events JAX-RS 2.0 Avatar (post-GA) HTML5client emulation JPA Change
 Notification Database • Server-Sent Events • JAX-RS 2.0 • WebSocket – JSR 356 • JPA 2.1, JSON-P • WebSocket Client Emulation • Avatar • Maven improvements • Classloader Analysis Tool updates
  • 70. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!70 Program Agenda Java EE 8 and beyond
  • 71. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!71 Java EE 8 ▪ New JSRs ▪ JCACHE (JSR 107) ▪ Data Grid API (JSR 347) ▪ State Management API (JSR 350) ▪ Identity API (JSR 351) ▪ Java API for JSON Binding ▪ Java EE Configuration ▪ … ▪ Profiles & Pruning Ideas… just ideas!
  • 72. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!72 Java EE 8 ▪ HTML 5 ▪ Server-sent events? ▪ JavaScript on the server? ▪ Something else? ▪ User Interface ▪ MVC? ▪ Client API for TSA? ▪ Templating? Facelet? Ideas (cont.)
  • 73. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!73 Java EE 8 ▪ CDI ▪ NoSQL ? ▪ Cloud ▪ PaaS, SaaS, Multi-tenancy ? ▪ Logging ▪ Security ▪ Testability ▪ Deployment, Management, Monitoring ▪ ??? Ideas (cont.)
  • 74. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!74 https://glassfish.org/survey Java EE 8 Survey
  • 75. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!75 Merci!
  • 76. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12!76 Graphic Section Divider