SlideShare a Scribd company logo
Java EE 7, what’s in it
for me
Alex Soto - @alexsotob
Alex Soto!
@alexsotob - asotobu@gmail.com
Member of
Scytl Architect Software Engineer
lordofthejars.com
Apache Tomcat!
Apache TomEE
Questions?
Ask them right away!
New Specifications
• Websockets
• Batch Applications
• Concurrency Utilities
• JSON Processing
Improvements
• Simplified JMS API
• Default Resources
• JAX-RS Client API
• EJB’s External Transactions
• CDI Annotations
• Entity Graphs
Java EE 7 JSRs
Websockets
• Supports Client and Server
• Declarative and Programmatic
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);}!
}
Websockets Chat Client
@ClientEndpoint!
public class ChatClientEndpoint {!
public static String TEXT = "Client1 joins";!
public static CountDownLatch latch;!
public static String response;!
!
@OnOpen!
public void onOpen(Session session) {!
session.getBasicRemote().sendText(TEXT);!
}!
!
@OnMessage!
public void processMessage(String message) {!
response = message;!
latch.countDown();!
}!
}
CDI
• Finer Scanning Control
• More Annotations
CDI
<beans!
xmlns="http://xmlns.jcp.org/xml/ns/javaee"!
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"!
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee !
http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"!
bean-discovery-mode="all">!
</beans>
CDI
@Vetoed,@Transactional, @TransactionScoped
@RequestScoped!
public class MyTransactionalTxTypeBean {!
@Transactional(Transactional.TxType.REQUIRED)!
public void required() {!
System.out.println(getClass().getName() + "Transactional.TxType.REQUIRED");!
}!
}
Bean Validation
• Design By Contract
• CDI integration
Bean Validation
@Future!
public Date showDate(boolean correct) {!
Calendar cal = Calendar.getInstance();!
cal.add(Calendar.DAY_OF_MONTH, correct ? 5 : -5);!
return cal.getTime();!
}!
!
public String showList(@NotNull @Size(min = 1, max = 3) List<String> list, @NotNull String prefix) {!
StringBuilder builder = new StringBuilder();!
!
for (String s : list) {!
builder.append(prefix).append(s).append(" ");!
}!
!
return builder.toString();!
}
Batch Applications
• For long, non-interactive processes
• Either sequential or parallel (partitions)
• Task or Chunk oriented processing
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
• Asynchronous capabilities to the Java EE world
• Java SE Concurrency API extension (Executor
Service, Scheduled Executor, ThreadFactory)
• Safe and propagates context
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
• Read, generate and transform JSON
• Streaming API and 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
• New interface JMSContext
• Modern API with Dependency Injection
• Resources AutoCloseable
• Simplified how to send messages
• Programmatic definition
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);!
}
JMS
String body=null;!
try (JMSContext context = connectionFactory.createContext();){!
JMSConsumer consumer = session.createConsumer(queue);!
body = consumer.receiveBody(String.class);!
} catch (JMSRuntimeException ex) {!
// handle exception (details omitted)!
}!
return body;
JMS
!
@JMSDestinationDefinition(!
name = Resources.REQUEST_QUEUE,!
resourceAdapter = "jmsra",!
interfaceName = "javax.jms.Queue",!
destinationName = "requestQueue",!
description = "Queue for service requests")!
public class Resources {!
public static final String REQUEST_QUEUE = "java:global/jms/
requestQueue";!
}
JAX-RS
• New API to consume REST services
• Asynchronous processing (client and server)
• Filters and Interceptors
JAX-RS
String movie = ClientBuilder.newClient()!
.target("http://www.movies.com/movie")!
.request(MediaType.TEXT_PLAIN)!
.get(String.class);
JAX-RS
@GET!
public void getList(@Suspended final AsyncResponse ar) throws NamingException {!
ar.setTimeoutHandler(new TimeoutHandler() );!
!
ar.register(new MyCompletionCallback());!
ar.register(new MyConnectionCallback());!
!
Executors.newSingleThreadExecutor(threadFactory).submit(new Runnable() {!
!
@Override!
public void run() {!
Thread.sleep(3000);!
ar.resume(response[0]);!
}!
});!
}!
JAX-RS
Future<Response> r1 = ClientBuilder.newClient()!
.target("http://www.movies.com/movie")!
! ! ! ! ! ! ! ! .request().async().get();
JAX-RS
• ClientRequestFilter
• ClientResponseFilter
• ContainerRequestFilter
• ContainerResponseFilter
• ReaderInterceptor (Entity Interceptor)
• WriterInterceptor (Entity Interceptor)
JPA
• Schema generation
• Stored Procedures
• Entity Graphs
• Unsynchronized Persistence Context
JPA
<persistence-unit name="myPU" transaction-type="JTA">!
<properties>!
<property name="javax.persistence.schema-generation.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-script-source" value="META-INF/
create.sql"/>!
<property name="javax.persistence.schema-generation.drop-script-source" 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);
JPA@Entity!
@NamedQueries({!
@NamedQuery(name = "Movie.findAll", query = "SELECT m FROM Movie m")!
})!
@NamedEntityGraphs({!
@NamedEntityGraph(!
name = "movieWithActors",!
attributeNodes = {!
@NamedAttributeNode("movieActors")!
}!
)!
public class Movie implements Serializable {!
!
@OneToMany!
@JoinColumn(name = "ID")!
private Set<MovieActor> movieActors;!
}
JPA
public List<Movie> listMovies(String hint, String graphName) {!
return entityManager.createNamedQuery("Movie.findAll")!
.setHint("javax.persistence.fetchgraph", entityManager.getEntityGraph(graphName))!
.getResultList();!
}
JSF
• HTML 5 support
• @FlowScoped and @ViewScoped
• File Upload component
• Flow Navigation by Convention
• Resource Library Contracts
Others
• Servlet: Non-blocking I/O, Security
• Default JMS Queue/Topic, DataSource, Concurrent
pool
• Mail Session definition: @MailSessionDefinition
• Interceptors: @Priority, @AroundConstruct
• EJB: Passivation opcional, EJB-Lite with
@Asynchronous and @Schedule
• EL: Lambdas, isolated API
Certified Servers
• Glassfish 4.0
• Wildfly 8.0.0
• TMAX JEUS 8
• Websphere Liberty Profile 9
• TomEE 7 on progress
Java EE 8
• Alignment with Java 8
• JCache
• JSON-B
• MVC
• HTTP 2.0 Support
• Cloud Support
• Security
How to get involved
• Join an expert group
• https://javaee-spec.java.net
• Adopt a JSR
• https://glassfish.java.net/adoptajsr/
Materials
• Tutorial Java EE 7 - http://docs.oracle.com/javaee/7/
tutorial/doc/home.htm
• Samples Java EE 7 - https://github.com/javaee-
samples/javaee7-samples
• Batch Sample - WoW Auctions - https://github.com/
radcortez/wow-auctions
• WebSocket Sample - Chat Server - https://
github.com/radcortez/cbrjug-websockets-chat
Thank you!

More Related Content

What's hot

Java EE Servlet/JSP Tutorial- Cookbook 2
Java EE Servlet/JSP Tutorial- Cookbook 2Java EE Servlet/JSP Tutorial- Cookbook 2
Java EE Servlet/JSP Tutorial- Cookbook 2
billdigman
 
Core web application development
Core web application developmentCore web application development
Core web application development
Bahaa Farouk
 
Gaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Gaelyk - SpringOne2GX - 2010 - Guillaume LaforgeGaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Gaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Guillaume Laforge
 
Profiling JavaScript Performance
Profiling JavaScript PerformanceProfiling JavaScript Performance
Profiling JavaScript Performance
FITC
 
Akka Http , Routes, Streams with Scala
Akka Http , Routes, Streams with ScalaAkka Http , Routes, Streams with Scala
Akka Http , Routes, Streams with Scala
Jerry Kuru
 

What's hot (20)

Introduction to Play Framework
Introduction to Play FrameworkIntroduction to Play Framework
Introduction to Play Framework
 
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...
 
Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017
 
Web container and Apache Tomcat
Web container and Apache TomcatWeb container and Apache Tomcat
Web container and Apache Tomcat
 
Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)
 
Ansible v2 and Beyond (Ansible Hawai'i Meetup)
Ansible v2 and Beyond (Ansible Hawai'i Meetup)Ansible v2 and Beyond (Ansible Hawai'i Meetup)
Ansible v2 and Beyond (Ansible Hawai'i Meetup)
 
Play framework productivity formula
Play framework   productivity formula Play framework   productivity formula
Play framework productivity formula
 
Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules upload
 
Java EE Servlet/JSP Tutorial- Cookbook 2
Java EE Servlet/JSP Tutorial- Cookbook 2Java EE Servlet/JSP Tutorial- Cookbook 2
Java EE Servlet/JSP Tutorial- Cookbook 2
 
Node.js Development with Apache NetBeans
Node.js Development with Apache NetBeansNode.js Development with Apache NetBeans
Node.js Development with Apache NetBeans
 
Php push notifications
Php push notificationsPhp push notifications
Php push notifications
 
Java servlet technology
Java servlet technologyJava servlet technology
Java servlet technology
 
Event Driven Architecture with Apache Camel
Event Driven Architecture with Apache CamelEvent Driven Architecture with Apache Camel
Event Driven Architecture with Apache Camel
 
Core web application development
Core web application developmentCore web application development
Core web application development
 
Gaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Gaelyk - SpringOne2GX - 2010 - Guillaume LaforgeGaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Gaelyk - SpringOne2GX - 2010 - Guillaume Laforge
 
Tools Coverage for the Java EE Platform @ Silicon Valley Code Camp 2010
Tools Coverage for the Java EE Platform @ Silicon Valley Code Camp 2010Tools Coverage for the Java EE Platform @ Silicon Valley Code Camp 2010
Tools Coverage for the Java EE Platform @ Silicon Valley Code Camp 2010
 
Developing, Testing and Scaling with Apache Camel - UberConf 2015
Developing, Testing and Scaling with Apache Camel - UberConf 2015Developing, Testing and Scaling with Apache Camel - UberConf 2015
Developing, Testing and Scaling with Apache Camel - UberConf 2015
 
Profiling JavaScript Performance
Profiling JavaScript PerformanceProfiling JavaScript Performance
Profiling JavaScript Performance
 
Apache Camel Introduction & What's in the box
Apache Camel Introduction & What's in the boxApache Camel Introduction & What's in the box
Apache Camel Introduction & What's in the box
 
Akka Http , Routes, Streams with Scala
Akka Http , Routes, Streams with ScalaAkka Http , Routes, Streams with Scala
Akka Http , Routes, Streams with Scala
 

Similar to Java EE 7, what's in it for me?

JUDCON India 2014 Java EE 7 talk
JUDCON India 2014 Java EE 7 talkJUDCON India 2014 Java EE 7 talk
JUDCON India 2014 Java EE 7 talk
Vijay Nair
 
Ajax tutorial
Ajax tutorialAjax tutorial
Ajax tutorial
Kat Roque
 
Enterprise Java Web Application Frameworks Sample Stack Implementation
Enterprise Java Web Application Frameworks   Sample Stack ImplementationEnterprise Java Web Application Frameworks   Sample Stack Implementation
Enterprise Java Web Application Frameworks Sample Stack Implementation
Mert Çalışkan
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)
Ran Mizrahi
 
Java EE 7 (Hamed Hatami)
Java EE 7 (Hamed Hatami)Java EE 7 (Hamed Hatami)
Java EE 7 (Hamed Hatami)
Hamed Hatami
 

Similar to Java EE 7, what's in it for me? (20)

JUDCON India 2014 Java EE 7 talk
JUDCON India 2014 Java EE 7 talkJUDCON India 2014 Java EE 7 talk
JUDCON India 2014 Java EE 7 talk
 
What’s new in Java SE, EE, ME, Embedded world & new Strategy
What’s new in Java SE, EE, ME, Embedded world & new StrategyWhat’s new in Java SE, EE, ME, Embedded world & new Strategy
What’s new in Java SE, EE, ME, Embedded world & new Strategy
 
Java EE 8
Java EE 8Java EE 8
Java EE 8
 
Ajax tutorial
Ajax tutorialAjax tutorial
Ajax tutorial
 
50 features of Java EE 7 in 50 minutes at Geecon 2014
50 features of Java EE 7 in 50 minutes at Geecon 201450 features of Java EE 7 in 50 minutes at Geecon 2014
50 features of Java EE 7 in 50 minutes at Geecon 2014
 
Spring 3 - An Introduction
Spring 3 - An IntroductionSpring 3 - An Introduction
Spring 3 - An Introduction
 
4 JVM Web Frameworks
4 JVM Web Frameworks4 JVM Web Frameworks
4 JVM Web Frameworks
 
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
 
Enterprise Java Web Application Frameworks Sample Stack Implementation
Enterprise Java Web Application Frameworks   Sample Stack ImplementationEnterprise Java Web Application Frameworks   Sample Stack Implementation
Enterprise Java Web Application Frameworks Sample Stack Implementation
 
The First Contact with Java EE 7
The First Contact with Java EE 7The First Contact with Java EE 7
The First Contact with Java EE 7
 
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
 
Java ee 7 New Features
Java ee 7   New FeaturesJava ee 7   New Features
Java ee 7 New Features
 
JS everywhere 2011
JS everywhere 2011JS everywhere 2011
JS everywhere 2011
 
Avatar 2.0
Avatar 2.0Avatar 2.0
Avatar 2.0
 
50 New Features of Java EE 7 in 50 minutes
50 New Features of Java EE 7 in 50 minutes50 New Features of Java EE 7 in 50 minutes
50 New Features of Java EE 7 in 50 minutes
 
Java EE 7 (Hamed Hatami)
Java EE 7 (Hamed Hatami)Java EE 7 (Hamed Hatami)
Java EE 7 (Hamed Hatami)
 
Experiences on a Design Approach for Interactive Web Applications
Experiences on a Design Approach for Interactive Web ApplicationsExperiences on a Design Approach for Interactive Web Applications
Experiences on a Design Approach for Interactive Web Applications
 
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
 

More from Alex Soto

More from Alex Soto (20)

Kubernetes Native Java
Kubernetes Native JavaKubernetes Native Java
Kubernetes Native Java
 
Reactive Programming for Real Use Cases
Reactive Programming for Real Use CasesReactive Programming for Real Use Cases
Reactive Programming for Real Use Cases
 
Chaos Engineering Kubernetes
Chaos Engineering KubernetesChaos Engineering Kubernetes
Chaos Engineering Kubernetes
 
Chaos Engineering Kubernetes
Chaos Engineering KubernetesChaos Engineering Kubernetes
Chaos Engineering Kubernetes
 
Microservices testing and automation
Microservices testing and automationMicroservices testing and automation
Microservices testing and automation
 
Testing in Production: From DevTestOops to DevTestOps
Testing in Production: From DevTestOops to DevTestOpsTesting in Production: From DevTestOops to DevTestOps
Testing in Production: From DevTestOops to DevTestOps
 
Supersonic Subatomic Java
Supersonic Subatomic JavaSupersonic Subatomic Java
Supersonic Subatomic Java
 
From DevTestOops to DevTestOps
From DevTestOops to DevTestOpsFrom DevTestOops to DevTestOps
From DevTestOops to DevTestOps
 
Istio service mesh & pragmatic microservices architecture
Istio service mesh & pragmatic microservices architectureIstio service mesh & pragmatic microservices architecture
Istio service mesh & pragmatic microservices architecture
 
Zero Downtime Deployment in Microservices era
Zero Downtime Deployment in Microservices eraZero Downtime Deployment in Microservices era
Zero Downtime Deployment in Microservices era
 
Service Mesh Patterns
Service Mesh PatternsService Mesh Patterns
Service Mesh Patterns
 
Supersonic, Subatomic Java
Supersonic, Subatomic JavaSupersonic, Subatomic Java
Supersonic, Subatomic Java
 
Zero Downtime Deployment in Microservices era
Zero Downtime Deployment in Microservices eraZero Downtime Deployment in Microservices era
Zero Downtime Deployment in Microservices era
 
Long Live and Prosper To Monolith
Long Live and Prosper To MonolithLong Live and Prosper To Monolith
Long Live and Prosper To Monolith
 
Sail in the cloud - An intro to Istio commit
Sail in the cloud - An intro to Istio commitSail in the cloud - An intro to Istio commit
Sail in the cloud - An intro to Istio commit
 
KubeBoot - Spring Boot deployment on Kubernetes
KubeBoot - Spring Boot deployment on KubernetesKubeBoot - Spring Boot deployment on Kubernetes
KubeBoot - Spring Boot deployment on Kubernetes
 
Sail in the Cloud - An intro to Istio
Sail in the Cloud  - An intro to IstioSail in the Cloud  - An intro to Istio
Sail in the Cloud - An intro to Istio
 
Testing XXIst Century
Testing XXIst CenturyTesting XXIst Century
Testing XXIst Century
 
Arquillian Constellation
Arquillian ConstellationArquillian Constellation
Arquillian Constellation
 
Testing for Unicorns
Testing for UnicornsTesting for Unicorns
Testing for Unicorns
 

Recently uploaded

Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Peter Udo Diehl
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 

Recently uploaded (20)

ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Introduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG EvaluationIntroduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG Evaluation
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 

Java EE 7, what's in it for me?

  • 1. Java EE 7, what’s in it for me Alex Soto - @alexsotob
  • 2. Alex Soto! @alexsotob - asotobu@gmail.com Member of Scytl Architect Software Engineer lordofthejars.com Apache Tomcat! Apache TomEE
  • 4.
  • 5. New Specifications • Websockets • Batch Applications • Concurrency Utilities • JSON Processing
  • 6. Improvements • Simplified JMS API • Default Resources • JAX-RS Client API • EJB’s External Transactions • CDI Annotations • Entity Graphs
  • 7. Java EE 7 JSRs
  • 8. Websockets • Supports Client and Server • Declarative and Programmatic
  • 9. 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);}! }
  • 10. Websockets Chat Client @ClientEndpoint! public class ChatClientEndpoint {! public static String TEXT = "Client1 joins";! public static CountDownLatch latch;! public static String response;! ! @OnOpen! public void onOpen(Session session) {! session.getBasicRemote().sendText(TEXT);! }! ! @OnMessage! public void processMessage(String message) {! response = message;! latch.countDown();! }! }
  • 11. CDI • Finer Scanning Control • More Annotations
  • 13. CDI @Vetoed,@Transactional, @TransactionScoped @RequestScoped! public class MyTransactionalTxTypeBean {! @Transactional(Transactional.TxType.REQUIRED)! public void required() {! System.out.println(getClass().getName() + "Transactional.TxType.REQUIRED");! }! }
  • 14. Bean Validation • Design By Contract • CDI integration
  • 15. Bean Validation @Future! public Date showDate(boolean correct) {! Calendar cal = Calendar.getInstance();! cal.add(Calendar.DAY_OF_MONTH, correct ? 5 : -5);! return cal.getTime();! }! ! public String showList(@NotNull @Size(min = 1, max = 3) List<String> list, @NotNull String prefix) {! StringBuilder builder = new StringBuilder();! ! for (String s : list) {! builder.append(prefix).append(s).append(" ");! }! ! return builder.toString();! }
  • 16. Batch Applications • For long, non-interactive processes • Either sequential or parallel (partitions) • Task or Chunk oriented processing
  • 18. 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>
  • 19. Concurrency Utilities • Asynchronous capabilities to the Java EE world • Java SE Concurrency API extension (Executor Service, Scheduled Executor, ThreadFactory) • Safe and propagates context
  • 20. 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! }! }! }
  • 21. JSON Processing • Read, generate and transform JSON • Streaming API and Object Model API
  • 22. 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”} ]
  • 23. JMS • New interface JMSContext • Modern API with Dependency Injection • Resources AutoCloseable • Simplified how to send messages • Programmatic definition
  • 24. 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);! }! }
  • 25. 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);! }
  • 26. JMS String body=null;! try (JMSContext context = connectionFactory.createContext();){! JMSConsumer consumer = session.createConsumer(queue);! body = consumer.receiveBody(String.class);! } catch (JMSRuntimeException ex) {! // handle exception (details omitted)! }! return body;
  • 27. JMS ! @JMSDestinationDefinition(! name = Resources.REQUEST_QUEUE,! resourceAdapter = "jmsra",! interfaceName = "javax.jms.Queue",! destinationName = "requestQueue",! description = "Queue for service requests")! public class Resources {! public static final String REQUEST_QUEUE = "java:global/jms/ requestQueue";! }
  • 28. JAX-RS • New API to consume REST services • Asynchronous processing (client and server) • Filters and Interceptors
  • 29. JAX-RS String movie = ClientBuilder.newClient()! .target("http://www.movies.com/movie")! .request(MediaType.TEXT_PLAIN)! .get(String.class);
  • 30. JAX-RS @GET! public void getList(@Suspended final AsyncResponse ar) throws NamingException {! ar.setTimeoutHandler(new TimeoutHandler() );! ! ar.register(new MyCompletionCallback());! ar.register(new MyConnectionCallback());! ! Executors.newSingleThreadExecutor(threadFactory).submit(new Runnable() {! ! @Override! public void run() {! Thread.sleep(3000);! ar.resume(response[0]);! }! });! }!
  • 31. JAX-RS Future<Response> r1 = ClientBuilder.newClient()! .target("http://www.movies.com/movie")! ! ! ! ! ! ! ! ! .request().async().get();
  • 32. JAX-RS • ClientRequestFilter • ClientResponseFilter • ContainerRequestFilter • ContainerResponseFilter • ReaderInterceptor (Entity Interceptor) • WriterInterceptor (Entity Interceptor)
  • 33. JPA • Schema generation • Stored Procedures • Entity Graphs • Unsynchronized Persistence Context
  • 34. JPA <persistence-unit name="myPU" transaction-type="JTA">! <properties>! <property name="javax.persistence.schema-generation.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-script-source" value="META-INF/ create.sql"/>! <property name="javax.persistence.schema-generation.drop-script-source" value="META-INF/ drop.sql"/>! <property name="javax.persistence.sql-load-script-source" value="META-INF/load.sql"/>! </properties>! </persistence-unit>
  • 35. 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);
  • 36. JPA@Entity! @NamedQueries({! @NamedQuery(name = "Movie.findAll", query = "SELECT m FROM Movie m")! })! @NamedEntityGraphs({! @NamedEntityGraph(! name = "movieWithActors",! attributeNodes = {! @NamedAttributeNode("movieActors")! }! )! public class Movie implements Serializable {! ! @OneToMany! @JoinColumn(name = "ID")! private Set<MovieActor> movieActors;! }
  • 37. JPA public List<Movie> listMovies(String hint, String graphName) {! return entityManager.createNamedQuery("Movie.findAll")! .setHint("javax.persistence.fetchgraph", entityManager.getEntityGraph(graphName))! .getResultList();! }
  • 38. JSF • HTML 5 support • @FlowScoped and @ViewScoped • File Upload component • Flow Navigation by Convention • Resource Library Contracts
  • 39. Others • Servlet: Non-blocking I/O, Security • Default JMS Queue/Topic, DataSource, Concurrent pool • Mail Session definition: @MailSessionDefinition • Interceptors: @Priority, @AroundConstruct • EJB: Passivation opcional, EJB-Lite with @Asynchronous and @Schedule • EL: Lambdas, isolated API
  • 40. Certified Servers • Glassfish 4.0 • Wildfly 8.0.0 • TMAX JEUS 8 • Websphere Liberty Profile 9 • TomEE 7 on progress
  • 41. Java EE 8 • Alignment with Java 8 • JCache • JSON-B • MVC • HTTP 2.0 Support • Cloud Support • Security
  • 42. How to get involved • Join an expert group • https://javaee-spec.java.net • Adopt a JSR • https://glassfish.java.net/adoptajsr/
  • 43. Materials • Tutorial Java EE 7 - http://docs.oracle.com/javaee/7/ tutorial/doc/home.htm • Samples Java EE 7 - https://github.com/javaee- samples/javaee7-samples • Batch Sample - WoW Auctions - https://github.com/ radcortez/wow-auctions • WebSocket Sample - Chat Server - https:// github.com/radcortez/cbrjug-websockets-chat