Huge Enterprise Systems Architecture Design with Java EE

Post on 19-Mar-2017

82 views 0 download

Transcript of Huge Enterprise Systems Architecture Design with Java EE

@HirofumiIwasaki 1

Huge Enterprise Systems Architecture Design

with Java EE

Oct 22, 2016

Hirofumi Iwasaki

Group Manager, Rakuten Card Co., Ltd.

@HirofumiIwasaki 2

Speaker Biography

Hirofumi Iwasaki

– Group Manager

– New System Technology Group, New System Development Department, Rakuten Card Co., Ltd. (seconded from Rakuten, Inc.)

Carrier

– 17 Years of experience in planning, designing and implementation of Japanese financial, manufacturing and public enterprise system with emphasis in Java EE and .NET enterprise middleware.

Opus, Lectures, etc.

– Conferences: JavaOne 2015, 2014, Oracle OpenWorld 2014, Java Day Tokyo 2016 - 2014, JJUG CCC Spring & Fall (2014), WebLogic roundtable (2012-2013), Rakuten Tech Conference 2016 – 2013, etc.

– Book: デベロッパーのキャリアと働き方を語ろうVol.1 (2016)

– Magazine: 日経コンピュータ 2015年8月号@IT (2005-2010), CIO Magazine (2009), IT Architect (2005-2009), Web+DB Press (2005), Java World (2001-2004), etc.

@HirofumiIwasaki 3

Agenda

1. Enterprise Systems and its Features

2. Java EE Specifications for Enterprise Systems

3. Java EE Applying Points for Real Enterprise Systems

a) Start Application Design with Java EE

b) Specify IDE for Modern Development Style

c) Web Front-End with JSF

d) Business Logic with EJB or CDI

e) Data Access with JPA

f) Connectivity with RMI-IIOP, REST and WebSocket

@HirofumiIwasaki 4

About the Enterprise Systems

Enterprise systems (ES) are large-scale application software

packages that support business processes, information flows,

reporting, and data analytics in complex organizations.

-(from Wikipedia "Enterprise Systems")

@HirofumiIwasaki 5

Enterprise Software on Enterprise Systems

Enterprise software, also known as enterprise application

software (EAS), is computer software used to satisfy the needs

of an organization rather than individual users. Such

organizations would include businesses, schools, interest-based

user groups, clubs, charities, or governments.[1] Enterprise

software is an integral part of a (computer-based) information

system.

Enterprise

Systems

Enterprise

Software

@HirofumiIwasaki 6

Non-Functional Requirements of Enterprise Software

Enterprise Software

ACID Transaction Management

Distributed

Transaction

Management

Efficient Database

& MQ Connectivity

Variety of

Communication

Protocols

Frameworks of

Web Systems and

Mobile Apps

Efficient

Development

EnvironmentSecurity

Management, etc.

@HirofumiIwasaki 7

Custom? or Packaged? on Enterprise Systems

Packaging Software

Approach

Custom Software

Approach

For strong area of the

enterprise.

Specialties of the

competitiveness,

depends on each

industries.

For non strong area of

the enterprise.

E.g. HR, accounting,

information sharing

systems, etc.

@HirofumiIwasaki 8

Custom? or Packaged? on Enterprise Systems

Packaging Software

Approach

Custom Software

Approach

For strong area of the

enterprise.

Specialties of the

competitiveness,

depends on each

industries.

For non strong area of

the enterprise.

E.g. HR, accounting,

information sharing

systems, etc.

@HirofumiIwasaki 9

For Start Making Custom Enterprise Software

Maturity for Huge Mission Critical Systems

Open S

tandard

, C

om

munity P

ow

er

Microsoft .NET

Framework

Java EE

Open Source Platform

like PHP, etc.

Vendor Locked-In

Platform, like ABAP,

etc.

@HirofumiIwasaki 10

For Start Making Custom Enterprise Software

Maturity for Huge Mission Critical Systems

Open S

tandard

