5. Top Ten Features in Java EE 7
1. WebSocket client/server endpoints
2. Batch Applications
3. JSON Processing
4. Concurrency Utilities
5. Simplified JMS API
6. @Transactional and @TransactionScoped
7. JAX-RS Client API
8. Default Resources
9. More annotated POJOs
10. Faces Flow
6. Java API for WebSocket 1.0
⢠Server and Client WebSocket Endpoint
⢠Annotated: @ServerEndpoint, @ClientEndpoint
⢠Programmatic: Endpoint
⢠Lifecycle events support
⢠Standard Packaging and Deployment
@ServerEndpoint("/chat")
public class ChatServer {
@OnMessage
public void chat(String m) {
. . .
}
}
Available 4Q2014 via Liberty Repository!
7. 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);
}
. . .
Chat Server
8. Java API for WebSocket 1.0
. . .
@OnMessage
public void message(String message) {
for (Session peer : peers) {
peer.getRemote().sendObject(message);
}
}
}
Chat Server (contd.)
9. JSON Processing 1.0
⢠API to parse and generate JSON
⢠Streaming API
⢠Low-level, efficient way to parse/generate JSON
⢠Similar to StAX API in XML world
⢠Object Model API
⢠Simple, easy to use high-level API
⢠Similar to DOM API in XML world
Available 4Q2014 via Liberty Repository!
13. <step id="sendStatements">
<chunk item-count="3">
<reader ref="accountReader"/>
<processor ref="accountProcessor"/>
<writer ref="emailWriter"/>
</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 statements) {
// use JavaMail to send email
}
Batch Applications 1.0
Chunked Job Specification
14. Concurrency Utilities for Java EE 1.0
⢠Extension of Java SE Concurrency Utilities API
⢠Provide asynchronous capabilities to Java EE application components
⢠Provides 4 types of managed objects
⢠ManagedExecutorService
⢠ManagedScheduledExecutorService
⢠ManagedThreadFactory
⢠ContextService
⢠Context Propagation
Available 4Q2014 via Liberty Repository!
15. Concurrency Utilities for Java EE 1.0
public class TestServlet extends HttpPServlet {
@Resource(name="java:comp/DefaultManagedExecutorService")
ManagedExecutorService executor;
Future future = executor.submit(new MyTask());
class MyTask implements Runnable {
public void run() {
. . . // task logic
}
}
}
Submit Tasks to ManagedExecutorService using JNDI
16. Java Message Service 2.0
⢠New JMSContext interface
⢠AutoCloseable JMSContext, Connection, Session, âŚ
⢠Use of runtime exceptions
⢠Method chaining on JMSProducer
⢠Simplified message sending
Get More from Less
Java EE 7
Available via Liberty Beta!
18. Java Message Service 2.0
@Inject
JMSContext context;
@Resource(lookup = "java:global/jms/demoQueue")
Queue demoQueue;
public void sendMessage(String payload) {
context.createProducer().send(demoQueue, payload);
}
Sending a Message
19. Java API for RESTful Web Services 2.0
⢠Client API
⢠Message Filters and Entity Interceptors
⢠Asynchronous Processing â Server and Client
⢠Common Configuration
Available via Liberty Beta!
20. Java API for RESTful Web Services 2.0
// Get instance of Client
Client client = ClientBuilder.newClient();
// Get customer name for the shipped products
String name =
client.target("../orders/{orderId}/customer")
.resolveTemplate("orderId", "10")
.queryParam("shipped", "true")
.request()
.get(String.class);
Client API
21. Contexts and Dependency Injection 1.1
⢠Automatic enablement for beans with scope annotation and
EJBs
⢠âbeans.xmlâ is optional
⢠Bean discovery mode
⢠all: All types
⢠annotated: Types with bean defining annotation (default)
⢠none: Disable CDI
⢠@Vetoed for programmatic disablement of classes
⢠Global ordering/priority of interceptors and decorators
Available via Liberty Beta!
22. Bean Validation 1.1
⢠Alignment with Dependency Injection
⢠Method-level validation
⢠Constraints on parameters and return values
⢠Check pre-/post-conditions
⢠Integration with JAX-RS
Java EE 7
Available via Liberty Beta!
23. Built-in
Custom
@Future
public Date getAppointment() {
//. . .
}
public void placeOrder(
@NotNull String productName,
@NotNull @Max("10") Integer quantity,
@Customer String customer) {
//. . .
}
Bean Validation 1.1
Method Parameter and Result Validation
24. 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
⢠Entity Graphs
Available via Liberty Beta!
25. Servlet 3.1
⢠Non-blocking I/O
⢠Protocol Upgrade
⢠HttpUpgradeHandler â necessary for Web Sockets
⢠Security Enhancements
⢠<deny-uncovered-http-methods>: Deny request to HTTP
methods not explicitly covered by specified constaints
Available 4Q2014 via Liberty Repository!
26. 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 I/O Traditional
28. Servlet 3.1
@Override
public 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 read
29. 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
⢠h:inputFile: New File Upload Component
30. Java Transaction API 1.2
ď§ @Transactional: Define transaction boundaries on CDI managed
beans
⢠@TransactionScoped: CDI scope for bean instances
scoped to the active JTA transaction
Java EE 7
Available via Liberty Beta!
32. WebSphere Java EE 7 âRoadmapâ
⢠Java EE 7 Statement of Direction
⢠http://www-
01.ibm.com/common/ssi/ShowDoc.wss?docURL=/common/ssi/rep_ca/4/897/ENUS214-
184/index.html&lang=en&request_locale=en
⢠IBM intends to deliver a Java EE 7 full platform compliant implementation of WebSphere
Application Server.
⢠IBM intends to deliver additional Java EE 7 components and additional technologies for
WebSphere Application Server through continuous delivery of new features in the coming
months.
⢠Liberty GA Deliverables of Java EE Features
⢠Web Sockets 1.0 (4Q2014) and Web Sockets 1.1 (1Q2015)
⢠Servlet 3.1 (4Q2014)
⢠JSON-P 1.0 (4Q2014)
⢠Concurrency Utilities 1.0 (4Q2014)
⢠Java Server Pages (JSP) 2.3 (1Q2015)
⢠Expression Language 3.0 (1Q2015)
⢠Common Annotations 1.2 (1Q2015)
⢠JDBC 4.1 (1Q2015)
⢠Liberty Beta (Preliminary versions of Java EE features)
⢠https://www.ibmdw.net/wasdev/downloads/liberty-profile-beta/
⢠Future Content âŚ
⢠Extrapolate at your own speed⌠ď
34. Sampling of Related SessionsâŚ
⢠AAI-1713A: Introduction to Java EE 7
⢠Monday, 2-3pm, Mandalay Bay, Reef Ballroom E
⢠AAI-1641A: Introduction to Web Sockets
⢠Monday, 5-6pm, Mandalay Bay, Reef Ballroom E
⢠AAI-1313A: Agile Development Using Java EE 7 with WebSphere Liberty Profile
(LAB)
⢠Tuesday, 8-10am, Mandalay Bay, South Seas Ballroom D
⢠AAI-2236A: Using the New Java Concurrency Utilities with IBM WebSphere
⢠Tuesday, 2-3pm, Mandalay Bay, Reef Ballroom D
⢠AAI-2235A: OpenJPA and EclipseLink Usage Scenarios Explained
⢠Wednesday, 5:30-6:30pm, Mandalay Bay, Surf Ballroom A
⢠AAI-1610A: Configuring IBM WebSphere Application Server for Enterprise
Messaging Needs
⢠Wednesday, 5:30-6:30pm, Mandalay Bay, Surf Ballroom E
⢠AAI-3085A: Donât Wait! Develop Responsive Applications with Java EE7 Instead
⢠Thursday, 10:30-11:30am, Mandalay Bay, Lagoon L
33
36. Notices and Disclaimers
Copyright Š 2015 by International Business Machines Corporation (IBM). No part of this document may be reproduced or
transmitted in any form without written permission from IBM.
U.S. Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with
IBM.
Information in these presentations (including information relating to products that have not yet been announced by IBM) has been
reviewed for accuracy as of the date of initial publication and could include unintentional technical or typographical errors. IBM
shall have no responsibility to update this information. THIS DOCUMENT IS DISTRIBUTED "AS IS" WITHOUT ANY WARRANTY,
EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL IBM BE LIABLE FOR ANY DAMAGE ARISING FROM THE USE OF
THIS INFORMATION, INCLUDING BUT NOT LIMITED TO, LOSS OF DATA, BUSINESS INTERRUPTION, LOSS OF PROFIT
OR LOSS OF OPPORTUNITY. IBM products and services are warranted according to the terms and conditions of the
agreements under which they are provided.
Any statements regarding IBM's future direction, intent or product plans are subject to change or withdrawal without
notice.
Performance data contained herein was generally obtained in a controlled, isolated environments. Customer examples are
presented as illustrations of how those customers have used IBM products and the results they may have achieved. Actual
performance, cost, savings or other results in other operating environments may vary.
References in this document to IBM products, programs, or services does not imply that IBM intends to make such products,
programs or services available in all countries in which IBM operates or does business.
Workshops, sessions and associated materials may have been prepared by independent session speakers, and do not
necessarily reflect the views of IBM. All materials and discussions are provided for informational purposes only, and are neither
intended to, nor shall constitute legal or other guidance or advice to any individual participant or their specific situation.
It is the customerâs responsibility to insure its own compliance with legal requirements and to obtain advice of competent legal
counsel as to the identification and interpretation of any relevant laws and regulatory requirements that may affect the customerâs
business and any actions the customer may need to take to comply with such laws. IBM does not provide legal advice or
represent or warrant that its services or products will ensure that the customer is in compliance with any law.
37. Notices and Disclaimers (conât)
Information concerning non-IBM products was obtained from the suppliers of those products, their published
announcements or other publicly available sources. IBM has not tested those products in connection with this
publication and cannot confirm the accuracy of performance, compatibility or any other claims related to non-IBM
products. Questions on the capabilities of non-IBM products should be addressed to the suppliers of those products.
IBM does not warrant the quality of any third-party products, or the ability of any such third-party products to
interoperate with IBMâs products. IBM EXPRESSLY DISCLAIMS ALL WARRANTIES, EXPRESSED OR IMPLIED,
INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE.
The provision of the information contained herein is not intended to, and does not, grant any right or license under any
IBM patents, copyrights, trademarks or other intellectual property right.
⢠IBM, the IBM logo, ibm.com, Bluemix, Blueworks Live, CICS, Clearcase, DOORSŽ, Enterprise Document
Management Systemâ˘, Global Business Services ÂŽ, Global Technology Services ÂŽ, Information on Demand,
ILOG, MaximoÂŽ, MQIntegratorÂŽ, MQSeriesÂŽ, NetcoolÂŽ, OMEGAMON, OpenPower, PureAnalyticsâ˘,
PureApplicationÂŽ, pureClusterâ˘, PureCoverageÂŽ, PureDataÂŽ, PureExperienceÂŽ, PureFlexÂŽ, pureQueryÂŽ,
pureScaleÂŽ, PureSystemsÂŽ, QRadarÂŽ, RationalÂŽ, RhapsodyÂŽ, SoDA, SPSS, StoredIQ, TivoliÂŽ, TrusteerÂŽ,
urban{code}ÂŽ, Watson, WebSphereÂŽ, WorklightÂŽ, X-ForceÂŽ and System zÂŽ Z/OS, are trademarks of
International Business Machines Corporation, registered in many jurisdictions worldwide. Other product and
service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on
the Web at "Copyright and trademark information" at: www.ibm.com/legal/copytrade.shtml.
38. Thank You
Your Feedback is
Important!
Access the InterConnect 2015
Conference CONNECT Attendee
Portal to complete your session
surveys from your smartphone,
laptop or conference kiosk.