SlideShare a Scribd company logo
Digital Java EE 7 with JSF
Conversations, Flows, and
CDI Scopes
Peter Pilgrim
JavaOne - CON5211
29th October 2015
Digital Java EE 7
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 2
About me
▪ Java Champion
▪ Java programming since 1998
▪ Independent contractor, LTD UK
▪ Java EE developer, designer and book author
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 3
Agenda
▪ Java EE 7 modern architecture
▪ CDI Scopes
▪ Conversation scoped beans
▪ Faces-Flows and flow scoped beans
▪ Bootstrap your enterprise
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 4
"Nobody is madder than me
about the fact that the
website isn't working”
President Obama
Rose Garden Speech, 21th October 2013
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 5
Demonstration
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 6
Digital Java EE application
Digital Java EE 7 Platform
▪ Java EE 7 is standard architecture for
building enterprise Java solutions
▪ Transactions, persistence, management
▪ Dynamic content: Servlets, JSP, JSF and
MVC
▪ Remote endpoints EJB, JAX-RS, JMS
WebSocket and JCA
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 7
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 8
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 9
EJB Container
Poolable managed remote end points with transactions and
concurrency , which are application wide
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 10
EJB Beans
@Stateless
class ProductQueryService { ... }
@Stateful
class ShoppingCartDao { ... }
@MessageDriven
class OrderProcessor implements
MessageListener { ... }
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 11
CDI Container
Dependency Injection with lifecycle and contextual information
managing POJO instances in an enterprise web application
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 12
CDI Beans
@Named @RequestScoped
class LivePriceController { ... }
@Named @SessionScoped
class ShoppingCart implements Serializable {
... }
@ApplicationScoped
class Utility implements Serializable { ... }
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 13
Servlet Container
A specific container to manage Java Servlets, Filters and Context
Listeners for a web application HTTP
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 14
Web Infrastructure Beans
@WebServlet(“/prices/live”)
class LivePriceServlet extends HttpServlet {
... }
@WebFilter(“/prices”)
class PriceEnricher implements Filter { ... }
@WebListener
class UserSecurityRemover implements
HttpSessionListener,
HttpSessionAttributeListener { ... }
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 15
Request Scope
Session Scope
Application
Scope
Arrow ofTime
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 16
Context & Dependency
Injection 1.1
▪ Different lifespans for stateful objects
▪ Typesafe dependency injection
▪ Can decorate injected objects
▪ Can interpret methods
▪ Event notification model
▪ Portable extensions mechanism through SPI
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 17
Injection from CDI container
interface PaymentIssuer {
void allocate( int id );
}
@ApplicationScoped
public class CreditCardTicketTrackerImpl {
@Inject PaymentIssuer issuer;
/* ... */
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 18
CDI Qualifiers
import java.inject.Qualifier;
import java.lang.annotation.*;
import static java.lang.annotation.ElementType.FIELD;
@Qualifier
@Retention(RUNTIME)
@Target({FIELD}
public @interface Premier { }
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 19
Use CDI Qualifiers #1
@Premier
class StellarPaymentImpl implements PaymentIssuer {
void allocate( int id ) { ... }
}
@Standard
class BasicPaymentImpl implements PaymentIssuer {
void allocate( int id ) { ... }
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 20
Use CDI Qualifiers #2
@ApplicationScoped
public class SmartCreditCardTicketTracker() {
@Premium @Inject PaymentIssuer issuer1;
@Standard @Inject PaymentIssuer issuer2;
public void processTickets() {
if (nightTime) { ... } else { ... }
}
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 21
Injection from EJB container
@Stateless public class OrderDAO {
List<Order> findByCustomer( int custId ) {...}
}
@SessionScoped
public class CustomerOrderProcessor {
@EJB OrderDao orderDao;
/* ... */
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 22
Injection from Servlet
container
class LivePriceServlet
extends HttpServlet { ... }
@Named @RequestScoped
class EntryController {
@Inject LivePriceServlet servlet;
// This does not work!
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 23
CDI: Inject a long lifespan
bean to a short lifespan bean
@ApplicationScoped class Utility { ...
}
@Named @RequestScoped
class DeliveryController {
@Inject Utility utility;
/* ... */
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 24
CDI: Inject a long lifespan
bean to a short lifespan bean
@ApplicationScoped class Utility
implements Serializable { ... }
@Named @SessionScoped
class ShoppingCartController implements
Serializable {
@Inject Utility utility;
/* ... */
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 25
CDI: Inject a short lifespan
bean to a long lifespan bean
@RequestScoped class SecureDomain {
... }
@Named @SessionScoped
class ShoppingCartController ... {
@Inject SecureDomain secDomain;
public void doAction() { ... }
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 26
CDI: Inject a short lifespan
bean to a long lifespan bean
@RequestScoped class SecureDomain { ... }
@Named @SessionScoped
class ShoppingCartController ... {
@Inject SecureDomain secDomain;
public void doAction() {
secDomain.invoke(...);
/* YMMV - it might work because of proxies */
}
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 27
CDI Events – Define a domain
value object
public class LivePriceEvent {
private String product;
private double price;
public LivePriceEvent(String product, double price)
{ ... }
public String getProduct() { ... }
public double getPrice() { ... }
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 28
CDI Event Source
@ApplicationScoped
public class PriceUpdater {
@Inject Event<LivePriceEvent> events;
public void announce() {
events.fire(new LivePriceEvent(
"Digital Java EE", 45.0 ));
}
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 29
CDI Event Target
@ApplicationScoped public class PriceListener {
public void listenAndReport(
@Observes LivePriceEvent event ){
System.out.printf("event.product = %sn",
event.getProduct());
System.out.printf("event.price = %sn",
event.getPrice());
}
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 30
Demonstration
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 31
View Scoped Form
JSF View Scoped Controller #1
▪ @ViewScoped belongs to JSF specification
▪ Retains the scope lifespan for current page view
▪ If the controller navigates away to a different page
view the bean is de-scoped
▪ Therefore view-scope is great for form validation
and richAJAX request and response sequences!
▪ #Fail for HTTP POST-REDIRECT-GET idiom
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 32
JSF View Scoped Controller #2
@Named @ViewScoped class ContactDetailController {
@EJB ContactDetailService dao;
ContactDetail contactDetail = new ContactDetail();
public String createContact() {
dao.add(contactDetail);
contactDetail = new ContactDetail();
return "index.xhtml";
}
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 33
Flash Scope #1
▪ JSF supports a flash map collection for controllers
▪ Only accessible through FacesContext
1. JSF places the flash data temporarily into the
HttpSession before it creates the Faces Response.
2. A special flash cookie is set before sending a
redirect HTTP response.
3. A HTTP client resends the flash cookie in a Faces
Request. JSF removes the flash cookie.
4. JSF copies the flash session data to request scope
and them removes it from the session scope.
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 34
Flash Scope #2
@Named @ViewScoped class FrenchSuitController {
private String firstName, lastName;
public String doAction() {
Flash flash = FacesContext.getCurrentInstance().
getExternalContext().getFlash();
flash.put("firstName",firstName);
flash.put("lastName",lastName);
return "/jsf-validation/french-suit-
complete?redirect=true";
} ...
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 35
Flash Scope #3
<ui:define name="mainContent">
<h1> House of Cards with JSF Validation</h1>
<div class="jumbotron">
Terrific! You completed the French suite action.
Your first name is <b>#{flash['firstName']}</b> and
your last name is <b>#{flash['lastName']}</b> and
you chose <b>#{flash['suit']}</b> as the suit.
</div> ...
</ui:define>
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 36
JSF 2.2 supports HTML5 content!
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 37
HTML5 friendly markup in JSF
2.2
▪ In JSF 2.2, by default XHTML are rendered with
HTML5 <DOCTYPE html>
▪ Pass-through attributes
▪ Pass-through elements
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 38
Pass-through attributes
<html xmlns="http://www.w3.org/1999/xhtml" ...
xmlns:p="http://xmlns.jcp.org/jsf/passthrough">
<div class="col-sm-9">
<h:inputText p:type="date"
class="form-control" id="birthday"
value="#{customerController.birthday}"
p:placeholder="1977-10-25” />
</div>
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 39
Pass-through elements
<html xmlns="http://www.w3.org/1999/xhtml” ...
xmlns:jsf="http://xmlns.jcp.org/jsf">
<head jsf:id="head"> ... </head>
<body jsf:id="body">
<form jsf:id="vacationForm">
...
<input type="text" jsf:id="companyId"
placeholder="Your company identity number”
jsf:value="#{vacationController.companyNo}” />
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 40
Conversations
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 41
Demonstration
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 42
Instant Smart Secure
Conversation scope
▪ A lifespan sits between a Http Request scope and
Http Session scope
▪ Maintains state for the unique interaction
▪ Works for individual tab in web browsers
▪ Better than @ViewScoped bean controllers
▪ Application defined lifespan
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 43
Conversation scoped bean #1
public interface Conversation {
void begin();
void begin(String id);
void end();
String getId();
long getTimeout();
void setTimeout(long milliseconds);
boolean isTransient();
} // import javax.enterprise.context.*;
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 44
Conversation scoped bean #2
@Named @ConversationScoped
public class LendingController
implements Serializable {
@EJB ApplicantService applicantService;
@Inject Conversation conversation;
@Inject Utility utility;
public String doConfirm() { ... }
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 45
Conversation scoped bean #3
@Named @ConversationScoped class LendingController ... {
public void checkAndStart() {
if ( conversation.isTransient()) conversation.begin();
recalculatePMT();
}
public void checkAndEnd() {
if (!conversation.isTransient()) conversation.end();
}
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 46
Conversation scoped bean #4
@Named @ConversationScoped
class LendingController ... {
public String doLandingPage() {
checkAndStart();
return "your-details?faces-redirect=true";
}
...
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 47
Conversation scoped bean #5
@Named @ConversationScoped
class LendingController ... {
public String doCancel() {
checkAndEnd();
return "index.xhtml?faces-redirect=true";
}
...
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 48
Conversation scope
conclusions
Pros
▪ Conversation scope is great for “wizards”
▪ Linear sequence of pages
▪ Conversation is unique per tab
▪ Application defines the entry & exit points
Cons
▪ Explicitly termination of conversation
▪ Customer jumps away and back again
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 49
JSF 2.2 Faces Flows
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 50
Flow scope #1
▪ Brand new scope in JSF 2.2 and Java EE 7
▪ Modular in execution
▪ Concept of nodes
▪ Associated with a URI path
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 51
Flow scope #2
▪ Flows can nested; a flow can invoke another
▪ Parameters and data can pass to and back through
Flow scope map collection
▪ package javax.faces.flow.*
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 52
Flow scope #3
▪ A Flow is a folder name in your web context
application
▪ A Flow must have a Flow Definition XML file that
matches the folder name
▪ <Flow-Name>/<Flow-Name>-flow.xml
▪ This file can be blank – implicit flow navigation
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 53
Flow node types
▪ View – represents any JSF page view
▪ Method Call – method invocation through EL
(expression language)
▪ FlowCall – invocation of another flow with inbound
and outbound parameters
▪ Flow Return – return to the calling flow
▪ Switch – navigation selection through EL
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 54
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 55
sector-flow
carbon-footprint-flow
Start
End
Demonstration
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 56
Flow scope application
Flow layout project
src/main/webapp/sector/
src/main/webapp/sector/sector-flow.xml
src/main/webapp/sector/sector.xhtml
src/main/webapp/sector/sector-page-1a.xthml
src/main/webapp/sector/sector-page-1b.xthml
src/main/webapp/sector/sector-page-1c.xthml
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 57
Flow layout project #2
src/main/webapp/footprint/
src/main/webapp/footprint/footprint-flow.xml
src/main/webapp/footprint/footprint.xhtml
src/main/webapp/footprint/footprint-page-1a.xml
src/main/webapp/endflow.xhtml
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 58
Flow scoped controller #1
@Named @FlowScoped("sector")
public class SectorFlow
implements Serializable {
@Inject UtilityHelper utilityHelper;
@Inject CarbonFootprintService service;
public SectorFlow() { ... }
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 59
Flow scoped controller #2
@Named @FlowScoped("sector")
public class SectorFlow
implements Serializable {
@Inject UtilityHelper utilityHelper;
@Inject CarbonFootprintService service;
public SectorFlow() { ... }
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 60
Flow scoped controller #4
public class SectorFlow ...{
@PostConstruct
public void initialize() {
footprint.setApplicationId(
utilityHelper.getNextApplicationId());
}
...
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 61
Flow scoped controller #5
public class SectorFlow ...{
public String gotoEndFlow() {
return "/endflow.xhtml";
}
public String saveFootprintRecord() {
service.add(footprint);
return "sector-page-1c.xhtml";
}
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 62
Flow definition XML file #1
<faces-config version="2.2" ...>
<flow-definition id="sector">
<flow-return id="goHome">
<from-outcome>/index</from-outcome>
</flow-return>
...
</flow-definition>
</faces-config>
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 63
Flow definition XML file #2
<faces-config version="2.2" ...>
<flow-definition id="sector">
<flow-return id="endFlow">
<from-outcome>#{sectorFlow.gotoEndFlow()}
</from-outcome>
</flow-return>
<flow-call id="callFootprintFlow”>...</flow-call>
</flow-definition> ...
</faces-config>
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 64
Flow definition XML file #3
<flow-call id="callFootprintFlow">
<flow-reference><flow-id>footprint</flow-id>
</flow-reference> ...
<outbound-parameter>
<name>param3FromSectorFlow</name>
<value>#{sectorFlow.footprint}</value>
</outbound-parameter>
</flow-call>
</flow-definition>
</faces-config>
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 65
Nested flow scope #1
@Named @FlowScoped("footprint")
public class FootprintFlow implements Serializable {
private CarbonFootprint footprint;
@PostConstruct public void initialize() {}
Map<Object,Object> flowMap =
FacesContext.getCurrentInstance()
.getApplication().getFlowHandler()
.getCurrentFlowScope();
footprint = (CarbonFootprint) flowMap.get("param3Value");
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 66
Nested flow scope #2
@Named @FlowScoped("footprint")
public class FootprintFlow ... {
public String exitFromFootprintFlow() {
return ”/sector";
}
. . .
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 67
Nested flow scope #3
@Named @FlowScoped("footprint")
public class FootprintFlow ... {
. . .
public String gotoPage2() {
return "footprint-page-1a";
}
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 68
Nested Flow definition XML
file #1
<faces-config version="2.2" ...>
<flow-definition id="footprint-flow">
<flow-return id="goHome">
<from-outcome>/index</from-outcome>
</flow-return>
...
</faces-config>
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 69
Nested Flow definition XML
file #2
<faces-config version="2.2" ...>
<flow-definition id="footprint"> ...
<flow-return id=”exitToCallerFlow">
<from-outcome>#{footprintFlow.exitFromFootprintFlow}
</from-outcome>
</flow-return>
<flow-return id="exitToSectorFlow">
<from-outcome>/sector-flow</from-outcome>
</flow-return>
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 70
Nested Flow definition XML
file #3
<flow-definition id="footprint"> ...
<inbound-parameter>
<name>param1FromSectorFlow</name>
<value>#{flowScope.param1Value}</value>
</inbound-parameter> ...
<inbound-parameter>
<name>param3FromSectorFlow</name>
<value>#{flowScope.param3Value}</value>
</inbound-parameter>
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 71
Flow scope bean conclusions
Pros
▪ Conversation scope is great for “wizards”
▪ Flow node demarcated by URI folder convention
▪ Nestable flow customer journeys
Cons
▪ Handling REDIRECT is difficult (JSF 2.3 perhaps?)
▪ Flow scope parameter passing can be peculiar
▪ Only one START NODE and not configurable
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 72
Choosing a scope for a
managed bean controller
▪ Sharing data, utility and information for all users,
prefer @ApplicationScoped
▪ Sharing information and behavior for an individual
customer, prefer @SessionScoped
▪ Customer journey restricted to a specific set of page
views, choose @FlowScoped
▪ Defined customer journey and custom application
entry and exit points, choose @ConversationScoped
▪ Basic rich validation entry and exit point, prefer
@ViewScoped
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 73
Adding Finesse
▪ Consider CSS framework such as Bootstrap
(http://getbootstrap.com) or Foundation
(http://foundation.zurb.com/ )
▪ Consider SASS or LESS for CSS templates
▪ Learn JavaScript programming
▪ Maybe learn aboutTranspilers
▪ Consider RequireJS (http://requirejs.org/) for
organising JavaScript modules
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 74
Design considerations
▪ Evolution of object oriented JavaScript leads to rich
frameworks inside the client’s web browser
▪ JSF lends itself to page view navigation
▪ Hybrid design is possible with JSF and adopting
JavaScript controller
▪ JSF 2.2 Faces Flows is a major feature worthy of
investigation
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 75
Non-Functional Requirement
HealthCare.gov site must
handle 10,000 customers at
once.
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 76
It failed with just a few
hundred users.
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 77
HealthCare.gov (USA)
Website cost $300 million price tag
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 78
Don’t worry USA!
British NHS IT system was abandoned after 10 years
and cost the tax payer £10bn so far
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 79
▪ Innovate with optionality
▪ Constraints
▪ Build fast, fail fast
▪ Communication
▪ Technology == evolution
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 80
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 81
Executive Summary
Hints and tips and where to go next
Conclusions
▪ Leverage Java EE 7 platform
▪ Choose scope by lifespan of the bean
▪ Prefer Faces Flows for digital customer journeys
▪ Otherwise Conversation-Scoped beans
▪ Prefer HTML5 friendly markup of Facelets views
▪ Prefer CDI
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 82
Conclusions #2
▪ Protect your from UX changes
▪ Keep action controller methods short
▪ Delegate complex logic to business logic
▪ Use DOMAIN MODEL CONTEXT objects
▪ Avoid methods with long parameter lists!
▪ Inject DOMAIN MODEL LOGIC
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 83
Contacts
▪ Follow me onTwitter @peter_pilgrim
▪ Read my blog http://xenonique.co.uk/blog/
▪ Books from Packt Publishing
–Digital Java EE 7
–Java EE 7 Developer Handbook
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 84
Photo credits (cc) 2016
▪ by Joshua Earle https://unsplash.com/joshuaearle
▪ By Lili Popper https://unsplash.com/lili_popper
▪ By Rowan Heuvel https://unsplash.com/insolitus
▪ By David Marcu https://stocksnap.io/author/302
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 85
Photo credits (cc) 2016
▪ By Gemma Bou (hand fractal)
https://www.flickr.com/photos/gemmabou/
▪ By Nicole Hanusek (luggage)
https://www.flickr.com/photos/nhanusek/
▪ By Navaneeth KN (group photo painted stork)
https://www.flickr.com/photos/navaneethkn/
▪ By Ruben Schade (container ship in the Straits of
Singapore) https://www.flickr.com/photos/rubenerd/
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 86
Photo credits (cc) 2016
▪ Joel Cooper (big face 1)
https://www.flickr.com/photos/origamijoel/
▪ Nullfy from nullfy.com! (Ring of Power!)
https://www.flickr.com/photos/130197050@N04/
▪ philippe leroyer (Student Demonstration (46) - 27Nov07, Paris
(France)) https://www.flickr.com/photos/philippeleroyer/
▪ philippe leroyer (Pupil's Demonstration (10) - 10Apr08, Paris
(France)) https://www.flickr.com/photos/philippeleroyer/
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 87
Ad

More Related Content

What's hot (20)

Extending Java EE with CDI and JBoss Forge
Extending Java EE with CDI and JBoss ForgeExtending Java EE with CDI and JBoss Forge
Extending Java EE with CDI and JBoss Forge
Antoine Sabot-Durand
 
Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014
Antoine Sabot-Durand
 
Hybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKitHybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKit
Ariya Hidayat
 
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFacesJavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
Mert Çalışkan
 
Clean Pragmatic Architecture - Avoiding a Monolith
Clean Pragmatic Architecture - Avoiding a MonolithClean Pragmatic Architecture - Avoiding a Monolith
Clean Pragmatic Architecture - Avoiding a Monolith
Victor Rentea
 
Java 9 New Features
Java 9 New FeaturesJava 9 New Features
Java 9 New Features
Ali BAKAN
 
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
Fred Sauer
 
Choosing a Java Web Framework
Choosing a Java Web FrameworkChoosing a Java Web Framework
Choosing a Java Web Framework
Will Iverson
 
Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...
Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...
Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...
Matt Raible
 
Guice tutorial
Guice tutorialGuice tutorial
Guice tutorial
Anh Quân
 
Functional Reactive Programming in the Netflix API
Functional Reactive Programming in the Netflix APIFunctional Reactive Programming in the Netflix API
Functional Reactive Programming in the Netflix API
C4Media
 
Front End Development for Backend Developers - GIDS 2019
Front End Development for Backend Developers - GIDS 2019Front End Development for Backend Developers - GIDS 2019
Front End Development for Backend Developers - GIDS 2019
Matt Raible
 
RESTful API Design & Implementation with CodeIgniter PHP Framework
RESTful API Design & Implementation with CodeIgniter PHP FrameworkRESTful API Design & Implementation with CodeIgniter PHP Framework
RESTful API Design & Implementation with CodeIgniter PHP Framework
Bo-Yi Wu
 
Gradle plugin, take control of the build
Gradle plugin, take control of the buildGradle plugin, take control of the build
Gradle plugin, take control of the build
Eyal Lezmy
 
Gradle plugins, take it to the next level
Gradle plugins, take it to the next levelGradle plugins, take it to the next level
Gradle plugins, take it to the next level
Eyal Lezmy
 
Asynchronous Programming at Netflix
Asynchronous Programming at NetflixAsynchronous Programming at Netflix
Asynchronous Programming at Netflix
C4Media
 
Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...
Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...
Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...
Matt Raible
 
Bootiful Development with Spring Boot and React - UberConf 2018
Bootiful Development with Spring Boot and React - UberConf 2018Bootiful Development with Spring Boot and React - UberConf 2018
Bootiful Development with Spring Boot and React - UberConf 2018
Matt Raible
 
Desiging for Modularity with Java 9
Desiging for Modularity with Java 9Desiging for Modularity with Java 9
Desiging for Modularity with Java 9
Sander Mak (@Sander_Mak)
 
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
Matt Raible
 
Extending Java EE with CDI and JBoss Forge
Extending Java EE with CDI and JBoss ForgeExtending Java EE with CDI and JBoss Forge
Extending Java EE with CDI and JBoss Forge
Antoine Sabot-Durand
 
Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014
Antoine Sabot-Durand
 
Hybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKitHybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKit
Ariya Hidayat
 
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFacesJavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
Mert Çalışkan
 
Clean Pragmatic Architecture - Avoiding a Monolith
Clean Pragmatic Architecture - Avoiding a MonolithClean Pragmatic Architecture - Avoiding a Monolith
Clean Pragmatic Architecture - Avoiding a Monolith
Victor Rentea
 
Java 9 New Features
Java 9 New FeaturesJava 9 New Features
Java 9 New Features
Ali BAKAN
 
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
Fred Sauer
 
Choosing a Java Web Framework
Choosing a Java Web FrameworkChoosing a Java Web Framework
Choosing a Java Web Framework
Will Iverson
 
Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...
Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...
Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...
Matt Raible
 
Guice tutorial
Guice tutorialGuice tutorial
Guice tutorial
Anh Quân
 
Functional Reactive Programming in the Netflix API
Functional Reactive Programming in the Netflix APIFunctional Reactive Programming in the Netflix API
Functional Reactive Programming in the Netflix API
C4Media
 
Front End Development for Backend Developers - GIDS 2019
Front End Development for Backend Developers - GIDS 2019Front End Development for Backend Developers - GIDS 2019
Front End Development for Backend Developers - GIDS 2019
Matt Raible
 
RESTful API Design & Implementation with CodeIgniter PHP Framework
RESTful API Design & Implementation with CodeIgniter PHP FrameworkRESTful API Design & Implementation with CodeIgniter PHP Framework
RESTful API Design & Implementation with CodeIgniter PHP Framework
Bo-Yi Wu
 
Gradle plugin, take control of the build
Gradle plugin, take control of the buildGradle plugin, take control of the build
Gradle plugin, take control of the build
Eyal Lezmy
 
Gradle plugins, take it to the next level
Gradle plugins, take it to the next levelGradle plugins, take it to the next level
Gradle plugins, take it to the next level
Eyal Lezmy
 
Asynchronous Programming at Netflix
Asynchronous Programming at NetflixAsynchronous Programming at Netflix
Asynchronous Programming at Netflix
C4Media
 
Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...
Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...
Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...
Matt Raible
 
Bootiful Development with Spring Boot and React - UberConf 2018
Bootiful Development with Spring Boot and React - UberConf 2018Bootiful Development with Spring Boot and React - UberConf 2018
Bootiful Development with Spring Boot and React - UberConf 2018
Matt Raible
 
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
Matt Raible
 

Similar to JavaOne 2015 CON5211 Digital Java EE 7 with JSF Conversations, Flows, and CDI Scopes (20)

Java EE & Glass Fish User Group: Digital JavaEE 7 - New and Noteworthy
Java EE & Glass Fish User Group: Digital JavaEE 7 - New and NoteworthyJava EE & Glass Fish User Group: Digital JavaEE 7 - New and Noteworthy
Java EE & Glass Fish User Group: Digital JavaEE 7 - New and Noteworthy
Peter Pilgrim
 
Avoiding and dealing with conflicting updates in Oak
Avoiding and dealing with conflicting updates in OakAvoiding and dealing with conflicting updates in Oak
Avoiding and dealing with conflicting updates in Oak
michid
 
It's complicated, but it doesn't have to be: a Dagger journey
It's complicated, but it doesn't have to be: a Dagger journeyIt's complicated, but it doesn't have to be: a Dagger journey
It's complicated, but it doesn't have to be: a Dagger journey
Thiago “Fred” Porciúncula
 
Trying to build an Open Source browser in 2020
Trying to build an Open Source browser in 2020Trying to build an Open Source browser in 2020
Trying to build an Open Source browser in 2020
Patricia Aas
 
Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008
Jonas Follesø
 
To Microservices and Beyond
To Microservices and BeyondTo Microservices and Beyond
To Microservices and Beyond
Matt Stine
 
Get Back in Control of Your SQL - #33rdDegree
Get Back in Control of Your SQL - #33rdDegreeGet Back in Control of Your SQL - #33rdDegree
Get Back in Control of Your SQL - #33rdDegree
DataGeekery
 
Contexts and Dependency Injection
Contexts and Dependency InjectionContexts and Dependency Injection
Contexts and Dependency Injection
Werner Keil
 
Trying to build an Open Source browser in 2020
Trying to build an Open Source browser in 2020Trying to build an Open Source browser in 2020
Trying to build an Open Source browser in 2020
Patricia Aas
 
The new and smart way to build microservices - Eclipse MicroProfile
The new and smart way to build microservices - Eclipse MicroProfileThe new and smart way to build microservices - Eclipse MicroProfile
The new and smart way to build microservices - Eclipse MicroProfile
Emily Jiang
 
OpenWebBeans and DeltaSpike at ApacheCon
OpenWebBeans and DeltaSpike at ApacheConOpenWebBeans and DeltaSpike at ApacheCon
OpenWebBeans and DeltaSpike at ApacheCon
os890
 
Cleaning your architecture with android architecture components
Cleaning your architecture with android architecture componentsCleaning your architecture with android architecture components
Cleaning your architecture with android architecture components
Debora Gomez Bertoli
 
M2M for Java Developers: MQTT with Eclipse Paho - Eclipsecon Europe 2013
M2M for Java Developers: MQTT with Eclipse Paho - Eclipsecon Europe 2013M2M for Java Developers: MQTT with Eclipse Paho - Eclipsecon Europe 2013
M2M for Java Developers: MQTT with Eclipse Paho - Eclipsecon Europe 2013
Dominik Obermaier
 
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
Alina Vilk
 
Get Back in Control of your SQL with jOOQ - GeekOut by ZeroTurnaround
Get Back in Control of your SQL with jOOQ - GeekOut by ZeroTurnaroundGet Back in Control of your SQL with jOOQ - GeekOut by ZeroTurnaround
Get Back in Control of your SQL with jOOQ - GeekOut by ZeroTurnaround
DataGeekery
 
Best Way to Write SQL in Java
Best Way to Write SQL in JavaBest Way to Write SQL in Java
Best Way to Write SQL in Java
Gerger
 
Open Admin
Open AdminOpen Admin
Open Admin
bpolster
 
Building cloud native microservices
Building cloud native microservicesBuilding cloud native microservices
Building cloud native microservices
Emily Jiang
 
Devoxx 2012 (v2)
Devoxx 2012 (v2)Devoxx 2012 (v2)
Devoxx 2012 (v2)
Jerome Dochez
 
Cross the Streams! Creating Streaming Data Pipelines with Apache Flink + Apac...
Cross the Streams! Creating Streaming Data Pipelines with Apache Flink + Apac...Cross the Streams! Creating Streaming Data Pipelines with Apache Flink + Apac...
Cross the Streams! Creating Streaming Data Pipelines with Apache Flink + Apac...
StreamNative
 
Java EE & Glass Fish User Group: Digital JavaEE 7 - New and Noteworthy
Java EE & Glass Fish User Group: Digital JavaEE 7 - New and NoteworthyJava EE & Glass Fish User Group: Digital JavaEE 7 - New and Noteworthy
Java EE & Glass Fish User Group: Digital JavaEE 7 - New and Noteworthy
Peter Pilgrim
 
Avoiding and dealing with conflicting updates in Oak
Avoiding and dealing with conflicting updates in OakAvoiding and dealing with conflicting updates in Oak
Avoiding and dealing with conflicting updates in Oak
michid
 
It's complicated, but it doesn't have to be: a Dagger journey
It's complicated, but it doesn't have to be: a Dagger journeyIt's complicated, but it doesn't have to be: a Dagger journey
It's complicated, but it doesn't have to be: a Dagger journey
Thiago “Fred” Porciúncula
 
Trying to build an Open Source browser in 2020
Trying to build an Open Source browser in 2020Trying to build an Open Source browser in 2020
Trying to build an Open Source browser in 2020
Patricia Aas
 
Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008
Jonas Follesø
 
To Microservices and Beyond
To Microservices and BeyondTo Microservices and Beyond
To Microservices and Beyond
Matt Stine
 
Get Back in Control of Your SQL - #33rdDegree
Get Back in Control of Your SQL - #33rdDegreeGet Back in Control of Your SQL - #33rdDegree
Get Back in Control of Your SQL - #33rdDegree
DataGeekery
 
Contexts and Dependency Injection
Contexts and Dependency InjectionContexts and Dependency Injection
Contexts and Dependency Injection
Werner Keil
 
Trying to build an Open Source browser in 2020
Trying to build an Open Source browser in 2020Trying to build an Open Source browser in 2020
Trying to build an Open Source browser in 2020
Patricia Aas
 
The new and smart way to build microservices - Eclipse MicroProfile
The new and smart way to build microservices - Eclipse MicroProfileThe new and smart way to build microservices - Eclipse MicroProfile
The new and smart way to build microservices - Eclipse MicroProfile
Emily Jiang
 
OpenWebBeans and DeltaSpike at ApacheCon
OpenWebBeans and DeltaSpike at ApacheConOpenWebBeans and DeltaSpike at ApacheCon
OpenWebBeans and DeltaSpike at ApacheCon
os890
 
Cleaning your architecture with android architecture components
Cleaning your architecture with android architecture componentsCleaning your architecture with android architecture components
Cleaning your architecture with android architecture components
Debora Gomez Bertoli
 
M2M for Java Developers: MQTT with Eclipse Paho - Eclipsecon Europe 2013
M2M for Java Developers: MQTT with Eclipse Paho - Eclipsecon Europe 2013M2M for Java Developers: MQTT with Eclipse Paho - Eclipsecon Europe 2013
M2M for Java Developers: MQTT with Eclipse Paho - Eclipsecon Europe 2013
Dominik Obermaier
 
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
Alina Vilk
 
Get Back in Control of your SQL with jOOQ - GeekOut by ZeroTurnaround
Get Back in Control of your SQL with jOOQ - GeekOut by ZeroTurnaroundGet Back in Control of your SQL with jOOQ - GeekOut by ZeroTurnaround
Get Back in Control of your SQL with jOOQ - GeekOut by ZeroTurnaround
DataGeekery
 
Best Way to Write SQL in Java
Best Way to Write SQL in JavaBest Way to Write SQL in Java
Best Way to Write SQL in Java
Gerger
 
Open Admin
Open AdminOpen Admin
Open Admin
bpolster
 
Building cloud native microservices
Building cloud native microservicesBuilding cloud native microservices
Building cloud native microservices
Emily Jiang
 
Cross the Streams! Creating Streaming Data Pipelines with Apache Flink + Apac...
Cross the Streams! Creating Streaming Data Pipelines with Apache Flink + Apac...Cross the Streams! Creating Streaming Data Pipelines with Apache Flink + Apac...
Cross the Streams! Creating Streaming Data Pipelines with Apache Flink + Apac...
StreamNative
 
Ad

More from Peter Pilgrim (12)

Devoxx 2019 - Why we pair?
Devoxx 2019 - Why we pair?Devoxx 2019 - Why we pair?
Devoxx 2019 - Why we pair?
Peter Pilgrim
 
Cloud native java are we there yet go tech world 2019
Cloud native java   are we there yet  go tech world 2019Cloud native java   are we there yet  go tech world 2019
Cloud native java are we there yet go tech world 2019
Peter Pilgrim
 
LJC 2018 - PEAT UK - Java EE - Ah, ah, ah! Staying Alive!
LJC 2018 - PEAT UK - Java EE - Ah, ah, ah! Staying Alive!LJC 2018 - PEAT UK - Java EE - Ah, ah, ah! Staying Alive!
LJC 2018 - PEAT UK - Java EE - Ah, ah, ah! Staying Alive!
Peter Pilgrim
 
CON6148 - You Are Not Cut Out To Be A Java Contractor - JavaOne 2017
CON6148 - You Are Not Cut Out To Be A Java Contractor - JavaOne 2017CON6148 - You Are Not Cut Out To Be A Java Contractor - JavaOne 2017
CON6148 - You Are Not Cut Out To Be A Java Contractor - JavaOne 2017
Peter Pilgrim
 
QCon 2015 Scala for the Enterprise: Get FuNkEd Up on the JVM
QCon 2015 Scala for the Enterprise: Get FuNkEd Up on the JVMQCon 2015 Scala for the Enterprise: Get FuNkEd Up on the JVM
QCon 2015 Scala for the Enterprise: Get FuNkEd Up on the JVM
Peter Pilgrim
 
BOF2644 Developing Java EE 7 Scala apps
BOF2644 Developing Java EE 7 Scala appsBOF2644 Developing Java EE 7 Scala apps
BOF2644 Developing Java EE 7 Scala apps
Peter Pilgrim
 
JavaCro 2014 Scala and Java EE 7 Development Experiences
JavaCro 2014 Scala and Java EE 7 Development ExperiencesJavaCro 2014 Scala and Java EE 7 Development Experiences
JavaCro 2014 Scala and Java EE 7 Development Experiences
Peter Pilgrim
 
JavaCro 2014 Digital Development with Java EE and Java Platform
JavaCro 2014 Digital Development with Java EE and Java PlatformJavaCro 2014 Digital Development with Java EE and Java Platform
JavaCro 2014 Digital Development with Java EE and Java Platform
Peter Pilgrim
 
ACCU 2013 Taking Scala into the Enterpise
ACCU 2013 Taking Scala into the EnterpiseACCU 2013 Taking Scala into the Enterpise
ACCU 2013 Taking Scala into the Enterpise
Peter Pilgrim
 
Devoxx UK 2013 Test-Driven Development with JavaEE 7, Arquillian and Embedded...
Devoxx UK 2013 Test-Driven Development with JavaEE 7, Arquillian and Embedded...Devoxx UK 2013 Test-Driven Development with JavaEE 7, Arquillian and Embedded...
Devoxx UK 2013 Test-Driven Development with JavaEE 7, Arquillian and Embedded...
Peter Pilgrim
 
JavaOne 2011 Progressive JavaFX 2.0 Custom Components
JavaOne 2011 Progressive JavaFX 2.0 Custom ComponentsJavaOne 2011 Progressive JavaFX 2.0 Custom Components
JavaOne 2011 Progressive JavaFX 2.0 Custom Components
Peter Pilgrim
 
ACCU 2011 Introduction to Scala: An Object Functional Programming Language
ACCU 2011 Introduction to Scala: An Object Functional Programming LanguageACCU 2011 Introduction to Scala: An Object Functional Programming Language
ACCU 2011 Introduction to Scala: An Object Functional Programming Language
Peter Pilgrim
 
Devoxx 2019 - Why we pair?
Devoxx 2019 - Why we pair?Devoxx 2019 - Why we pair?
Devoxx 2019 - Why we pair?
Peter Pilgrim
 
Cloud native java are we there yet go tech world 2019
Cloud native java   are we there yet  go tech world 2019Cloud native java   are we there yet  go tech world 2019
Cloud native java are we there yet go tech world 2019
Peter Pilgrim
 
LJC 2018 - PEAT UK - Java EE - Ah, ah, ah! Staying Alive!
LJC 2018 - PEAT UK - Java EE - Ah, ah, ah! Staying Alive!LJC 2018 - PEAT UK - Java EE - Ah, ah, ah! Staying Alive!
LJC 2018 - PEAT UK - Java EE - Ah, ah, ah! Staying Alive!
Peter Pilgrim
 
CON6148 - You Are Not Cut Out To Be A Java Contractor - JavaOne 2017
CON6148 - You Are Not Cut Out To Be A Java Contractor - JavaOne 2017CON6148 - You Are Not Cut Out To Be A Java Contractor - JavaOne 2017
CON6148 - You Are Not Cut Out To Be A Java Contractor - JavaOne 2017
Peter Pilgrim
 
QCon 2015 Scala for the Enterprise: Get FuNkEd Up on the JVM
QCon 2015 Scala for the Enterprise: Get FuNkEd Up on the JVMQCon 2015 Scala for the Enterprise: Get FuNkEd Up on the JVM
QCon 2015 Scala for the Enterprise: Get FuNkEd Up on the JVM
Peter Pilgrim
 
BOF2644 Developing Java EE 7 Scala apps
BOF2644 Developing Java EE 7 Scala appsBOF2644 Developing Java EE 7 Scala apps
BOF2644 Developing Java EE 7 Scala apps
Peter Pilgrim
 
JavaCro 2014 Scala and Java EE 7 Development Experiences
JavaCro 2014 Scala and Java EE 7 Development ExperiencesJavaCro 2014 Scala and Java EE 7 Development Experiences
JavaCro 2014 Scala and Java EE 7 Development Experiences
Peter Pilgrim
 
JavaCro 2014 Digital Development with Java EE and Java Platform
JavaCro 2014 Digital Development with Java EE and Java PlatformJavaCro 2014 Digital Development with Java EE and Java Platform
JavaCro 2014 Digital Development with Java EE and Java Platform
Peter Pilgrim
 
ACCU 2013 Taking Scala into the Enterpise
ACCU 2013 Taking Scala into the EnterpiseACCU 2013 Taking Scala into the Enterpise
ACCU 2013 Taking Scala into the Enterpise
Peter Pilgrim
 
Devoxx UK 2013 Test-Driven Development with JavaEE 7, Arquillian and Embedded...
Devoxx UK 2013 Test-Driven Development with JavaEE 7, Arquillian and Embedded...Devoxx UK 2013 Test-Driven Development with JavaEE 7, Arquillian and Embedded...
Devoxx UK 2013 Test-Driven Development with JavaEE 7, Arquillian and Embedded...
Peter Pilgrim
 
JavaOne 2011 Progressive JavaFX 2.0 Custom Components
JavaOne 2011 Progressive JavaFX 2.0 Custom ComponentsJavaOne 2011 Progressive JavaFX 2.0 Custom Components
JavaOne 2011 Progressive JavaFX 2.0 Custom Components
Peter Pilgrim
 
ACCU 2011 Introduction to Scala: An Object Functional Programming Language
ACCU 2011 Introduction to Scala: An Object Functional Programming LanguageACCU 2011 Introduction to Scala: An Object Functional Programming Language
ACCU 2011 Introduction to Scala: An Object Functional Programming Language
Peter Pilgrim
 
Ad

Recently uploaded (20)

TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 

JavaOne 2015 CON5211 Digital Java EE 7 with JSF Conversations, Flows, and CDI Scopes

  • 1. Digital Java EE 7 with JSF Conversations, Flows, and CDI Scopes Peter Pilgrim JavaOne - CON5211 29th October 2015
  • 2. Digital Java EE 7 JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 2
  • 3. About me ▪ Java Champion ▪ Java programming since 1998 ▪ Independent contractor, LTD UK ▪ Java EE developer, designer and book author JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 3
  • 4. Agenda ▪ Java EE 7 modern architecture ▪ CDI Scopes ▪ Conversation scoped beans ▪ Faces-Flows and flow scoped beans ▪ Bootstrap your enterprise JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 4
  • 5. "Nobody is madder than me about the fact that the website isn't working” President Obama Rose Garden Speech, 21th October 2013 JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 5
  • 6. Demonstration JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 6 Digital Java EE application
  • 7. Digital Java EE 7 Platform ▪ Java EE 7 is standard architecture for building enterprise Java solutions ▪ Transactions, persistence, management ▪ Dynamic content: Servlets, JSP, JSF and MVC ▪ Remote endpoints EJB, JAX-RS, JMS WebSocket and JCA JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 7
  • 8. JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 8
  • 9. JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 9
  • 10. EJB Container Poolable managed remote end points with transactions and concurrency , which are application wide JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 10
  • 11. EJB Beans @Stateless class ProductQueryService { ... } @Stateful class ShoppingCartDao { ... } @MessageDriven class OrderProcessor implements MessageListener { ... } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 11
  • 12. CDI Container Dependency Injection with lifecycle and contextual information managing POJO instances in an enterprise web application JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 12
  • 13. CDI Beans @Named @RequestScoped class LivePriceController { ... } @Named @SessionScoped class ShoppingCart implements Serializable { ... } @ApplicationScoped class Utility implements Serializable { ... } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 13
  • 14. Servlet Container A specific container to manage Java Servlets, Filters and Context Listeners for a web application HTTP JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 14
  • 15. Web Infrastructure Beans @WebServlet(“/prices/live”) class LivePriceServlet extends HttpServlet { ... } @WebFilter(“/prices”) class PriceEnricher implements Filter { ... } @WebListener class UserSecurityRemover implements HttpSessionListener, HttpSessionAttributeListener { ... } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 15
  • 16. Request Scope Session Scope Application Scope Arrow ofTime JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 16
  • 17. Context & Dependency Injection 1.1 ▪ Different lifespans for stateful objects ▪ Typesafe dependency injection ▪ Can decorate injected objects ▪ Can interpret methods ▪ Event notification model ▪ Portable extensions mechanism through SPI JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 17
  • 18. Injection from CDI container interface PaymentIssuer { void allocate( int id ); } @ApplicationScoped public class CreditCardTicketTrackerImpl { @Inject PaymentIssuer issuer; /* ... */ } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 18
  • 19. CDI Qualifiers import java.inject.Qualifier; import java.lang.annotation.*; import static java.lang.annotation.ElementType.FIELD; @Qualifier @Retention(RUNTIME) @Target({FIELD} public @interface Premier { } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 19
  • 20. Use CDI Qualifiers #1 @Premier class StellarPaymentImpl implements PaymentIssuer { void allocate( int id ) { ... } } @Standard class BasicPaymentImpl implements PaymentIssuer { void allocate( int id ) { ... } } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 20
  • 21. Use CDI Qualifiers #2 @ApplicationScoped public class SmartCreditCardTicketTracker() { @Premium @Inject PaymentIssuer issuer1; @Standard @Inject PaymentIssuer issuer2; public void processTickets() { if (nightTime) { ... } else { ... } } } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 21
  • 22. Injection from EJB container @Stateless public class OrderDAO { List<Order> findByCustomer( int custId ) {...} } @SessionScoped public class CustomerOrderProcessor { @EJB OrderDao orderDao; /* ... */ } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 22
  • 23. Injection from Servlet container class LivePriceServlet extends HttpServlet { ... } @Named @RequestScoped class EntryController { @Inject LivePriceServlet servlet; // This does not work! } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 23
  • 24. CDI: Inject a long lifespan bean to a short lifespan bean @ApplicationScoped class Utility { ... } @Named @RequestScoped class DeliveryController { @Inject Utility utility; /* ... */ } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 24
  • 25. CDI: Inject a long lifespan bean to a short lifespan bean @ApplicationScoped class Utility implements Serializable { ... } @Named @SessionScoped class ShoppingCartController implements Serializable { @Inject Utility utility; /* ... */ } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 25
  • 26. CDI: Inject a short lifespan bean to a long lifespan bean @RequestScoped class SecureDomain { ... } @Named @SessionScoped class ShoppingCartController ... { @Inject SecureDomain secDomain; public void doAction() { ... } } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 26
  • 27. CDI: Inject a short lifespan bean to a long lifespan bean @RequestScoped class SecureDomain { ... } @Named @SessionScoped class ShoppingCartController ... { @Inject SecureDomain secDomain; public void doAction() { secDomain.invoke(...); /* YMMV - it might work because of proxies */ } } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 27
  • 28. CDI Events – Define a domain value object public class LivePriceEvent { private String product; private double price; public LivePriceEvent(String product, double price) { ... } public String getProduct() { ... } public double getPrice() { ... } } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 28
  • 29. CDI Event Source @ApplicationScoped public class PriceUpdater { @Inject Event<LivePriceEvent> events; public void announce() { events.fire(new LivePriceEvent( "Digital Java EE", 45.0 )); } } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 29
  • 30. CDI Event Target @ApplicationScoped public class PriceListener { public void listenAndReport( @Observes LivePriceEvent event ){ System.out.printf("event.product = %sn", event.getProduct()); System.out.printf("event.price = %sn", event.getPrice()); } } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 30
  • 31. Demonstration JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 31 View Scoped Form
  • 32. JSF View Scoped Controller #1 ▪ @ViewScoped belongs to JSF specification ▪ Retains the scope lifespan for current page view ▪ If the controller navigates away to a different page view the bean is de-scoped ▪ Therefore view-scope is great for form validation and richAJAX request and response sequences! ▪ #Fail for HTTP POST-REDIRECT-GET idiom JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 32
  • 33. JSF View Scoped Controller #2 @Named @ViewScoped class ContactDetailController { @EJB ContactDetailService dao; ContactDetail contactDetail = new ContactDetail(); public String createContact() { dao.add(contactDetail); contactDetail = new ContactDetail(); return "index.xhtml"; } } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 33
  • 34. Flash Scope #1 ▪ JSF supports a flash map collection for controllers ▪ Only accessible through FacesContext 1. JSF places the flash data temporarily into the HttpSession before it creates the Faces Response. 2. A special flash cookie is set before sending a redirect HTTP response. 3. A HTTP client resends the flash cookie in a Faces Request. JSF removes the flash cookie. 4. JSF copies the flash session data to request scope and them removes it from the session scope. JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 34
  • 35. Flash Scope #2 @Named @ViewScoped class FrenchSuitController { private String firstName, lastName; public String doAction() { Flash flash = FacesContext.getCurrentInstance(). getExternalContext().getFlash(); flash.put("firstName",firstName); flash.put("lastName",lastName); return "/jsf-validation/french-suit- complete?redirect=true"; } ... JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 35
  • 36. Flash Scope #3 <ui:define name="mainContent"> <h1> House of Cards with JSF Validation</h1> <div class="jumbotron"> Terrific! You completed the French suite action. Your first name is <b>#{flash['firstName']}</b> and your last name is <b>#{flash['lastName']}</b> and you chose <b>#{flash['suit']}</b> as the suit. </div> ... </ui:define> JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 36
  • 37. JSF 2.2 supports HTML5 content! JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 37
  • 38. HTML5 friendly markup in JSF 2.2 ▪ In JSF 2.2, by default XHTML are rendered with HTML5 <DOCTYPE html> ▪ Pass-through attributes ▪ Pass-through elements JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 38
  • 39. Pass-through attributes <html xmlns="http://www.w3.org/1999/xhtml" ... xmlns:p="http://xmlns.jcp.org/jsf/passthrough"> <div class="col-sm-9"> <h:inputText p:type="date" class="form-control" id="birthday" value="#{customerController.birthday}" p:placeholder="1977-10-25” /> </div> JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 39
  • 40. Pass-through elements <html xmlns="http://www.w3.org/1999/xhtml” ... xmlns:jsf="http://xmlns.jcp.org/jsf"> <head jsf:id="head"> ... </head> <body jsf:id="body"> <form jsf:id="vacationForm"> ... <input type="text" jsf:id="companyId" placeholder="Your company identity number” jsf:value="#{vacationController.companyNo}” /> JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 40
  • 41. Conversations JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 41
  • 42. Demonstration JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 42 Instant Smart Secure
  • 43. Conversation scope ▪ A lifespan sits between a Http Request scope and Http Session scope ▪ Maintains state for the unique interaction ▪ Works for individual tab in web browsers ▪ Better than @ViewScoped bean controllers ▪ Application defined lifespan JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 43
  • 44. Conversation scoped bean #1 public interface Conversation { void begin(); void begin(String id); void end(); String getId(); long getTimeout(); void setTimeout(long milliseconds); boolean isTransient(); } // import javax.enterprise.context.*; JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 44
  • 45. Conversation scoped bean #2 @Named @ConversationScoped public class LendingController implements Serializable { @EJB ApplicantService applicantService; @Inject Conversation conversation; @Inject Utility utility; public String doConfirm() { ... } } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 45
  • 46. Conversation scoped bean #3 @Named @ConversationScoped class LendingController ... { public void checkAndStart() { if ( conversation.isTransient()) conversation.begin(); recalculatePMT(); } public void checkAndEnd() { if (!conversation.isTransient()) conversation.end(); } } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 46
  • 47. Conversation scoped bean #4 @Named @ConversationScoped class LendingController ... { public String doLandingPage() { checkAndStart(); return "your-details?faces-redirect=true"; } ... } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 47
  • 48. Conversation scoped bean #5 @Named @ConversationScoped class LendingController ... { public String doCancel() { checkAndEnd(); return "index.xhtml?faces-redirect=true"; } ... } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 48
  • 49. Conversation scope conclusions Pros ▪ Conversation scope is great for “wizards” ▪ Linear sequence of pages ▪ Conversation is unique per tab ▪ Application defines the entry & exit points Cons ▪ Explicitly termination of conversation ▪ Customer jumps away and back again JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 49
  • 50. JSF 2.2 Faces Flows JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 50
  • 51. Flow scope #1 ▪ Brand new scope in JSF 2.2 and Java EE 7 ▪ Modular in execution ▪ Concept of nodes ▪ Associated with a URI path JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 51
  • 52. Flow scope #2 ▪ Flows can nested; a flow can invoke another ▪ Parameters and data can pass to and back through Flow scope map collection ▪ package javax.faces.flow.* JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 52
  • 53. Flow scope #3 ▪ A Flow is a folder name in your web context application ▪ A Flow must have a Flow Definition XML file that matches the folder name ▪ <Flow-Name>/<Flow-Name>-flow.xml ▪ This file can be blank – implicit flow navigation JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 53
  • 54. Flow node types ▪ View – represents any JSF page view ▪ Method Call – method invocation through EL (expression language) ▪ FlowCall – invocation of another flow with inbound and outbound parameters ▪ Flow Return – return to the calling flow ▪ Switch – navigation selection through EL JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 54
  • 55. JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 55 sector-flow carbon-footprint-flow Start End
  • 56. Demonstration JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 56 Flow scope application
  • 58. Flow layout project #2 src/main/webapp/footprint/ src/main/webapp/footprint/footprint-flow.xml src/main/webapp/footprint/footprint.xhtml src/main/webapp/footprint/footprint-page-1a.xml src/main/webapp/endflow.xhtml JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 58
  • 59. Flow scoped controller #1 @Named @FlowScoped("sector") public class SectorFlow implements Serializable { @Inject UtilityHelper utilityHelper; @Inject CarbonFootprintService service; public SectorFlow() { ... } } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 59
  • 60. Flow scoped controller #2 @Named @FlowScoped("sector") public class SectorFlow implements Serializable { @Inject UtilityHelper utilityHelper; @Inject CarbonFootprintService service; public SectorFlow() { ... } } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 60
  • 61. Flow scoped controller #4 public class SectorFlow ...{ @PostConstruct public void initialize() { footprint.setApplicationId( utilityHelper.getNextApplicationId()); } ... } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 61
  • 62. Flow scoped controller #5 public class SectorFlow ...{ public String gotoEndFlow() { return "/endflow.xhtml"; } public String saveFootprintRecord() { service.add(footprint); return "sector-page-1c.xhtml"; } } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 62
  • 63. Flow definition XML file #1 <faces-config version="2.2" ...> <flow-definition id="sector"> <flow-return id="goHome"> <from-outcome>/index</from-outcome> </flow-return> ... </flow-definition> </faces-config> JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 63
  • 64. Flow definition XML file #2 <faces-config version="2.2" ...> <flow-definition id="sector"> <flow-return id="endFlow"> <from-outcome>#{sectorFlow.gotoEndFlow()} </from-outcome> </flow-return> <flow-call id="callFootprintFlow”>...</flow-call> </flow-definition> ... </faces-config> JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 64
  • 65. Flow definition XML file #3 <flow-call id="callFootprintFlow"> <flow-reference><flow-id>footprint</flow-id> </flow-reference> ... <outbound-parameter> <name>param3FromSectorFlow</name> <value>#{sectorFlow.footprint}</value> </outbound-parameter> </flow-call> </flow-definition> </faces-config> JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 65
  • 66. Nested flow scope #1 @Named @FlowScoped("footprint") public class FootprintFlow implements Serializable { private CarbonFootprint footprint; @PostConstruct public void initialize() {} Map<Object,Object> flowMap = FacesContext.getCurrentInstance() .getApplication().getFlowHandler() .getCurrentFlowScope(); footprint = (CarbonFootprint) flowMap.get("param3Value"); } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 66
  • 67. Nested flow scope #2 @Named @FlowScoped("footprint") public class FootprintFlow ... { public String exitFromFootprintFlow() { return ”/sector"; } . . . } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 67
  • 68. Nested flow scope #3 @Named @FlowScoped("footprint") public class FootprintFlow ... { . . . public String gotoPage2() { return "footprint-page-1a"; } } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 68
  • 69. Nested Flow definition XML file #1 <faces-config version="2.2" ...> <flow-definition id="footprint-flow"> <flow-return id="goHome"> <from-outcome>/index</from-outcome> </flow-return> ... </faces-config> JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 69
  • 70. Nested Flow definition XML file #2 <faces-config version="2.2" ...> <flow-definition id="footprint"> ... <flow-return id=”exitToCallerFlow"> <from-outcome>#{footprintFlow.exitFromFootprintFlow} </from-outcome> </flow-return> <flow-return id="exitToSectorFlow"> <from-outcome>/sector-flow</from-outcome> </flow-return> JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 70
  • 71. Nested Flow definition XML file #3 <flow-definition id="footprint"> ... <inbound-parameter> <name>param1FromSectorFlow</name> <value>#{flowScope.param1Value}</value> </inbound-parameter> ... <inbound-parameter> <name>param3FromSectorFlow</name> <value>#{flowScope.param3Value}</value> </inbound-parameter> JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 71
  • 72. Flow scope bean conclusions Pros ▪ Conversation scope is great for “wizards” ▪ Flow node demarcated by URI folder convention ▪ Nestable flow customer journeys Cons ▪ Handling REDIRECT is difficult (JSF 2.3 perhaps?) ▪ Flow scope parameter passing can be peculiar ▪ Only one START NODE and not configurable JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 72
  • 73. Choosing a scope for a managed bean controller ▪ Sharing data, utility and information for all users, prefer @ApplicationScoped ▪ Sharing information and behavior for an individual customer, prefer @SessionScoped ▪ Customer journey restricted to a specific set of page views, choose @FlowScoped ▪ Defined customer journey and custom application entry and exit points, choose @ConversationScoped ▪ Basic rich validation entry and exit point, prefer @ViewScoped JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 73
  • 74. Adding Finesse ▪ Consider CSS framework such as Bootstrap (http://getbootstrap.com) or Foundation (http://foundation.zurb.com/ ) ▪ Consider SASS or LESS for CSS templates ▪ Learn JavaScript programming ▪ Maybe learn aboutTranspilers ▪ Consider RequireJS (http://requirejs.org/) for organising JavaScript modules JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 74
  • 75. Design considerations ▪ Evolution of object oriented JavaScript leads to rich frameworks inside the client’s web browser ▪ JSF lends itself to page view navigation ▪ Hybrid design is possible with JSF and adopting JavaScript controller ▪ JSF 2.2 Faces Flows is a major feature worthy of investigation JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 75
  • 76. Non-Functional Requirement HealthCare.gov site must handle 10,000 customers at once. JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 76
  • 77. It failed with just a few hundred users. JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 77
  • 78. HealthCare.gov (USA) Website cost $300 million price tag JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 78
  • 79. Don’t worry USA! British NHS IT system was abandoned after 10 years and cost the tax payer £10bn so far JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 79
  • 80. ▪ Innovate with optionality ▪ Constraints ▪ Build fast, fail fast ▪ Communication ▪ Technology == evolution JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 80
  • 81. JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 81 Executive Summary Hints and tips and where to go next
  • 82. Conclusions ▪ Leverage Java EE 7 platform ▪ Choose scope by lifespan of the bean ▪ Prefer Faces Flows for digital customer journeys ▪ Otherwise Conversation-Scoped beans ▪ Prefer HTML5 friendly markup of Facelets views ▪ Prefer CDI JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 82
  • 83. Conclusions #2 ▪ Protect your from UX changes ▪ Keep action controller methods short ▪ Delegate complex logic to business logic ▪ Use DOMAIN MODEL CONTEXT objects ▪ Avoid methods with long parameter lists! ▪ Inject DOMAIN MODEL LOGIC JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 83
  • 84. Contacts ▪ Follow me onTwitter @peter_pilgrim ▪ Read my blog http://xenonique.co.uk/blog/ ▪ Books from Packt Publishing –Digital Java EE 7 –Java EE 7 Developer Handbook JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 84
  • 85. Photo credits (cc) 2016 ▪ by Joshua Earle https://unsplash.com/joshuaearle ▪ By Lili Popper https://unsplash.com/lili_popper ▪ By Rowan Heuvel https://unsplash.com/insolitus ▪ By David Marcu https://stocksnap.io/author/302 JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 85
  • 86. Photo credits (cc) 2016 ▪ By Gemma Bou (hand fractal) https://www.flickr.com/photos/gemmabou/ ▪ By Nicole Hanusek (luggage) https://www.flickr.com/photos/nhanusek/ ▪ By Navaneeth KN (group photo painted stork) https://www.flickr.com/photos/navaneethkn/ ▪ By Ruben Schade (container ship in the Straits of Singapore) https://www.flickr.com/photos/rubenerd/ JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 86
  • 87. Photo credits (cc) 2016 ▪ Joel Cooper (big face 1) https://www.flickr.com/photos/origamijoel/ ▪ Nullfy from nullfy.com! (Ring of Power!) https://www.flickr.com/photos/130197050@N04/ ▪ philippe leroyer (Student Demonstration (46) - 27Nov07, Paris (France)) https://www.flickr.com/photos/philippeleroyer/ ▪ philippe leroyer (Pupil's Demonstration (10) - 10Apr08, Paris (France)) https://www.flickr.com/photos/philippeleroyer/ JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 87

Editor's Notes

  • #28: You probably need to use Java Web Filter mechanism to add the security domain to your request scope