, C

om

munity P

ow

er

Microsoft .NET

Framework

Java EE

Open Source Platform

like PHP, etc.

Vendor Locked-In

Platform, like ABAP,

etc.

@HirofumiIwasaki 11

Summary: Select Java EE for Enterprise Apps

is even better platform for

Huge, mission critical systems.

Vendor free.

Larger community power.

Amount of engineers.

@HirofumiIwasaki 12

Agenda

1. Enterprise Systems and its Features

2. Java EE Specifications for Enterprise Systems

3. Java EE Applying Points for Real Enterprise Systems

a) Start Application Design with Java EE

b) Specify IDE for Modern Development Style

c) Web Front-End with JSF

d) Business Logic with EJB or CDI

e) Data Access with JPA

f) Connectivity with RMI-IIOP, REST and WebSocket

@HirofumiIwasaki 13

Java EE Overview

Java EE = Java Platform, Enterprise Edition

Java specification for enterprise systems, not light weight

systems.

– For other matured mission critical systems.

– Especially for financial industry systems.

@HirofumiIwasaki 14

Java EE Spec & App Servers

Java EE specification is managed by

Java community process (JCP).

Many vendors are making

Java EE app server

not only for commercial usage

but also for free. Specification

Java EE

App Servers

@HirofumiIwasaki 15

History of Java EE Specification

1999 2001 2003 2006 2009 2013 2017

J2EE 1.2 (Dec, 1999)

J2EE 1.3 (Sep, 2001)

J2EE 1.4 (Nov, 2003)

Java EE 5 (May, 2006)

Java EE 6 (May, 2006)

Project

JPE

Java EE 7

(June, 2013)

@HirofumiIwasaki 16

1999 2001 2003 2006 2009 2013

Java EE 7 Svrs

J2EE 1.2 Servers

Pre-J2EE

J2EE 1.3 Servers

J2EE 1.4 Servers

Java EE 5 Servers

Java EE 6 Servers

2017

History of Java EE Spec Servers

@HirofumiIwasaki 17

Combination of Java EE and Java SE

J2EE 1.2

(1999)

J2EE 1.3

(2001)

J2EE 1.4

(2003)

Java EE 5

(2006)

Java EE 6

(2009)

Java EE 7

(2013)

J2SE 1.2

(1998)

J2SE1.3

(2000)

J2SE1.4

(2002)

J2SE 5

(2004)

Java SE 6

(2006)

Java SE 7

(2011)

Java SE 8

(2014)

One EE specification, with latest SE version

Java EE 7 relies on SE 7

Sun

Microsystems Oracle

@HirofumiIwasaki 18

Enterprise Systems

Web Front End Business Logic Back End

@HirofumiIwasaki 19

Enterprise Systems and Java EE Specifications

JSF

Servlet

Web Front End Business Logic

JTA

CDI

EJB

Back End

JDBCRMI-

IIOP

JAX-

RSJPA

JMS

JAX-

WSWeb

Socket

JBatchJava

Mail

@HirofumiIwasaki 20

Standardization History of Java EE

J2EE 1.2

J2EE 1.3

J2EE 1.4

Java EE 5

Java EE 6

Java EE 7

Java EE 8

JD

BC

EJB

/JT

A/X

A/IIO

P

Serv

let/J

SP

JM

S

RM

I

SO

AP JP

A

JS

F/F

acele

t

RE

ST

CD

I

Java B

atc

h

Project JPE

or earlier

Web S

ocket

WebLogic

Hibernate

Spring Framework

@HirofumiIwasaki 21

New Specs of Java EE

J2EE 1.2

J2EE 1.3

J2EE 1.4

Java EE 5

Java EE 6

Java EE 7

Java EE 8

JD

BC

EJB

JS

P JM

S

RM

I

SO

AP JP

A

JS

F/F

acele

t

RE

ST

CD

I

Java B

atc

h

Project JPE

or earlier

Web S

ocket

EJB

