Java EE 7 - Novidades e Mudanças
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

Java EE 7 - Novidades e Mudanças

  • 2,976 views
Uploaded on

Apresentação feita ao SERPRO em Fevereiro de 2014, para a equipe do Framework Demoiselle. ...

Apresentação feita ao SERPRO em Fevereiro de 2014, para a equipe do Framework Demoiselle.

Video com Q&A disponivel aqui: https://www.youtube.com/watch?v=c1FrV4UmKEA

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
2,976
On Slideshare
2,956
From Embeds
20
Number of Embeds
2

Actions

Shares
Downloads
22
Comments
0
Likes
3

Embeds 20

https://twitter.com 17
http://www.linkedin.com 3

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Java EE 7: Novidades e Mudanças Bruno Borges Oracle Product Manager Java Evangelist @brunoborges 2Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 2. Bruno Borges Oracle Product Manager / Evangelist Desenvolvedor, Gamer Entusiasta em Java Embedded e JavaFX Twitter: @brunoborges 3Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 3. Java EE 7 - Produtividade - Suporte HTML5 - Funcionalidades Enterprise Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 4. Concurrency 1.0 Interceptors 1.2 Bean Validation 1.1 CDI 1.1 Java EE 7 JSP 2.3 JSTL EL 3.0 Servlet 3.1 Web Socket 1.0 JAX-RS 2.0 JSON-P 1.0 Batch 1.0 JTA 1.2 EJB 3.2 JPA 2.1 Java EE 7 5Copyright © 2012, Oracle and/or its affiliates. All rights reserved. JSF 2.2 Insert Information Protection Policy Classification from Slide 13 JMS 2.0 JavaMail 1.5 JCA 1.7
  • 5. Java EE 7 Web Profile  Web Profile atualizado para incluir: – JAX-RS – WebSocket – JSON-P – EJB 3.2 Lite 6Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 6. Construindo aplicações HTML5  WebSocket 1.0  JAX-RS 2.0  JavaServer Faces 2.2  JSON-P API 7Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 7. HTTP vs WebSockets  Protocolo HTTP é half-duplex  Gambiarras – Polling – Long polling – Streaming  WebSocket resolve o problema de uma vez por todas – Full-duplex 8Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 8. WebSockets Handshake  Cliente solicita um UPGRADE  Server confirma (Servlet 3.1)  Cliente recebe o OK  Inicia a sessão WebSocket http://farata.github.io/slidedecks/state_of_websocket/slides.html#13.4 9Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 9. Java API for WebSockets 1.0  API para definir WebSockets, tanto Client como Server – Annotation-driven (@ServerEndpoint) – Interface-driven (Endpoint) – Client (@ClientEndpoint)  SPI para data frames – Negociação handshake na abertura do WebSocket  Integração com o Java EE Web container 10Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 10. Java API for WebSockets 1.0 import javax.websocket.*; import javax.websocket.server.*; @ServerEndpoint(“/hello”) public class HelloBean {     @OnMessage     public String sayHello(String name) {         return “Hello “ + name;     } } 11Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 11. Java API for WebSockets 1.0 @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));     } } 12Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 12. JAX-RS 2.0  Client API  Message Filters & Entity Interceptors  Asynchronous Processing – Server & Client  Suporte Hypermedia  Common Configuration – Compartilhar configuração comum entre diversos serviços REST 13Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 13. JAX-RS 2.0 - Client // Get instance of Client Client client = ClientFactory.getClient(); // Get customer name for the shipped products String name = client.target(“http://.../orders/{orderId}/customer”)                     .resolveTemplate(“orderId”, “10”)                     .queryParam(“shipped”, “true)”                     .request()                     .get(String.class); 14Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 14. JAX-RS 2.0 - Server @Path("/async/longRunning") public class MyResource { @GET public void longRunningOp(@Suspended AsyncResponse ar) { ar.setTimeoutHandler(new MyTimoutHandler()); ar.setTimeout(15, SECONDS); Executors.newSingleThreadExecutor().submit(new Runnable() { public void run() { ... ar.resume(result); }}); } } 15Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 15. JavaServer Faces 2.2  Flow Faces  HTML5 Friendly Markup  Cross-site Request Forgery Protection  Carregamento de Facelets via ResourceHandler  Componente de File Upload  Multi-templating 16Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 16. JSON API 1.0  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, ... 17Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 17. JSON API 1.0 "phoneNumber": [ { "type": "home", "number": ”408-123-4567” }, { "type": ”work", "number": ”408-987-6543” } ] 18Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 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(); Insert Information Protection Policy Classification from Slide 13
  • 18. JavaServer Faces 2.2 19Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 19. JavaServer Faces 2.2 ● ● ● ● Faces Flow Resource Library Contracts Multi-templating HTML5 Friendly Markup Support – Pass through attributes and elements ● ● ● Cross Site Request Forgery Protection Loading Facelets via ResourceHandler File Upload Component 20Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 20. JavaServer Faces 2.2 – HTML5 Friendly Markup file:///home/bruno/project/web/myPage.xhtml <form jsf:id="form" jsf:prependId="false"> <label jsf:for="name">Name < /label> <input jsf:id="name" type="text" jsf:value="#{complex.name}" /> <label jsf:for="tel">Tel < /label> <input jsf:id="tel" type="tel" jsf:value="#{complex.tel}" /> <label jsf:for="email">Email < /label> <input jsf:id="email" type="email" jsf:value="#{complex.email}" /> <label for="progress">Progress < /label> <progress jsf:id="progress" max="3"> #{complex.progress} of 3 </progress> </form> 21Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 21. JavaServer Faces 2.2  Flow Faces 22Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 22. JavaServer Faces 2.2 – Flow Faces <j:faces-flow-definition>   <j:initializer>#{someBean.init}</j:initializer> <j:start-node>startNode</j:start-node>   <j:switch id="startNode"> <j:navigation-case> <j:if>#{someBean.someCondition}</j:if> <j:from-outcome>fooView</j:from-outcome> </j:navigation-case> </j:switch>   <j:view id="barFlow"> <j:vdl-document>barFlow.xhtml</j:vdl-document> </j:view> <j:view id="fooView"> <j:vdl-document>create-customer.xhtml</j:vdl-document> </j:view> </j:faces-flow-definition> 23Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 23. JavaServer Faces 2.2  Multi-Templating – Seleção default – Seleção dinâmica <ui:composition template="#{userBean.template}"> 24Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 24. JMS para Mensageria 25Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 25. Java Message Service API 2.0  Simplificação da JMS API 1.1 sem quebrar compatibilidade  Nova API requer menos objetos – JMSContext, JMSProducer...  No Java EE, permite que JMSContext seja injetado e gerenciado pelo container, usando CDI  Objetos JMS implementam AutoCloseable  Envio Async de mensagens 26Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 26. Java Message Service API 2.0  JMSContext  Encapsula Connection e Session  Criado a partir de um default ConnectionFactory – Permite especificar um ConnectionFactory também  Unchecked exceptions  Suporta encadeamento de métodos, para fluid style 27Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 27. Java Message Service API 2.0 @Resource(lookupName = “java:comp/defaultJMSConnectionFactory”) ConnectionFactory myJMScf; @Resource(lookupName = “jms/inboud”) private Queue inboundQueue; @Inject @JMSConnectionFactory(“jms/myCF”) private JMSContext context; 28Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 28. Java Message Service API 2.0 @JMSConnectionFactoryDefinition( name=”java:global/jms/demoCF” className = “javax.jms.ConnectionFactory”) @JMSDestinationDefinition( name = “java:global/jms/inboudQueue” className = “javax.jms.Queue” destinationName = “inboundQueue”) 29Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 29. Message Driven Beans para JMS 2.0 @MessageDriven( mappedName = “jms/myQueue”, activationConfig = { @ActivationConfigProperty( propertyName = “destinationLookup”, propertyValue = “jms/myQueue”), @ActivationConfigProperty( propertyName = “connectionFactoryLookup”, propertyValue = “jms/myCF”) }) 30Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 30. Bean Validation Batch API Concurrency Utilities 31Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 31. Bean Validation 1.1 public void placeOrder( @NotNull String productName, @NotNull @Max(“10”) Integer quantity, @Customer String customer) { //. . . } @Future public Date getAppointment() { //. . . } 32Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 32. 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> 33Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 33. Batch Applications 1.0 Job Specification Language – Chunked Step <step id=”sendStatements”> …implements ItemReader { <chunk reader ref=”accountReader” public Object readItem() { processor ref=”accountProcessor” // read account using JPA writer ref=”emailWriter” } chunk-size=”10” /> </step> …implements ItemProcessor { Public Object processItems(Object account) { // read Account, return Statement } …implements ItemWriter { public void writeItems(List accounts) { // use JavaMail to send email } 34Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 34. Concurrency Utilities for Java EE 1.0 ● Provide asynchronous capabilities to Java EE application components – ● ● Without compromising container integrity Extension of Java SE Concurrency Utilities API (JSR 166) Support simple (common) and advanced concurrency patterns 35Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 35. Concurrency Utilities for Java EE 1.0 ● Provide 4 managed objects – – ● ManagedThreadFactory – ● ManagedScheduledExecutorService – ● ManagedExecutorService ContextService Context propagation Task event notifications Transactions 36Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 36. Concurrency Utilities for Java EE 1.0 Submit Tasks to ManagedExecutorService using JNDI public class TestServlet extends HTTPServlet { @Resource(name=“concurrent/BatchExecutor”) ManagedExecutorService executor; Future future = executor.submit(new MyTask()); class MyTask implements Runnable { public void run() { . . . // task logic } } } 37Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 37. NetBeans e o suporte ao HTML5 38Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 38. NetBeans 7.3 39Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 39. HTML5 Wizard  Twitter Bootstrap  HTML5 Boilerplate  Initializr  AngularJS  Mobile Boilerplate 40Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 40. Javascript Editor  Code Completion  Contexto de Execução  Debug com Chrome  Browser log 41Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 41. Instalando o Chrome Extension do NetBeans  Instalação Offline 42Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 42. Q&A 43Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 43. 44Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 44. Java EE nas Redes Sociais Twitter @java_ee Facebook facebook.com/javaeeplatform Google+ 45Copyright © 2012, Oracle and/or its affiliates. All rights reserved. gplus.to/JavaEE Insert Information Protection Policy Classification from Slide 13
  • 45. Adopt a JSR  JUGs participando ativamente  Promovendo as JSRs – Para a comunidade Java – Revendo specs – Testando betas e códigos de exemplo – Examplos, docs, bugs – Blogging, palestrando, reuniões de JUG 46Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 46. Adopt a JSR JUGs Participantes 47Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 47. E o futuro do Java EE 8? Cloud Programming Model Storage JSON-B  Arquitetura Cloud  Multi tenancy para aplicações SaaS  Entrega incremental de JSRs  Modularidade baseada no Jigsaw  glassfish.org/survey 48Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13 Modularity NoSQL Multitenancy Java EE 8 Cloud PaaS Enablement Thin Server Architecture
  • 48. Participe hoje mesmo!  GlassFish 4.0 Java EE 7 RI – http://www.glassfish.org  Java EE Expert Group – http://javaee-spec.java.net  Adopt a JSR – http://glassfish.org/adoptajsr  The Aquarium (GF Blog) – http://blogs.oracle.com/theaquarium  NetBeans e Java EE 7 – http://wiki.netbeans.org/JavaEE7  Java EE 7 HOL – http://www.glassfish.org/hol 49Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 49. OBRIGADO! @brunoborges blogs.oracle.com/brunoborges 50Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 50. The preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 51Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13
  • 51. 52Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13