OTN Tour 2013: What's new in java EE 7
-
date post
18-Oct-2014 -
Category
Technology
-
view
1.918 -
download
0
description
Transcript of OTN Tour 2013: What's new in java EE 7
![Page 1: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/1.jpg)
What's new in Java EE 7?
Bruno BorgesOracle Product Manager e Java Evangelistblogs.oracle.com/brunoborges@brunoborges
![Page 2: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/2.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Hola!
@brunoborgesblogs.oracle.com/brunoborges
![Page 3: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/3.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
The preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.
![Page 4: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/4.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
5
Top Ten Features in Java EE 6
1. EJB packaging in a WAR2. Type-safe dependency injection3. Optional deployment descriptors (web.xml, faces-config.xml)
4. JSF standardizing on Facelets5. One class per EJB6. Servlet and CDI extension points7. CDI Events8. EJBContainer API9. Cron-based @Schedule10. Web Profile
Launched in December 2009
![Page 5: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/5.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
6
![Page 6: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/6.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
Java EE 7- Productivity- HTML5 Support- Enterprise Demands
![Page 7: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/7.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Trends versus Spring
![Page 8: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/8.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
Java EE 7 Themes
More annotated POJOs Less boilerplate code Cohesive integrated platform Default resources
Batch Applications Concurrency Utilities Simplified JMS and
Compatibility
WebSocket JSON Processing Servlet 3.1 NIO REST HTML5-Friendly
Markup
![Page 9: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/9.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
14
EJB 3.2
Servlet 3.1
CDIExtensions
Batch 1.0
Web Fragments
Java EE 7 JSRs
JCA 1.7JMS 2.0JPA 2.1
Managed Beans 1.0
Concurrency 1.0Common
Annotations 1.1Interceptors1.2, JTA 1.2✔
CDI 1.1
JSF 2.2,JSP 2.3,EL 3.0
JAX-RS 2.0,JAX-WS 2.2
JSON 1.0WebSocket
1.0
![Page 10: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/10.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
15
Top 10 Features Java EE 7
WebSocket client/server endpoints Batch Applications JSON Processing Concurrency Utilities Simplified JMS API @Transactional and @TransactionScoped! JAX-RS Client API Default Resources More annotated POJOs Faces Flow
![Page 11: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/11.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
16
Java API for WebSocket 1.0Annotated Endpointimport javax.websocket.*;
@ServerEndpoint("/hello")public class HelloBean {
@OnMessage public String sayHello(String name) { return “Hello “ + name; }}
![Page 12: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/12.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
17
Java API for WebSocket 1.0
@ServerEndpoint("/chat")
public class ChatBean {
static Set<Session> peers = Collections.synchronizedSet(…);
@OnOpen public void onOpen(Session peer) {peers.add(peer);}
@OnClose public void onClose(Session peer) {peers.remove(peer);}
@OnMessage
public void message(String message, Session client) { peers.forEach(peer -> peer.getRemote().sendObject(message);
}}
Chat Server
![Page 13: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/13.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
18
Java API for JSON Processing 1.0
API to parse and generate JSON Streaming API
– Low-level, efficient way to parse/generate JSON– Provides pluggability for parsers/generators
Object Model API– Simple, easy-to-use high-level API– Implemented on top of Streaming API
Binding JSON to Java objects forthcoming
![Page 14: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/14.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
19
{
"firstName": "John", "lastName": "Smith", "age": 25, "phoneNumber": [ { "type": "home", "number": "212 555-1234" }, { "type": "fax", "number": "646 555-4567" } ]}
Iterator<Event> it = parser.iterator();
Event event = it.next(); // START_OBJECT
event = it.next(); // KEY_NAME
event = it.next(); // VALUE_STRING
String name = parser.getString(); // "John”
Java API for JSON Processing 1.0Streaming API – JsonParser
![Page 15: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/15.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
20
Batch Applications 1.0
Suited for non-interactive, bulk-oriented and long-running tasks
Computationally intensive Can execute sequentially/parallel May be initiated
– Adhoc– Scheduled
No scheduling APIs included
![Page 16: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/16.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
21
Batch Applications 1.0
Job: Batch process Step: Independent, sequential phase of job
– Reader, Processor, Writer
Job Operator: Manage batch processing Job Repository: Metadata for jobs
![Page 17: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/17.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
22
Batch Applications 1.0
<step id=”sendStatements”> <chunk reader ref=”accountReader” processor ref=”accountProcessor” writer ref=”emailWriter” chunk-size=”10” /></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}
Job Specification Language – Chunked Step
![Page 18: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/18.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
23
Concurrency Utilities for Java EE 1.0
Provide asynchronous capabilities to Java EE application components
– Without compromising container integrity
Extension of Java SE Concurrency Utilities API (JSR 166)
Support simple (common) and advanced concurrency patterns
![Page 19: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/19.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
24
Concurrency Utilities for Java EE 1.0
Provide 4 managed objects– ManagedExecutorService
– ManagedScheduledExecutorService
– ManagedThreadFactory
– ContextService
Context propagation Task event notifications Transactions
![Page 20: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/20.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
25
Concurrency Utilities for Java EE 1.0
public class TestServlet extends HTTPServlet { @Resource(name=“concurrent/BatchExecutor”) ManagedExecutorService executor;
Future future = executor.submit(new MyTask());
class MyTask implements Runnable { public void run() { . . . // task logic } }}
Submit Tasks to ManagedExecutorService using JNDI
![Page 21: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/21.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
26
Java API for RESTful Web Services 2.0
Client API Message Filters and Entity Interceptors Asynchronous Processing – Server and Client Common Configuration
![Page 22: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/22.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
27
Java API for RESTful Web Services 2.0Client API
// Get instance of ClientClient client = ClientBuilder.newClient(); // Get customer name for the shipped productsString name = client.target(“../orders/{orderId}/customer”) .resolveTemplate(”orderId", ”10”) .queryParam(”shipped", ”true”) .request() .get(String.class);
![Page 23: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/23.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
28
Java Message Service 2.0
Simplified API– Less verbose– Reduced boilerplate code– Resource injection
– Try-with-resources for Connection, Session, etc.
Both in Java EE and SE
![Page 24: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/24.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
29
Java Message Service 2.0
@Resource(lookup = "myConnectionFactory”)ConnectionFactory connectionFactory;
@Resource(lookup = "myQueue”)Queue myQueue;
public void sendMessage (String payload) { Connection connection = null; try { connection = connectionFactory.createConnection(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageProducer messageProducer = session.createProducer(myQueue); TextMessage textMessage = session.createTextMessage(payload); messageProducer.send(textMessage); } catch (JMSException ex) { //. . . } finally { if (connection != null) { try { connection.close(); } catch (JMSException ex) {
//. . . } } }}
Sending a Message using JMS 1.1
Application Server Specific Resources
Boilerplate Code
Exception Handling
![Page 25: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/25.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
30
Java Message Service 2.0
@InjectJMSContext context;
@Resource(lookup = "java:global/jms/demoQueue”)Queue demoQueue;
public void sendMessage(String payload) { context.createProducer().send(demoQueue, payload);}
Sending message using JMS 2.0
![Page 26: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/26.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
31
Bean Validation 1.1
Alignment with Dependency Injection Method-level validation
– Constraints on parameters and return values– Check pre-/post-conditions
![Page 27: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/27.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
32
Bean Validation 1.1Method Parameter and Result Validation
Built-in
Custom
@Futurepublic Date getAppointment() { //. . .}
public void placeOrder( @NotNull String productName, @NotNull @Max(“10”) Integer quantity, @Customer String customer) { //. . .}
![Page 28: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/28.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
33
Java Persistence API 2.1
Schema Generation– javax.persistence.schema-generation.* properties
Unsynchronized Persistence Contexts Bulk update/delete using Criteria User-defined functions using FUNCTION Stored Procedure Query
![Page 29: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/29.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
34
Servlet 3.1
Non-blocking I/O Protocol Upgrade Security Enhancements
– <deny-uncovered-http-methods>: Deny request to HTTP methods not explicitly covered
![Page 30: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/30.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
35
Servlet 3.1
public class TestServlet extends HttpServlet protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { ServletInputStream input = request.getInputStream(); byte[] b = new byte[1024]; int len = -1; while ((len = input.read(b)) != -1) { . . . } }}
Non-blocking IO - Traditional
![Page 31: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/31.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
36
Servlet 3.1
AsyncContext context = request.startAsync();ServletInputStream input = request.getInputStream();input.setReadListener( new MyReadListener(input, context));
Non-blocking I/O: doGet Code Sample
![Page 32: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/32.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
37
Servlet 3.1
@Overridepublic void onDataAvailable() { try { StringBuilder sb = new StringBuilder(); int len = -1; byte b[] = new byte[1024]; while (input.isReady() && (len = input.read(b)) != -1) { String data = new String(b, 0, len); System.out.println("--> " + data); } } catch (IOException ex) { . . . }}. . .
Non-blocking I/O: MyReadListener Code Sample
![Page 33: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/33.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
38
JavaServer Faces 2.2
Faces Flow Resource Library Contracts HTML5 Friendly Markup Support
– Pass through attributes and elements
Cross Site Request Forgery Protection Loading Facelets via ResourceHandler File Upload Component
![Page 34: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/34.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
39
Java Transaction API 1.2
@Transactional: Define transaction boundaries on CDI managed beans
@TransactionScoped: CDI scope for bean instances scoped to the current JTA transaction
![Page 35: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/35.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
40
Novas Possibilidades com Java EE 7
Camada Web 100% server-side
– JSF 100% client-side
– JAX-RS + WebSockets + (Angular.JS) Híbrido
– Utilize o que achar conveniente, e melhor, para cada caso da aplicação
![Page 36: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/36.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
41
Novas Possibilidades com Java EE 7
Camada Back-end Java EE Web Profile
– EJB3 Lite + CDI + JTA + JPA Java EE Full Profile
– WebP + JMS + JCA + Batch
![Page 37: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/37.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
glassfish.org
![Page 38: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/38.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
46
Call to Action
• Specs: javaee-spec.java.net
• Implementation: glassfish.org
• The Aquarium: blogs.oracle.com/theaquarium
• Adopt a JSR: glassfish.org/adoptajsr
• NetBeans: wiki.netbeans.org/JavaEE7
![Page 39: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/39.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
47
Grácias!
@brunoborgesblogs.oracle.com/brunoborges
![Page 40: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/40.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
48
Preguntas?
![Page 41: OTN Tour 2013: What's new in java EE 7](https://reader033.fdocuments.in/reader033/viewer/2022052409/54431021b1af9f410a8b4860/html5/thumbnails/41.jpg)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
49