a4m36jee pokročilé java technologie: jboss Část 1. - Úvod ... · a4m36jee pokročilé java...

30
a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod, Java EE 7 Jiří Pechanec listopad 2014

Upload: others

Post on 09-Jul-2020

13 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod ... · a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod, Java EE 7 Jiří Pechanec listopad 2014

a4m36jee Pokročilé Java technologie:

JBoss

Část 1. - Úvod, Java EE 7

Jiří Pechanec

listopad 2014

Page 2: a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod ... · a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod, Java EE 7 Jiří Pechanec listopad 2014

2

Agenda

Introduction Course information Tools Java EE 7

Page 3: a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod ... · a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod, Java EE 7 Jiří Pechanec listopad 2014

3

Motivation

Bring the latest information about Java EE technologies Provide information about JBoss projects Feedback NEEDED

Page 4: a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod ... · a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod, Java EE 7 Jiří Pechanec listopad 2014

4

Organization

6 lessons● Presentation followed by practical training

● Source code available in public Evaluation based on a homework project developed using

Java EE 7 technologies Project is expected to be deployed and run on OpenShift

PaaS

Page 5: a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod ... · a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod, Java EE 7 Jiří Pechanec listopad 2014

5

Topics

Introduction to Java EE 7 CDI 1.1, EJB 3.2 HTML5 – WebSockets, JSON, REST Datagrids, Infinispan Java EE security Clustering and scalability in WildFly 8 Management and monitoring

Page 6: a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod ... · a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod, Java EE 7 Jiří Pechanec listopad 2014

6

Tools

WildFly 8 Final JBoss Developer Studio 7 Maven Git You can use any IDE you want

● But only JBDS is supported by teachers

Page 7: a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod ... · a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod, Java EE 7 Jiří Pechanec listopad 2014

7

Java EE 7 (1/2)

New/major upgrade specifications for web 2.0 apps● WebSocket 1.0● JSON-P 1.0● JAX-RS 2.0

New/major upgrade specifications for backend● Batch Applications 1.0● Concurrency 1.0● JMS 2.0

Page 8: a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod ... · a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod, Java EE 7 Jiří Pechanec listopad 2014

8

Java EE 7 (2/2)

Minor updates (not comprehensive)● CDI 1.1● JSF 2.2● Bean Validation 1.1● JPA 1.1● JTA 1.2● Servlet 3.1

Other updates● EL 3.0

Page 9: a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod ... · a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod, Java EE 7 Jiří Pechanec listopad 2014

9

Concurrency Utilities 1.0 (1/2)

Application managed multithreading Based on java.util.concurrent infrastructure

● ExecutorService● ScheduleExecutorService● ThreadFactory

Page 10: a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod ... · a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod, Java EE 7 Jiří Pechanec listopad 2014

10

Concurrency Utilities 1.0 (2/2)

Java EE 7 counterparts● ManagedExecutorService● ManagedScheduledExecutorService● ManagedThreadFactory

Configured in container● @Resource

ContextService● Allows execution of task in a context of current thread

● e.g. security Tasks/threads run in its own transaction

Page 11: a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod ... · a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod, Java EE 7 Jiří Pechanec listopad 2014

11

Batch Applications 1.0 (1/8)

For non-interactive long-running tasks Usually very big, running in the night Typical uses cases

● Billing● Clearing (banks)● Bulk data processing● Mass customer operations

Page 12: a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod ... · a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod, Java EE 7 Jiří Pechanec listopad 2014

12

Batch Applications 1.0 (2/8)

Page 13: a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod ... · a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod, Java EE 7 Jiří Pechanec listopad 2014

13

Batch Applications 1.0 (3/8)

Job is a sequence of Steps Step is

● A simple Batchlet● Or a combination of reader/processor/writer

JobOperator manages jobs (starts/stops) and is an interface to JobRepository

JobRepository stores information about running and past Jobs

Id of classes● CDI name (@Named)● XML file

Page 14: a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod ... · a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod, Java EE 7 Jiří Pechanec listopad 2014

14

Batch Applications 1.0 (4/8)

Packaging● Class ids in

● META-INF/batch.xml● Job definitions

● META-INF/batch-jobs/<jobname>.xml

API entry point● BatchRuntime.getJobOperator()

Page 15: a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod ... · a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod, Java EE 7 Jiří Pechanec listopad 2014

15

Batch Applications 1.0 (5/8)

Batchlet processes everything in one phase Reader/processor/writer supports chunks

● Processing and aggregation of subset of records in a single transaction

● Checkpoints● Allows to restart a job from last processed chunk● Defined by item count, time or custom

● Errors/exceptions● Could be ignored (skipped) or retried

Page 16: a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod ... · a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod, Java EE 7 Jiří Pechanec listopad 2014

16

Batch Applications 1.0 (6/8)

