EJB and CDI Alignment and Strategy

Similar documents
Java EE 7: Back-End Server Application Development

Agilité des applications Java EE 6

The Java EE 6 Platform. Alexis Moussine-Pouchkine GlassFish Team

OpenShift is FanPaaStic For Java EE. By Shekhar Gulati Promo Code JUDCON.IN

Java EE 6 development with Eclipse, Netbeans, IntelliJ and GlassFish. Ludovic Champenois Oracle Corporation

<Insert Picture Here> Java EE 7: the New Cloud Platform

<Insert Picture Here> Java EE 7. Linda DeMichiel Java EE Platform Lead

Java in Web 2.0. Alexis Roos Principal Field Technologist, CTO Office OEM SW Sales Sun Microsystems, Inc.

<Insert Picture Here> Java EE 7: the New Cloud Platform

rpaf KTl enterprise EJB 3.1 Cookbook I I flv* IV I I professional expertise distilled

RESIN APPLICATION SERVER JAVA EE 6 WEB PROFILE

Java EE 6 Ce qui vous attends

JSR-303 Bean Validation

Reusing Existing * Java EE Applications from Oracle SOA Suite

White Paper: Why Upgrade from WebSphere Application Server (WAS) v7 to v8.x?

OUR COURSES 19 November All prices are per person in Swedish Krona. Solid Beans AB Kungsgatan Göteborg Sweden

GlassFish v3. Building an ex tensible modular Java EE application server. Jerome Dochez and Ludovic Champenois Sun Microsystems, Inc.

Enterprise JavaBeans 3.1

Enterprise JavaBeans' Future: Getting Simpler, More Ubiquitous, but Not Dominant

JAVA ENTERPRISE IN A NUTSHELL. Jim Farley and William Crawford. O'REILLY 4 Beijing Cambridge Farnham Koln Paris Sebastopol Taipei Tokyo.

Accelerated Java EE Open Source Development with Eclipse CON1905

Module 13 Implementing Java EE Web Services with JAX-WS

How To Write A Web Framework In Java

The end. Carl Nettelblad

Running and Testing Java EE Applications in Embedded Mode with JupEEter Framework

Spring 3.1 to 3.2 in a Nutshell. Sam Brannen Senior Software Consultant

Server-Side JavaScript auf der JVM. Peter Doschkinow Senior Java Architect

Adopt-a-JSR Program. Heather VanCura (JCP), Martijn Verburg (London Java Community), Arun Gupta (Oracle/Java EE)

APPLICATION SECURITY ENHANCEMENTS IN JAVA EE 6

What's new in Java EE 6? Antonio Goncalves

Converting Java EE Applications into OSGi Applications

Framework Adoption for Java Enterprise Application Development

An introduction to creating JSF applications in Rational Application Developer Version 8.0

Das Spring Framework - Einführung in leichtgewichtige J2EE Architektur. Jürgen Höller. Organized by:

Java EE Introduction, Content. Component Architecture: Why and How Java EE: Enterprise Java

JBoss JEE5 with EJB3.0 on NonStop. JAVA SIG, San Jose

Course Description. Course Audience. Course Outline. Course Page - Page 1 of 5

Operations and Monitoring with Spring

Bienvenue chez le Ch ti JUG!

EJB & J2EE. Component Technology with thanks to Jim Dowling. Components. Problems with Previous Paradigms. What EJB Accomplishes

<Insert Picture Here> Building a Complex Web Application Using ADF and Siebel

JSLEE and SIP-Servlets Interoperability with Mobicents Communication Platform

JBS-102: Jboss Application Server Administration. Course Length: 4 days

This presentation will provide a brief introduction to Rational Application Developer V7.5.

Contents. Client-server and multi-tier architectures. The Java 2 Enterprise Edition (J2EE) platform

Sun Microsystems Inc. Java Transaction Service (JTS)

Chapter 5 Application Server Middleware

<Insert Picture Here> Java, the language for the future

JAX-WS Developer's Guide

ActiveVOS Server Architecture. March 2009

