SlideShare a Scribd company logo
Vaadin with
Java EE 7
Java EE 7
Vaadin
CDI
Addon
Application
architecture
Hack
Hack
Hack
Java
Enterprise Edition 7
Collection of Java Specification
Requests (JSRs)
Collection of Java Specification
Requests (JSRs)
Implemented by app servers
JavaEE with Vaadin - Workshop
JavaEE with Vaadin - Workshop
Do you know some
Java EE specs?
Java Persistence
API 2.1 (JPA)

(JSR-338)
Java Persistence
API 2.1 (JPA)

(JSR-338)
Enterprise Java
Beans 3.2 (EJB)

(JSR-345)
Java Persistence
API 2.1 (JPA)

(JSR-338)
Enterprise Java
Beans 3.2 (EJB)

(JSR-345)
Java Servlet 3.1

(JSR-340)
Java Persistence
API 2.1 (JPA)

(JSR-338)
Enterprise Java
Beans 3.2 (EJB)

(JSR-345)
Java Servlet 3.1

(JSR-340)
Context and 

Dependency

Injection 1.2(CDI)

(JSR-340)
Java Persistence
API 2.1 (JPA)

(JSR-338)
Enterprise Java
Beans 3.2 (EJB)

(JSR-345)
Java Servlet 3.1

(JSR-340)
Context and 

Dependency

Injection 1.2(CDI)

(JSR-340)
Interceptors 1.2

(JSR-318)
Java Persistence
API 2.1 (JPA)

(JSR-338)
Enterprise Java
Beans 3.2 (EJB)

(JSR-345)
Java Servlet 3.1

(JSR-340)
Context and 

Dependency

Injection 1.2(CDI)

(JSR-340)
Interceptors 1.2

(JSR-318)
Java Transaction
API 1.2 (JTA)

(JSR-907)
Java Persistence API 2.1
(JPA)
Customer
@Entity
______________________________
@Id

@AutoGenerated

Long id;

@Column(nullable = false)

String name;

Date birthdate;
Customer
@Entity
______________________________
Customer
Id name birthdate
1 Alex 07.02.1984
2 John 18.2.1992
@Id

@AutoGenerated

Long id;

@Column(nullable = false)

String name;

Date birthdate;
Customer
@Id

@AutoGenerated

Long id;

@Column(nullable = false)

String name;

Date birthdate;

@OneToMany(mappedBy=“customer”)

List<Invoice> invoices;
@Entity
______________________________
Customer
Id name birthdate
1 Alex 07.02.1984
2 John 18.2.1992
Invoice
Id customer number
1 1 123
2 1 124
Enterprise Java Beans 3.2 

(EJB)
Business layer services
Enterprise Java Beans
Business layer services
@local and @remote
Enterprise Java Beans
Business layer services
@local and @remote
Enterprise Java Beans
Transaction boundaries
(UI)
CustomerView
(@Remote)
CustomerService

(UI)
CustomerView

@Remote
@Local
(@Remote)
CustomerService

(UI)
CustomerView

(@Stateless)
CustomerService

Bean

@Remote
@Local
@Stateless
@Stateful
@Singleton
(@Stateless)
CustomerService

Bean

(@Stateless)
CustomerService

Bean
(DB)
Customer

Database
@Local
public interface CustomerService {
void storeCustomers(Collection<Customer> customers);
void removeCustomers(Collection<Customer> customers);
Collection<Customer> getAllCustomers()
Optional<Customer> getCustomerByName(String name);
}
@Stateless
public class CustomerServiceBean implements
CustomerService {
@PersistenceContext
private EntityManager em;
public void storeCustomers(Collection<Customer> cu) {
cu.forEach(c -> storeCustomer(c));
}
public void storeCustomer(Customer c) {
em.persist(c);
}
}
Context and 

Dependency

Injection 1.2 (CDI)
Instead of saying new say @Inject
Context and Dependency
Injection
Instead of saying new say @Inject
Decouples code and lets container
manage dependencies
Context and Dependency
Injection
Object references by scopes
Context and Dependency
Injection
@ApplicationScoped
@SessionScoped
@RequestScoped
Context and Dependency
Injection
Object references by scopes
@UIScoped
@ViewScoped
Context and Dependency
Injection
@ApplicationScoped
@SessionScoped
@RequestScoped
Object references by scopes
@Stateless
CustomerService

