SlideShare ist ein Scribd-Unternehmen logo
1 von 65
Downloaden Sie, um offline zu lesen
Main sponsor




Plataforma Java EE 7: Produtividade & HTML5
Bruno Borges - @brunoborges
Oracle Java EE/Middleware Product Manager
The following 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.


2   Copyright © 2012, Oracle and/or its affiliates. All rights
    reserved.
Java EE 6
                                                                 10 Dezembro 2009



3   Copyright © 2012, Oracle and/or its affiliates. All rights
    reserved.
Java EE 6 – Estatísticas

       •      40+ Milhões de Downloads de Componentes Java EE
       •      #1 Escolha para Desenvolvedores Enterprise
       •      #1 Plataforma de Desenvolvimento de Aplicações
       •      Mais rápida implementação do Java EE




4   Copyright © 2012, Oracle and/or its affiliates. All rights
    reserved.
Top 10 Features do Java EE 6
    1. EJB dentro de um WAR
    2. Injeção de Dependência type-safe
    3. Descritores de Deploy opcionais (web.xml, faces-config.xml)
    4. JSF padronizado com Facelets
    5. Uma única classe por EJB
    6. Pontos de Extensão para Servlets e CDI
    7. Eventos CDI
    8. API de EJBContainer
    9. Anotação @Schedule baseado em cron
    10. Profile Web para desenvolvimento Java EE leve
5   Copyright © 2012, Oracle and/or its affiliates. All rights
    reserved.
Escopo do Java EE 7
    Produtividade e HTML5
    • Mais Produtividade
             – Menos código “boilerplate”
             – Funcionalidades mais ricas
             – Mais padrões e convenções
    • Suporte ao HTML5
             – WebSocket
             – JSON
             – Formulários HTML5


6   Copyright © 2012, Oracle and/or its affiliates. All rights
    reserved.
Java EE 7 –JSRs Candidatas
                                                                                JAX-RS
                                                                                 JAX-RS                 Java Caching API
                                                                                                         Java Caching API
                                 JSP 2.2 JSF 2.2
                                  JSP 2.2 JSF 2.2                                 2.0
                                                                                            EL 3.0
                                                                                             EL 3.0         (JSR 107)
                                                                                                             (JSR 107)
 Portable
                                                                                   2.0
  Portable
Extensions
 Extensions
                                                                                                       Concurrency Utilities
                                                                                                        Concurrency Utilities
                                                                     Servlet 3.1
                                                                      Servlet 3.1                           (JSR 236)
                                                                                                             (JSR 236)

  Common
   Common                                                                                               Batch Applications
                                                                                                         Batch Applications
                Interceptors 1.1                                                       CDI 1.1
Annotations 1.1 Interceptors 1.1                                                       CDI 1.1              (JSR 352)
                                                                                                             (JSR 352)
Annotations 1.1
                                                                                                        Java API for JSON
                                                                                                         Java API for JSON
 Managed Beans 1.0
 Managed Beans 1.0                                                               EJB 3.2
                                                                                  EJB 3.2                   (JSR 353)
                                                                                                             (JSR 353)

Connector
Connector                                                                                             Java API for WebSocket
                                                                                                       Java API for WebSocket
                                        JPA 2.1
                                         JPA 2.1                            JTA 1.2
                                                                             JTA 1.2      JMS 2.0
                                                                                           JMS 2.0           (JSR 356)
   1.6
    1.6                                                                                                       (JSR 356)


      Novo                     Nova                           Atualização
                               Versão

  7    Copyright © 2012, Oracle and/or its affiliates. All rights
       reserved.
Agenda

       •      JAX-RS 2.0
       •      JMS 2.0
       •      JSON API 1.0
       •      WebSockets API 1.0
       •      Bean Validation 1.1
       •      Batch API 1.0
       •      JCache API 1.0
       •      JPA 2.1
8   Copyright © 2012, Oracle and/or its affiliates. All rights
    reserved.
Java API for RESTful Web Services 2.0
    Client API - Antes
      String address = String.format("http://…/orders/%0$s/customer?shipped=
      %1$b", "10", true);

      URL url = new URL(address);
      HttpURLConnection conn = (HttpURLConnection) url.openConnection();
      conn.setRequestMethod("GET");
      conn.setDoInput(true);
      conn.setDoOutput(false);

      BufferedReader br = new BufferedReader(
                                  new
      InputStreamReader(conn.getInputStream()));
      String line;
      while ((line = br.readLine()) != null) {
          //. . .
      }
9   Copyright © 2012, Oracle and/or its affiliates. All rights
    reserved.
Java API for RESTful Web Services 2.0
     Client API - Agora

      // Obtém instância do Client
      Client client = ClientFactory.newClient();

      // Obtém nome do cliente para o produto enviado
      String name = client.target(“../orders/
      {orderId}/customer”)
                                .resolveTemplate(”orderId", ”10”)
                                .queryParam(”shipped", ”true”)
                                .request()
                                .get(String.class);




10   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java API for RESTful Web Services 2.0
     Client API - Agora


       // Sacar dinheiro
       Money mon = client.target("http://.../atm/{cardId}/withdrawal")
             .resolveTemplate("cardId", "111122223333")
             .queryParam("pin", "9876")
             .request("application/json")
             .post(text("50.0"), Money.class);




11   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java API for RESTful Web Services 2.0
     Client-side Async
Client client = ClientFactory.newClient();
Future<String> future = client.target("http://.../atm/{card}/balance")
                    .pathParam("card", "1111222233334444")
                    .queryParam("pin", "1234")
                    .request("text/plain")
                    .async()
                    .get(
                       new InvocationCallback<String>() {
                          public void completed(String result) { }
                          public void failed(InvocationException e) { }
                     });




12   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java API for RESTful Web Services 2.0
     Server-side Async
@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);
                              }});
          }
}
13   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java API for RESTful Web Services 2.0
     Pré-Configurações
     public class MyApp extends javax.ws.rs.core.Application {
         public Set<Class<?>> getClasses() {
             Set<Class<?>> classes = new HashSet<…>();
             …
             classes.add(JsonMessageBodyReader.class);
             classes.add(JsonMessageBodyWriter.class);
             classes.add(JsonpInterceptor.class);
             …
             return classes;
         }
     }                                  public Set<Class<?>> getClasses() {
                                            …
                                            classes.add(JsonFeature.class);
                                            …
                                        }

14   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java Message Service 2.0
     Enviando mensagem com JMS 1.1 - Antes
           @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);
                                                                                               13 LDCs só
                 } finally {                                                                   pra enviar
                    connection.close();                                                        a msg
                 }
              } catch (JMSException ex) {
                 Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
              }
           }



15   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java Message Service 2.0
     API simplificada para fechar objetos JMS
 @Resource(lookup = "jms/connFactory")
 ConnectionFactory cf;
                                                                  Uso do bloco
 @Resource(lookup="jms/inboundQueue")                             try-with-resource
 Destination dest;                                                s

 public void sendMessage (String payload) throws JMSException {
    try ( Connection conn = connectionFactory.createConnection();
          Session session = conn.createSession();
          MessageProducer producer = session.createProducer(dest);
    ){
       Message mess = sess.createTextMessage(payload);       close() é
       producer.send(mess);                                  chamado
    } catch(JMSException e){                                 automaticamente
       // exception handling
    }
 }
18   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java Message Service 2.0                                                  JMSContext
     Introdução do JMSContext e JMSProducer                                    combina
                                                                               Connection
                                                                               e Session
 @Resource(lookup = "java:global/jms/demoConnectionFactory")
 ConnectionFactory connectionFactory;
                                                                                Mensagem
 @Resource(lookup = "java:global/jms/demoQueue")                                enviada
 Queue demoQueue;                                                               diretamente
 public void sendMessage (String payload) {
    try (JMSContext context = connectionFactory.createContext();){
       context.createProducer().send(demoQueue, payload);
    } catch (JMSRuntimeException ex) {
       // exception handling
    }                                                        close() é
 }                                                           chamado
                                        Sem checked          automaticamente
                                                                  exceptions