How To Develop A Web Service In A Microsoft J2Ee (Java) 2.5 (Oracle) 2-Year Old (Orcient) 2Dj (Oracles) 2E (Orca) 2Gj (J

APAC WebLogic Suite Workshop Oracle Parcel Service Overview. Jeffrey West Application Grid Product Management

Migrating JEE Applications from WLS/WAS to SpringSource tc Server. A Technical Perspective

A Guide to Migrating Enterprise Applications to Spring

WASv6_Scheduler.ppt Page 1 of 18

<Insert Picture Here> GlassFish v3 - A Taste of a Next Generation Application Server

This presentation is for informational purposes only and may not be incorporated into a contract or agreement.

JSR 375 (EE Security API) Review

Monitoring Pramati EJB Server

FUSE-ESB4 An open-source OSGi based platform for EAI and SOA

Glassfish, JAVA EE, Servlets, JSP, EJB

Building Web Services with Apache Axis2

Java-technology based projects

The Oracle Fusion Development Platform

Java Servlet 3.0. Rajiv Mordani Spec Lead

Learning GlassFish for Tomcat Users

Market Leading Web Application Server Product

WebSphere Training Outline

<Insert Picture Here> Oracle Mobile Enterprise Application Platform Overview

Oracle WebLogic Server 11g Administration

Case Studies of Running the Platform. NetBeans UML Servlet JSP GlassFish EJB

Basic TCP/IP networking knowledge of client/server concepts Basic Linux commands and desktop navigation (if don't know we will cover it )

How to Build an E-Commerce Application using J2EE. Carol McDonald Code Camp Engineer

White Paper: 1) Architecture Objectives: The primary objective of this architecture is to meet the. 2) Architecture Explanation

Component Middleware. Sophie Chabridon. INT - INF Department - Distributed Systems team 2006

Motivation Definitions EAI Architectures Elements Integration Technologies. Part I. EAI: Foundations, Concepts, and Architectures

Smalltalk in Enterprise Applications. ESUG Conference 2010 Barcelona

applications. JBoss Enterprise Application Platform

This training is targeted at System Administrators and developers wanting to understand more about administering a WebLogic instance.

Oracle WebLogic Foundation of Oracle Fusion Middleware. Lawrence Manickam Toyork Systems Inc

FEATURE MATRIX. ORACLE WEBLOGIC SERVER STANDARD EDITION 11g ORACLE WEBLOGIC SERVER ENTERPRISE EDITION 11g ORACLE WEBLOGIC SUITE 11g

Nicholas S. Williams. wrox. A Wiley Brand

CHAPTER 1 - JAVA EE OVERVIEW FOR ADMINISTRATORS

Introducing Apache Pivot. Greg Brown, Todd Volkert 6/10/2010

WebLogic Server 11g Administration Handbook

Java 2 Platform, Enterprise Edition (J2EE): Enabling Technologies for EAI

JBoss Enterprise App. Platforms Roadmap. Rich Sharples Director of Product Management, Red Hat 4th April 2011

JAVA API FOR XML WEB SERVICES INTRODUCTION TO JAX-WS, THE JAVA API FOR XML BASED WEB SERVICES (SOAP, WSDL)

Servlet 3.0. Alexis Moussine-Pouchkine. mercredi 13 avril 2011

Oracle WebLogic Server

Administering batch environments

WebSphere and Message Driven Beans

DEPLOYMENT ARCHITECTURE FOR JAVA ENVIRONMENTS

Enterprise Application Development In Java with AJAX and ORM

Web Services in Oracle Fusion Middleware. Raghu Kodali Consulting Product Manager & SOA Evangelist Oracle Fusion Middleware Oracle USA

Why IBM WebSphere Application Server V8.0?

Announcements. Comments on project proposals will go out by in next couple of days...

How To Write A Microsoft.Net Event Management System (Mnet)

CQCON 2013: five Sling features you should know

ucosminexus Application Server and BPM/ESB Platform Terminology Guide Y99(E)

Transcription:

EJB and CDI Alignment and Strategy Linda DeMichiel Java EE Specification Lead Oracle Java Day Tokyo 2015 April 8, 2015

Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle s products remains at the sole discretion of Oracle. 4

Program Agenda 1 2 3 4 5 EJB History, Goals, Evolution CDI History, Goals, Evolution Advantages/disadvantages when to use EJB/CDI Java EE Managed Bean Alignment What is our strategy for the future 5

EJB Some Background and History EJB 1.0 (begun 1996) Origins in TP monitors and component-based systems (e.g. Microsoft MTS) Designed for remote access and coarse-grained components EJB 1.1 (J2EE 1.2) First "real" EJB EJB 2.0 (J2EE 1.3) Updated Entity Beans; EJB QL; Message-driven Beans; IIOP Interoperability EJB 2.1 (J2EE 1.4) Web services support; Timer service 6

