EJB 3.1
-
Upload
waelson-negreiros -
Category
Documents
-
view
2.933 -
download
8
description
Transcript of EJB 3.1
![Page 1: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/1.jpg)
![Page 2: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/2.jpg)
Sobre Mim
Trabalha com EJB desde a versão 2.1 Possui mais de 10 anos de
experiência em TI Arquiteto de Software Sênior Instrutor da Bluestar Tecnologia
desde 2006 Possui várias certificações Java
![Page 3: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/3.jpg)
Sobre Você
Quantas pessoas utilizam ou já utilizaram EJB (qualquer versão)?
Quantas pessoas já precisaram escalar suas aplicações?
Quantas pessoas utilizam produtos não padronizados com as mesmas características?
![Page 4: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/4.jpg)
Agenda
Visão Geral Novas Características Conclusão Dúvidas e Perguntas
![Page 5: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/5.jpg)
Visão Geral
![Page 6: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/6.jpg)
Visão Geral
A comunidade foi ouvida
![Page 7: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/7.jpg)
Visão Geral
Spec EJB 3.1• JSR 318• Iniciou em 17/07/2007• Release final liberada em 10/12/2009• Liderada por Kenneth Saks, Sun
Microsystens• JPA definida pela JSR 317
![Page 8: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/8.jpg)
Visão Geral
Objetivos• Simplificar a arquitetura EJB• Reduzir a complexidade• Adicionar novas funcionalidade
![Page 9: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/9.jpg)
Novas Características
![Page 10: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/10.jpg)
Novas Características
Singleton Interface Opcional Timer Service Melhorado EJB na Camada Web Session Bean Assíncronos EJB Lite Nomes JNDI Padronizados EJB 3 Java SE Runtime
![Page 11: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/11.jpg)
Novas Características
Singleton• Novo EJB• Similar ao pattern Singleton (GOF)• Boa opção para cache• Dispõem dos serviços do container
![Page 12: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/12.jpg)
Novas Características
Singleton• É necessário controlar:
• Concorrência• Integridade dos dados
• Dois métodos• Container Managed Concurrency
– O container controla concorrência baseada em annotation ao nível de método
• Bean Managed Concurrency– O desenvolvedor é responsável pelo controle de
concorrência
![Page 13: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/13.jpg)
Novas Características
![Page 14: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/14.jpg)
Novas Características
Singleton• Container Managed Concurrency
• @Lock(READ)– Habilita leitura a todos os acessos
• @Lock(WRITE)– Permite apenas um único acesso
• @AccessTimeout(value=1, unit=SECONDS)– Aplicável a classes e métodos– Especifica o tempo que o método pode ficar
bloqueado
![Page 15: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/15.jpg)
Novas Características
![Page 16: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/16.jpg)
Novas Características
![Page 17: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/17.jpg)
Novas Características
Singleton• O Singleton pode ser iniciado junto com
o container• Basta usar a annotation @Startup
![Page 18: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/18.jpg)
Novas Características
![Page 19: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/19.jpg)
Novas Características
Singleton• Um Singleton pode depender de outro
durante a subida do container• @DependsOn – Define a sequência de
inicialização dos EJBs
![Page 20: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/20.jpg)
Novas Características
![Page 21: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/21.jpg)
Novas Características
Interface Opcional• EJBs parecidos com POJO• Interfaces as vezes são desnecessárias
![Page 22: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/22.jpg)
Novas Características
![Page 23: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/23.jpg)
Novas Características
Time Service melhorado• Uso simplificado• Pode-se utilizar Annotations• Similar a Cron Linux
![Page 24: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/24.jpg)
Novas Características
Time Service melhorado• Exemplo de limitações do EJB 3.0
• Agendamento feito programaticamente• Tarefas executados apenas um vez ou em
ciclos bem definidos
![Page 25: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/25.jpg)
Novas Características
![Page 26: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/26.jpg)
Novas Características
![Page 27: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/27.jpg)
Novas Características
![Page 28: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/28.jpg)
Novas Características
![Page 29: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/29.jpg)
Novas Características
EJB na Camada Web• Modelo de empacotamento diferenciado
para aplicações Web-Centric• EJBs dentro de WAR• JAR e WAR continuam existindo
![Page 30: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/30.jpg)
Novas Características
![Page 31: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/31.jpg)
Novas Características
![Page 32: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/32.jpg)
Novas Características
Session Bean Assíncrono• Alternativa ao JMS• Uso de Annotations• APIs Future e AsyncResult
![Page 33: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/33.jpg)
Novas Características
![Page 34: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/34.jpg)
Novas Características
![Page 35: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/35.jpg)
Novas Características
EJB Lite• Subconjunto da API EJB3.1 para Web
Profile• Expansão da portabilidade do EJBs• Publicação do EJB podem ser feitas em
• Web Profile• Full Profile
![Page 36: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/36.jpg)
Novas Características
![Page 37: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/37.jpg)
Novas Características
Nome JNDI Padronizado• Problema
• Portabilidade dos EJBs não transparente para o cliente
![Page 38: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/38.jpg)
Novas Características
Nome JNDI Padronizado• OC4J
• Usa o nome especificado na annotation @Stateless
• JBOSS• Usa application EAR + Nome do EJB +
/remote– App/CustomerManager/remote
![Page 39: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/39.jpg)
Novas Características
Nome JNDI Padronizado• Padrão
java:global[/application-name]/<module-name>/<bean-name>[!<fully-qualified-interface-name>]
java:app[/<module-name>]/<bean-name>[!<fully-qualified-interface-name>]
java:module/<bean-name>[!<fully-qualified-interface-name>]
![Page 40: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/40.jpg)
Novas Características
Nome JNDI Padronizado• MyWebApp.war
java:global/MyWebApp/CustomerManager! br.com.waelson.CustomerManager
• MyAppEJB.jarjava:app/MyAppEJB/CustomerManager!
br.com.waelson.CustomerManager
• MyApp.earjava:module/MyApp/MyAppEJB/
CustomerManager! br.com.waelson.CustomerManager
![Page 41: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/41.jpg)
EJB 3 Java SE Runtime
Principais motivações:• Dificuldade em testes locais com EJB• Necessidade de rodar EJBs sobre a
mesma JVM do cliente
![Page 42: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/42.jpg)
EJB 3 Java SE Runtime
![Page 43: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/43.jpg)
EJB 3 Java SE Runtime
São necessários 3 jars• accountEJB.jar• clienteAccount.jar• vendor-provider.jar
% java -cp account.jar:client.jar:vendor-provider.jar br.com.waelson.AccountTest
![Page 44: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/44.jpg)
Conclusão
![Page 45: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/45.jpg)
Conclusão
A cada versão torna-se mais fácil trabalhar com EJBs
JNDI Names portável Novas funcionalidades
• Asynchronous Beans e Singleton
![Page 46: EJB 3.1](https://reader031.fdocumentos.tips/reader031/viewer/2022020101/55393e634a79596f718b490a/html5/thumbnails/46.jpg)
Dúvidas e Perguntas