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
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.