Entity

Bean

JS

P

@HirofumiIwasaki 22

2017: Java EE 8 – Now RevisingO

rigin

al P

lan:

Fin

al R

ele

ase:

H1 2

017

Revis

ed

Pla

n:

Fin

al R

ele

ase:

Q3 2

017

Early

Draft

Public

Review

Propos

ed Final

Draft

Final

Release

2016 2017

Q3, 2017

1H, 2017, canceled

Public

Survey

Propos

ed Final

Draft

Final

Release

@HirofumiIwasaki 23

Agenda

1. Enterprise Systems and its Features

2. Java EE Specifications for Enterprise Systems

3. Java EE Applying Points for Real Enterprise Systems

a) Start Application Design with Java EE

b) Specify IDE for Modern Development Style

c) Web Front-End with JSF

d) Business Logic with EJB or CDI

e) Data Access with JPA

f) Connectivity with RMI-IIOP, REST and WebSocket

@HirofumiIwasaki 24

Application Design with Java EE: Keywords

App Server and

Version

Vendor

Selection

Java EE

Version

Commercial or

Free

Product

Roadmap

@HirofumiIwasaki 25

Rich Clients

Web Presentation Business Logic

(no presentations)

Typical Enterprise Systems

DBs

MQ

ConnectionOther

Servers

EMailMTA

Call

Call

Call

Call

Call

Call

Data Access

Messaging

@HirofumiIwasaki 26

Rich Clients

Web Presentation Business Logic

(no presentations)

Typical Usage of Java EE 7

JPA

EJBJSF

DBs

Java FX JTA

Automatic

Transaction

JMS MQ

Connection

RMI-IIOPOther

Servers

EMailMTAJavaMail

JAX

Call

Call

Call

Call

Call

Call

Data Access

Messaging

CDI

@HirofumiIwasaki 27

Use Latest Product, Latest Spec

I'll start my new project with

Java EE.

Which version should use?

Use latest product version,

with latest Java EE specification.

Because latest version is free of EOL,

greater APIs for ease of development.

@HirofumiIwasaki 29

Details of Java EE Application Servers

Vendor App Server EE 1.4

(2003-)

EE 5

(2006-)

EE 6

(2009-)

EE 7

(2013-)

Open Source GlassFish / Payara - 2.x 3.x 4.x

Oracle WebLogic 9.x 10.x 12.1 12.2

IBM WebSphere 5.1-6.x 7.0 8.5 8.5.5

Red Hat JBoss 4.x 5.1 6.0 7.0

Red Hat WildFly - - - 8.0-10.0

Hitachi Cosminexus 7.x 8.x 9.x 10.0

TmaxSoft JEUS 5.0 6.0 7.0 8.0

Fujitsu Interstage 9.0,9.1 9.2-11.0 11.1 -

Apache Geronimo - 2.x 3.x -

Apache TomEE - - 1.x -

@HirofumiIwasaki 31

Summary: Select Your Appropriate Server

Select the appropriate Java EE server.

Vendor

Applied Java EE version

Free or Commercial

Commercial support required or not

@HirofumiIwasaki 32

Agenda

1. Enterprise Systems and its Features

2. Java EE Specifications for Enterprise Systems

3. Java EE Applying Points for Real Enterprise Systems

a) Start Application Design with Java EE

b) Specify IDE for Modern Development Style

c) Web Front-End with JSF

d) Business Logic with EJB or CDI

e) Data Access with JPA

f) Connectivity with RMI-IIOP, REST and WebSocket

@HirofumiIwasaki 33

IDE: Keywords

IDE or Not

Repository

Building System

Productivity

Development

Standard

@HirofumiIwasaki 34

In 1990’s – early 2000’s

“Great Engineers” never

use such IDEs!

Instead, they use text editor!

*Is Japanese special habit not to use IDEs?

@HirofumiIwasaki 35

“Great Engineer” never

use such IDEs!

Instead, use text editor!