EJB Some Background and History EJB 3.0 (Java EE 5) First "modern" EJB Theme is "Ease of Development" Annotations; resource injection; simple interfaces; Java Persistence API; interceptors EJB 3.1 (Java EE 6) No-interface view; asynchronous methods; singletons; EJB Lite; Embedded EJB Interceptors separated into own spec; JPA separated into own JSR EJB 3.2 (Java EE 7) EJB Entity Beans and JAX-RPC now optional 7

EJB Today EJBs are POJOs Container provides services for ease-of-development Injection Transactions (declarative with defaults or programmatic) Security (declarative with defaults or programmatic) Thread management; synchronization; async support Timed notifications (declarative or programmatic) Integration with JMS, Web Services, IIOP-based clients and services 8

Program Agenda 1 2 3 4 5 EJB History, Goals, Evolution CDI History, Goals, Evolution Advantages/disadvantages when to use EJB/CDI Java EE Managed Bean Alignment What is our strategy for the future 9

CDI Some Background and History CDI 1.0 (Java EE 6) Original goal: direct JSF and EJB integration Dependency injection with typed injection points; typesafe resolution Annotations, qualifiers, stereotypes for strong typing Scopes, contexts for automatic bean lifecycle management Producers Interceptor bindings; decorators Events and observers Rich SPI for portable extensions 10

CDI Some Background and History CDI 1.1 (Java EE 7) Implicit bean archives Globally enabled interceptors, decorators, alternatives (with @Priority) JTA transactional interceptors; @AroundConstruct interceptors Enhancements to SPI and portable extensions 11

CDI Today Managed Bean POJOs are central @Named qualifier allows direct use in JSF, EL, Container provides services Type-safe injection Lifecycle management; contexts; scopes; lifecycle callbacks Event firing and delivery Producers, Alternatives to configure available beans Extensible model and rich SPI 12

Program Agenda 1 2 3 4 5 EJB History, Goals, Evolution CDI History, Goals, Evolution Advantages/disadvantages when to use EJB/CDI Java EE Managed Bean Alignment What is our strategy for the future 13

CDI Advantages What does CDI give you that EJB alone does not? Annotation-based programming model; stereotypes Type-safe injection, interceptors, decorators Context management, scopes, conversations Events and observers Producers and disposers Extensibility Custom scopes; programmatically defined beans; etc. Higher level of abstraction 14

CDI Advantages Higher level of abstraction vs EJB Automatic context and lifecycle management Events+observers callbacks Conversations Metalevel programming / extensibility remove/pooling 15

EJB Advantages What does EJB give you that CDI does not? Remote access RMI / CORBA Web Services MDBs / JMS Timers; scheduled events Asynchronous methods Security intergration JPA integration; container-managed extended persistence context Locking for concurrent access 16

EJB Advantages What else does EJB give you? EJBs (session beans) are CDI managed beans They have all the benefits of CDI Stateless session beans @Dependent scope Stateful session beans any scope Singleton session beans @ApplicationScoped However, need to use @Inject, not @EJB to acquire Converse is not true CDI beans are not EJBs However: We are moving EJB benefits into CDI 17

Program Agenda 1 2 3 4 5 EJB History, Goals, Evolution CDI History, Goals, Evolution Advantages/disadvantages when to use EJB/CDI Java EE Managed Bean Alignment What is our strategy for the future 18

CDI and EJB: Bridging the Gap in Java EE @ManagedBean Managed Bean spec, introduced in Java EE 6 Identified commonalities among different components as "managed beans" Identified points for extension "Managed Bean Alignment" was an important theme of Java EE 7 Generalize use of injection, interceptors, new scopes 19

