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

3,737 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
3,737
On SlideShare
0
From Embeds
0
Number of Embeds
2,627
Actions
Shares
0
Downloads
15
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

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

  1. 1. What’s New in the Java EE Platform Alpes JUG - March 2014 ! David Delabassee @delabassee Software Evangelist - Oracle
  2. 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. 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. 4. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!4 Java EE 7 Momentum
  5. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 70. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!70 Program Agenda Java EE 8 and beyond
  71. 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. 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. 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. 74. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!74 https://glassfish.org/survey Java EE 8 Survey
  75. 75. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.!75 Merci!
  76. 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

×