19   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java Message Service 2.0
     Definição padrão de recursos
                                                                    Definição de recurso
                                                                             ou
                                                                  @JmsConnectionFactory
     @Inject
     JMSContext context;

     @Resource(lookup = "java:global/jms/demoQueue”)
     Queue demoQueue;

     public void sendMessage(String payload) {
         context.createProducer().send(demoQueue, payload);
     }
                                                                    13 linhas 1 line



20   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java API for JSON Processing 1.0
     Streaming API – JsonParser e JsonGenerator
     • 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, ...




21   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java API for JSON Processing 1.0
     Streaming API – JsonParser
     {
                 "firstName": "John", "lastName": "Smith", "age": 25,
                 "phoneNumber": [
                                { "type": "home", "number": "212 555-1234" },
                                { "type": "fax", "number": "646 555-4567" }
                 ]
     }
     Iterator<Event> it = parser.iterator();
     Event event = it.next();                                     // START_OBJECT
     event = it.next();                                           // KEY_NAME
     event = it.next();                                           // VALUE_STRING
     String name = parser.getString();                            // "John”
29   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java API for JSON Processing 1.0
     Streaming API – JsonParser e JsonGenerator
     • JsonGenerator
           – Gera JSON no modo streaming
                    • Similar ao XMLStreamWriter do StaX
           – Como criar
                    • Json.createGenerator(…)
                    • Json.createGeneratorFactory().createGenerator(…)
           – Funcionalidades adicionais
                    • Ex: código gerado formatado




30   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java API for JSON Processing 1.0
     Streaming API – JsonGenerator

                                                                  JsonGenerator jg = Json.createGenerator(…);
"phoneNumber": [
      {                                                           jg.
          "type": "home",                                           .beginArray("phoneNumber")
          "number": ”408-123-4567”                                    .beginObject()
      },                                                                .add("type", "home")
      {                                                                 .add("number", "408-123-4567")
          "type": ”work",                                             .endObject()
          "number": ”408-987-6543”                                    .beginObject()
      }                                                                 .add("type", ”work")
  ]                                                                     .add("number", "408-987-6543")
                                                                      .endObject()
                                                                    .endArray();
                                                                  jg.close();



31   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java API for JSON Processing 1.0
     Object Model API
     • JsonObject/JsonArray – Objeto JSON e estruturas
       de Array
           – JsonString e JsonNumber para valores texto e numéricos
     • JsonBuilder – Cria JsonObject e JsonArray
     • JsonReader – Lê JsonObject e JsonArray
     • JsonWriter – Escreve JsonObject e JsonArray



32   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java API for JSON Processing 1.0
     DOM API – JsonReader

     • Lê JsonObject e JsonArray de algum input
              – I/O Reader, InputStream (+ encoding)
     • Possível configurar outras opções
     • Utiliza um JsonParser plugável
     // Leitura de um objeto JSON
     try(JsonReader reader = new JsonReader(io)) {
                  JsonObject obj = reader.readObject();
     }

33   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java API for JSON Processing 1.0
     DOM API – Writer

     • Escreve JsonObject e JsonArray para algum output
              – I/O Writer, OutputStream (+ encoding)
     • Outras configurações, como “pretty printing”
     • Utiliza um JsonGenerator plugável

     // Escreve um objeto JSON
     try(JsonWriter writer = new JsonWriter(io)) {
                  writer.writeObject(obj);
     }
34   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java API for WebSocket 1.0
     Hello World – POJO/Annotation-driven
 import javax.websocket.*;

 @WebSocketEndpoint("/hello")
 public class HelloBean {

                @WebSocketMessage
                public String sayHello(String name) {
                    return “Hello “ + name;
                }
 }




35   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java API for WebSocket 1.0
     Anotações WebSocket
                        Annotation                                Level                       Purpose
     @WebSocketEndpoint                                             class   Torna um POJO em um WebSocket Endpoint

     @WebSocketClient                                               class   Torna um POJO em um WebSocket Client

     @WebSocketOpen                                                method   Intercepta eventos WebSocket Open

     @WebSocketClose                                               method   Intercepta eventos WebSocket Close

     @WebSocketMessage                                             method   Intercepta eventos WebSocket Message

     @WebSocketPathParam                                           method
                                                                  parameter Marca um segmento de um template de URI

     @WebSocketError                                               method   Intercepta erros durante a conversação


36   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java API for WebSocket 1.0
     Atributos do @WebSocketEndpoint


                             value                                   URI relativa ou template de URI
                                                                  ex. “/hello” ou “/chat/{subscriber-level}”

                       decoders                                   lista de decodificadores de mensagens

                       encoders                                    lista de codificadores de mensagens

              subprotocols                                            lista dos protocolos suportados




37   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java API for WebSocket 1.0
     Mensagens customizadas
     @WebSocketEndpoint(
         value="/hello",
         encoders={MyMessage.class},
         decoders={MyMessage.class}
     )
     public class MyEndpoint {
         . . .
     }


38   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java API for WebSocket 1.0
     Mensagens customizadas – Text
     public class MyMessage implements Decoder.Text<MyMessage>,
     Encoder.Text<MyMessage> {
       private JsonObject jsonObject;

           public MyMessage decode(String s) {
             jsonObject = new JsonReader(new StringReader(s)).readObject();
             return this;
           }
           public boolean willDecode(String string) {
             return true; // Only if can process the payload
           }


           public String encode(MyMessage myMessage) {
             return myMessage.jsonObject.toString();
           }
     }
     Copyright © 2012, Oracle and/or its affiliates. All rights
39
     reserved.
Java API for WebSocket 1.0
     Mensagens customizadas – Binary
     public class MyMessage implements Decoder.Binary<MyMessage>,
     Encoder.Binary<MyMessage> {

          public MyMessage decode(byte[] bytes) {
            . . .
            return this;
          }
          public boolean willDecode(byte[] bytes) {
            . . .
            return true; // Only if can process the payload
          }
          public byte[] encode(MyMessage myMessage) {
            . . .
          }
     }

40   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java API for WebSocket 1.0
     URI Template Matching
     • Um nível somente (1 parâmetro na URL)


     @WebSocketEndpoint(“/orders/{order-id}”)
     public class MyEndpoint {
       @WebSocketMessage
       public void processOrder(
         @WebSocketPathParam(“order-id”)String orderId) {
         . . .
       }
     }



41   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java API for WebSocket 1.0
     Hello World Client
     @WebSocketClient
     public class HelloClient {
       @WebSocketMessage
       public void message(String message, Session session) {
         // process message from server
       }
     }

     WebSocketContainer c =
     ContainerProvider.getClientContainer();
     c.connectToServer(HelloClient.class, “…/hello”);


42   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Bean Validation 1.1
         Parâmetro de Método e Validação de Resultado

         public void placeOrder(
Built-in
                 @NotNull String productName,
                 @NotNull @Max(“10”) Integer quantity,
Custom           @Customer String customer) {
                    //. . .
         }

         @Future
         public Date getAppointment() {
             //. . .
         }
    43   Copyright © 2012, Oracle and/or its affiliates. All rights
         reserved.
Batch Applications for the Java Platform 1.0

     •   Serve para tarefas não-interativas e processos longos
     •   Processamento computacional intensivo
     •   Pode executar sequencial ou paralelo
     •   Pode ser inicializado com:
           – Chamada adhoc
           – Agendado
                    • Não há uma API de agendamento incluída



44   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Batch Applications for the Java Platform 1.0
     Job Specification Language
     • Define um Job, Steps e direciona a execução
     • Implementado em XML
              – Também chamado de “Job XML”
     • Suporta herança de Job, Step, Flow, e Split




49   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Batch Applications for the Java Platform 1.0
     Job Specification Language – Exemplo
     <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>

50   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Batch Applications for the Java Platform 1.0
       Job Specification Language – Chunked
<step id=”sendStatements”>            @ReadItem
  <chunk reader=”AccountReader”       public Account readAccount() {
     processor=”AccountProcessor”         // read account using JPA
     writer=”EmailWriter”             }
     chunk-size=”10” />
</step>
                      @ProcessItem
                      public Account processAccount(Account account) {
                           // calculate balance
                      }
  @WriteItems
  public void sendEmail(List<Account> accounts) {
      // use JavaMail to send email
  }

  51   Copyright © 2012, Oracle and/or its affiliates. All rights
       reserved.
Batch Applications for the Java Platform 1.0
     Job Specification Language: Batchlet

            <step id=”transferFile”>
              <batchlet ref=“MyFileTransfer” />
            </step>




                                                                  @Process
                                                                  public void transferFile(String name) {
                                                                      // Transfer file
                                                                  }



52   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Batch Applications for the Java Platform 1.0
     Conceitos: Listeners
     • Job listener: intercepta a execução batch
              – @BeforeJob, @AfterJob
     • Step listener
              – @BeforeStep, @AfterStep
     • Chunk listener
              – @BeforeChunk, @AfterChunk, @BeforeCheckpoint,
                @AfterCheckpoint
     • Listeners para read/process/write de itens, . . .

53   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java Temporary Caching API 1.0

     • API e semântica para cache temporário em memória
       para objetos Java
           –      Criação de objetos
           –      Acesso compartilhado
           –      Spooling
           –      Invalidez de objetos
           –      Consistência entre diversas JVMs
     • SPI para implementações


55   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java Temporary Caching API 1.0
     Exemplo – Criando um CacheManager
     CacheManager cacheManager =
     CacheManagerFactory.getCacheManager();

     ou verbosamente

     CacheManager cacheManager =
     CacheManagerFactory.getCacheManager(DEFAULT_CACHE_M
     ANAGER_NAME,
     Thread.currentThread().getContextClassLoader());


60   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java Temporary Caching API 1.0
     Exemplo – Usando o Cache
     • Obtém um cache do CacheManager

        Cache<Integer, Date> cache =
           cacheManager.getCache(“testCache”);




61   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java Temporary Caching API 1.0
     Exemplo – Configurando o Cache
     • Configurar um cache para “read-through”

     CacheManager cacheManager = getCacheManager();
      Cache testCache =
           cacheManager.createCacheBuilder(“testCache”)
          .setReadThrough(true)
          .setSize(Size.UNLIMITED)
          .setExpiry(Duration.ETERNAL)
          .build();


62   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java Temporary Caching API 1.0
     Exemplo – Colocando um valor no cache
     Cache<Integer, Date> cache =
        cacheManager.getCache(cacheName);
     Integer key = 1;
     cache.put(key, new Date());




63   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java Temporary Caching API 1.0
     Exemplo – Obtendo um valor do cache
     Cache<Integer, Date> cache =
        cacheManager.getCache(cacheName);
     Date value = cache.get(key);




64   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java Temporary Caching API 1.0
     Exemplo – Removendo um valor do cache
     Cache<Integer, Date> cache =
        cacheManager.getCache(cacheName);
     Integer key = 1;
     cache.remove(1);




65   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java Temporary Caching API 1.0
     Exemplo – Blog
     public class BlogManager {
           @CachePut(cacheName=”blogManager”)
           public void createEntry(
                 @CacheKeyParam String title,
                 @CacheValue Blog blog) {...}

           . . .




66   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java Temporary Caching API 1.0
     Exemplo – Blog
           . . .

           @CacheResult(cacheName="blogManager")
           public Blog getBlogEntry(String title) {...}

           @CacheResult(cacheName="blogManager")
           public Blog getEntryCached(
             String randomArg,
             @CacheKeyParam String title) {...}

           . . .
67   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java Temporary Caching API 1.0
     Annotations – Exemplo do Blog
           . . .

           @CacheRemoveEntry(cacheName="blogManager")
           public void removeBlogEntry(String title) {...}

           @CacheRemoveAll(cacheName="blogManager")
           public void removeAllBlogs() {...}
     }



68   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java Temporary Caching API 1.0
     Possíveis implementações
     •   Terracotta – Ehcache
     •   Oracle – Coherence
     •   JBoss – Inifinispan
     •   IBM – ExtremeeScale
     •   SpringSorce – Gemfire
     •   Google App Engine – Java memcache client
     •   Spymemcache memcache client

69   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java Persistence API 2.1

     •   Geração do schema
     •   Persistence Context assíncronos
     •   Converters
     •   Bulk (batch) update/delete usando o Criteria
     •   Acesso padronizado a FUNCTIONS pela API
     •   Acesso padronizado a Stored Procedures pela API



70   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java Persistence API 2.1
     Unsynchronized Persistence Contexts
     • Synchronized: TX aplicada no banco no commit
     • Unsynchronized: Não fica sincronizada com a TX do JTA até o
       joinTransaction ser chamado
           – Não permite escrita no banco de dados
           – Mas pode chamar: persist, merge, remove, refresh
     • Funciona tanto gerenciado pelo container quanto pela aplicação
     • Caso de uso
           – Conversão de modelagem
           – Monitorar mudanças na persistência, efetuar commit somente no final


76   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java Persistence API 2.1
     Unsynchronized Persistence Contexts Sample
     @Stateful public class ShoppingCart {
        @PersistenceContext(type=EXTENDED, synchronization=UNSYNCHRONIZED)
         EntityManager em;


         @PersistenceContext EntityManager dataMiningEM;


         Customer customer;
         Order order;


         public void startToShop(Integer custId) {
               customer = em.find(Customer.class, custId);
               order = new Order(); }

77   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java Persistence API 2.1
     Unsynchronized Persistence Contexts - Exemplo

         public Collection<Book> viewCart() {
            // suggest other books based on interests
            ...}


         // purchase the books
         public void confirmOrder() {
               em.joinTransaction();
               customer.addOrder(order);
            }




78   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java Persistence API 2.1
     Stored Procedure Query
     @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);
     // there are other setParameter methods for defining the temporal type
     . . .
     query.execute();
     String response = query.getOutputParameterValue(1);


79   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
Java Persistence API 2.1
     Update e Delete com Criteria
     CriteriaUpdate<Customer> q = cb.createCriteriaUpdate(Customer.class);
     Root<Customer> c = q.from(Customer.class);        UPDATE Customer c
     q.set(c.get(Customer_.status), "outstanding")     SET c.status = 'outstanding'
      .where(cb.lt(c.get(Customer_.balance), 10000)); WHERE c.balance < 10000
     . . .
     @PersistenceContext EntityManager em;
     Query query = em.createQuery(q);
     query.executeUpdate();



       CriteriaDelete<Customer> q = cb.createCriteriaDelete(Customer.class);
       Root<Customer> c = q.from(Customer.class);
       q.where(cb.equal(c.get(Customer_.status), "inactive"),
               cb.isEmpty(c.get(Customer_.orders)));     DELETE FROM Customer c
       . . .                                             WHERE c.status = 'inactive'
                                                                  AND c.orders IS EMPTY

80   Copyright © 2012, Oracle and/or its affiliates. All rights
     reserved.
GlassFish Roadmap
GlassFish v3                                                               GlassFish Server 3.1              GlassFish Server 3.1.2
•Java EE 6 support                                                         •Centralized administration       •Bug Fixes
•Single instance                                                           •Clustering / HA                  •Incremental features
•GlassFish Enterprise Mgr                                                  •GlassFish Server Control




 2009                                                2010                                2011               2012                     2013


     GlassFish Server 3.0.1                                                        GlassFish Server 3.1.1            GlassFish Server 4
     •Oracle branding                                                              •Bug fixes                        •Java EE 7
     •Oracle platform support                                                      •Updated components               •Productivity
     •Oracle interoperability                                                      •Incremental features             •HTML5




        121   Copyright © 2012, Oracle and/or its affiliates. All rights
              reserved.
Transparência
      • JSRs de Java EE 7 da Oracle estão abertos no java.net
            – http://javaee-spec.java.net
            – One project per spec – ex: jpa-spec, jax-rs-spec, jms-spec…
      •   Mensagens de email do EG são públicas
      •   Área de download com acesso público
      •   Issue Tracker com acesso público
      •   Compromisso para atualizar para o JCP 2.8



122   Copyright © 2012, Oracle and/or its affiliates. All rights
      reserved.
Java EE 7: Status e Agenda


• Todas as JSRs estão ativas e em andamento
• Todas já publicaram Early Drafts, várias em Public Review
• Lançamento em: Q2 2013




 123   Copyright © 2012, Oracle and/or its affiliates. All rights
       reserved.
Adopt-a-JSR
      O que é ?
      • Iniciativa de líderes JUGs para se involverem em JSR
      • Promover as JSRs para a comunidade Java
      • O que posso fazer ?
            –      Revisar a spec e os javadocs
            –      Criar aplicações usando a spec beta
            –      Contribuir para a RI, exemplos, docs
            –      Apresentar para JUGs ou conferências
            –      Blog
            –      ...
126   Copyright © 2012, Oracle and/or its affiliates. All rights
      reserved.
Adopt-a-JSR
      Como posso começar? – glassfish.org/adoptajsr




127   Copyright © 2012, Oracle and/or its affiliates. All rights
      reserved.
Adopt-a-JSR
      JUGs participando do programa




128   Copyright © 2012, Oracle and/or its affiliates. All rights
      reserved.
Como participar

      • Java EE 7 Expert Group
               – javaee-spec.java.net
      • Java EE 7 Reference Implementation
               – glassfish.org
      • The Aquarium
               – blogs.oracle.com/theaquarium
      • Adopt-a-JSR
               – glassfish.org/adoptajsr

129   Copyright © 2012, Oracle and/or its affiliates. All rights
      reserved.
130   Copyright © 2012, Oracle and/or its affiliates. All rights
      reserved.

Weitere ähnliche Inhalte

Was ist angesagt?

The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUG
The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUGThe Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUG
The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUGArun Gupta
 
Java EE 6 : Paving The Path For The Future
Java EE 6 : Paving The Path For The FutureJava EE 6 : Paving The Path For The Future
Java EE 6 : Paving The Path For The FutureIndicThreads
 
The Java EE 7 Platform: Productivity++ & Embracing HTML5
The Java EE 7 Platform: Productivity++ & Embracing HTML5The Java EE 7 Platform: Productivity++ & Embracing HTML5
The Java EE 7 Platform: Productivity++ & Embracing HTML5Arun Gupta
 
Java EE 6 & GlassFish v3: Paving the path for the future - Tech Days 2010 India
Java EE 6 & GlassFish v3: Paving the path for the future - Tech Days 2010 IndiaJava EE 6 & GlassFish v3: Paving the path for the future - Tech Days 2010 India
Java EE 6 & GlassFish v3: Paving the path for the future - Tech Days 2010 IndiaArun Gupta
 
GlassFish REST Administration Backend
GlassFish REST Administration BackendGlassFish REST Administration Backend
GlassFish REST Administration BackendArun Gupta
 
Andrei Niculae - JavaEE6 - 24mai2011
Andrei Niculae - JavaEE6 - 24mai2011Andrei Niculae - JavaEE6 - 24mai2011
Andrei Niculae - JavaEE6 - 24mai2011Agora Group
 
Java Summit Chennai: Java EE 7
Java Summit Chennai: Java EE 7Java Summit Chennai: Java EE 7
Java Summit Chennai: Java EE 7Arun Gupta
 
S313557 java ee_programming_model_explained_dochez
S313557 java ee_programming_model_explained_dochezS313557 java ee_programming_model_explained_dochez
S313557 java ee_programming_model_explained_dochezJerome Dochez
 
GlassFish 3.1 at JCertif 2011
GlassFish 3.1 at JCertif 2011GlassFish 3.1 at JCertif 2011
GlassFish 3.1 at JCertif 2011Arun Gupta
 
TDC 2011: OSGi-enabled Java EE Application
TDC 2011: OSGi-enabled Java EE ApplicationTDC 2011: OSGi-enabled Java EE Application
TDC 2011: OSGi-enabled Java EE ApplicationArun Gupta
 
Web Application Architecture
Web Application ArchitectureWeb Application Architecture
Web Application ArchitectureAbhishek Chikane
 
N(i)2 technical architecture 2.0 (v1 1)
N(i)2 technical architecture 2.0 (v1 1)N(i)2 technical architecture 2.0 (v1 1)
N(i)2 technical architecture 2.0 (v1 1)kvz
 
The State of Java under Oracle at JCertif 2011
The State of Java under Oracle at JCertif 2011The State of Java under Oracle at JCertif 2011
The State of Java under Oracle at JCertif 2011Arun Gupta
 
The Java EE 7 Platform: Developing for the Cloud
The Java EE 7 Platform: Developing for the CloudThe Java EE 7 Platform: Developing for the Cloud
The Java EE 7 Platform: Developing for the CloudArun Gupta
 
Java EE 7 at JAX London 2011 and JFall 2011
Java EE 7 at JAX London 2011 and JFall 2011Java EE 7 at JAX London 2011 and JFall 2011
Java EE 7 at JAX London 2011 and JFall 2011Arun Gupta
 
TDC 2011: The Java EE 7 Platform: Developing for the Cloud
TDC 2011: The Java EE 7 Platform: Developing for the CloudTDC 2011: The Java EE 7 Platform: Developing for the Cloud
TDC 2011: The Java EE 7 Platform: Developing for the CloudArun Gupta
 
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...Arun Gupta
 

Was ist angesagt? (19)

The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUG
The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUGThe Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUG
The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUG
 
Java EE 6 : Paving The Path For The Future
Java EE 6 : Paving The Path For The FutureJava EE 6 : Paving The Path For The Future
Java EE 6 : Paving The Path For The Future
 
Java 7 workshop
Java 7 workshopJava 7 workshop
Java 7 workshop
 
The Java EE 7 Platform: Productivity++ & Embracing HTML5
The Java EE 7 Platform: Productivity++ & Embracing HTML5The Java EE 7 Platform: Productivity++ & Embracing HTML5
The Java EE 7 Platform: Productivity++ & Embracing HTML5
 
Java EE 6 & GlassFish v3: Paving the path for the future - Tech Days 2010 India
Java EE 6 & GlassFish v3: Paving the path for the future - Tech Days 2010 IndiaJava EE 6 & GlassFish v3: Paving the path for the future - Tech Days 2010 India
Java EE 6 & GlassFish v3: Paving the path for the future - Tech Days 2010 India
 
GlassFish REST Administration Backend
GlassFish REST Administration BackendGlassFish REST Administration Backend
GlassFish REST Administration Backend
 
Andrei Niculae - JavaEE6 - 24mai2011
Andrei Niculae - JavaEE6 - 24mai2011Andrei Niculae - JavaEE6 - 24mai2011
Andrei Niculae - JavaEE6 - 24mai2011
 
Java EE 6 and GlassFish portfolio
Java EE 6 and GlassFish portfolioJava EE 6 and GlassFish portfolio
Java EE 6 and GlassFish portfolio
 
Java Summit Chennai: Java EE 7
Java Summit Chennai: Java EE 7Java Summit Chennai: Java EE 7
Java Summit Chennai: Java EE 7
 
S313557 java ee_programming_model_explained_dochez
S313557 java ee_programming_model_explained_dochezS313557 java ee_programming_model_explained_dochez
S313557 java ee_programming_model_explained_dochez
 
GlassFish 3.1 at JCertif 2011
GlassFish 3.1 at JCertif 2011GlassFish 3.1 at JCertif 2011
GlassFish 3.1 at JCertif 2011
 
TDC 2011: OSGi-enabled Java EE Application
TDC 2011: OSGi-enabled Java EE ApplicationTDC 2011: OSGi-enabled Java EE Application
TDC 2011: OSGi-enabled Java EE Application
 
Web Application Architecture
Web Application ArchitectureWeb Application Architecture
Web Application Architecture
 
N(i)2 technical architecture 2.0 (v1 1)
N(i)2 technical architecture 2.0 (v1 1)N(i)2 technical architecture 2.0 (v1 1)
N(i)2 technical architecture 2.0 (v1 1)
 
The State of Java under Oracle at JCertif 2011
The State of Java under Oracle at JCertif 2011The State of Java under Oracle at JCertif 2011
The State of Java under Oracle at JCertif 2011
 
The Java EE 7 Platform: Developing for the Cloud
The Java EE 7 Platform: Developing for the CloudThe Java EE 7 Platform: Developing for the Cloud
The Java EE 7 Platform: Developing for the Cloud
 
Java EE 7 at JAX London 2011 and JFall 2011
Java EE 7 at JAX London 2011 and JFall 2011Java EE 7 at JAX London 2011 and JFall 2011
Java EE 7 at JAX London 2011 and JFall 2011
 
TDC 2011: The Java EE 7 Platform: Developing for the Cloud
TDC 2011: The Java EE 7 Platform: Developing for the CloudTDC 2011: The Java EE 7 Platform: Developing for the Cloud
TDC 2011: The Java EE 7 Platform: Developing for the Cloud
 
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
 

Ähnlich wie Plataforma Java EE 7: Produtividade & HTML5 - Parte 1

The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012
The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012
The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012Arun Gupta
 
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3 Arun Gupta: London Java Community: Java EE 6 and GlassFish 3
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3 Skills Matter
 
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...Arun Gupta
 
Java EE 6 Component Model Explained
Java EE 6 Component Model Explained Java EE 6 Component Model Explained
Java EE 6 Component Model Explained Shreedhar Ganapathy
 
Spark IT 2011 - Java EE 6 Workshop
Spark IT 2011 - Java EE 6 WorkshopSpark IT 2011 - Java EE 6 Workshop
Spark IT 2011 - Java EE 6 WorkshopArun Gupta
 
Vaadin 7 - Java Enterprise Edition integration
Vaadin 7 - Java Enterprise Edition integrationVaadin 7 - Java Enterprise Edition integration
Vaadin 7 - Java Enterprise Edition integrationPeter Lehto
 
Java EE 6 & GlassFish = Less Code + More Power at CEJUG
Java EE 6 & GlassFish = Less Code + More Power at CEJUGJava EE 6 & GlassFish = Less Code + More Power at CEJUG
Java EE 6 & GlassFish = Less Code + More Power at CEJUGArun Gupta
 
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnition
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnitionJava EE 6 & GlassFish = Less Code + More Power @ DevIgnition
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnitionArun Gupta
 
Java EE 6 = Less Code + More Power
Java EE 6 = Less Code + More PowerJava EE 6 = Less Code + More Power
Java EE 6 = Less Code + More PowerArun Gupta
 
Java EE 6 & GlassFish v3: Paving the path for the future - Spark IT 2010
Java EE 6 & GlassFish v3: Paving the path for the future - Spark IT 2010Java EE 6 & GlassFish v3: Paving the path for the future - Spark IT 2010
Java EE 6 & GlassFish v3: Paving the path for the future - Spark IT 2010Arun Gupta
 
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010Arun Gupta
 
Sun Java EE 6 Overview
Sun Java EE 6 OverviewSun Java EE 6 Overview
Sun Java EE 6 Overviewsbobde
 

Ähnlich wie Plataforma Java EE 7: Produtividade & HTML5 - Parte 1 (20)

The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012
The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012
The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012
 
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3 Arun Gupta: London Java Community: Java EE 6 and GlassFish 3
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3
 
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...
 
Java EE 6 Component Model Explained
Java EE 6 Component Model Explained Java EE 6 Component Model Explained
Java EE 6 Component Model Explained
 
Spark IT 2011 - Java EE 6 Workshop
Spark IT 2011 - Java EE 6 WorkshopSpark IT 2011 - Java EE 6 Workshop
Spark IT 2011 - Java EE 6 Workshop
 
Java EE 6 Aquarium Paris
Java EE 6 Aquarium ParisJava EE 6 Aquarium Paris
Java EE 6 Aquarium Paris
 
Java E
Java EJava E
Java E
 
Java EE6 Overview
Java EE6 OverviewJava EE6 Overview
Java EE6 Overview
 
Jcp adopt jsr
Jcp adopt jsrJcp adopt jsr
Jcp adopt jsr
 
Whats New In Java Ee 6
Whats New In Java Ee 6Whats New In Java Ee 6
Whats New In Java Ee 6
 
Vaadin 7 - Java Enterprise Edition integration
Vaadin 7 - Java Enterprise Edition integrationVaadin 7 - Java Enterprise Edition integration
Vaadin 7 - Java Enterprise Edition integration
 
Java EE 6 & GlassFish = Less Code + More Power at CEJUG
Java EE 6 & GlassFish = Less Code + More Power at CEJUGJava EE 6 & GlassFish = Less Code + More Power at CEJUG
Java EE 6 & GlassFish = Less Code + More Power at CEJUG
 
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnition
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnitionJava EE 6 & GlassFish = Less Code + More Power @ DevIgnition
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnition
 
Java EE 6 = Less Code + More Power
Java EE 6 = Less Code + More PowerJava EE 6 = Less Code + More Power
Java EE 6 = Less Code + More Power
 
Java EE 6
Java EE 6Java EE 6
Java EE 6
 
Java EE 6 & GlassFish v3: Paving the path for the future - Spark IT 2010
Java EE 6 & GlassFish v3: Paving the path for the future - Spark IT 2010Java EE 6 & GlassFish v3: Paving the path for the future - Spark IT 2010
Java EE 6 & GlassFish v3: Paving the path for the future - Spark IT 2010
 
JBoss AS7 Reloaded
JBoss AS7 ReloadedJBoss AS7 Reloaded
JBoss AS7 Reloaded
 
JBoss AS / EAP and Java EE6
JBoss AS / EAP and Java EE6JBoss AS / EAP and Java EE6
JBoss AS / EAP and Java EE6
 
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010
 
Sun Java EE 6 Overview
Sun Java EE 6 OverviewSun Java EE 6 Overview
Sun Java EE 6 Overview
 

Mehr von Bruno Borges

Secrets of Performance Tuning Java on Kubernetes
Secrets of Performance Tuning Java on KubernetesSecrets of Performance Tuning Java on Kubernetes
Secrets of Performance Tuning Java on KubernetesBruno Borges
 
[Outdated] Secrets of Performance Tuning Java on Kubernetes
[Outdated] Secrets of Performance Tuning Java on Kubernetes[Outdated] Secrets of Performance Tuning Java on Kubernetes
[Outdated] Secrets of Performance Tuning Java on KubernetesBruno Borges
 
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX Apps
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX AppsFrom GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX Apps
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX AppsBruno Borges
 
Making Sense of Serverless Computing
Making Sense of Serverless ComputingMaking Sense of Serverless Computing
Making Sense of Serverless ComputingBruno Borges
 
Visual Studio Code for Java and Spring Developers
Visual Studio Code for Java and Spring DevelopersVisual Studio Code for Java and Spring Developers
Visual Studio Code for Java and Spring DevelopersBruno Borges
 
Taking Spring Apps for a Spin on Microsoft Azure Cloud
Taking Spring Apps for a Spin on Microsoft Azure CloudTaking Spring Apps for a Spin on Microsoft Azure Cloud
Taking Spring Apps for a Spin on Microsoft Azure CloudBruno Borges
 
A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...
A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...
A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...Bruno Borges
 
Melhore o Desenvolvimento do Time com DevOps na Nuvem
Melhore o Desenvolvimento do Time com DevOps na NuvemMelhore o Desenvolvimento do Time com DevOps na Nuvem
Melhore o Desenvolvimento do Time com DevOps na NuvemBruno Borges
 
Tecnologias Oracle em Docker Containers On-premise e na Nuvem
Tecnologias Oracle em Docker Containers On-premise e na NuvemTecnologias Oracle em Docker Containers On-premise e na Nuvem
Tecnologias Oracle em Docker Containers On-premise e na NuvemBruno Borges
 
Java EE Arquillian Testing with Docker & The Cloud
Java EE Arquillian Testing with Docker & The CloudJava EE Arquillian Testing with Docker & The Cloud
Java EE Arquillian Testing with Docker & The CloudBruno Borges
 
Migrating From Applets to Java Desktop Apps in JavaFX
Migrating From Applets to Java Desktop Apps in JavaFXMigrating From Applets to Java Desktop Apps in JavaFX
Migrating From Applets to Java Desktop Apps in JavaFXBruno Borges
 
Servidores de Aplicação: Por quê ainda precisamos deles?
Servidores de Aplicação: Por quê ainda precisamos deles?Servidores de Aplicação: Por quê ainda precisamos deles?
Servidores de Aplicação: Por quê ainda precisamos deles?Bruno Borges
 
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]Bruno Borges
 
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]Bruno Borges
 