_________________

@UIScoped
AppUI

_________________

@EJB

CustomerService service;
@Stateless
InvoiceService

@Stateless
CustomerService

_________________

@EJB

InvoiceService invoices;
@UIScoped
AppUI

_________________

@EJB

CustomerService service;
@Stateless
CustomerService

_________________

@EJB

InvoiceService invoices;
@UIScoped
AppUI

_________________

@EJB

CustomerService service;

@Inject

MainMenu mainMenu;

@Inject

User currentUser;
@UIScoped
MainMenu

_________________

@Inject

Event<MenuEvent> menuEventSource;
@Stateless
InvoiceService
@UIScoped
AppUI
_____________________________
@Inject

private MainMenu menu;

@Inject

private ViewManager viewMgr;

@Inject

private User loggedInUser;

<<UIScope>>
MainMenu

ViewManager

<<SessionScope>>
User
<<UIScope>>
MenuBar

Footer

ViewManager

<<SessionScope>>
User

@UIScoped
AppUI
_____________________________
@Inject

private MenuBar menu;

@Inject

private ViewManager viewMgr;

@Inject

private User loggedInUser;

<<UIScope>>
MenuBar

Footer

ViewManager

<<UIScope>>
MenuBar

Footer

ViewManager

<<UIScope>>
MenuBar

ViewManager
Integration to EE through
Vaadin CDI
Managed UI with @CDIUI
Managed UI with @CDIUI
Allows injection with @Inject and @EJB
Easily reference EE objects
Allows injection with @Inject and @EJB
Managed UI with @CDIUI
@CDIUI(“”)
public class AppUI extends UI {
}
@CDIUI(“”)
public class AppUI extends UI {
@Inject
private MainMenu mainMenu;
@Inject
private User currentUser;
@Inject
private ViewManager viewManager;
public void init(VaadinRequest request) {
VerticalLayout layout = new VerticalLayout();
layout.addComponent(mainMenu);
setContent(layout);
}
}
@UIScoped
@UIScoped
UI specific bean references
@UIScoped
UI specific bean references
CDI context for mapping beans per UI
@UIScoped
UI specific bean references
CDI context for mapping beans per UI
@UIScoped
@UIScoped
public class MainMenu extends CustomComponent {
}
@UIScoped
public class MainMenu extends CustomComponent {
@Inject
private Event<NavigationEvent> eventSource;
protected void onMenuItemClicked(MenuItem item) {
eventSource.fireEvent(new NavigationEvent(item));
}
}
@CDIUI(“”)
public class AppUI extends UI {
…
protected void onNavigationEvent(@Observes
NavigationEvent event) {
viewMgr.navigateTo(event.getView());
}
}
Application
Architecture
Client
Browser
View
<<EJB>>
Business
Logic
Server-side-UI
Presenter
<<JPA>>
Persistency
Business Persistency
Client
Browser
View
Server-side-UI
public interface CustomerView extends
ApplicationView<CustomerViewPresenter> {
}
public interface CustomerView extends
ApplicationView<CustomerViewPresenter> {
void populateCustomers(Collection<Customer> customers);
void openEditorFor(Customer customer);
void closeEditor();
void removeTableSelection();
}
Client
Browser
View
Server-side-UI
Presenter
@ViewScoped
public class CustomerViewPresenter extends AbstractPresenter<CustomerView> {
}
@ViewScoped
public class CustomerViewPresenter extends AbstractPresenter<CustomerView> {
@EJB
private CustomerService customerService;
@Override
protected void onViewEnter() {
getView().populateCustomers(customerService.getAllCustomers());
}
}
@ViewScoped
public class CustomerViewPresenter extends AbstractPresenter<CustomerView> {
@EJB
private CustomerService customerService;
@Override
protected void onViewEnter() {
getView().populateCustomers(customerService.getAllCustomers());
}
public void onCustomerSaved(@Observes CustomerSavedEvent event) { … }
public void onCustomerRemoved(@Observes CustomerRemovedEvent event) { … }
public void onCustomerSelected(@Observes CustomerSelectedEvent event) { … }
}
Client
Browser
View
<<EJB>>
Business
Logic
Server-side-UI
Presenter
Business
@Local
public interface CustomerService {
void storeCustomers(Collection<Customer> customers);
void removeCustomers(Collection<Customer> customers);
Collection<Customer> getAllCustomers();
Optional<Customer> getCustomerByUsername(String username);
}
Application
Architecture
@Stateless
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class CustomerServiceBean implements CustomerService {
@PersistenceContext(unitName = "appUnit")
private EntityManager entityManager;
@Override
public void storeCustomers(Collection<Customer> customers) {
customers.forEach(cu -> entityManager.merge(cu));
}
@Override
public Collection<Customer> getAllCustomers() {
return entityManager.createQuery(query).getResultList();
}
…
}
Client
Browser
View
<<EJB>>
Business
Logic
Server-side-UI
Presenter
<<JPA>>
Persistency
Business Persistency
Application
Architecture
@Entity
public class Customer {
@Id
@AutoGenerated
private Long id;
private String name;
@Temporal(DATE)
private Date birthDate;
public boolean isPersisted() {
return id != null;
}
…
}
<persistence-unit name="appUnit" transaction-type="JTA">
<jta-data-source>jdbc/app-backend</jta-data-source>
<class>org.vaadin.example.backend.entity.Customer</class>
<properties>
<property name="…" … />
</properties>
</persistence-unit>
github.com/peterl1084/
customermanager

