Java EE 7 Overview Hamed Hatami January 2014 from Iran JUG.

Slides:



Advertisements
Similar presentations
JSP and Servelets.
Advertisements

OASIS OData Technical Committee. AGENDA Introduction OASIS OData Technical Committee OData Overview Work of the Technical Committee Q&A.
JLab Lattice Portal – Data Grid Web Service Ying Chen, Chip Watson Thomas Jefferson National Accelerator Facility.
Web Services Web Services are the basic fundamental building blocks of invoking features that can be accessed by an application program. The accessibility.
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.Public 1 JavaScript/HTML5 Rich Clients Using Java EE 7 Reza Rahman Java EE/GlassFish.
 Java EE 7 The new features of the upcoming Enterprise Edition.
ISE 390 Dynamic Web Development Java EE Web Applications.
Java Servlet & JSP © copyright 2005 SNU OOPSLA Lab.
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13 1.
An architecture for webb applications, J2EE
Integrating SOA and the Application Development Framework Shaun O’Brien Principal Product Manager – Oracle JDeveloper / ADF.
Web applications using JavaServer Faces (JSF) A brief introduction 1JavaServer Faces (JSF)
JBoss Seam: Contextual Components Jason Bechtel
Sapana Mehta (CS-6V81) Overview Of J2EE & JBoss Sapana Mehta.
Layers & Tiers Umair Javed Lec - 41.
Session-01. What is a Servlet? Servlet can be described in many ways, depending on the context: 1.Servlet is a technology i.e. used to create web application.
Servlets Compiled by Dr. Billy B. L. Lim. Servlets Servlets are Java programs which are invoked to service client requests on a Web server. Servlets extend.
Introduction to Java web programming Dr Jim Briggs JWP intro1.
© Internna Technologies 1 IWebMvc Features, Possibilities & Goals.
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 1.
J AVA SE, EE, AND ME Compiled (with permission) from Sang Shin’s Introduction to Java EE Online Course Introduction to Java EE Online Course.
1 WebSocket & JSON Java APIs Hackday By Somay David
JavaServer Faces: The Fundamentals Compiled from Sun TechDays workshops (JSF Basics, Web-Tier Codecamp: JavaServer Faces, Java Studio Creator; IBM RAD)
Chapter 10 EJB Concepts of EJB Three Components in Creating an EJB Starting/Stopping J2EE Server and Deployment Tool Installation and Configuration of.
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 1.
CSCI 6962: Server-side Design and Programming Course Introduction and Overview.
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.Public 1.
Bayu Priyambadha, S.Kom. What is J2EE? * Open and standard based platform for developing, deploying and managing n-tier, Web-enabled, server-centric,
Using JavaBeans and Custom Tags in JSP Lesson 3B / Slide 1 of 37 J2EE Web Components Pre-assessment Questions 1.The _____________ attribute of a JSP page.
Enterprise JavaBeans. What is EJB? l An EJB is a specialized, non-visual JavaBean that runs on a server. l EJB technology supports application development.
Message-Driven Beans and EJB Security Lesson 4B / Slide 1 of 37 J2EE Server Components Objectives In this lesson, you will learn about: Identify features.
Java Server Pages A JSP page is a text-based document that contains two types of text: static template data, which can be expressed in any text-based format,
Web applications using JavaServer Faces (JSF) A brief introduction 1JavaServer Faces (JSF)
第十四章 J2EE 入门 Introduction What is J2EE ?
J2EE Structure & Definitions Catie Welsh CSE 432
Enterprise Java v120131Intro to JavaEE1 Java EE 5 TM Introduction.
Web Server Programming 1. Nuts and Bolts. Premises of Course Provides general introduction, no in-depth training Assumes some HTML knowledge Assumes some.
Source: Peter Eeles, Kelli Houston, and Wojtek Kozaczynsky, Building J2EE Applicationa with the Rational Unified Process, Addison Wesley, 2003 Prepared.
1 Apache TomEE // JavaEE Web Profile on Tomcat Jonathan #TomEE.
1 ObjectRiver Metadata Compilers Programmatic WebSockets JavaOne 2014 – Steven Lemmo.
INTEGRATION OF BACKBONE.JS WITH SPRING 3.1. Agenda New Features and Enhancements in Spring 3.1 What is Backbone.js and why I should use it Spring 3.1.
Java Servlets and Java Server Pages Norman White Stern School of Business.
January 29th, 2013 Thanks to Mike Perez and Chris Ritchie for the graphic.
Assignment of JAVA id : BSSE-F10-M-10-JAVA1 Overview of J2EE/Session 2/Slide 1 of 38.
Jonathan Gallimore | Tomitribe Cluster your application with JCache and CDI.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, written in Java code, that.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 3 1COMP9321, 15s2, Week.
Using WebSockets in Web apps Presenter: Shahzad Badar.
1 Copyright © 2004, Oracle. All rights reserved. Oracle Application Development Framework.
Session Beans Based on: Patel, Brose, Silverman, Mastering Enterprise JavaBeans 3.0.
REST By: Vishwanath Vineet.
Introduction to EJB. What is an EJB ?  An enterprise java bean is a server-side component that encapsulates the business logic of an application. By.
Java Servlets and Java Server Pages
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
10 Copyright © 2004, Oracle. All rights reserved. Building ADF View Components.
Singleton Academy, Pune. Course syllabus Singleton Academy Pune – Course Syllabus1.
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Think Async Masoud Kalali, Software Engineer, Embrace and.
1.Education Overview JAVA EE 6 Technologies
Speaker Name Speaker Title Speaker Title Oracle Corporation Olivier Le Diouris Principal Product Manager Oracle Corporation Building Servlet and JSP Applications.
Enterprise Java Beans. Contents  Understanding EJBs  Practice Section.
Java Servlets By: Tejashri Udavant..
JMS.Next(): JMS 2.0 and Beyond
BluePrints Reimagined
Java Messaging Service (JMS)
ISE 390 Dynamic Web Development
Distributed System Using Java 2 Enterprise Edition (J2EE)
ESIS Consulting LLC (C) ESIS Consulting LLC. All rights reserved
JavaServer Faces: The Fundamentals
J2EE Lecture 13: JMS and WebSocket
Presentation transcript:

Java EE 7 Overview Hamed Hatami January 2014 from Iran JUG

Hamed 2014 Agenda  Overview  A Taste of API Changes  Looking Ahead

Hamed 2014 Java EE 7 Launch Last Month June 2013

Hamed 2014 Java EE 7 - Major Themes in Context Future Future Enterprise Java Platform Robustness Web Services J2EE 20 specs Java EE Ease of Development Lightweight Developer Productivity & HTML5 32 specs EE 5, EE 6 28 specs

Hamed 2014 Java EE 7 – Past, Present, Future

Hamed 2014 Java EE 7 – Themes

Hamed 2014 Java EE 7 - JSRs Connector 1.6 Managed Beans 1.0 EJB 3.2 Servlet 3.1 Portable Extension s Portable Extension s JSF 2.2 JAX-RS 2.0 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 Concurrency Utilities (JSR 236) Concurrency Utilities (JSR 236) Batch Applications (JSR 352) Java API for JSON (JSR 353) Java API for WebSocket (JSR 356) Java API for WebSocket (JSR 356) Updated Major Release New

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

Hamed 2014 JSR 343: Java Message Service 2.0 API modernization using dependency injection Delivery delay, async send, MDB alignment, JMS resource definition Fixes, clarifications

Hamed 2014 JMS - Old = "java:global/jms/demoConnectionFactory") ConnectionFactory = "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); }

Hamed 2014 JMS 2 - Simplified private JMSContext = "jms/inboundQueue") private Queue inboundQueue; public void sendMessage (String payload) { context.createProducer().send(inboundQueue, payload); }

Hamed 2014 JMS 2/Java EE name="java:global/jms/demoConnectionFactory", className= "javax.jms.ConnectionFactory", description="ConnectionFactory to use in name = "java:global/jms/demoQueue", description = "Queue to use in demonstration", className = "javax.jms.Queue", destinationName="demoQueue")