Booting Up Spring Apps on Lightweight Cloud Services [CON10258]
Booting Up Spring Apps on Lightweight Cloud Services [CON10258]Booting Up Spring Apps on Lightweight Cloud Services [CON10258]
Booting Up Spring Apps on Lightweight Cloud Services [CON10258]Bruno Borges
 
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]Bruno Borges
 
Running Oracle WebLogic on Docker Containers [BOF7537]
Running Oracle WebLogic on Docker Containers [BOF7537]Running Oracle WebLogic on Docker Containers [BOF7537]
Running Oracle WebLogic on Docker Containers [BOF7537]Bruno Borges
 
Lightweight Java in the Cloud
Lightweight Java in the CloudLightweight Java in the Cloud
Lightweight Java in the CloudBruno Borges
 
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFX
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFXTweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFX
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFXBruno Borges
 
Integrando Oracle BPM com Java EE e WebSockets
Integrando Oracle BPM com Java EE e WebSocketsIntegrando Oracle BPM com Java EE e WebSockets
Integrando Oracle BPM com Java EE e WebSocketsBruno Borges
 

Mehr von Bruno Borges (20)

Secrets of Performance Tuning Java on Kubernetes
Secrets of Performance Tuning Java on KubernetesSecrets of Performance Tuning Java on Kubernetes
Secrets of Performance Tuning Java on Kubernetes
 