More Related Content

What's hot (20)

PDF
Vaadin JPAContainer
cmkandemir
 
PDF
Vaadin Flow - JavaLand 2018
Peter Lehto
 
PDF
Vaadin DevDay 2017 - Web Components
Peter Lehto
 
PDF
Introduction to Spring's Dependency Injection
Richard Paul
 
ODT
Spring IOC advantages and developing spring application sample
Sunil kumar Mohanty
 
PDF
Vaadin DevDay 2017 - Data Binding in Vaadin 8
Peter Lehto
 
PDF
Building web apps with Vaadin 8
Marcus Hellberg
 
PPT
Android应用开发简介
easychen
 
PDF
Vaadin 7 CN
jojule
 
PDF
Web Components for Java Developers
Joonas Lehtinen
 
ODT
Types of Dependency Injection in Spring
Sunil kumar Mohanty
 
PDF
Vaadin Components @ Angular U
Joonas Lehtinen
 
PPTX
Spring andspringboot training
Mallikarjuna G D
 
PDF
Extending Java EE with CDI and JBoss Forge
Antoine Sabot-Durand
 
PDF
Vaadin Components
Joonas Lehtinen
 
ODP
OpenWebBeans/Web Beans
Gurkan Erdogdu
 
PDF
Spring Framework -I
People Strategists
 
PDF
Keycloak Single Sign-On
Ravi Yasas
 
PPTX
Dependency injection with unity 2.0 Dmytro Mindra Lohika
Alex Tumanoff
 
PPTX
Agile methodologies based on BDD and CI by Nikolai Shevchenko
Moldova ICT Summit
 
Vaadin JPAContainer
cmkandemir
 
Vaadin Flow - JavaLand 2018
Peter Lehto
 
Vaadin DevDay 2017 - Web Components
Peter Lehto
 
Introduction to Spring's Dependency Injection
Richard Paul
 
Spring IOC advantages and developing spring application sample
Sunil kumar Mohanty
 
Vaadin DevDay 2017 - Data Binding in Vaadin 8
Peter Lehto
 
Building web apps with Vaadin 8
Marcus Hellberg
 
Android应用开发简介
easychen
 
Vaadin 7 CN
jojule
 
Web Components for Java Developers
Joonas Lehtinen
 
Types of Dependency Injection in Spring
Sunil kumar Mohanty
 
Vaadin Components @ Angular U
Joonas Lehtinen
 
Spring andspringboot training
Mallikarjuna G D
 
Extending Java EE with CDI and JBoss Forge
Antoine Sabot-Durand
 
Vaadin Components
Joonas Lehtinen
 
OpenWebBeans/Web Beans
Gurkan Erdogdu
 
Spring Framework -I
People Strategists
 
Keycloak Single Sign-On
Ravi Yasas
 
Dependency injection with unity 2.0 Dmytro Mindra Lohika
Alex Tumanoff
 
