Coimbra JUG - 2º Encontro - O primeiro contacto com Java EE 7
Upcoming SlideShare
Loading in...5
×
 

Coimbra JUG - 2º Encontro - O primeiro contacto com Java EE 7

on

  • 341 views

 

Statistics

Views

Total Views
341
Slideshare-icon Views on SlideShare
341
Embed Views
0

Actions

Likes
0
Downloads
5
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Coimbra JUG - 2º Encontro - O primeiro contacto com Java EE 7 Coimbra JUG - 2º Encontro - O primeiro contacto com Java EE 7 Presentation Transcript

    • 2º Encontro 13/02/2014 Departamento de Engenharia Informática - Faculdade de Ciências e Tecnologia Universidade de Coimbra
    • Objectivos • Promover a comunidade de Java na zona Centro através de eventos periódicos • Encorajar a participação de membros • Aprender e divertir-se
    • Contactos • Meetup - http://www.meetup.com/Coimbra-JUG/ • Mailing List - coimbra-jug-list@meetup.com • Youtube - http://www.youtube.com/user/coimbrajug
    • O primeiro contacto com Java EE 7
    • Roberto Cortez Freelancer twitter:! @radcortez! ! mail:! radcortez@yahoo.com! ! blog:! http://www.radcortez.com
    • Questões? Assim que tiverem!
    • Novas Especificações • Websockets • Batch Applications • Concurrency Utilities • JSON Processing
    • Melhorias • Simplificação API JMS • Default Resources • JAX-RS Client API • Transacções externas a EJB’s • Mais Anotações • Entity Graphs
    • Java EE 7 JSRs
    • Websockets • Suporta cliente e servidor • Declarativo e Programático
    • Websockets Chat Server @ServerEndpoint("/chatWebSocket")! public class ChatWebSocket {! private static final Set<Session> sessions = Collections.synchronizedSet(new HashSet<Session>());! ! @OnOpen! public void onOpen(Session session) {sessions.add(session);}! ! @OnMessage! public void onMessage(String message) {! for (Session session : sessions) { session.getAsyncRemote().sendText(message);}! }! ! @OnClose! public void onClose(Session session) {sessions.remove(session);}! }
    • Batch Applications • Ideal para processos massivos, longos e nãointeractivos • Execução sequencial ou paralela • Processamento orientado à tarefa ou em secções.
    • Batch Applications
    • Batch Applications - job.xml <job id="myJob" xmlns="http://xmlns.jcp.org/xml/ns/ javaee" version="1.0">! <step id="myStep" >! <chunk item-count="3">! <reader ref="myItemReader"/>! <processor ref="myItemProcessor"/>! <writer ref="myItemWriter"/>! </chunk>! ! </step>! </job>
    • Concurrency Utilities • Capacidades assíncronas para componentes Java EE • Extensão da API de Java SE Concurrency • API segura e propaga contexto.
    • Concurrency Utilities public class TestServlet extends HttpServlet {! @Resource(name = "concurrent/MyExecutorService")! ManagedExecutorService executor;! ! Future future = executor.submit(new MyTask());! ! class MyTask implements Runnable {! public void run() {! ! ! ! // do something! }! }! }
    • JSON Processing • API para ler, gerar e transformar JSON • Streaming API e Object Model API
    • JSON Processing JsonArray jsonArray = Json.createArrayBuilder()! .add(Json.createObjectBuilder()! .add("name", “Jack"))! .add("age", "30"))! .add(Json.createObjectBuilder()! .add("name", “Mary"))! .add("age", "45"))! .build();! ! [ {“name”:”Jack”, “age”:”30”}, ! {“name”:”Mary”, “age”:”45”} ]
    • JMS • Nova interface JMSContext • Modernização da API utilizando DI • AutoCloseable dos recursos • Simplificação no envio de mensagens
    • JMS @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);! } finally {! connection.close();! }! } catch (JMSException ex) {! Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);! }! }
    • JMS @Inject! private JMSContext context;! ! @Resource(mappedName = "jms/inboundQueue")! private Queue inboundQueue;! ! public void sendMessage (String payload) {! context.createProducer()! .setPriority(1)! .setTimeToLive(1000)! .setDeliveryMode(NON_PERSISTENT)! .send(inboundQueue, payload);! }
    • JAX-RS • Nova API para consumir serviços REST • Processamento assíncrono (cliente e servidor) • Filtros e Interceptors
    • JAX-RS String movie = ClientBuilder.newClient()! .target("http://www.movies.com/movie")! .request(MediaType.TEXT_PLAIN)! .get(String.class);
    • JPA • Geração do schema da BD • Stored Procedures • Entity Graphs • Unsynchronized Persistence Context
    • JPA <persistence-unit name="myPU" transaction-type="JTA">! <properties>! <property name="javax.persistence.schemageneration.database.action" value="drop-and-create"/>! <property name="javax.persistence.schema-generation.create-source" value="script"/>! <property name="javax.persistence.schema-generation.drop-source" value="script"/>! <property name="javax.persistence.schema-generation.create-scriptsource" value="META-INF/create.sql"/>! <property name="javax.persistence.schema-generation.drop-scriptsource" value="META-INF/drop.sql"/>! <property name="javax.persistence.sql-load-script-source" value="META-INF/load.sql"/>! </properties>! </persistence-unit>
    • JPA @Entity! @NamedStoredProcedureQuery(name="top10MoviesProcedure",! procedureName = "top10Movies")! public class Movie {}! ! StoredProcedureQuery query = entityManager.createNamedStoredProcedureQuery(! "top10MoviesProcedure");! query.registerStoredProcedureParameter(1, String.class, ParameterMode.INOUT);! query.setParameter(1, "top10");! query.registerStoredProcedureParameter(2, Integer.class, ParameterMode.IN);! query.setParameter(2, 100);! query.execute();! query.getOutputParameterValue(1);
    • JSF • Suporte HTML 5 • @FlowScoped e @ViewScoped • Componente para File Upload • Navegação de flow por convenção • Resource Library Contracts
    • Outros • JTA: @Transactional, @TransactionScoped • Servlet: Non-blocking I/O, Segurança • CDI: Automáticos para EJB’s e beans anotados (beans.xml opcional), @Vetoed • Interceptors: @Priority, @AroundConstruct • EJB: Passivation opcional • EL: Lambdas, API isolada • Bean Validator: Restrições nos parâmetros dos métodos e retornos
    • Servidores Certificados • Glassfish 4.0 • Wildfly 8.0.0 • TMAX JEUS 8
    • Futuro Java EE 8 • JCache • Logging • JSON-B • Security • Testability • Cloud? • Modularity? • NoSQL?
    • Materiais • Tutorial Java EE 7 - http://docs.oracle.com/javaee/ 7/tutorial/doc/home.htm • Exemplos Java EE 7 - https://github.com/javaeesamples/javaee7-samples
    • Obrigado!