[Outdated] Secrets of Performance Tuning Java on Kubernetes
[Outdated] Secrets of Performance Tuning Java on Kubernetes[Outdated] Secrets of Performance Tuning Java on Kubernetes
[Outdated] Secrets of Performance Tuning Java on Kubernetes
 
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX Apps
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX AppsFrom GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX Apps
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX Apps
 
Making Sense of Serverless Computing
Making Sense of Serverless ComputingMaking Sense of Serverless Computing
Making Sense of Serverless Computing
 
Visual Studio Code for Java and Spring Developers
Visual Studio Code for Java and Spring DevelopersVisual Studio Code for Java and Spring Developers
Visual Studio Code for Java and Spring Developers
 
Taking Spring Apps for a Spin on Microsoft Azure Cloud
Taking Spring Apps for a Spin on Microsoft Azure CloudTaking Spring Apps for a Spin on Microsoft Azure Cloud
Taking Spring Apps for a Spin on Microsoft Azure Cloud
 
A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...
A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...
A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...
 
Melhore o Desenvolvimento do Time com DevOps na Nuvem
Melhore o Desenvolvimento do Time com DevOps na NuvemMelhore o Desenvolvimento do Time com DevOps na Nuvem
Melhore o Desenvolvimento do Time com DevOps na Nuvem
 