Agile methodologies based on BDD and CI by Nikolai Shevchenko
Moldova ICT Summit
 

Similar to JavaEE with Vaadin - Workshop (20)

PDF
JavaCro'15 - Web UI best practice integration with Java EE 7 - Peter Lehto
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
PDF
JavaCro'14 - Vaadin web application integration for Enterprise systems – Pete...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
ODP
JavaEE Spring Seam
Carol McDonald
 
PDF
Moving to Java EE 6 and CDI and away from the clutter
Dan Allen
 
PPTX
Java EE 6
Geert Pante
 
PPTX
Top 50 java ee 7 best practices [con5669]
Ryan Cuprak
 
PDF
Java Ide Day 2008 - Presentation on JDeveloper by Paolo Ramasso
JUG Genova
 
DOCX
Se276 enterprise computingassignment
harinathinfotech
 
PDF
Beginning java ee_7
Rodrigo Hiemer
 
PDF
Seam Glassfish Perspective
Eduardo Pelegri-Llopart
 
PDF
Andrei Niculae - JavaEE6 - 24mai2011
Agora Group
 
PPTX
Go Fullstack: JSF for Public Sites (CONFESS 2013)
Michael Kurz
 
PDF
Contextual Dependency Injection for Apachecon 2010
Rohit Kelapure
 
DOC
J2EE Online Training
Srihitha Technologies
 
PPT
EJB 3.0 Java Persistence with Oracle TopLink
Bill Lyons
 
PPTX
Java EE vs Spring Framework
Rohit Kelapure
 
PPT
Java EE and Spring Side-by-Side
Reza Rahman
 
PDF
Java EE 與 雲端運算的展望
javatwo2011
 
ODP
Javaee6 Overview
Carol McDonald
 
PPT
J2 ee architecture
saurabhshertukde
 
JavaCro'15 - Web UI best practice integration with Java EE 7 - Peter Lehto
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
JavaCro'14 - Vaadin web application integration for Enterprise systems – Pete...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
JavaEE Spring Seam
Carol McDonald
 
Moving to Java EE 6 and CDI and away from the clutter
Dan Allen
 
Java EE 6
Geert Pante
 
Top 50 java ee 7 best practices [con5669]
Ryan Cuprak
 
Java Ide Day 2008 - Presentation on JDeveloper by Paolo Ramasso
JUG Genova
 
Se276 enterprise computingassignment
harinathinfotech
 
Beginning java ee_7
Rodrigo Hiemer
 
Seam Glassfish Perspective
Eduardo Pelegri-Llopart
 
Andrei Niculae - JavaEE6 - 24mai2011
Agora Group
 
Go Fullstack: JSF for Public Sites (CONFESS 2013)
Michael Kurz
 
Contextual Dependency Injection for Apachecon 2010
Rohit Kelapure
 
J2EE Online Training
Srihitha Technologies
 
EJB 3.0 Java Persistence with Oracle TopLink
Bill Lyons
 
Java EE vs Spring Framework
Rohit Kelapure
 
Java EE and Spring Side-by-Side
Reza Rahman
 
Java EE 與 雲端運算的展望
javatwo2011
 
Javaee6 Overview
Carol McDonald
 
J2 ee architecture
saurabhshertukde
 
Ad

More from Peter Lehto (6)

PDF
Vaadin 8 and 10
Peter Lehto
 
PDF
Vaadin 8 - Data Binding with Binder
Peter Lehto
 
PDF
GWT integration with Vaadin
Peter Lehto
 
PDF
Remote controlling Parrot AR Drone with Spring Boot & Vaadin (JavaCro15)
Peter Lehto
 
PDF
Remote controlling Parrot AR drone with Vaadin & Spring Boot @ GWT.create
Peter Lehto
 
PDF
WebApp controlled Parrot AR Drone with Vaadin and Spring Boot
Peter Lehto
 
Vaadin 8 and 10
Peter Lehto
 
Vaadin 8 - Data Binding with Binder
Peter Lehto
 
GWT integration with Vaadin
Peter Lehto
 
Remote controlling Parrot AR Drone with Spring Boot & Vaadin (JavaCro15)
Peter Lehto
 
Remote controlling Parrot AR drone with Vaadin & Spring Boot @ GWT.create
Peter Lehto
 