Hamed 2014 JMS 2/EJB = propertyName = "destinationType", propertyValue = propertyName = "destinationLookup", propertyValue = propertyName = "connectionFactoryLookup", propertyValue = "jms/MyConnectionFactory")}) public class OrderListener implements MessageListener {... public void onMessage(Message message) {... }... }

Hamed 2014 Why WebSocket? HTTP is half duplex HTTP is verbose Hacks for Server Push Polling Long Polling Comet/Ajax Complex, Wasteful, Inefficient

Hamed 2014 HTTP Communication

Hamed 2014 Polling

Hamed 2014 Long Polling

Hamed 2014 HTTP Streaming (Comet)

Hamed 2014 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

Hamed 2014 Java API for public class ChatServer { Set peers public void onOpen(Session peer) { peers.add(peer); public void onClose(Session peer) { peers.remove(peer); }...

Hamed 2014 Java API for public void message(String message, Session client) throws IOException { for (Session session : peers) { if (!session.equals(client)) { session.getRemote().sendObject(message); }

Hamed 2014 JSON (JavaScript Object Notation) JSON 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 JSON is a text format that is completely language independent but uses conventions that are familiar to programmers.

Hamed 2014 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. API to parse, generate, transform, query JSON Binding JSON to Java objects forthcoming.

Hamed 2014 Java API for JSON Processing JsonArray value = Json.createArrayBuilder().add(Json.createObjectBuilder().add("type", "home").add("number", " ") ).add(Json.createObjectBuilder().add("type", "fax").add("number", " ") ).build(); [ { "type": "home”, "number": " " }, { "type": "fax”, "number": " " } ]

Hamed 2014 JSR 338: Java API for RESTful Web Services 2.0 Client API Message Filters & Entity Interceptors Asynchronous Processing – Server & Client Hypermedia Support Content negotiation

Hamed 2014 JAX-RS 2 // 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);

Hamed 2014 JAX-RS 2 / Logging Filter public class RequestLoggingFilter implements ContainerRequestFilter public void filter(ContainerRequestContext requestContext) { log(requestContext); // Non-wrapping => returns without invoking next filter }... }

Hamed 2014 JSR 339: Java Persistence API 2.1 The new features can be described with the following short list: Automatic schema generation Stored procedure mapping Unsynchronized persistence context Criteria Bulk updates and deletes JOIN using the ON condition Support for downcast in JPQL Support for Functions in JPQL CDI listeners in Entity classes Dynamically defined named queries

Hamed 2014 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”

Hamed 2014 JPA 2.1 / Stored Procedures Now there's a portable way to achieve it using: StoredProcedureQuery spq = em.createStoredProcedureQuery("PERSON_SP"); If we have any parameters in this stored procedure we need to register them, for example: spq.registerStoredProcedureParameter(1, String.class, ParameterMode.INOUT); spq.setParameter(1, "FRANK"); spq.registerStoredProcedureParameter(2, Integer.class, ParameterMode.IN); spq.setParameter(2, 100); You can define it as well @NamedStoredProcedureQuery(name="PERSON_StoredProcedure", procedureName="PERSON_SP") public class Product { … } and in your JPA client: StoredProcedreQuery spq = EntityManager.createNamedStoredProcedureQuery("PERSON_StoredProcedure"); spq.registerStoredProcedureParameter(1, String.class, ParameterMode.INOUT); spq.setParameter(1, "FRANK"); spq.registerStoredProcedureParameter(2, Integer.class, ParameterMode.IN); spq.setParameter(2, 100); query.execute(); String response = query.getOutputParameterValue(1);

Hamed 2014 JPA 2.1 / Unsynchronized Persistence public class ShoppingCart Private EntityManager em; Private Customer customer; Private Order order; public void startToShop(Integer custId) { customer = em.find(Customer.class,custId); order = new Order(); } public void addToCart(Book book) { Item item = new Item(book); order.addItem(item); } public void confirmOrder() { em.joinTransaction(); customer.addOrder(order); }

Hamed 2014 JPA 2.1 JOIN using the ON condition SELECT e FROM Employee e LEFT JOIN e.address ON a.city = :city Support for downcast in JPQL SELECT b.name FROM User e JOIN TREAT(e.projects AS LargeProject) b Support for Functions in JPQL SELECT FUNCTION('YEAR', e. startDate ) AS year, COUNT(e) FROM Employee e GROUP BY year Criteria Bulk updates and deletes: CDI listeners in Entity classes CriteriaUpdate q = cb.createCriteriaUpdate(Employee.class); Root c = q.from(Employee.class); q.set(c.get(Employee.wage), public class Customer private Integer id; private String name; … } public class Alarm public void alert(Customer c) { … }

Hamed 2014 JPA 2.1 Dynamically defined named Private EntityManager em; private EntityManagerFactory emf = em.getEntityManagerFactory(); emf.addNamedQuery("supplierStatus", em.createQuery("SELECT e.name FROM Employee e WHERE e.status = :status") );

Hamed 2014 JTA 1.2 * Declarative transactions outside EJB * Transaction scope

Hamed 2014 JTA 1.2 / @Target({TYPE, Transactional { TxType value() default TxType.REQUIRED; Class[] rollbackOn() default {}; Class[] dontRollbackOn() default {}; dontRollbackOn={SQLWarning.class}) public class UserService {...}

Hamed 2014 JSR 344: JavaServer Faces 2.2 HTML5 Support for CDI Stateless views Resource library contracts File upload component View actions Security Fixes and enhancements

Hamed 2014 JSF 2.2 / Pass-Through HTML 5 Components......

Hamed 2014 JSF 2.2 / public class FlowABean implements Serializable { public String getName() { return "FlowABean"; } public String getReturnValue() { return "/return1"; 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(); }

Hamed 2014 JSF 2.2 / File public class FileUploadBean { private Part uploadedFile; // getter/setter public String getFileText() { String text = ""; if (null != uploadedFile) { try { InputStream is = uploadedFile.getInputStream(); text = new Scanner( is ).useDelimiter("\\A").next(); } catch (IOException ex) {} } return text; }

Hamed 2014 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

Hamed 2014 Batch Applications for the Java Platform / Step Example <chunk reader=”accountReader” processor=”accountProcessor” writer=” Writer” item-count=”10” ItemReader... { public Account readItem() { // read account using ItemProcessor... { Public Statement processItems(Account account) { // read Account, return ItemWriter... { public void writeItems(List statements) { // use JavaMail to send

Hamed 2014 JSR 349: Bean Validation 1.1 Method constraints Bean Validation artifacts injectable Fixes, clarifications and enhancements

Hamed 2014 Bean Validation 1.1 / Method Level Constraints public void Integer String customer) {... public Date getAppointment() {... }

Hamed 2014 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

Hamed 2014 Concurrency Utilities for Java EE Managed Task Executor public class TestServlet extends HTTPServlet private ManagedExecutorService executor; Future future = executor.submit(new MyTask()); class MyTask implements Runnable { public void run() {... // Task logic }

Hamed 2014 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

Hamed 2014 Servlet asyncSupported=true) public class TestServlet extends HttpServlet { protected void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { AsyncContext ac = req.startAsync(); ac.addListener(new AsyncListener() { public void onComplete(AsyncEvent event) throws IOException { event.getSuppliedResponse().getOutputStream().print("Complete"); } public void onError(AsyncEvent event) { System.out.println(event.getThrowable()); } public void onStartAsync(AsyncEvent event) { } public void onTimeout(AsyncEvent event) { System.out.println("my asyncListener.onTimeout"); } });...

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

Hamed 2014 Others CDI 1.1: EL 3.0: Lambda expressions. Collections, Operators, Standalone API...

Hamed 2014 Support IDEs and Servers IDEs Netbeans 7.4 – free IntelliJ IDEA 12.x~13 – commercial and community edition Eclipse Juno free Servers GlassFish 4.0 (RI) Wildfly 8.0 (CR1) Weblogic c Partially (WS,JSON-P). Apache Tomcat Version RC5.

Hamed 2014 Resources Java EE Tutorials Digging Deeper Java EE 7 Transparent Expert Groups Java EE 7 Reference Implementación The Aquarium Speakers

Hamed 2014 Thanks for listening and attending