Tecnologias Oracle em Docker Containers On-premise e na Nuvem
Tecnologias Oracle em Docker Containers On-premise e na NuvemTecnologias Oracle em Docker Containers On-premise e na Nuvem
Tecnologias Oracle em Docker Containers On-premise e na Nuvem
 
Java EE Arquillian Testing with Docker & The Cloud
Java EE Arquillian Testing with Docker & The CloudJava EE Arquillian Testing with Docker & The Cloud
Java EE Arquillian Testing with Docker & The Cloud
 
Migrating From Applets to Java Desktop Apps in JavaFX
Migrating From Applets to Java Desktop Apps in JavaFXMigrating From Applets to Java Desktop Apps in JavaFX
Migrating From Applets to Java Desktop Apps in JavaFX
 
Servidores de Aplicação: Por quê ainda precisamos deles?
Servidores de Aplicação: Por quê ainda precisamos deles?Servidores de Aplicação: Por quê ainda precisamos deles?
Servidores de Aplicação: Por quê ainda precisamos deles?
 
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]
 
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]
 
Booting Up Spring Apps on Lightweight Cloud Services [CON10258]
Booting Up Spring Apps on Lightweight Cloud Services [CON10258]Booting Up Spring Apps on Lightweight Cloud Services [CON10258]
Booting Up Spring Apps on Lightweight Cloud Services [CON10258]
 
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]
 