WebApp controlled Parrot AR Drone with Vaadin and Spring Boot
Peter Lehto
 
Ad

Recently uploaded (20)

PDF
I Want to join occult brotherhood for money ritual#((+2347089754903))
haragonoccult
 
PDF
The Convergence of Threat Behaviors Across Intrusions
Joe Slowik
 
PDF
Beginning-Laravel-Build-Websites-with-Laravel-5.8-by-Sanjib-Sinha-z-lib.org.pdf
TagumLibuganonRiverB
 
PDF
03 Internal Analysis Strategik Manajemen.pdf
AhmadRifaldhi
 
PDF
What Is Google Chrome? Fast & Secure Web Browser Guide
hgfdsqetuiplmnvcz43
 
PDF
Google Chrome vs Other Browsers: Why Users Still Prefer It.pdf
hgfdsqetuiplmnvcz43
 
PPTX
My Mother At 66! (2).pptx00000000000000000000000000000
vedapattisiddharth
 
PDF
Slides: Eco Economic Epochs for The World Game (s) pdf
Steven McGee
 
PDF
Transmission Control Protocol (TCP) and Starlink
APNIC
 
PDF
web application development company in bangalore.pdf
https://dkpractice.co.in/seo.html tech
 
PPTX
BitRecover OST to PST Converter Software
antoniogosling01
 
PPTX
Q1 English3 Week5 [email protected]
JenniferCawaling1
 
PDF
ContextForge MCP Gateway - the missing proxy for AI Agents and Tools
Mihai Criveti
 
PPTX
Lesson 1.1 Career-Opportunities-in-Ict.pptx
lizelgumadlas1
 
PPTX
The ARUBA Kind of new Proposal Umum .pptx
andiwarneri
 
PDF
Download Google Chrome for Fast and Secure Web Browsing Experience
hgfdsqetuiplmnvcz43
 
PDF
B M Mostofa Kamal Al-Azad [Document & Localization Expert]
Mostofa Kamal Al-Azad
 
PPTX
原版一样(ANU毕业证书)澳洲澳大利亚国立大学毕业证在线购买
Taqyea
 
PPTX
Class_4_Limbgvchgchgchgchgchgcjhgchgcnked_Lists.pptx
test123n
 
PDF
Materi tentang From Digital Economy to Fintech.pdf
Abdul Hakim
 
I Want to join occult brotherhood for money ritual#((+2347089754903))
haragonoccult
 
The Convergence of Threat Behaviors Across Intrusions
Joe Slowik
 
Beginning-Laravel-Build-Websites-with-Laravel-5.8-by-Sanjib-Sinha-z-lib.org.pdf
TagumLibuganonRiverB
 
03 Internal Analysis Strategik Manajemen.pdf
AhmadRifaldhi
 
What Is Google Chrome? Fast & Secure Web Browser Guide
hgfdsqetuiplmnvcz43
 
Google Chrome vs Other Browsers: Why Users Still Prefer It.pdf
hgfdsqetuiplmnvcz43
 
My Mother At 66! (2).pptx00000000000000000000000000000
vedapattisiddharth
 
Slides: Eco Economic Epochs for The World Game (s) pdf
Steven McGee
 
Transmission Control Protocol (TCP) and Starlink
APNIC
 
web application development company in bangalore.pdf
https://dkpractice.co.in/seo.html tech
 
BitRecover OST to PST Converter Software
antoniogosling01
 
ContextForge MCP Gateway - the missing proxy for AI Agents and Tools
Mihai Criveti
 
Lesson 1.1 Career-Opportunities-in-Ict.pptx
lizelgumadlas1
 
The ARUBA Kind of new Proposal Umum .pptx
andiwarneri
 
Download Google Chrome for Fast and Secure Web Browsing Experience
hgfdsqetuiplmnvcz43
 
B M Mostofa Kamal Al-Azad [Document & Localization Expert]
Mostofa Kamal Al-Azad
 
原版一样(ANU毕业证书)澳洲澳大利亚国立大学毕业证在线购买
Taqyea
 
Class_4_Limbgvchgchgchgchgchgcjhgchgcnked_Lists.pptx
test123n
 
Materi tentang From Digital Economy to Fintech.pdf
Abdul Hakim
 

JavaEE with Vaadin - Workshop