Managed Beans Java EE 6 MATRIX1 Java EE 6 Contextual Support CDI injection into them Support Java EE Resource injection into them Injectable with @Inject Injectable with @Resource, @EJB, (EEdefined) Support CDI interceptors Support EE interceptors Support Decorators Support Observer methods Can fire events Support Producer methods Can have Qualifiers Can have Scope Support CDI Constructor injection Y Y Y Y Y Y Y(1) Y Y Y Y Y Y Y CDI managed beans (non-ejbs) Session beans Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y (CDI-enabled behavior via @Inject) Java EE Y Y Y Y Y Y Y Y Y Y Y Y Y Y @ManagedBean beans (CDIenabled behavior via @Inject) Session beans Y Y Y Y Y Y obtained via @EJB or JNDI lookup (with CDI enabled) Java EE Y Y Y Y Y @ManagedBeans beans obtained via @Resource or JNDI lookup (with CDI enabled) MDBs Y Y Y Y Y JAX-RS Resource Y Y Y classes Servlets Y Y Y Servlet filters, Y Y Y listeners Other Java EE Y Y Y component classes (Table EE. 5-1) JPA entities JPA entity Y(4) Y listeners Interceptors Y Y Y Decorators Y Y Y Producer Y(3) Y(5) Y(5) Y Y (2)(3) Y(2) methods Producer fields Y(2) Y(2) Disposer Y(3) Y(5) Y(5) Y Y(3) methods Observer methods Y(3) Y(5) Y(5) Y Y(3) Support Timers 20

CDI and EJB: Bridging the Gap in Java EE 7 Enabling CDI by Default CDI is enabled by default in "implicit bean archives" Use of CDI bean-defining annotations results in implicit bean archives @SessionScoped, @Dependent, Bean archives include library jars, EJB jars, WEB-INF classes, No beans.xml required 21

CDI and EJB: Bridging the Gap in Java EE 7 Injection CDI injection applies to all Java EE components when CDI is enabled Java EE components support resource injection + CDI injection Support for constructor injection added as well CDI beans support CDI injection + resource injection CDI producers can "transform" resource injection into CDI injection, making it strongly typed @Produces @Resource(lookup="java:global/env/jdbc/CustomerDatasource") @CustomerDatabase DataSource customerdatabase; 22

CDI and EJB: Bridging the Gap in Java EE 7 Interceptors CDI interceptor-binding interceptors apply to all Java EE components when CDI is enabled EJBs support "EJB interceptors" + CDI interceptor-binding interceptors CDI beans support CDI interceptor-binding interceptors + "EJB interceptors" Java EE components also support both 23

JTA Transactional Interceptors Generalization of Container-managed Transactions (Java EE 7) @Inherited @InterceptorBinding @Target({TYPE, METHOD}) @Retention(RUNTIME) public @interface Transactional { TxType value() default TxType.REQUIRED; Class[] rollbackon() default{}; Class[] dontrollbackon() default{}; } @Transactional(rollbackOn={SQLException.class}, dontrollbackon={sqlwarning.class}) public class ShoppingCart {...} 24

Bean Validation Interceptors Method-level Validation (Bean Validation 1.1, Java EE 7) @Stateless public class OrderService {... @ValidOrder public Order placeorder( @NotNull String productname, @Max(10) int quantity, @NotNull String customername, @Address String customeraddress) {... } } 25

CDI and EJB: Bridging the Gap in Java EE 7 Scopes CDI Scopes are extensible @TransactionScope Defined in JTA 1.2 Used by JMS 2.0 @FlowScoped (JSF 2.2) WebSocket expected to define scope for WebSocket endpoints in Java EE 8 26

Managed Beans Java EE 7 MATRIX Java EE 7 Contextual Support CDI injection into them Support Java EE Resource injection into them Injectable with @Inject Injectable with @Resource, @EJB, (EEdefined) Support CDI interceptors Support EE interceptors (1) Support Decorators Support Observer methods Can fire events Support Producer methods Can have Qualifiers Can have Scope Support CDI Constructor injection Y Y Y Y Y Y Y Y Y Y Y Y Y Y CDI managed beans (non-ejbs) Session beans Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y (CDI-enabled behavior via @Inject) Java EE Y Y Y Y Y Y Y Y Y Y Y Y Y Y @ManagedBean beans (CDIenabled behavior via @Inject) Session beans Y Y Y Y Y Y Y Y Y obtained via @EJB or JNDI lookup (with CDI enabled) Java EE Y Y Y Y Y Y Y Y @ManagedBeans beans obtained via @Resource or JNDI lookup (with CDI enabled) MDBs Y Y Y(6) Y Y Y Y Y JAX-RS Resource Y Y Y(6) Y Y Y Y Y classes Servlets Y Y Y(6) Y Y Y Y Y Servlet filters, Y Y Y(6) Y Y Y Y Y listeners Other Java EE Y Y Y(6) Y Y Y Y Y component classes (Table EE. 5-1) JPA entities Y(6) JPA entity listeners (4) Y Y(6) Y Y Y Y Y Interceptors Y Y Y(6) Y Y Decorators Y Y Y Y Producer Y(3) Y(5) Y(5) Y Y (2)(3) Y(2) methods Producer fields Y(2) Y(2) Disposer Y(3) Y(5) Y(5) Y Y(3) methods Observer methods Y(3) Y(5) Y(5) Y Y(3) Support Timers 27