Running Oracle WebLogic on Docker Containers [BOF7537]
Running Oracle WebLogic on Docker Containers [BOF7537]Running Oracle WebLogic on Docker Containers [BOF7537]
Running Oracle WebLogic on Docker Containers [BOF7537]
 
Lightweight Java in the Cloud
Lightweight Java in the CloudLightweight Java in the Cloud
Lightweight Java in the Cloud
 
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFX
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFXTweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFX
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFX
 
Integrando Oracle BPM com Java EE e WebSockets
Integrando Oracle BPM com Java EE e WebSocketsIntegrando Oracle BPM com Java EE e WebSockets
Integrando Oracle BPM com Java EE e WebSockets
 

Kürzlich hochgeladen

Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 

Kürzlich hochgeladen (20)

Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 

Plataforma Java EE 7: Produtividade & HTML5 - Parte 1

  • 1. Main sponsor Plataforma Java EE 7: Produtividade & HTML5 Bruno Borges - @brunoborges Oracle Java EE/Middleware Product Manager
  • 2. The following 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. 2 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 3. Java EE 6 10 Dezembro 2009 3 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 4. Java EE 6 – Estatísticas • 40+ Milhões de Downloads de Componentes Java EE • #1 Escolha para Desenvolvedores Enterprise • #1 Plataforma de Desenvolvimento de Aplicações • Mais rápida implementação do Java EE 4 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 5. Top 10 Features do Java EE 6 1. EJB dentro de um WAR 2. Injeção de Dependência type-safe 3. Descritores de Deploy opcionais (web.xml, faces-config.xml) 4. JSF padronizado com Facelets 5. Uma única classe por EJB 6. Pontos de Extensão para Servlets e CDI 7. Eventos CDI 8. API de EJBContainer 9. Anotação @Schedule baseado em cron 10. Profile Web para desenvolvimento Java EE leve 5 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 6. Escopo do Java EE 7 Produtividade e HTML5 • Mais Produtividade – Menos código “boilerplate” – Funcionalidades mais ricas – Mais padrões e convenções • Suporte ao HTML5 – WebSocket – JSON – Formulários HTML5 6 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 7. Java EE 7 –JSRs Candidatas JAX-RS JAX-RS Java Caching API Java Caching API JSP 2.2 JSF 2.2 JSP 2.2 JSF 2.2 2.0 EL 3.0 EL 3.0 (JSR 107) (JSR 107) Portable 2.0 Portable Extensions Extensions Concurrency Utilities Concurrency Utilities Servlet 3.1 Servlet 3.1 (JSR 236) (JSR 236) Common Common Batch Applications Batch Applications Interceptors 1.1 CDI 1.1 Annotations 1.1 Interceptors 1.1 CDI 1.1 (JSR 352) (JSR 352) Annotations 1.1 Java API for JSON Java API for JSON Managed Beans 1.0 Managed Beans 1.0 EJB 3.2 EJB 3.2 (JSR 353) (JSR 353) Connector Connector Java API for WebSocket Java API for WebSocket JPA 2.1 JPA 2.1 JTA 1.2 JTA 1.2 JMS 2.0 JMS 2.0 (JSR 356) 1.6 1.6 (JSR 356) Novo Nova Atualização Versão 7 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 8. Agenda • JAX-RS 2.0 • JMS 2.0 • JSON API 1.0 • WebSockets API 1.0 • Bean Validation 1.1 • Batch API 1.0 • JCache API 1.0 • JPA 2.1 8 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 9. Java API for RESTful Web Services 2.0 Client API - Antes String address = String.format("http://…/orders/%0$s/customer?shipped= %1$b", "10", true); URL url = new URL(address); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.setDoInput(true); conn.setDoOutput(false); BufferedReader br = new BufferedReader( new InputStreamReader(conn.getInputStream())); String line; while ((line = br.readLine()) != null) { //. . . } 9 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 10. Java API for RESTful Web Services 2.0 Client API - Agora // Obtém instância do Client Client client = ClientFactory.newClient(); // Obtém nome do cliente para o produto enviado String name = client.target(“../orders/ {orderId}/customer”) .resolveTemplate(”orderId", ”10”) .queryParam(”shipped", ”true”) .request() .get(String.class); 10 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 11. Java API for RESTful Web Services 2.0 Client API - Agora // Sacar dinheiro Money mon = client.target("http://.../atm/{cardId}/withdrawal") .resolveTemplate("cardId", "111122223333") .queryParam("pin", "9876") .request("application/json") .post(text("50.0"), Money.class); 11 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 12. Java API for RESTful Web Services 2.0 Client-side Async Client client = ClientFactory.newClient(); Future<String> future = client.target("http://.../atm/{card}/balance") .pathParam("card", "1111222233334444") .queryParam("pin", "1234") .request("text/plain") .async() .get( new InvocationCallback<String>() { public void completed(String result) { } public void failed(InvocationException e) { } }); 12 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 13. Java API for RESTful Web Services 2.0 Server-side Async @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); }}); } } 13 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 14. Java API for RESTful Web Services 2.0 Pré-Configurações public class MyApp extends javax.ws.rs.core.Application { public Set<Class<?>> getClasses() { Set<Class<?>> classes = new HashSet<…>(); … classes.add(JsonMessageBodyReader.class); classes.add(JsonMessageBodyWriter.class); classes.add(JsonpInterceptor.class); … return classes; } } public Set<Class<?>> getClasses() { … classes.add(JsonFeature.class); … } 14 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 15. Java Message Service 2.0 Enviando mensagem com JMS 1.1 - Antes @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); 13 LDCs só } finally { pra enviar connection.close(); a msg } } catch (JMSException ex) { Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex); } } 15 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 16. Java Message Service 2.0 API simplificada para fechar objetos JMS @Resource(lookup = "jms/connFactory") ConnectionFactory cf; Uso do bloco @Resource(lookup="jms/inboundQueue") try-with-resource Destination dest; s public void sendMessage (String payload) throws JMSException { try ( Connection conn = connectionFactory.createConnection(); Session session = conn.createSession(); MessageProducer producer = session.createProducer(dest); ){ Message mess = sess.createTextMessage(payload); close() é producer.send(mess); chamado } catch(JMSException e){ automaticamente // exception handling } } 18 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 17. Java Message Service 2.0 JMSContext Introdução do JMSContext e JMSProducer combina Connection e Session @Resource(lookup = "java:global/jms/demoConnectionFactory") ConnectionFactory connectionFactory; Mensagem @Resource(lookup = "java:global/jms/demoQueue") enviada Queue demoQueue; diretamente public void sendMessage (String payload) { try (JMSContext context = connectionFactory.createContext();){ context.createProducer().send(demoQueue, payload); } catch (JMSRuntimeException ex) { // exception handling } close() é } chamado Sem checked automaticamente exceptions 19 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 18. Java Message Service 2.0 Definição padrão de recursos Definição de recurso ou @JmsConnectionFactory @Inject JMSContext context; @Resource(lookup = "java:global/jms/demoQueue”) Queue demoQueue; public void sendMessage(String payload) { context.createProducer().send(demoQueue, payload); } 13 linhas 1 line 20 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 19. Java API for JSON Processing 1.0 Streaming API – JsonParser e JsonGenerator • 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, ... 21 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 20. Java API for JSON Processing 1.0 Streaming API – JsonParser { "firstName": "John", "lastName": "Smith", "age": 25, "phoneNumber": [ { "type": "home", "number": "212 555-1234" }, { "type": "fax", "number": "646 555-4567" } ] } Iterator<Event> it = parser.iterator(); Event event = it.next(); // START_OBJECT event = it.next(); // KEY_NAME event = it.next(); // VALUE_STRING String name = parser.getString(); // "John” 29 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 21. Java API for JSON Processing 1.0 Streaming API – JsonParser e JsonGenerator • JsonGenerator – Gera JSON no modo streaming • Similar ao XMLStreamWriter do StaX – Como criar • Json.createGenerator(…) • Json.createGeneratorFactory().createGenerator(…) – Funcionalidades adicionais • Ex: código gerado formatado 30 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 22. Java API for JSON Processing 1.0 Streaming API – JsonGenerator JsonGenerator jg = Json.createGenerator(…); "phoneNumber": [ { jg. "type": "home", .beginArray("phoneNumber") "number": ”408-123-4567” .beginObject() }, .add("type", "home") { .add("number", "408-123-4567") "type": ”work", .endObject() "number": ”408-987-6543” .beginObject() } .add("type", ”work") ] .add("number", "408-987-6543") .endObject() .endArray(); jg.close(); 31 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 23. Java API for JSON Processing 1.0 Object Model API • JsonObject/JsonArray – Objeto JSON e estruturas de Array – JsonString e JsonNumber para valores texto e numéricos • JsonBuilder – Cria JsonObject e JsonArray • JsonReader – Lê JsonObject e JsonArray • JsonWriter – Escreve JsonObject e JsonArray 32 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 24. Java API for JSON Processing 1.0 DOM API – JsonReader • Lê JsonObject e JsonArray de algum input – I/O Reader, InputStream (+ encoding) • Possível configurar outras opções • Utiliza um JsonParser plugável // Leitura de um objeto JSON try(JsonReader reader = new JsonReader(io)) { JsonObject obj = reader.readObject(); } 33 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 25. Java API for JSON Processing 1.0 DOM API – Writer • Escreve JsonObject e JsonArray para algum output – I/O Writer, OutputStream (+ encoding) • Outras configurações, como “pretty printing” • Utiliza um JsonGenerator plugável // Escreve um objeto JSON try(JsonWriter writer = new JsonWriter(io)) { writer.writeObject(obj); } 34 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 26. Java API for WebSocket 1.0 Hello World – POJO/Annotation-driven import javax.websocket.*; @WebSocketEndpoint("/hello") public class HelloBean { @WebSocketMessage public String sayHello(String name) { return “Hello “ + name; } } 35 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 27. Java API for WebSocket 1.0 Anotações WebSocket Annotation Level Purpose @WebSocketEndpoint class Torna um POJO em um WebSocket Endpoint @WebSocketClient class Torna um POJO em um WebSocket Client @WebSocketOpen method Intercepta eventos WebSocket Open @WebSocketClose method Intercepta eventos WebSocket Close @WebSocketMessage method Intercepta eventos WebSocket Message @WebSocketPathParam method parameter Marca um segmento de um template de URI @WebSocketError method Intercepta erros durante a conversação 36 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 28. Java API for WebSocket 1.0 Atributos do @WebSocketEndpoint value URI relativa ou template de URI ex. “/hello” ou “/chat/{subscriber-level}” decoders lista de decodificadores de mensagens encoders lista de codificadores de mensagens subprotocols lista dos protocolos suportados 37 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 29. Java API for WebSocket 1.0 Mensagens customizadas @WebSocketEndpoint( value="/hello", encoders={MyMessage.class}, decoders={MyMessage.class} ) public class MyEndpoint { . . . } 38 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 30. Java API for WebSocket 1.0 Mensagens customizadas – Text public class MyMessage implements Decoder.Text<MyMessage>, Encoder.Text<MyMessage> { private JsonObject jsonObject; public MyMessage decode(String s) { jsonObject = new JsonReader(new StringReader(s)).readObject(); return this; } public boolean willDecode(String string) { return true; // Only if can process the payload } public String encode(MyMessage myMessage) { return myMessage.jsonObject.toString(); } } Copyright © 2012, Oracle and/or its affiliates. All rights 39 reserved.
  • 31. Java API for WebSocket 1.0 Mensagens customizadas – Binary public class MyMessage implements Decoder.Binary<MyMessage>, Encoder.Binary<MyMessage> { public MyMessage decode(byte[] bytes) { . . . return this; } public boolean willDecode(byte[] bytes) { . . . return true; // Only if can process the payload } public byte[] encode(MyMessage myMessage) { . . . } } 40 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 32. Java API for WebSocket 1.0 URI Template Matching • Um nível somente (1 parâmetro na URL) @WebSocketEndpoint(“/orders/{order-id}”) public class MyEndpoint { @WebSocketMessage public void processOrder( @WebSocketPathParam(“order-id”)String orderId) { . . . } } 41 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 33. Java API for WebSocket 1.0 Hello World Client @WebSocketClient public class HelloClient { @WebSocketMessage public void message(String message, Session session) { // process message from server } } WebSocketContainer c = ContainerProvider.getClientContainer(); c.connectToServer(HelloClient.class, “…/hello”); 42 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 34. Bean Validation 1.1 Parâmetro de Método e Validação de Resultado public void placeOrder( Built-in @NotNull String productName, @NotNull @Max(“10”) Integer quantity, Custom @Customer String customer) { //. . . } @Future public Date getAppointment() { //. . . } 43 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 35. Batch Applications for the Java Platform 1.0 • Serve para tarefas não-interativas e processos longos • Processamento computacional intensivo • Pode executar sequencial ou paralelo • Pode ser inicializado com: – Chamada adhoc – Agendado • Não há uma API de agendamento incluída 44 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 36. Batch Applications for the Java Platform 1.0 Job Specification Language • Define um Job, Steps e direciona a execução • Implementado em XML – Também chamado de “Job XML” • Suporta herança de Job, Step, Flow, e Split 49 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 37. Batch Applications for the Java Platform 1.0 Job Specification Language – Exemplo <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> 50 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 38. Batch Applications for the Java Platform 1.0 Job Specification Language – Chunked <step id=”sendStatements”> @ReadItem <chunk reader=”AccountReader” public Account readAccount() { processor=”AccountProcessor” // read account using JPA writer=”EmailWriter” } chunk-size=”10” /> </step> @ProcessItem public Account processAccount(Account account) { // calculate balance } @WriteItems public void sendEmail(List<Account> accounts) { // use JavaMail to send email } 51 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 39. Batch Applications for the Java Platform 1.0 Job Specification Language: Batchlet <step id=”transferFile”> <batchlet ref=“MyFileTransfer” /> </step> @Process public void transferFile(String name) { // Transfer file } 52 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 40. Batch Applications for the Java Platform 1.0 Conceitos: Listeners • Job listener: intercepta a execução batch – @BeforeJob, @AfterJob • Step listener – @BeforeStep, @AfterStep • Chunk listener – @BeforeChunk, @AfterChunk, @BeforeCheckpoint, @AfterCheckpoint • Listeners para read/process/write de itens, . . . 53 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 41. Java Temporary Caching API 1.0 • API e semântica para cache temporário em memória para objetos Java – Criação de objetos – Acesso compartilhado – Spooling – Invalidez de objetos – Consistência entre diversas JVMs • SPI para implementações 55 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 42. Java Temporary Caching API 1.0 Exemplo – Criando um CacheManager CacheManager cacheManager = CacheManagerFactory.getCacheManager(); ou verbosamente CacheManager cacheManager = CacheManagerFactory.getCacheManager(DEFAULT_CACHE_M ANAGER_NAME, Thread.currentThread().getContextClassLoader()); 60 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 43. Java Temporary Caching API 1.0 Exemplo – Usando o Cache • Obtém um cache do CacheManager Cache<Integer, Date> cache = cacheManager.getCache(“testCache”); 61 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 44. Java Temporary Caching API 1.0 Exemplo – Configurando o Cache • Configurar um cache para “read-through” CacheManager cacheManager = getCacheManager(); Cache testCache = cacheManager.createCacheBuilder(“testCache”) .setReadThrough(true) .setSize(Size.UNLIMITED) .setExpiry(Duration.ETERNAL) .build(); 62 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 45. Java Temporary Caching API 1.0 Exemplo – Colocando um valor no cache Cache<Integer, Date> cache = cacheManager.getCache(cacheName); Integer key = 1; cache.put(key, new Date()); 63 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 46. Java Temporary Caching API 1.0 Exemplo – Obtendo um valor do cache Cache<Integer, Date> cache = cacheManager.getCache(cacheName); Date value = cache.get(key); 64 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 47. Java Temporary Caching API 1.0 Exemplo – Removendo um valor do cache Cache<Integer, Date> cache = cacheManager.getCache(cacheName); Integer key = 1; cache.remove(1); 65 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 48. Java Temporary Caching API 1.0 Exemplo – Blog public class BlogManager { @CachePut(cacheName=”blogManager”) public void createEntry( @CacheKeyParam String title, @CacheValue Blog blog) {...} . . . 66 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 49. Java Temporary Caching API 1.0 Exemplo – Blog . . . @CacheResult(cacheName="blogManager") public Blog getBlogEntry(String title) {...} @CacheResult(cacheName="blogManager") public Blog getEntryCached( String randomArg, @CacheKeyParam String title) {...} . . . 67 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 50. Java Temporary Caching API 1.0 Annotations – Exemplo do Blog . . . @CacheRemoveEntry(cacheName="blogManager") public void removeBlogEntry(String title) {...} @CacheRemoveAll(cacheName="blogManager") public void removeAllBlogs() {...} } 68 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 51. Java Temporary Caching API 1.0 Possíveis implementações • Terracotta – Ehcache • Oracle – Coherence • JBoss – Inifinispan • IBM – ExtremeeScale • SpringSorce – Gemfire • Google App Engine – Java memcache client • Spymemcache memcache client 69 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 52. Java Persistence API 2.1 • Geração do schema • Persistence Context assíncronos • Converters • Bulk (batch) update/delete usando o Criteria • Acesso padronizado a FUNCTIONS pela API • Acesso padronizado a Stored Procedures pela API 70 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 53. Java Persistence API 2.1 Unsynchronized Persistence Contexts • Synchronized: TX aplicada no banco no commit • Unsynchronized: Não fica sincronizada com a TX do JTA até o joinTransaction ser chamado – Não permite escrita no banco de dados – Mas pode chamar: persist, merge, remove, refresh • Funciona tanto gerenciado pelo container quanto pela aplicação • Caso de uso – Conversão de modelagem – Monitorar mudanças na persistência, efetuar commit somente no final 76 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 54. Java Persistence API 2.1 Unsynchronized Persistence Contexts Sample @Stateful public class ShoppingCart { @PersistenceContext(type=EXTENDED, synchronization=UNSYNCHRONIZED) EntityManager em; @PersistenceContext EntityManager dataMiningEM; Customer customer; Order order; public void startToShop(Integer custId) { customer = em.find(Customer.class, custId); order = new Order(); } 77 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 55. Java Persistence API 2.1 Unsynchronized Persistence Contexts - Exemplo public Collection<Book> viewCart() { // suggest other books based on interests ...} // purchase the books public void confirmOrder() { em.joinTransaction(); customer.addOrder(order); } 78 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 56. Java Persistence API 2.1 Stored Procedure Query @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); // there are other setParameter methods for defining the temporal type . . . query.execute(); String response = query.getOutputParameterValue(1); 79 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 57. Java Persistence API 2.1 Update e Delete com Criteria CriteriaUpdate<Customer> q = cb.createCriteriaUpdate(Customer.class); Root<Customer> c = q.from(Customer.class); UPDATE Customer c q.set(c.get(Customer_.status), "outstanding") SET c.status = 'outstanding' .where(cb.lt(c.get(Customer_.balance), 10000)); WHERE c.balance < 10000 . . . @PersistenceContext EntityManager em; Query query = em.createQuery(q); query.executeUpdate(); CriteriaDelete<Customer> q = cb.createCriteriaDelete(Customer.class); Root<Customer> c = q.from(Customer.class); q.where(cb.equal(c.get(Customer_.status), "inactive"), cb.isEmpty(c.get(Customer_.orders))); DELETE FROM Customer c . . . WHERE c.status = 'inactive' AND c.orders IS EMPTY 80 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 58. GlassFish Roadmap GlassFish v3 GlassFish Server 3.1 GlassFish Server 3.1.2 •Java EE 6 support •Centralized administration •Bug Fixes •Single instance •Clustering / HA •Incremental features •GlassFish Enterprise Mgr •GlassFish Server Control 2009 2010 2011 2012 2013 GlassFish Server 3.0.1 GlassFish Server 3.1.1 GlassFish Server 4 •Oracle branding •Bug fixes •Java EE 7 •Oracle platform support •Updated components •Productivity •Oracle interoperability •Incremental features •HTML5 121 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 59. Transparência • JSRs de Java EE 7 da Oracle estão abertos no java.net – http://javaee-spec.java.net – One project per spec – ex: jpa-spec, jax-rs-spec, jms-spec… • Mensagens de email do EG são públicas • Área de download com acesso público • Issue Tracker com acesso público • Compromisso para atualizar para o JCP 2.8 122 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 60. Java EE 7: Status e Agenda • Todas as JSRs estão ativas e em andamento • Todas já publicaram Early Drafts, várias em Public Review • Lançamento em: Q2 2013 123 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 61. Adopt-a-JSR O que é ? • Iniciativa de líderes JUGs para se involverem em JSR • Promover as JSRs para a comunidade Java • O que posso fazer ? – Revisar a spec e os javadocs – Criar aplicações usando a spec beta – Contribuir para a RI, exemplos, docs – Apresentar para JUGs ou conferências – Blog – ... 126 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 62. Adopt-a-JSR Como posso começar? – glassfish.org/adoptajsr 127 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 63. Adopt-a-JSR JUGs participando do programa 128 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 64. Como participar • Java EE 7 Expert Group – javaee-spec.java.net • Java EE 7 Reference Implementation – glassfish.org • The Aquarium – blogs.oracle.com/theaquarium • Adopt-a-JSR – glassfish.org/adoptajsr 129 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 65. 130 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.