We’re now living in 2010’s

NEVER

Not good for productivity on

enterprise development.

Apply the latest technologies!

*Is Japanese special habit not to use IDEs?

@HirofumiIwasaki 36

Over 10,000 classes in real large systems

Crazy amount of

source codes!

@HirofumiIwasaki 37

Manage tons of codes with modern IDE

@HirofumiIwasaki 38

Summary: modern IDE for Java EE

@HirofumiIwasaki 39

De-Facto standard building tool

Determined with “pom.xml”

Automatic library downloading

Ease of use, script not supported

Determined with “build.gradle”

Automatic library downloading

Complex scripting supported

@HirofumiIwasaki 40

Three major IDEs support Maven in default setting

*Additional plugin required

* *“New Project” Dialogs:

@HirofumiIwasaki 41

“Special Project Files” are not required anymore with Maven

Maven Project are used by these three IDEs

@HirofumiIwasaki 42

Summary: recommendation to make Java EE project

Make project with ,

Enjoy programming with

(Choose anything you want)

@HirofumiIwasaki 43

Agenda

1. Enterprise Systems and its Features

2. Java EE Specifications for Enterprise Systems

3. Java EE Applying Points for Real Enterprise Systems

a) Start Application Design with Java EE

b) Specify IDE for Modern Development Style

c) Web Front-End with JSF

d) Business Logic with EJB or CDI

e) Data Access with JPA

f) Connectivity with RMI-IIOP, REST and WebSocket

@HirofumiIwasaki 44

Web Front-End: Keywords

Security

JavaServer

Faces (JSF)

Page Flow

HTTP

Facelet

Post Back

@HirofumiIwasaki 45

Rich Clients

Web Presentation Business Logic

(no presentations)

Typical usage of Java EE 7

JPA

EJBJSF

DBs

Java FX JTA

Automatic

Transaction

JMS MQ

Connection

RMI-IIOPOther

Servers

EMailMTAJavaMail

JAX

Call

Call

Call

Call

Call

Call

Data Access

Messaging

CDI

@HirofumiIwasaki 48

Paradigm Changes: From 2000's to 2010's

<<JSP>>

View1

<<JSP>>

View 2

Action1

+ action()

<<JSP>>

View 3Action2

+ action()

ActionForm1- fields+ validate()

ActionForm2- fields+ validate()

Operate

Action

Build

Next View

Operate

Action

Build

Next View

<Facelet>

View 1Backing1- fields+ load()

+ action()

<Facelet>

View 2Backing2- fields+ load()

+ action()

<Facelet>

View 3Backing3- fields+ load()

+ action()

Front View

& Backing Bean

1.x

@HirofumiIwasaki 50

Security Countermeasures and JSF

Cross Site

Scripting

(XSS)

Cross Site

Request Forgery

(CSRF)

Output values to

HTML with escaping.

Requirement

Output one time

token for next page

transitions.

JSF

Automatically

operated

Automatically

operated

@HirofumiIwasaki 52

Agenda

1. Enterprise Systems and its Features

2. Java EE Specifications for Enterprise Systems

3. Java EE Applying Points for Real Enterprise Systems

a) Start Application Design with Java EE

b) Specify IDE for Modern Development Style

c) Web Front-End with JSF

d) Business Logic with EJB or CDI

e) Data Access with JPA

f) Connectivity with RMI-IIOP, REST and WebSocket

@HirofumiIwasaki 53

Business Logic: Keywords

Enterprise

JavaBeans

(EJB)

Context and

Dependency

Injection (CDI)

JBatch

Transaction

Management

Container

Managed

Transaction

(CMT)

@HirofumiIwasaki 54

Rich Clients

Web Presentation Business Logic

(no presentations)

Typical usage of Java EE 7

JPA

EJBJSF

DBs

Java FX JTA

Automatic

Transaction

JMS MQ

Connection

RMI-IIOPOther

Servers

EMailMTAJavaMail

JAX

Call

Call