Program Agenda 1 2 3 4 5 EJB History, Goals, Evolution CDI History, Goals, Evolution Advantages/disadvantages when to use EJB/CDI Java EE Managed Bean Alignment What is our strategy for the future 28

CDI and EJB: Bridging the Gap in Java EE 8 Expanded use of EJB Container Services Java EE 8 continues the theme of Managed-Bean Alignment Container-managed security: authorization Message-driven beans 29

Proposed: Authorization via Security Interceptors Java EE Security 1.0 (Java EE 8) @IsAuthorized("hasRoles('Manager') && schedule.officehrs") public void transferfunds() {...} @IsAuthorized("hasRoles('Manager') && hasattribute('directreports', employee.id)") public double getsalary(int employeeid) {...} @IsAuthorized(ruleSourceName="java:app/payrollAuthRules", rule="report") public void displayreport() {...}; 30

Message-driven Beans JMS 2.1: New API to receive messages asynchronously (Java EE 8) Alternative to EJB message-driven beans Usable by any CDI managed bean Simpler JMS-specific annotations No need for MessageListener implementation 31

Message-driven Beans EJB MDBs Today (Java EE 7) @MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName="connectionFactoryLookup", propertyvalue="jms/mycf"), @ActivationConfigProperty(propertyName="destinationLookup", propertyvalue="jms/myqueue"), @ActivationConfigProperty(propertyName="destinationType", propertyvalue="javax.jms/queue")} public class MyMDB implements MessageListener { public void onmessage(message message) { // extract message body String body = message.getbody(string.class)); // process message body } } 32

Proposed: Message-driven Beans JMS 2.1 Tomorrow: Allow any Java EE bean to be a listener (Java EE 8) @RequestScoped public class MyListenerBean { @JMSListener(destinationLookup="jms/myQueue") @Transactional public void mycallback(message message) {... } } 33

Bridging the Gap Other Areas of Alignment JAX-RS Injection alignment Parameter injection Scope for WebSocket endpoints Extension of Timer Service and Timer notifications (@Schedule) 34

Some Gaps Remain Java EE components are CDI managed beans They can be injected with @Inject But, Java EE components other than session beans lose their Java EE "componentness" E.g., you can inject a servlet into a managed bean, but the injected instance won't still service web requests 35

Summary EJB Features made more broadly available through CDI Java EE 6 Interceptors Java EE 7 Container-managed transactions transactional interceptors Java EE 8 Container-managed authorization security interceptors Message-driven beans simplified messaging with CDI-based MDBs Java EE 9 Timer Service (?) Timed Events (?) (?) 36

What is the Future of EJB? Part of EJB becoming Optional EJB Entity Beans, EJB QL Optional as of Java EE 7; superseded by JPA Support for JAX-RPC Optional as of Java EE 7; superseded by JAX-WS IIOP Interoperability?? Java EE 8 Experts will decide on "Proposed Optional" status Remote interfaces?? Java EE 8 Experts will decide on "Proposed Optional" status Optionality process is slow Takes 2 Java EE Platform release cycles 37

What is the Future of EJB? Important EJB features are being made more broadly available Interceptors, container-managed txs and security, MDBs, Availability is through mechanisms of CDI Will EJB still be relevant? EJB's long-term future depends on the future of remaining features Remote access (RMI, Web Services) @Schedule'd events and Timer Service Singletons - @Startup; @DependsOn; container-managed concurrency Asynchronous methods Integration with JPA 38

How You Can Influence the Discussion Adopt a JSR http://glassfish.org/adoptajsr Join an Expert Group project http://javaee-spec.java.net https://java.net/projects/javaee-spec/pages/specifications The Aquarium http://blogs.oracle.com/theaquarium Java EE 8 Reference Implementation http://glassfish.org 39

Safe Harbor Statement The preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle s products remains at the sole discretion of Oracle. 40

41