SlideShare a Scribd company logo
Çağatay ÇİVİCİ
Mert ÇALIŞKAN
July ’13
DEMYSTIFIED
Released on June 12, 2013.
Focuses on HTML 5, higher productivity, more to meet industrial
standards.
Glassfish 4.0 is EE 7 ready.
Java EE 7
Enterprise JAVA
• Java EE = Java Enterprise Edition
• Extends Java SE
javax.faces.* UI + JSF Related Stuff
javax.servlet.* Handling HTTP invocations
javax.enterprise.inject.* CDI, Like Spring depedency Inj.
javax.ejb.* EJB Stuff
javax.validation.* BeanValidation
javax.persistence.* Persistency
javax.transaction.* Stuff for transactions
javax.jms.* Messaging Stuff
CHRONOLOGY OF JAVA EE
Java EE 5
May 11, 2006
Java EE 6
December 10, 2009
J2EE 1.2
December 12, 1999
J2EE 1.3
Sept. 12, 2001
J2EE 1.4
Nov. 11, 2003
Servlet 2.2 Servlet 2.3 Servlet 2.4
JSP
EJB
JMS
JTA
JAAS
JSF
EL
JAX-WS
JAX-RS
JAX-B
JPA
JSTL
any many
more...
Servlet 2.5
Servlet 3.0
Java EE 7 Agenda
Java API for RESTful Web Services 2.0
Java Message Service 2.0
Java API for JSON Processing 1.0
Java API for WebSocket 1.0
CDI 1.1
Batch Applications for the Java Platform 1.0
Java Persistence API 2.1
Servlet 3.1
JavaServer Faces 2.2
Java EE 7
Project Creation
NetBeans, current version 7.3.1, supports Java EE 7.
Can be downloaded with Glassfish 4.0, which also supports
EE 7.
Maven archetypes are @ https:/
/nexus.codehaus.org/
content/repositories/releases/org/codehaus/mojo/archetypes
Archetypes can easily be integrated into NetBeans.
Java EE7 Demystified
Servlets
3.0 recap
Managing state on stateless HTTP protocol by processing
HTML pages back and forth between client and server.
highlights with 3.0:
- ease of development: the annotations like,
@Servlet @ServletFilter and etc.
- partial web.xml with metadata-complete attribute and
web-fragment.xml files under .jar/META-INF
- static resources & jsps inside a jar file to be reused.
Servlets
3.1 highlights
Async Non-Blocking IO
New interface javax.servlet.ReadListener
void onDataAvailable() throws IOException
void onAllDataRead() throws IOException
void onError(Throwable t)
New interface javax.servlet.WriteListener
void onWritePossible() throws IOException
void onError(Throwable t)
Upgrade Mode, Transition to some other, incompatible protocol
like websockets.
API to track down session fixation attacks
HttpServletRequest.changeSessionId
HttpSessionIdListener
Java EE7 Demystified
JSF
2.0 recap
JSF : Java Server Faces. Provided standardization on building
server-side user interfaces.
- Data Conversion & Validation
- Event handling
- Managing state of UI Components
- Page Navigation
- i18n and accessibility and many others...
2.0 provided:
- composite components, single file w/ no JAVA code
- standardized AJAX Lifecycle, <f:ajax>, PartialViewContext...
- implicit navigation based on view-id.
- conditional and preemptive navigation (GET based nav.)
- @ViewScoped, flash scope and custom scopes.
- annotations: @ManagedBean, Component Annotations
@FacesComponent, @FacesRenderer, @FacesConverter
JSF
2.2 highlights - 1
File Upload Component
<h:inputFile> since its JSF component, supports converters &
validators
Faces Flow
@FlowScoped in action.
n-number of flows.
programmatic or xml configuration of flows.
JSF
2.2 highlights - 2
HTML5 Friendly Markup
<!DOCTYPE html>
<html xmlns="http:/
/www.w3.org/1999/xhtml"
xmlns:jsf="http:/
/java.sun.com/jsf"
xmlns:p="http:/
/primefaces.org/ui"
xmlns:f="http:/
/java.sun.com/jsf/core">
<head jsf:id="head">
<title>Putting it all together</title>
<script jsf:target="body" jsf:name="js.js"/>
<link jsf:name="css.css" rel="stylesheet" type="text/css" />
</head>
...
</html>
JSF
2.2 highlights - 3
HTML5 Friendly Markup
<body jsf:id="body">
<form jsf:id="form" jsf:prependId="false">
<p:panelGrid id="panel" columns="2">
<label jsf:for="name">Name</label>
<input jsf:id="name" type="text" jsf:value="#{friendlyMarkupBean.name}" />
<label jsf:for="tel">Phone</label>
<input jsf:id="tel" type="tel" jsf:value="#{friendlyMarkupBean.phone}" />
<label jsf:for="email">Email</label>
<input jsf:id="email" type="email" jsf:value="#{friendlyMarkupBean.email}" />
<label for="progress">Progress</label>
<progress jsf:id="progress" max="3">#{friendlyMarkupBean.progress} of 3</progress>
</p:panelGrid>
</form>
</body>
JSF
2.2 highlights - 4
Resource Library Contracts
better templating than facelets
/contracts in the web application root & META-INF/contracts on
the classpath.
Passthrough attributes
<p:inputText value=”#{bean.value}” pt:placeholder=”Watermark
here” />
Java EE7 Demystified
JMS
Message Oriented Middleware (MOM)
P2P or PubSub Models
Versions
JMS 1.1 (March 2002)
JMS 2.0 (May 2013)
JMS
JMS 1.x
@Resource(lookup = "java:global/jms/ankarajugconnectionfactory")
ConnectionFactory connectionFactory;
@Resource(lookup = "java:global/jms/ankarajugdemoqueue")
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 2
Cleaner APIs
Dependency Injection
Async Send
Delivery delay
JMS Resource
JMS 2.0
@Inject
private JMSContext context;
@Resource(mappedName = "jms/ankarajugqueue")
private Queue inboundQueue;
public void sendMessage (String payload) {
context.createProducer().send(inboundQueue, payload);
}
CDI 1.0
recap
Cool stuff like: Bean Definition and Dependency Injection
CDI brings transactional support to the web tier.
(EJB-JPA <> JSF)
Type Safe,
POJO based,
Interceptors,
Decorators,
Events,
Unified EL Integration
CDI 1.1 highlights
auto CDI activation w/out beans.xml, just annotate the bean with
@*Scoped and it will be picked up.
bean exclusing in beans.xml with
<scan>
<exclude name=”com.primetek.badbeans.* />
</scan>
@Vetoed: Ignored by CDI
Global Enablement of @Interceptor, @Decorator, @Alternative
with prioritization like @Priority(APPLICATION+100)
APPLICATION range: 2000-3000, LIBRARY and SYSTEM ranges
@Initialized qualifier to observe objects like
@Initialized(SessionScoped.class)
http:/
/in.relation.to/Bloggers/CDI11Available
more @
WebSocket
Full-Duplex
TCP Based
Handshake and Transfer
Non-Standard in pre JavaEE7
Java WebSocket API
Endpoints
Programmatic
Annotated
Send/Receive Messages
Path Parameters
Encoder/Decoder
Java WebSocket API
@ServerEndpoint("/echo")
public class EchoEndpoint {
@OnMessage
public void onMessage(Session session, String msg) {
try {
session.getBasicRemote().sendText(msg);
} catch (IOException e) { ... }
}
}
Java API for JSON
JSON Processing
Generate, Parse, Transform, Query
Object Model and Streaming APIs
JSON
{
"firstName": "John",
"lastName": "Smith",
"age": 25,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": 10021
},
"phoneNumbers": [
{
"type": "home",
"number": "212 555-1234"
},
{
"type": "fax",
"number": "646 555-4567"
}
]
}
Java API for JSON
JsonBuilderFactory factory = Json.createBuilderFactory(null);
JsonArray jsonArray = factory.createArrayBuilder()
.add(factory.createObjectBuilder().
add("type", "home").
add("number", "(800) 111-1111"))
.add(factory.createObjectBuilder().
add("type", "cell").
add("number", "(800) 222-2222")).build();
[
{
"type": "home”,
"number": "(800) 111-1111"
},{
"type": "fax”,
"number": "646 555-4567"
}
]
Java EE7 Demystified
JavaPersistence API
Map Objects to Relational Database
Versions
JPA 1.0 - May 2006
JPA 2.0 - Dec 2009
JPA 2.1 - April 2013
JPA 2.1
Standard Schema Generation
Stored Procedures
Unsynchronized Persistence Contexts
Converters
Criteria Update-Delete
JPA 2.1
@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);
. . .
query.execute();
String response = query.getOutputParameterValue(1);
JAX-RS
1.1 recap
JAVA API to provide Web Services on REST Architecture.
v1.1 provided:
- part of EE 6, zero config for usage.
- annotations: @GET, @POST, @Produces, @Consumes and
others.
- Utility Classes:
MediaType,
UriBuilder,
Response.ResponseBuilder
JAX-RS
2.0 highlights
Client Framework, request builder
Async Client API, w/ java.util.concurrent.Future
Server Side Async API
Filters and Entity Interceptors,
filters to modify request/response headers.
interceptors to wrap MessageBodyReader & MessageBodyWriter
Java EE7 Demystified
Batch Apps for Java
Batch Apps for Java
<job id="myJob" xmlns="http:/
/batch.jsr352/jsl">
<step id="myStep" >
<chunk reader="MyItemReader"
writer="MyItemWriter"
processor="MyItemProcessor"
buffer-size="5"
checkpoint-policy="item"
commit-interval="10" />
</step>
</job>
Step Example
<step id=”sendStatements”>
<chunk reader=”accountReader”
processor=”accountProcessor”
writer=”emailWriter”
item-count=”10” />
</step>
@Named(“accountReader")
...implements ItemReader... {
public Account readItem() {
/
/ read account using JPA
@Named(“emailWriter")
...implements ItemWriter... {
public void
writeItems(List<Statements>
statements) {
/
/ use JavaMail to send email
@Named(“accountProcessor")
...implements ItemProcessor... {
Public Statement
processItems(Account account)
{ /
/ read Account, return
Statement
Concurrency Utilities
ManagedExecutorService
Options (pool, threads, timeout)
ManagedScheduledExecutorService
ManagedThreadFactory
Concurrency Utilities
<resource-env-ref>
<resource-env-ref-name>
concurrent/BatchExecutor
</resource-env-ref-name>
<resource-env-ref-type>
javax.enterprise.concurrent.ManagedExecutorService
</resource-env-ref-type>
<resource-env-ref>
@Resource(name="concurrent/BatchExecutor")
ManagedExecutorService executor;
Future<String> future = executor.submit(new
MyRunnableTask(), String.class);
Config
Inject
Execute
JAVA EE 8
Stuff to Read on EE 7
@ankarajug
#javaEE7

More Related Content

What's hot (20)

PDF
JavaFX Uni Parthenope
Emanuela Giannetta
 
PDF
Sun Java EE 6 Overview
sbobde
 
PPT
Java EE Introduction
ejlp12
 
PPTX
JSF 2.2
Edward Burns
 
PDF
Java EE 6 Component Model Explained
Shreedhar Ganapathy
 
PDF
Java EE 6 workshop at Dallas Tech Fest 2011
Arun Gupta
 
PDF
JavaOne 2011: Migrating Spring Applications to Java EE 6
Bert Ertman
 
PPTX
J2ee seminar
Sahil Kukreja
 
PPT
Java EE 7 (Hamed Hatami)
Hamed Hatami
 
PPTX
Move from J2EE to Java EE
Hirofumi Iwasaki
 
PDF
Java EE 6 & GlassFish 3
Arun Gupta
 
PPTX
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
Mert Çalışkan
 
PDF
Overview of Java EE 6 by Roberto Chinnici at SFJUG
Marakana Inc.
 
PDF
Java EE6 CodeCamp16 oct 2010
Codecamp Romania
 
PDF
GlassFish REST Administration Backend
Arun Gupta
 
PDF
GlassFish REST Administration Backend at JavaOne India 2012
Arun Gupta
 
PPTX
Future of Java EE with Java SE 8
Hirofumi Iwasaki
 
PDF
50 New Features of Java EE 7 in 50 minutes
Arun Gupta
 
PPT
Designing JEE Application Structure
odedns
 
PDF
The Java EE 7 Platform: Developing for the Cloud (FISL 12)
Arun Gupta
 
JavaFX Uni Parthenope
Emanuela Giannetta
 
Sun Java EE 6 Overview
sbobde
 
Java EE Introduction
ejlp12
 
JSF 2.2
Edward Burns
 
Java EE 6 Component Model Explained
Shreedhar Ganapathy
 
Java EE 6 workshop at Dallas Tech Fest 2011
Arun Gupta
 
JavaOne 2011: Migrating Spring Applications to Java EE 6
Bert Ertman
 
J2ee seminar
Sahil Kukreja
 
Java EE 7 (Hamed Hatami)
Hamed Hatami
 
Move from J2EE to Java EE
Hirofumi Iwasaki
 
Java EE 6 & GlassFish 3
Arun Gupta
 
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
Mert Çalışkan
 
Overview of Java EE 6 by Roberto Chinnici at SFJUG
Marakana Inc.
 
Java EE6 CodeCamp16 oct 2010
Codecamp Romania
 
GlassFish REST Administration Backend
Arun Gupta
 
GlassFish REST Administration Backend at JavaOne India 2012
Arun Gupta
 
Future of Java EE with Java SE 8
Hirofumi Iwasaki
 
50 New Features of Java EE 7 in 50 minutes
Arun Gupta
 
Designing JEE Application Structure
odedns
 
The Java EE 7 Platform: Developing for the Cloud (FISL 12)
Arun Gupta
 

Similar to Java EE7 Demystified (20)

PDF
Contextual Dependency Injection for Apachecon 2010
Rohit Kelapure
 
PPTX
Java EE 6
Geert Pante
 
PDF
NLOUG 2018 - Future of JSF and ADF
Daniel Merchán García
 
PDF
S313557 java ee_programming_model_explained_dochez
Jerome Dochez
 
PDF
In The Brain of Cagatay Civici: Exploring JavaServer Faces 2.0 and PrimeFaces
Skills Matter
 
PDF
Andrei Niculae - JavaEE6 - 24mai2011
Agora Group
 
KEY
LatJUG. JSF2.0 - The JavaEE6 Standard
denis Udod
 
PPT
Contexts and Dependency Injection for the JavaEE platform
Bozhidar Bozhanov
 
PDF
Spark IT 2011 - Java EE 6 Workshop
Arun Gupta
 
PDF
What’s new in Java SE, EE, ME, Embedded world & new Strategy
Mohamed Taman
 
ODP
OTN Developer Days - Java EE 6
glassfish
 
PDF
Web Technologies in Java EE 7
Lukáš Fryč
 
PDF
2012 04-06-v2-tdp-1163-java e-evsspringshootout-final
Rohit Kelapure
 
PDF
Java EE 8: On the Horizon
Josh Juneau
 
PDF
InterConnect 2016 Java EE 7 Overview (PEJ-5296)
Kevin Sutter
 
PDF
JavaEE & GlassFish UG - Digital JavaEE 7 New & Noteworthy by P.Pilgrim
Payara
 
PDF
Java EE & Glass Fish User Group: Digital JavaEE 7 - New and Noteworthy
Peter Pilgrim
 
PDF
CDI Best Practices with Real-Life Examples - TUT3287
Ahmad Gohar
 
PDF
Burns jsf-confess-2015
Edward Burns
 
PDF
JSF 2.0 Preview
Skills Matter
 
Contextual Dependency Injection for Apachecon 2010
Rohit Kelapure
 
Java EE 6
Geert Pante
 
NLOUG 2018 - Future of JSF and ADF
Daniel Merchán García
 
S313557 java ee_programming_model_explained_dochez
Jerome Dochez
 
In The Brain of Cagatay Civici: Exploring JavaServer Faces 2.0 and PrimeFaces
Skills Matter
 
Andrei Niculae - JavaEE6 - 24mai2011
Agora Group
 
LatJUG. JSF2.0 - The JavaEE6 Standard
denis Udod
 
Contexts and Dependency Injection for the JavaEE platform
Bozhidar Bozhanov
 
Spark IT 2011 - Java EE 6 Workshop
Arun Gupta
 
What’s new in Java SE, EE, ME, Embedded world & new Strategy
Mohamed Taman
 
OTN Developer Days - Java EE 6
glassfish
 
Web Technologies in Java EE 7
Lukáš Fryč
 
2012 04-06-v2-tdp-1163-java e-evsspringshootout-final
Rohit Kelapure
 
Java EE 8: On the Horizon
Josh Juneau
 
InterConnect 2016 Java EE 7 Overview (PEJ-5296)
Kevin Sutter
 
JavaEE & GlassFish UG - Digital JavaEE 7 New & Noteworthy by P.Pilgrim
Payara
 
Java EE & Glass Fish User Group: Digital JavaEE 7 - New and Noteworthy
Peter Pilgrim
 
CDI Best Practices with Real-Life Examples - TUT3287
Ahmad Gohar
 
Burns jsf-confess-2015
Edward Burns
 
JSF 2.0 Preview
Skills Matter
 
Ad

More from Ankara JUG (10)

PDF
Home Automation Using RPI
Ankara JUG
 
PDF
Ankara JUG Şubat 2014 Etkinliği - Design Patterns
Ankara JUG
 
PPTX
Ankara JUG Eylül 2013 Etkinliği - Eclipse RCP 4
Ankara JUG
 
PDF
AnkaraJUG Haziran 2013 - No SQL / Big Data
Ankara JUG
 
PDF
Ankara jug mayıs 2013 sunumu
Ankara JUG
 
PPTX
AnkaraJUG Nisan 2013 - Java Persistance API
Ankara JUG
 
PDF
HTML5 - Daha Flash bir web?
Ankara JUG
 
PDF
AnkaraJUG Aralık 2012 - Agile, Adaptasyon ve Dönüşüm
Ankara JUG
 
PDF
AnkaraJUG Kasım 2012 - PrimeFaces
Ankara JUG
 
KEY
Ankara jug 201211
Ankara JUG
 
Home Automation Using RPI
Ankara JUG
 
Ankara JUG Şubat 2014 Etkinliği - Design Patterns
Ankara JUG
 
Ankara JUG Eylül 2013 Etkinliği - Eclipse RCP 4
Ankara JUG
 
AnkaraJUG Haziran 2013 - No SQL / Big Data
Ankara JUG
 
Ankara jug mayıs 2013 sunumu
Ankara JUG
 
AnkaraJUG Nisan 2013 - Java Persistance API
Ankara JUG
 
HTML5 - Daha Flash bir web?
Ankara JUG
 
AnkaraJUG Aralık 2012 - Agile, Adaptasyon ve Dönüşüm
Ankara JUG
 
AnkaraJUG Kasım 2012 - PrimeFaces
Ankara JUG
 
Ankara jug 201211
Ankara JUG
 
Ad

Recently uploaded (20)

PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
July Patch Tuesday
Ivanti
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
July Patch Tuesday
Ivanti
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 

Java EE7 Demystified

  • 2. Released on June 12, 2013. Focuses on HTML 5, higher productivity, more to meet industrial standards. Glassfish 4.0 is EE 7 ready. Java EE 7
  • 3. Enterprise JAVA • Java EE = Java Enterprise Edition • Extends Java SE javax.faces.* UI + JSF Related Stuff javax.servlet.* Handling HTTP invocations javax.enterprise.inject.* CDI, Like Spring depedency Inj. javax.ejb.* EJB Stuff javax.validation.* BeanValidation javax.persistence.* Persistency javax.transaction.* Stuff for transactions javax.jms.* Messaging Stuff
  • 4. CHRONOLOGY OF JAVA EE Java EE 5 May 11, 2006 Java EE 6 December 10, 2009 J2EE 1.2 December 12, 1999 J2EE 1.3 Sept. 12, 2001 J2EE 1.4 Nov. 11, 2003 Servlet 2.2 Servlet 2.3 Servlet 2.4 JSP EJB JMS JTA JAAS JSF EL JAX-WS JAX-RS JAX-B JPA JSTL any many more... Servlet 2.5 Servlet 3.0
  • 5. Java EE 7 Agenda Java API for RESTful Web Services 2.0 Java Message Service 2.0 Java API for JSON Processing 1.0 Java API for WebSocket 1.0 CDI 1.1 Batch Applications for the Java Platform 1.0 Java Persistence API 2.1 Servlet 3.1 JavaServer Faces 2.2
  • 6. Java EE 7 Project Creation NetBeans, current version 7.3.1, supports Java EE 7. Can be downloaded with Glassfish 4.0, which also supports EE 7. Maven archetypes are @ https:/ /nexus.codehaus.org/ content/repositories/releases/org/codehaus/mojo/archetypes Archetypes can easily be integrated into NetBeans.
  • 8. Servlets 3.0 recap Managing state on stateless HTTP protocol by processing HTML pages back and forth between client and server. highlights with 3.0: - ease of development: the annotations like, @Servlet @ServletFilter and etc. - partial web.xml with metadata-complete attribute and web-fragment.xml files under .jar/META-INF - static resources & jsps inside a jar file to be reused.
  • 9. Servlets 3.1 highlights Async Non-Blocking IO New interface javax.servlet.ReadListener void onDataAvailable() throws IOException void onAllDataRead() throws IOException void onError(Throwable t) New interface javax.servlet.WriteListener void onWritePossible() throws IOException void onError(Throwable t) Upgrade Mode, Transition to some other, incompatible protocol like websockets. API to track down session fixation attacks HttpServletRequest.changeSessionId HttpSessionIdListener
  • 11. JSF 2.0 recap JSF : Java Server Faces. Provided standardization on building server-side user interfaces. - Data Conversion & Validation - Event handling - Managing state of UI Components - Page Navigation - i18n and accessibility and many others... 2.0 provided: - composite components, single file w/ no JAVA code - standardized AJAX Lifecycle, <f:ajax>, PartialViewContext... - implicit navigation based on view-id. - conditional and preemptive navigation (GET based nav.) - @ViewScoped, flash scope and custom scopes. - annotations: @ManagedBean, Component Annotations @FacesComponent, @FacesRenderer, @FacesConverter
  • 12. JSF 2.2 highlights - 1 File Upload Component <h:inputFile> since its JSF component, supports converters & validators Faces Flow @FlowScoped in action. n-number of flows. programmatic or xml configuration of flows.
  • 13. JSF 2.2 highlights - 2 HTML5 Friendly Markup <!DOCTYPE html> <html xmlns="http:/ /www.w3.org/1999/xhtml" xmlns:jsf="http:/ /java.sun.com/jsf" xmlns:p="http:/ /primefaces.org/ui" xmlns:f="http:/ /java.sun.com/jsf/core"> <head jsf:id="head"> <title>Putting it all together</title> <script jsf:target="body" jsf:name="js.js"/> <link jsf:name="css.css" rel="stylesheet" type="text/css" /> </head> ... </html>
  • 14. JSF 2.2 highlights - 3 HTML5 Friendly Markup <body jsf:id="body"> <form jsf:id="form" jsf:prependId="false"> <p:panelGrid id="panel" columns="2"> <label jsf:for="name">Name</label> <input jsf:id="name" type="text" jsf:value="#{friendlyMarkupBean.name}" /> <label jsf:for="tel">Phone</label> <input jsf:id="tel" type="tel" jsf:value="#{friendlyMarkupBean.phone}" /> <label jsf:for="email">Email</label> <input jsf:id="email" type="email" jsf:value="#{friendlyMarkupBean.email}" /> <label for="progress">Progress</label> <progress jsf:id="progress" max="3">#{friendlyMarkupBean.progress} of 3</progress> </p:panelGrid> </form> </body>
  • 15. JSF 2.2 highlights - 4 Resource Library Contracts better templating than facelets /contracts in the web application root & META-INF/contracts on the classpath. Passthrough attributes <p:inputText value=”#{bean.value}” pt:placeholder=”Watermark here” />
  • 17. JMS Message Oriented Middleware (MOM) P2P or PubSub Models Versions JMS 1.1 (March 2002) JMS 2.0 (May 2013)
  • 18. JMS
  • 19. JMS 1.x @Resource(lookup = "java:global/jms/ankarajugconnectionfactory") ConnectionFactory connectionFactory; @Resource(lookup = "java:global/jms/ankarajugdemoqueue") 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); } }
  • 20. JMS 2 Cleaner APIs Dependency Injection Async Send Delivery delay JMS Resource
  • 21. JMS 2.0 @Inject private JMSContext context; @Resource(mappedName = "jms/ankarajugqueue") private Queue inboundQueue; public void sendMessage (String payload) { context.createProducer().send(inboundQueue, payload); }
  • 22. CDI 1.0 recap Cool stuff like: Bean Definition and Dependency Injection CDI brings transactional support to the web tier. (EJB-JPA <> JSF) Type Safe, POJO based, Interceptors, Decorators, Events, Unified EL Integration
  • 23. CDI 1.1 highlights auto CDI activation w/out beans.xml, just annotate the bean with @*Scoped and it will be picked up. bean exclusing in beans.xml with <scan> <exclude name=”com.primetek.badbeans.* /> </scan> @Vetoed: Ignored by CDI Global Enablement of @Interceptor, @Decorator, @Alternative with prioritization like @Priority(APPLICATION+100) APPLICATION range: 2000-3000, LIBRARY and SYSTEM ranges @Initialized qualifier to observe objects like @Initialized(SessionScoped.class) http:/ /in.relation.to/Bloggers/CDI11Available more @
  • 24. WebSocket Full-Duplex TCP Based Handshake and Transfer Non-Standard in pre JavaEE7
  • 25. Java WebSocket API Endpoints Programmatic Annotated Send/Receive Messages Path Parameters Encoder/Decoder
  • 26. Java WebSocket API @ServerEndpoint("/echo") public class EchoEndpoint { @OnMessage public void onMessage(Session session, String msg) { try { session.getBasicRemote().sendText(msg); } catch (IOException e) { ... } } }
  • 27. Java API for JSON JSON Processing Generate, Parse, Transform, Query Object Model and Streaming APIs
  • 28. JSON { "firstName": "John", "lastName": "Smith", "age": 25, "address": { "streetAddress": "21 2nd Street", "city": "New York", "state": "NY", "postalCode": 10021 }, "phoneNumbers": [ { "type": "home", "number": "212 555-1234" }, { "type": "fax", "number": "646 555-4567" } ] }
  • 29. Java API for JSON JsonBuilderFactory factory = Json.createBuilderFactory(null); JsonArray jsonArray = factory.createArrayBuilder() .add(factory.createObjectBuilder(). add("type", "home"). add("number", "(800) 111-1111")) .add(factory.createObjectBuilder(). add("type", "cell"). add("number", "(800) 222-2222")).build(); [ { "type": "home”, "number": "(800) 111-1111" },{ "type": "fax”, "number": "646 555-4567" } ]
  • 31. JavaPersistence API Map Objects to Relational Database Versions JPA 1.0 - May 2006 JPA 2.0 - Dec 2009 JPA 2.1 - April 2013
  • 32. JPA 2.1 Standard Schema Generation Stored Procedures Unsynchronized Persistence Contexts Converters Criteria Update-Delete
  • 33. JPA 2.1 @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); . . . query.execute(); String response = query.getOutputParameterValue(1);
  • 34. JAX-RS 1.1 recap JAVA API to provide Web Services on REST Architecture. v1.1 provided: - part of EE 6, zero config for usage. - annotations: @GET, @POST, @Produces, @Consumes and others. - Utility Classes: MediaType, UriBuilder, Response.ResponseBuilder
  • 35. JAX-RS 2.0 highlights Client Framework, request builder Async Client API, w/ java.util.concurrent.Future Server Side Async API Filters and Entity Interceptors, filters to modify request/response headers. interceptors to wrap MessageBodyReader & MessageBodyWriter
  • 38. Batch Apps for Java <job id="myJob" xmlns="http:/ /batch.jsr352/jsl"> <step id="myStep" > <chunk reader="MyItemReader" writer="MyItemWriter" processor="MyItemProcessor" buffer-size="5" checkpoint-policy="item" commit-interval="10" /> </step> </job>
  • 39. Step Example <step id=”sendStatements”> <chunk reader=”accountReader” processor=”accountProcessor” writer=”emailWriter” item-count=”10” /> </step> @Named(“accountReader") ...implements ItemReader... { public Account readItem() { / / read account using JPA @Named(“emailWriter") ...implements ItemWriter... { public void writeItems(List<Statements> statements) { / / use JavaMail to send email @Named(“accountProcessor") ...implements ItemProcessor... { Public Statement processItems(Account account) { / / read Account, return Statement
  • 40. Concurrency Utilities ManagedExecutorService Options (pool, threads, timeout) ManagedScheduledExecutorService ManagedThreadFactory
  • 43. Stuff to Read on EE 7