Call

Call

Call

Call

Data Access

Messaging

CDI

@HirofumiIwasaki 56

Review: What’s EJB? Why EJB?

EJBClient

1. Remote Invocation

EJB

2. Automatic Transaction Management

Database

(BEGIN)

(COMMIT)

EJB

EJBEJB

EJB

Instance

Pool

Activate

3. Instance Pooling for Faster Operation

RMI-IIOP

SOAP

REST

Web Socket

EJBClient

4. Security Management

@HirofumiIwasaki 57

Review: CDI – Light Version of EJB

CDIClient

1. Remote Invocation

CDI

2. Automatic Transaction Management

Database

(BEGIN)

(COMMIT)

EJB

EJB

Instance

Pool

Activate

3. Instance Pooling for Faster Operation

RMI-IIOP

SOAP

REST

Web Socket

Client

4. Security Management

Few Functions, Faster Deployment

@HirofumiIwasaki 58

POJO

Java EE ServerJava EE Server

Java Batch

How Design the Batch Logics?

Choice 1: Use EJB/CDI,

Call via EJB/CDI Remote

from Outside

EJB

Batch

Batch

Kicker Call

Choice 2: Use

Java Batch Framework,

Call from Outside

Batch

Kicker Call

Choice 3:

Micro Service

(Java EE 9 style)

Batch

Kicker Call

Full automatic transaction,

Able to use embedded server.

If the standard templates

suitable for your app, try it.

Not released yet, but you can

try with Payara Micro now.

@HirofumiIwasaki 60

Agenda

1. Enterprise Systems and its Features

2. Java EE Specifications for Enterprise Systems

3. Java EE Applying Points for Real Enterprise Systems

a) Start Application Design with Java EE

b) Specify IDE for Modern Development Style

c) Web Front-End with JSF

d) Business Logic with EJB or CDI

e) Data Access with JPA

f) Connectivity with RMI-IIOP, REST and WebSocket

@HirofumiIwasaki 61

Data Access: Keywords

Java

Persistence API

(JPA)

Data Access

Object (DAO)

JDBC

Auto

Generation

Java

Persistence

Query

Language

(JPQL)

@HirofumiIwasaki 62

Rich Clients

Web Presentation Business Logic

(no presentations)

Typical usage of Java EE 7

JPA

EJBJSF

DBs

Java FX JTA

Automatic

Transaction

JMS MQ

Connection

RMI-IIOPOther

Servers

EMailMTAJavaMail

JAX

Call

Call

Call

Call

Call

Call

Messaging

Data Access

CDI

@HirofumiIwasaki 63

About JPA – Java Persistence API

Java Persistence API

(from Java EE 5)

@HirofumiIwasaki 64

JPA – Simple Database Mapper

Relational Database

(E-R Diagram)

One by One

JPA Entity

(Class Diagram)

Auto Generate

With Bean Validation

@HirofumiIwasaki 65

JPA – Simple Database Mapper

JPA Entity

JPA Data Access Object (DAO)

Auto CRUD

to Database

Access to RDB

@HirofumiIwasaki 66

public List<Member> findMemberByName(String name) {

String queryString = "SELECT a FROM Member m " +

"WHERE m.name = LOWER(:name)";

Query query = getEntityManager().createQuery(queryString);

query.setParameter("name", name);

List<Member> result = query.getResultList();

}

JPA Custom Queries – JPQL and Criteria QueryJPQL:

Criteria Query:

public List<Member> findMemberByName(String name) {

CriteriaBuilder builder = this.em.getCriteriaBuilder();

CriteriaQuery query = builder.createQuery();

Root<Member> member = query.from(Member.class);

query.select(member);

query.where(builder.equal(member.get(”name"), name));

List<Member> result = this.em.createQuery(query).getResultList();

}

@HirofumiIwasaki 67

JTA Transaction

Management

Java EE Application

EJB Business Logic

Why You Should Not Use Raw JDBC in Java EE?

Java EE Application Server

Java VM

Connection

Pool

EJB Object

Pool

Thread

PoolSelf-Managed

JDBC Connection

JPA

Entity Manager

JNDI

JDBC

Driver Manager

RAW

?

?No Global Transaction

No Connection Management

@HirofumiIwasaki 69

Summary: Use JPA, Instead of Raw JDBC.

Apply JPA ordinarily for data,

within the EJB / CDI

Container

Managed Transaction

(CMT)

@HirofumiIwasaki 70

Agenda

1. Enterprise Systems and its Features

2. Java EE Specifications for Enterprise Systems

3. Java EE Applying Points for Real Enterprise Systems

a) Start Application Design with Java EE

b) Specify IDE for Modern Development Style

c) Web Front-End with JSF

d) Business Logic with EJB or CDI

e) Data Access with JPA

f) Connectivity with RMI-IIOP, REST and WebSocket

@HirofumiIwasaki 71

Connectivity: Keywords

RMI over IIOP

(RMI-IIOP)

Web Services

JAX-WS

Web Socket

+ JSON

Remote Method

Invocation

(RMI)

REST + JSONGlobal

Transaction

(XA)

@HirofumiIwasaki 72

Review: What’s EJB? Why EJB?

EJBClient

1. Remote Invocation

EJB

2. Automatic Transaction Management

Database

(BEGIN)

(COMMIT)

EJB

EJBEJB

EJB

Instance

Pool

Activate

3. Instance Pooling for Faster Operation

RMI-IIOP

SOAP

REST

Web Socket

EJBClient

4. Security Management

@HirofumiIwasaki 73

Supported protocols of Java EE 7 (EJB)

Protocol Supported

From

Annotation Client Stub Value

Marshaling

Global

Transaction

RMI-IIOP J2EE 1.2 @Remote in

remote interface

Remote interface

with auto generate

Auto XA Supported

SOAP Java EE 5 @WebService Auto generate in

development

Auto N/A

REST Java EE 6 @GET, @POST,

etc.

(Nothing special) Work with JSON

or something

(string base)

N/A

Web Socket Java EE 7 @ServerEndpoint @ClientEndpoint

with auto generate

Work with JSON

or something

(string base)

N/A

@HirofumiIwasaki 74

Global Transaction

Management

with XA Protocol

For heavy transaction: consider RMI-IIOP

EJB

Session BeanClient RMI-IIOP

Other

System’s

EJB

Database

Other

Enterprise

Information

Systems

IIOP

AUTO

BEGIN

AUTO

COMMIT

@HirofumiIwasaki 75

For light-weight usage: consider Web Socket / REST + JSON

Local Transaction

Management

EJB

Session BeanClient Web Socket or REST

Database

AUTO

BEGIN

AUTO

COMMIT

Ultra-Fast,

Ease of Dev.

@HirofumiIwasaki 76

EJB Session Bean with RMI-IIOP and Web Socket

@Stateless

@Remote

@ServerEndpoint(value = "/memberlogic")

public class MemberLogic implements MemberLogicRemote {

@OnMessage

public String register(String message, Session session) {

// WRITE TRANSACTIONAL LOGICS HERE!

return xxxx;

}

}

EJB

RMI-IIOP

Web Socket

Some ClientsTransactional

Processing

for RMI-IIOP

for Web Socket

for RMI-IIOPfor Web Socket

@HirofumiIwasaki 77

Summary: Recommendation of Protocols

Select the RMI-IIOP

for heavy transactional distributed systems.

Select the Web Socket or REST

for system that requires light-weight and

faster speed.

@HirofumiIwasaki 78

Summary

Enterprise systems require many mission critical basement.

Java EE is one of the best platform on the aspect of the vendor free.

Consider many critical points when Java EE design & development start.

@HirofumiIwasaki 79

Contact

Hirofumi Iwasaki (@HirofumiIwasaki)

We’re Hiring!!

Rakuten.Careers