Mohamed Taman S y s t e m s A r c h i t e c t & D e s i g n S u p e r v i s o r, J C P, J C P E x e c u t i v e C o m m i t t e e , E x p e r t G r o u p h t t p : / / a b o u t . m e / m o h a m e d t am a n
About Me
• A Systems Architect & Design supervisor @ “e-finance”.
• JCP, Executive Committee, Expert Group Member, responsible for JSRs revision, evaluation, RI testing and evangelist the new technologies specifications & JCP process standardization.
• Board member of “Oracle Egypt Architect Club”.
• A frequent Speaker (JavaOne, Devoxx, Oracle Days, Tunis JUG Day, jMaghreb, JEEConf & JDC... etc.),
• Consultant, Trainer, Blogger, & articles writer, books author and tech. reviewer.
• Regularly posts on my blog , and also on DZone & JCG community.
Catch Me
Agenda • What is Java EE 7?
• Main aim and objectives of Java EE 7.
• What is new in Java EE 7? • HTML5 support.
• IDEs support.
• Glassfish v4.0 as RI.
• Netbeans IDE.
• Adopt-a-JSR organization on Github.
• What's new
• The new Strategy
Java EE Past, Present, & Future
J2EE 1.2 Servlet, JSP, EJB, JMS, RMI
Dec 1999
J2EE 1.2 CMP, Connector Architecture
Sep 2001
J2EE 1.4 Web Services Mgmt, Deployment, Async Connector
Nov 2003
Java EE 5 Ease of Development, EJB 3, JPA, JSF, JAXB, JAX-WS, StAX, SAAJ
May 2006
Java EE 6 Pruning, Extensibility Ease of Dev, CDI, JAX-RS
Web Profile Servlet 3, EJB 3.1 Lite
Dec 2009
Java EE 7 JMS 2, Batch, TX, Concurrency, Interceptor, WebSocket, JSON
Web Profile JAX-RS 2
Jun 2013
JAX-RPC, CMP/ BMP, JSR 88
Java EE 6 - Achievements • 50,000,000 + downloads
• #1 choice for enterprise developers
• #1 application development platform
• Fastest adoptions of any Java EE release – 18 complaint servers
Java EE 6 – Main Features • Web Profile
• EJB packaged in war
• Optional web.xml
• Type-safe dependency injection
• CDI Events
• JSF standardizing on facelets
• @Schedule
What is new in Java EE 7? MA I N CO MP O NENT S
Main aim and objectives of Java EE 7
Java EE 7 – Candidate JSRs
Connector 1.6
Managed Beans 1.0 EJB 3.2
Servlet 3.1
Portable Extension
s
JSF 2.2 JAX-RS
2.0
Bea
n V
alid
atio
n 1.
1
JMS 2.0 JPA 2.1
EL 3.0
JTA 1.2
JSP 2.2
Interceptors 1.1 CDI 1.1 Common
Annotations 1.1
Updated
Major Release
New
Concurrency Utilities (JSR 236)
Batch Applications (JSR 352)
Java API for JSON (JSR 353)
Java API for WebSocket (JSR 356)
Active JSRs • JSR 342: Java EE 7 Platform
• JSR 338: Java API for RESTful Web Services 2.0
• JSR 339: Java Persistence API 2.1
• JSR 340: Servlet 3.1
• JSR 341: Expression Language 3.0
• JSR 343: Java Message Service 2.0
• JSR 344: JavaServer Faces 2.2
• JSR 345: Enterprise JavaBeans 3.2
• JSR 346: Contexts and Dependency Injection 1.1
• JSR 349: Bean Validation 1.1
• JSR 236: Concurrency Utilities for Java EE 1.0
• JSR 352: Batch Applications for the Java Platform 1.0
• JSR 353: Java API for JSON Processing 1.0
• JSR 356: Java API for WebSocket 1.0
Java EE 7 new Features
Java EE Web Profile Enhancements • The Java Enterprise Edition Web Profile was introduced in Java EE 6
• Most Web applications have significant requirements in the areas of transaction management, security, and persistence.
• but are not supported by standalone servlet containers.
• Web Profile is provided with pre-installed, pre-integrated, fully tested Web infrastructure features.
• The Java EE 7 Web Profile adds support for HTML5 with WebSockets, JSON, JAX-RS 2.0, and more.
JSR 343: Java Message Service 2.0
• API modernization using dependency injection
• Delivery delay, async send, MDB alignment, JMS resource definition
• Fixes, clarifications
JMS 2 - Old API @Resource(lookup = "java:global/jms/demoConnectionFactory") ConnectionFactory connectionFactory; @Resource(lookup = "java:global/jms/demoQueue") Queue demoQueue; public void sendMessage(String payload) { try { Connection connection = connectionFactory.createConnection(); try { Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageProducer messageProducer = session.createProducer(demoQueue); TextMessage textMessage = session.createTextMessage(payload); messageProducer.send(textMessage); } finally { connection.close(); } } catch (JMSException ex) { Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex); } }
JMS 2 Simplified API
@Inject private JMSContext context; @Resource(mappedName = "jms/inboundQueue") private Queue inboundQueue; public void sendMessage (String payload) { context.createProducer().send(inboundQueue, payload); }
JMS 2/Java EE 7 JMS Resource Definition
@JMSConnectionFactoryDefinition( name="java:global/jms/demoConnectionFactory", interfaceName= "javax.jms.ConnectionFactory", description="ConnectionFactory to use in demonstration") @JMSDestinationDefinition( name = "java:global/jms/demoQueue", description = "Queue to use in demonstration", interfaceName = "javax.jms.Queue", destinationName="demoQueue")
JMS 2/EJB 3.2 More Standard MDB Properties
@MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), @ActivationConfigProperty( propertyName = "destinationLookup", propertyValue = "jms/OrderQueue"), @ActivationConfigProperty( propertyName = "connectionFactoryLookup", propertyValue = "jms/MyConnectionFactory")}) public class OrderListener implements MessageListener { ... public void onMessage(Message message) { ... } ... }
Why WebSocket? • HTTP is half duplex
• HTTP is verbose
• Hacks for Server Push • Polling
• Long Polling
• Comet/Ajax
• Complex, Wasteful, Inefficient
WebSocket to rescue • TCP based, bi-directional, full-duplex messaging
• Capable of sending both UTF-8 string and binary frames in any direction at the same time
• Operating from a single socket across the web
• As part of HTML5, the application of the client interface will become native to all modern browsers
• To establish a Web Socket connection, the browser or client simply makes a request to the server for an upgrade from HTTP to a Web Socket
“Reducing kilobytes of data to 2 bytes…and reducing latency from 150ms
to 50ms is far more than marginal. In fact, these two factors alone are enough
to make Web Sockets seriously interesting to Google.”
JSR 356: Java API for WebSocket 1.0
• Higher level API for WebSocket
• Both client and server-side (Java SE and Java EE)
• Both declarative and programmatic
Java API for WebSocket Connection Life Cycle
@ServerEndpoint(”/chat”) public class ChatServer { Set<Session> peers = ... @OnOpen public void onOpen(Session peer) { peers.add(peer); } @OnClose public void onClose(Session peer) { peers.remove(peer); } ...
Java API for WebSocket WebSocket Communication
... @OnMessage public void message(String message, Session client) throws IOException { for (Session session : peers) { if (!session.equals(client)) { session.getRemote().sendObject(message); } } } }
JSON (JavaScript Object Notation) • JSON (JavaScript Object Notation)
is a lightweight data-interchange format. It is easy for humans to read and write.
• It is easy for machines to parse and generate.
• It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999.
• JSON is a text format that is completely language independent but uses conventions that are familiar to programmers
{ “employee": [ { "firstName":“MOh" , "lastName":“Taman" }, { "firstName":"Anna" , "lastName":"Smith" }, { "firstName":"Peter" , "lastName":"Jones" } ] }
Why we need another API?
• JSON has become a defacto data transfer standard specially for RESTful Web Services.
• Java applications use different implementations to consume and process JSON data.
• There should be standardized Java API for JSON so that applications do not need to bundle the implementation libraries.
JSR 353: Java API for JSON Processing 1.0 • API to parse, generate, transform, query JSON
• Binding JSON to Java objects forthcoming.
• API to parse and generate JSON • Streaming API
• Low level efficient way to parse/generate JSON • Provide Pluggability for parser/generator
• Object Model • similar to DOM and StAX • Simple, Easy-to-use high-level API • Implemented on top of Streaming API
Java API for JSON Processing Writing JSON (Object Model API)
JsonArray value = Json.createArrayBuilder() .add(Json.createObjectBuilder() .add("type", "home") .add("number", "212 555-1234") ) .add(Json.createObjectBuilder() .add("type", "fax") .add("number", "646 555-4567") ) .build();
[ { "type": "home”, "number": "212 555-1234" }, { "type": "fax”, "number": "646 555-4567" } ]
Java API for JSON Processing Reading JSON (Streaming API)
{ "firstName": “Mohamed", "lastName": “Taman", "age": 25, "phoneNumber": [ { "type": "home", "number": "212 555-1234" }, { "type": "fax", "number": "646 555-4567" } ] }
Event event = parser.next(); // START_OBJECT event = parser.next(); // KEY_NAME event = parser.next(); // VALUE_STRING String name = parser.getString(); // “Mohamed”
JSR 338: Java API for RESTful Web Services 2.0 • Client API
• Message Filters & Entity Interceptors
• Asynchronous Processing – Server & Client
• Hypermedia Support
• Content negotiation
JAX-RS 2 Client API
// Get instance of Client Client client = ClientBuilder.newClient(); // Get customer name for the shipped products String name = client.target(“../orders/{orderId}/customer”) .pathParam(”orderId", ”10”) .queryParam(”shipped", ”true”) .request() .get(String.class);
JAX-RS 2 Logging Filter
public class RequestLoggingFilter implements ContainerRequestFilter { @Override public void filter(ContainerRequestContext requestContext) { log(requestContext); // Non-wrapping => returns without invoking next filter } ... }
JSR 339: Java Persistence API 2.1 • The first spec to include new features is the JPA 2.1. The new features can be
described with the following short list:
• Schema Generation (Additional mapping metadata to provide better standardization)
• Stored procedures
• Unsynchronized persistence contexts
• Entity converters
• Multi-Tenancy (Table discriminator)
• Custom types and transformation methods - Query by Example
• Dynamic PU Definition
• Fixes and enhancements
JPA 2.1 Schema Generation Properties
• javax.persistence.schema-generation.[database|scripts].action “none”, “create”, “drop-and-create”, “drop”
• javax.persistence.schema-generation.scripts.[create|drop]-target
• javax.persistence.schema-generation.[create|drop]-script-source
• javax.persistence.sql-load-script-source
• javax.persistence.schema-generation.[create|drop]-source “metadata”, “script”, “metadata-then-script”, “script-then-metadata”
JPA 2.1 Stored Procedures
@Entity @NamedStoredProcedureQuery(name="topGiftsStoredProcedure”, procedureName="Top10Gifts") public class Product { StoredProcedreQuery query = EntityManager.createNamedStoredProcedureQuery( "topGiftsStoredProcedure"); query.registerStoredProcedureParameter(1, String.class, ParameterMode.INOUT); query.setParameter(1, "top10"); query.registerStoredProcedureParameter(2, Integer.class, ParameterMode.IN); query.setParameter(2, 100); . . . query.execute(); String response = query.getOutputParameterValue(1);
JTA 1.2 • Declarative transactions outside EJB
• Transaction scope - @TransactionScoped
JTA 1.2 @Transactional Annotation
@Inherited @InterceptorBinding @Target({TYPE, METHOD}) @Retention(RUNTIME) public @interface Transactional { TxType value() default TxType.REQUIRED; Class[] rollbackOn() default {}; Class[] dontRollbackOn() default {}; } @Transactional(rollbackOn={SQLException.class}, dontRollbackOn={SQLWarning.class}) public class UserService {...}
JSR 344: JavaServer Faces 2.2 • HTML5 Support (Form API)
• @FlowScoped
• @ViewScoped for CDI
• Managed beans deprecated/CDI alignment
• Stateless views
• Resource library contracts
• File upload component
• View actions
• Security
• Fixes and enhancements
JSF 2.2 Pass-Through HTML 5 Components
<html> ... <input type=“color” jsf:value=“#{colorBean.color2}” /> <input type=“date” jsf:value=“#{calendarBean.date1}” /> ... </html>
JSF 2.2 Faces Flow @Named
@FlowScoped(id="flow-a") public class FlowABean implements Serializable { public String getName() { return "FlowABean"; } public String getReturnValue() { return "/return1"; } @Produces public Flow getFlow(FlowBuilder builder) { builder.startNode("router1"); builder.flowReturn("success").fromOutcome("/complete"); builder.flowReturn("errorOccurred").fromOutcome("error"); builder.switchNode("router1") .navigationCase().condition("#{facesFlowScope.customerId == null}") .fromOutcome("create-customer") .defaultOutcome("view-customer"); builder.viewNode("create-customer"); builder.viewNode("maintain-customer-record"); builder.methodCall("upgrade-customer") .method("#{maintainCustomerBean.upgradeCustomer}").defaultOutcome("view-customer"); builder.initializer("#{maintainCustomerBean.initializeFlow}"); builder.finalizer("#{maintainCustomerBean.cleanUpFlow}"); return builder.getFlow(); } }
JSR 352: Batch Applications for the Java Platform 1.0 • Batch processing is execution of series of "jobs" that is suitable for
non-interactive, bulk-oriented and long-running tasks.
• no standard Java programming model existed for batch applications.
• API for robust batch processing targeted to Java EE, Java SE
Batch Applications for the Java Platform Step Example
<step id=”sendStatements”> <chunk reader=”accountReader” processor=”accountProcessor” writer=”emailWriter” item-count=”10” /> </step>
@Named(“accountReader") ...implements ItemReader... { public Account readItem() { // read account using JPA
@Named(“accountProcessor") ...implements ItemProcessor... { Public Statement processItems(Account account) { // read Account, return Statement
@Named(“emailWriter") ...implements ItemWriter... { public void writeItems(List<Statements> statements) { // use JavaMail to send email
1
2
3
JSR 349: Bean Validation 1.1 • Method constraints
• Bean Validation artifacts injectable
• Fixes, clarifications and enhancements
Bean Validation 1.1 Method Level Constraints
public void placeOrder( @NotNull String productName, @NotNull @Max(“10”) Integer quantity, @Customer String customer) { . . . } @Future public Date getAppointment() { . . . }
JSR 236: Concurrency Utilities for Java EE 1.0 • Provides simple, safe API for concurrency in Java EE
• Builds on Java SE concurrency
• java.util.concurrent.ExecutorService
• Relatively low-level API
• Important enabler for Java EE ecosystem
• Managing your own threads within a Java EE container is not recommended
• Using java.util.concurrent API in a Java EE application component such as EJB or Servlet are problematic since the container and server have no knowledge of these resource
Concurrency Utilities for Java EE Managed Task Executor
public class TestServlet extends HTTPServlet { @Resource(name=“concurrent/MyExecutorService”) ManagedExecutorService executor; Future future = executor.submit(new MyTask()); class MyTask implements Runnable { public void run() { ... // Task logic } } }
JSR 340: Servlet 3.1 • NIO.2 async I/O (Non-blocking I/O)
• Leverage Java EE concurrency
• Security improvements
• Web Sockets support
• Ease-of-Development
JSR 345: Enterprise JavaBeans 3.2
The scope of EJB 3.2 is intended to be relatively constrained in focusing on these goals:
• Incremental factorization (Interceptors).
• Further use of annotations to simplify the EJB programming model.
• Proposed Optional: BMP/CMP.
• Proposed Optional: Web Services invocation using RPC.
Others • CDI 1.1:
• Global enablement.
• @AroundConstruct.
• @Vetoed…
• EL 3.0: • Lambda expressions.
• Collections,
• Operators,
• Standalone API…
Support IDEs and Servers
IDEs • Netbeans 7.4 - free
• IntelliJ IDEA 12.x – commercial and community edition
• Eclipse Juno 4.0 - free
They supports the following main features: • Java EE 7 support (Web and enterprise support). • Mobile Development support (Android development, Cordova API). • JDK 8 EA support. • Full HTML5 support.
Servers
• GlassFish 4.0 (RI)
• Weblogic 12.1.2c Partially (WS, JSON-P).
• Apache Tomcat Version 8.0.0-RC5.
http://download.java.net/glassfish/4.0/release/glassfish-4.0.zip
RI
4.0
What's new in Java World
Java.next() EE 8 and beyond.
• JSON-B
• JCache
• CDI.next()
• More CDI/EJB alignment
• Cloud, PaaS, multitenancy/SaaS
• Security?
• Testability?
• Modularity?
• Management/deployment APIs?
• NoSQL?
• Action-oriented Web framework/HTML 5?
• JMS.next()?
Java SE 8 and beyond. • Lambda Expressions.
• Compact Profiles.
• Nashorn JavaScript Engine.
• Annotations on Java Types.
• DocTree API.
• Parallel Array Sorting.
• Unicode 6.2.
• Stronger Algorithms for Password-Based Encryption.
• Bulk Data Operations for Collections.
• Date & Time API.
• JDBC 4.2.
• More ++++
You are Java Developer.
• Before you were a Java SE, EE, ME, Embedded Developer.
• In the future of Java you will become Java Developer.
• Because of Java platform editions converges, then One platform will fit all needs.
Java & Embedded world.
• Oracle enhance the embedded APIs.
• Oracle becomes part of Raspberry PI equation. • http://www.raspberrypi.org
• Oracle developed dukePad as BOC on Raspberry PI platform. • https://wiki.openjdk.java.net/display/OpenJFX/DukePad
Internet of Things - IoT • The Internet of Things (or IoT for short) refers to uniquely identifiable
objects and their virtual representations in an Internet-like structure.
• Equipping all objects in the world with minuscule identifying devices or machine-readable identifiers could be transformative of daily life.
• According to ABI Research more than 30 billion devices will be wirelessly connected to the Internet of Things (Internet of Everything) by 2020.
• This concept, where devices connect to the internet/web via low power radio is the most active research area in IoT.
Wikipedia
Thanks for listening and attending.
See you in upcoming events
Resources • Java EE Tutorials
• http://docs.oracle.com/javaee/7/tutorial/doc/home.htm
• http://www.programming-simplified.com/index.html
• Digging Deeper
• http://docs.oracle.com/javaee/7/firstcup/doc/home.htm
• https://glassfish.java.net/hol/
• https://java.net/projects/cargotracker/
• Java EE 7 Transparent Expert Groups
• http://javaee-spec.java.net
• Java EE 7 Reference Implementación
• http://glassfish.org
• The Aquarium
• http://blogs.oracle.com/theaquarium
• Speakers
• http://www.infoq.com/presentations/Java-EE-7-8
Top Related