Whats new in Java EE 7?From HTML5 to JMS 2.0
The preceding is intended to outline our general product direction. It isintended for information purposes only, and may n...
...
Bruno Borges● Oracle Product Manager● Java Evangelist● Developer● Gamer● Beer lover● Java Embedded newbie● GoT / TBBT / De...
Agenda● Java EE 7 – Whats new?● Building HTML5 Applications– WebSockets 1.0– JAX-RS 2.0– JavaServer Faces 2.2● Messaging w...
Whats new in Java EE 7?● Servlet 3.1● Java API for JSON Processing 1.0● Bean Validation 1.1● Batch Applications API 1.0● J...
Whats new in Java EE 7?● Web Profile updated to include– JAX-RS– WebSocket– JSON-P– EJB 3.2 Lite– Others– Batch and/or JMS...
Building HTML5 Applications● WebSocket 1.0● JAX-RS 2.0● JavaServer Faces 2.2
WebSockets 1.0● API for WebSocket Client/Endpoints– Annotation-driven (@WebSocketEndpoint)– Interface-driven (Endpoint)– C...
Hello WebSocketsimport javax.websocket.*;import javax.websocket.server.*;@ServerEndpoint(“/hello”)public class HelloBean {...
Chat Server@ServerEndpoint(“/chat”)public class ChatBean {    @OnOpen    public void onOpen(Session peer) {        peers.a...
DEMO WebSockets
Maven Archetypes for Java EE 7● Maven Archetypes for Java EE 7– http://mojo.codehaus.org● Maven Archetype for Embedded Gla...
JAX-RS 2.0● Client API● Message Filters & Entity Interceptors● Asynchronous Processing – Server & Client● Hypermedia Suppo...
JAX-RS 2.0 Client// Get instance of ClientClient client = ClientFactory.getClient();// Get customer name for the shipped p...
JAX-RS 2.0 Server@Path("/async/longRunning")public class MyResource {@GETpublic void longRunningOp(@Suspended AsyncRespons...
JavaServer Faces 2.2● Flow Faces● HTML5 Friendly Markup● Cross-site Request Forgery Protection● Loading Facelets via Resou...
DEMO JSF 2.2
Java Message Service API 2.0● Simplified existing JMS API 1.1 withoutbreaking compatibility● New API requiring fewer objec...
Java Message Service API 2.0● JMSContext– Encapsulates Connection, Session, andanonymous MessageProducer● Created from a d...
Default JMS resources● Default objects and JNDI names@Resource(lookupName =“java:comp/defaultJMSConnectionFactory”)Connect...
Easier definition of JMS resources@JMSConnectionFactoryDefinition(name=”java:global/jms/demoCF”className = “javax.jms.Conn...
Message Driven Beans@MessageDriven(mappedName = “jms/myQueue”,activationConfig = {@ActivationConfigProperty(propertyName =...
DEMO JMS 2.0
More Java EE 7 Sample CodeCant DEMO everything...
Java API for JSON-P● JsonParser– Processa JSON em modo “streaming”● Similar ao XMLStreamReader do StaX– Como criar● Json.c...
Java API for JSON-P"phoneNumber": [{"type": "home","number": ”408-123-4567”},{"type": ”work","number": ”408-987-6543”}]Jso...
Bean Validation 1.1public void placeOrder(@NotNull String productName,@NotNull @Max(“10”) Integer quantity,@Customer Strin...
Batch API 1.0<job id=“myJob”><step id=“init”><chunk reader=“R” writer=W” processor=“P” /><next on=“initialized” to=“proces...
Schedule● GlassFish 4.0 and Java EE 7 to be releasedalmost together– this year for sure :-)
Transparency● Most on JCP 2.8, some on JCP 2.9– Open mailing list– Open Issue tracker– Public access to download artifacts
Adopt a JSR● JUGs participating actively● Promoting JSRs tothe Java community– Reviewing specs– Trying out beta specs with...
Links● Java EE 7 Expert Group Project– http://javaee-spec.java.net● Java EE 7 Reference Implementation– http://www.glassfi...
Thank youFollow me on Twitter: @brunoborgeshttp://blogs.oracle.com/brunoborges
What's new in Java EE 7? From HTML5 to JMS 2.0
Upcoming SlideShare
Loading in …5
×

What's new in Java EE 7? From HTML5 to JMS 2.0

10,651 views

Published on

Discover the new capabilities that Java EE 7 has to offer for you to build HTML5 applications. See some of the changes JMS brought to increase your Productivity!

These slides were presented at JBoss Users and Developers Conference, JUDCon Brazil 2013, on April 19th.

Published in: Technology

What's new in Java EE 7? From HTML5 to JMS 2.0

  1. 1. Whats new in Java EE 7?From HTML5 to JMS 2.0
  2. 2. The preceding is intended to outline our general product direction. It isintended for information purposes only, and may not be incorporated intoany contract.It is not a commitment to deliver any material, code, or functionality, andshould not be relied upon in making purchasing decisions. Thedevelopment, release, and timing of any features or functionalitydescribed for Oracle’s products remains at the sole discretion of Oracle.
  3. 3. ...
  4. 4. Bruno Borges● Oracle Product Manager● Java Evangelist● Developer● Gamer● Beer lover● Java Embedded newbie● GoT / TBBT / Dexter addicted@brunoborgeshttp://blogs.oracle.com/brunoborges
  5. 5. Agenda● Java EE 7 – Whats new?● Building HTML5 Applications– WebSockets 1.0– JAX-RS 2.0– JavaServer Faces 2.2● Messaging with JMS 2.0● More code samples for Java EE 7● Upcoming
  6. 6. Whats new in Java EE 7?● Servlet 3.1● Java API for JSON Processing 1.0● Bean Validation 1.1● Batch Applications API 1.0● Java Persistence API 2.1● Concurrency Utilities for Java EE 1.0● And more... :-)
  7. 7. Whats new in Java EE 7?● Web Profile updated to include– JAX-RS– WebSocket– JSON-P– EJB 3.2 Lite– Others– Batch and/or JMS maybe?
  8. 8. Building HTML5 Applications● WebSocket 1.0● JAX-RS 2.0● JavaServer Faces 2.2
  9. 9. WebSockets 1.0● API for WebSocket Client/Endpoints– Annotation-driven (@WebSocketEndpoint)– Interface-driven (Endpoint)– Client (@WebSocketClient)● SPI for data frames– WebSocket opening handshake negotiation● Integration with Java EE Web container
  10. 10. Hello WebSocketsimport javax.websocket.*;import javax.websocket.server.*;@ServerEndpoint(“/hello”)public class HelloBean {    @OnMessage    public String sayHello(String name) {        return “Hello “ + name;    }}
  11. 11. Chat Server@ServerEndpoint(“/chat”)public class ChatBean {    @OnOpen    public void onOpen(Session peer) {        peers.add(peer);    }    @OnClose    public void onClose(Session peer) {        peers.remove(peer);    }    @OnMessage    public void message(String msg, Session client) {        peers.forEach(p ­> p.getRemote().sendMessage(msg));    }}
  12. 12. DEMO WebSockets
  13. 13. Maven Archetypes for Java EE 7● Maven Archetypes for Java EE 7– http://mojo.codehaus.org● Maven Archetype for Embedded GlassFishand Java EE 7– http://github.com/brunoborges/javaee7-archetype– All you need is:● $ mvn package embedded-glassfish:run
  14. 14. JAX-RS 2.0● Client API● Message Filters & Entity Interceptors● Asynchronous Processing – Server & Client● Hypermedia Support● Common Configuration
  15. 15. JAX-RS 2.0 Client// Get instance of ClientClient client = ClientFactory.getClient();// Get customer name for the shipped productsString name = client.target(“http://.../orders/{orderId}/customer”)                    .resolveTemplate(“orderId”, “10”)                    .queryParam(“shipped”, “true)”                    .request()                    .get(String.class);
  16. 16. JAX-RS 2.0 Server@Path("/async/longRunning")public class MyResource {@GETpublic void longRunningOp(@Suspended AsyncResponse ar) {ar.setTimeoutHandler(new MyTimoutHandler());ar.setTimeout(15, SECONDS);Executors.newSingleThreadExecutor().submit(new Runnable() {public void run() {...ar.resume(result);}});}}
  17. 17. JavaServer Faces 2.2● Flow Faces● HTML5 Friendly Markup● Cross-site Request Forgery Protection● Loading Facelets via ResourceHandler● File Upload Component● Multi-templating
  18. 18. DEMO JSF 2.2
  19. 19. Java Message Service API 2.0● Simplified existing JMS API 1.1 withoutbreaking compatibility● New API requiring fewer objects– JMSContext, JMSProducer...● In Java EE, allow JMSContext to be injectedand managed by container● JMS objects implement AutoCloseable● Async send
  20. 20. Java Message Service API 2.0● JMSContext– Encapsulates Connection, Session, andanonymous MessageProducer● Created from a default (or specified)ConnectionFactory● Unchecked exceptions● Supports method chaining for fluid style
  21. 21. Default JMS resources● Default objects and JNDI names@Resource(lookupName =“java:comp/defaultJMSConnectionFactory”)ConnectionFactory myJMScf;@Resource(lookupName = “jms/inboud”)private Queue inboundQueue;@Inject@JMSConnectionFactory(“jms/myCF”)private JMSContext context;
  22. 22. Easier definition of JMS resources@JMSConnectionFactoryDefinition(name=”java:global/jms/demoCF”className = “javax.jms.ConnectionFactory”)@JMSDestinationDefinition(name = “java:global/jms/inboudQueue”className = “javax.jms.Queue”destinationName = “inboundQueue”)
  23. 23. Message Driven Beans@MessageDriven(mappedName = “jms/myQueue”,activationConfig = {@ActivationConfigProperty(propertyName = “destinationLookup”,propertyValue = “jms/myQueue”),@ActivationConfigProperty(propertyName = “connectionFactoryLookup”,propertyValue = “jms/myCF”)})
  24. 24. DEMO JMS 2.0
  25. 25. More Java EE 7 Sample CodeCant DEMO everything...
  26. 26. Java API for JSON-P● JsonParser– Processa JSON em modo “streaming”● Similar ao XMLStreamReader do StaX– Como criar● Json.createParser(...)● Json.createParserFactory().createParser(...)– Eventos do processador● START_ARRAY, END_ARRAY, START_OBJECT,END_OBJECT, ...
  27. 27. Java API for JSON-P"phoneNumber": [{"type": "home","number": ”408-123-4567”},{"type": ”work","number": ”408-987-6543”}]JsonGenerator jg =Json.createGenerator(...);jg..beginArray("phoneNumber").beginObject().add("type", "home").add("number", "408-123-4567").endObject().beginObject().add("type", ”work").add("number", "408-987-6543").endObject().endArray();jg.close();
  28. 28. Bean Validation 1.1public void placeOrder(@NotNull String productName,@NotNull @Max(“10”) Integer quantity,@Customer String customer) {//. . .}@Futurepublic Date getAppointment() {//. . .}
  29. 29. Batch API 1.0<job id=“myJob”><step id=“init”><chunk reader=“R” writer=W” processor=“P” /><next on=“initialized” to=“process”/><fail on=“initError”/></step><step id=“process”><batchlet ref=“ProcessAndEmail”/><end on=”success”/><fail on=”*” exit-status=“FAILURE”/></step></job>
  30. 30. Schedule● GlassFish 4.0 and Java EE 7 to be releasedalmost together– this year for sure :-)
  31. 31. Transparency● Most on JCP 2.8, some on JCP 2.9– Open mailing list– Open Issue tracker– Public access to download artifacts
  32. 32. Adopt a JSR● JUGs participating actively● Promoting JSRs tothe Java community– Reviewing specs– Trying out beta specs with samples– Examples, docs, bugs– Blogging, speaking at conferences, JUG meetings
  33. 33. Links● Java EE 7 Expert Group Project– http://javaee-spec.java.net● Java EE 7 Reference Implementation– http://www.glassfish.org● Adopt a JSR– http://glassfish.org/adoptajsr● NetBeans and Java EE 7– http://wiki.netbeans.org/JavaEE7
  34. 34. Thank youFollow me on Twitter: @brunoborgeshttp://blogs.oracle.com/brunoborges

×