Batchlet● Batchlet, AbstractBatchlet

Reader● ItemReader, AbstractItemReader

Processor● ItemProcessor

Writer ● ItemWriter, AbstractItemWriter

Job/step can have property – defined in XML @BatchProperty

Page 17: a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod ... · a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod, Java EE 7 Jiří Pechanec listopad 2014

17

Batch Applications 1.0 (7/8)

Injectable● @BatchProperty● JobContext● StepContext

Page 18: a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod ... · a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod, Java EE 7 Jiří Pechanec listopad 2014

18

Batch Applications 1.0 (8/8)

Chunks can be executed in parallel – partition Jobs can contain complex processes

● Flow● Split● Decision● Transition● Fail/End/Stop

Page 19: a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod ... · a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod, Java EE 7 Jiří Pechanec listopad 2014

19

JMS 2.0 (1/2)

Aligned with Java 7 and CDI Much easier used and less verbose code Auto-closeable objects

● Connection, Session, MessageProducer/Consumer● Significantly improves resource handling

Admin object definitions● Simpler deployment – destinations and CF configurable

in code● @JMSDestinationDefinition(s)● @JMSConnectionFactoryDefinition(s)

Page 20: a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod ... · a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod, Java EE 7 Jiří Pechanec listopad 2014

20

JMS 2.0 (2/2)

New construct – JMSContext● @Inject● Replaces Connection, Session,

MessageProducer/Consumer● Fully managed by container – no resource handling

Further configurable with● @JMSConnectionFactory● @JMSPasswordCredential● @JMSSessionMode

Page 21: a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod ... · a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod, Java EE 7 Jiří Pechanec listopad 2014

21

EL 3.0 (1/2)

Standalone API● Can use EL for application purpose● Works in Java SE

New operators● += (string concatenation)● ; (expression chaining – like , in C)

Can access static fields and methods Lambdas

● Ported from Java 8 Stream API

Page 22: a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod ... · a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod, Java EE 7 Jiří Pechanec listopad 2014

22

EL 3.0 (2/2)

Lambdas● Ported from Java 8● Functions can be assigned to variables● FP-like features

Stream API● Collection can be converted to stream, FP-like functions

supported● filter, map, distinct, sorted, forEach● reduce, max, min, count, sum● anyMatch, allMatch, findFirst

Page 23: a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod ... · a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod, Java EE 7 Jiří Pechanec listopad 2014

23

Servlet 3.1

Support for NIO in async execution● Reads and writes are event based

● ReadListener● WriteListener

HTTP Protocol Upgrade Support● e.g. for HTTP → WebSocket

Page 24: a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod ... · a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod, Java EE 7 Jiří Pechanec listopad 2014

24

JTA 1.2

Allows CDI bean methods to run in transaction context● @Transactional - required, requires new, etc.● Handled via CDI interceptors

New CDI scope - @TransactionScoped● The bean's lifecycle is tied to a running transaction

Page 25: a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod ... · a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod, Java EE 7 Jiří Pechanec listopad 2014

25

Bean Validation 1.1

CDI Integration● Can @Inject Validator and ValidatorFactory

Design by contract● Constructor and method params can be validated

Support for EL in error messages● Incl. locales

Group conversion● @ConvertGroup● Maps requested validation group to the group actually

used

Page 26: a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod ... · a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod, Java EE 7 Jiří Pechanec listopad 2014

26

JPA 2.1 (1/2)

Criteria API – bulk updates● createCriteriaUpdate● createCriteriaDelete● Portable way for big database changes

Schema generation● Standardized across JPA providers

Page 27: a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod ... · a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod, Java EE 7 Jiří Pechanec listopad 2014

27

JPA 2.1 (2/2)

Stored procedures● create(Named)StoredProcedureQuery● @NamedStoredProcedureQuery/ies

Native FUNCTION call● Used in JPQL query

● FUNCTION(f_name {,args}*)● Can execute any SQL native function● Potentially non-portable

Page 28: a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod ... · a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod, Java EE 7 Jiří Pechanec listopad 2014

28

OpenShift

Platform-as-a-Service IaaS, SaaS, PaaS http://openshift.redhat.com PHP hosting on steroids Controlled from JBDS or Git CLI

Page 29: a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod ... · a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod, Java EE 7 Jiří Pechanec listopad 2014

29

Setup IDE

Download JBDS 7 from● http://devstudio.jboss.com

Download WildFly 8 from● http://www.wildfly.org/download/

Unzip WildFly 8 Install JBDS

● java -jar ...● Direct JBDS to the directory with WildFly 8 during

installation And you are done :-)

Page 30: a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod ... · a4m36jee Pokročilé Java technologie: JBoss Část 1. - Úvod, Java EE 7 Jiří Pechanec listopad 2014

30

Questions?

[email protected] | www.jboss.org