Seam. Pete Muir JBoss, a Division of Red Hat.

Similar documents
Introduction to Seam. Pete Muir. JBoss, a division of Red Hat

Seam & Web Beans. Pete Muir JBoss, a division of Red Hat.

Seam. Pete Muir JBoss, a Division of Red Hat.

Introduction to JBoss Seam

Improve and Expand JavaServer Faces Technology with JBoss Seam

Seam 3. Pete Muir JBoss, a Division of Red Hat

object/relational persistence What is persistence? 5

JBoss Seam. Israel JBoss User Group Session 05 / By : Yanai Franchi, Chief Architect Tikal

Refactoring to Seam. NetBeans. Brian Leonard Sun Microsystems, Inc. 14o

Developing Applications with Java EE 6 on WebLogic Server 12c

JBoss Seam Integration with intent to use. Dan Allen Software Consultant Author, Seam in Action

Shale and the Java Persistence Architecture. Craig McClanahan Gary Van Matre. ApacheCon US 2006 Austin, TX

Oracle - Developing Applications for the Java EE 7 Platform Ed 1 (Training On Demand)

Fast Track to EJB 3.0 and the JPA Using JBoss

CO Java EE 6: Develop Database Applications with JPA

More reading: A series about real world projects that use JavaServer Faces:

foreword to the first edition preface xxi acknowledgments xxiii about this book xxv about the cover illustration

CMP 436/774. Introduction to Java Enterprise Edition. Java Enterprise Edition

Java EE 6: Develop Web Applications with JSF

Contents at a Glance

Spring Framework 2.0 New Persistence Features. Thomas Risberg

The Next Generation. Prabhat Jha Principal Engineer

Web Application Development Using Spring, Hibernate and JPA

Type of Classes Nested Classes Inner Classes Local and Anonymous Inner Classes

"Web Age Speaks!" Webinar Series

Enterprise Java Development using JPA, Hibernate and Spring. Srini Penchikala Detroit JUG Developer Day Conference November 14, 2009

Web Application Development Using Spring, Hibernate and JPA

Web Application Development Using Spring, Hibernate and JPA

JBoss Seam. Michael Yuan, PhD Ezee Inc.

Enterprise JavaBeans, Version 3 (EJB3) Programming

Java- EE Web Application Development with Enterprise JavaBeans and Web Services

Oracle Fusion Middleware 11g: Build Applications with ADF I

Not just an App. Server

Object-relational mapping EJB and Hibernate

Migrating traditional Java EE applications to mobile

Pro JPA 2. Mastering the Java Persistence API. Apress* Mike Keith and Merrick Schnicariol

What s new in Spring Web Flow 2.0

Java EE 6 - Update Harpreet Singh GlassFish Portfolio Product Manager

Oracle Fusion Middleware 11g: Build Applications with ADF Accel

POJOs to the rescue. Easier and faster development with POJOs and lightweight frameworks

EJB ENTERPRISE JAVA BEANS INTRODUCTION TO ENTERPRISE JAVA BEANS, JAVA'S SERVER SIDE COMPONENT TECHNOLOGY. EJB Enterprise Java

JBoss Seam and beyond

Java Enterprise Edition

Oracle Fusion Middleware 11g: Build Applications with ADF I

Session 24. Introduction to Java Server Faces (JSF) Robert Kelly, Reading.

Java EE 6 New features in practice Part 2

Introduction to JPA. Fabio Falcinelli

Java EE 7: Back-End Server Application Development

The Good, the Bad and the Ugly

PATTERNS & BEST PRACTICES FOR CDI

SOFTWARE DEVELOPMENT SERVICES WEB APPLICATION PORTAL (WAP) TRAINING. Intuit 2007

What is it? What does it do?

ADVANCED JAVA TRAINING IN BANGALORE

Example jsf-cdi-and-ejb can be browsed at

CO Java EE 7: Back-End Server Application Development

JSF Tags. This tutorial will cover a number of useful JSF tags. For a complete listing of available JSF tags consult the Oracle documentation at:

Java Training Center, Noida - Java Expert Program

Lightweight J2EE Framework

Fast Track to Spring 3 and Spring MVC / Web Flow

Spring BlazeDS Integration. Jeremy Grelle SpringSource, a Division of VMware

Devoxx 2008 in a breeze

J2EE - Version: 25. Developing Enterprise Applications with J2EE Enterprise Technologies

1 Copyright 2011, Oracle and/or its affiliates. All rights reserved.

Web Application Development Using JEE, Enterprise JavaBeans and JPA

Oracle Application Development Framework Overview

JSF. What is JSF (Java Server Faces)?

Introduction to Web Application Development Using JEE, Frameworks, Web Services and AJAX

Specialized - Mastering JEE 7 Web Application Development

Maturing your application s security with Seam Security. Dan Allen Senior Software Engineer JBoss, by Red Hat

Web Application Development Using JEE, Enterprise JavaBeans and JPA

Java EE 6: Develop Business Components with JMS & EJBs

Introduction to CDI Contexts and Dependency Injection

<Insert Picture Here> Productive JavaEE 5.0 Development

E Eclipse debugging a JSF application, 25 downloading, 2 installing, 2 launching JBoss in, 3

Introduction to Java Enterprise Edition For Database Application Developer

}w!"#$%&'()+,-./012345<ya

Oracle Developer Day

Rational Application Developer 7 Bootcamp

Spring & Hibernate. Knowledge of database. And basic Knowledge of web application development. Module 1: Spring Basics

Java EE Application Assembly & Deployment Packaging Applications, Java EE modules. Model View Controller (MVC)2 Architecture & Packaging EJB Module

<Insert Picture Here> Accelerated Java EE Development: The Oracle Way

Chapter 1 Introducing EJB 1. What is Java EE Introduction to EJB...5 Need of EJB...6 Types of Enterprise Beans...7

Oracle Developer Day

JVA-163. Enterprise JavaBeans

Hibernate Search Googling your persistence domain model. Emmanuel Bernard Doer JBoss, a division of Red Hat

Java EE Architecture, Part Three. Java EE architecture, part three 1(57)

SUN Sun Certified Enterprise Architect for J2EE 5. Download Full Version :


JAVA SYLLABUS FOR 6 MONTHS

JPA and CDI JPA and EJB

1Z Oracle. Java Enterprise Edition 5 Enterprise Architect Certified Master

Struts: Struts 1.x. Introduction. Enterprise Application

Hibernate Interview Questions

Building JavaServer Faces Applications

Courses For Event Java Advanced Summer Training 2018

Building Java Persistence API Applications with Dali 1.0 Shaun Smith

Enterprise JavaBeans 3.1

5/2/2017. The entity manager. The entity manager. Entities lifecycle and manipulation

Integrating Seam and GWT

Spring Interview Questions

Transcription:

Seam Pete Muir JBoss, a Division of Red Hat http://in.relation.to/bloggers/pete pete.muir@jboss.org 1

Road Map Background Seam Future 2

Advantages of JSF/JPA over Struts/EJB 2 Fewer, finer grained artifacts No DTOs required Clean MVC Less noise No Struts/EJB 2.x boilerplate code No direct calls to HttpSession or HttpRequest Simple ORM Even simpler than the Hibernate API! 3

Advantages of JSF/JPA over Struts/EJB 2 JSF is flexible and extensible JPA Custom UI widget suites (open source) Good AJAX support Powerful object/relational mapping, far beyond EJB 2.x CMP entity beans All components are POJO so easily testable with TestNG or JUnit 4

But, still some problems JSF Backing bean couples layers and is just noise Hard to refactor all the XML and String outcomes No support for the business layer Validation breaks DRY XML is too verbose How do we write our business layer EJB3? - can t be used directly by JSF EJB3? - no concept of scopes 5

And some more challenges Workflow Ad-hoc back buttoning not suppored No stateful navigation Long running business processes? Multi-tab/window support is not built in All operations happen in the session - leakage No support for a conversation context Memory leak - objects don t get cleaned up quickly 6

Adding Seam Reference the entities directly! <h:form> Item: <h:outputtext value="#{itemeditor.id} /> Name: <h:inputtext value="#{itemeditor.item.name}"> <f:validatelength maximum="255" /> </h:inputtext> Price (EUR): <h:inputtext value="#{itemeditor.item.price}"/> <f:convertnumber type="currency" pattern="$###.##" /> </h:inputtext> <h:messages /> <h:commandbutton value="save" action="#{itemeditor.save}" /> </h:form> 7

Adding Seam @Name("itemEditor") @Scope(CONVERSATION) public class EditItemBean implements EditItem { @In EntityManager entitymanager; Long id; Item item; // getter and setter pairs @Begin public String find(long id) { item = entitymanager.find(item.class, id); return item == null? "notfound" : "success"; } A conversation scoped Seam component Begin and End a conversation - state is maintained over multiple requests between these methods } @End public String save(item item) { item = entitymanager.merge(item); return "success"; } 8

Road Map Background Seam Future 9

Contextual variables Contexts available in Seam Event Page Conversation Session Business Process Application 10

JSF lifecycle - quick review RESTORE VIEW: Restore the tree of UI components APPLY REQUEST VALUES: Synchronize request parameters with UI components PROCESS VALIDATIONS: Validate state of UI components UPDATE MODEL: Synchronize UI components with bound backing bean properties INVOKE APPLICATION: Notify action listeners, call action methods RENDER RESPONSE: Render a new tree of UI components 11

Application lifecycle Seam provides hierarchical, BUSINESS PROCESS stateful contexts APPLICATION SESSION SESSION CONVERSATION CONVERSATION EVENT EVENT EVENT PAGE INVOKE APPLICATION RENDER RESPONSE INVOKE APPLICATION 12

How is state stored? Seam provides hierarchical, stateful contexts Depends on the context: Conversation context Segmented HttpSession - times out if not used Page context Stored in the component tree of the JSF view (page) Can be stored in HttpSession or serialized to client Business Process context Persisted to database, handled by jbpm 13

Bijection Seam provides hierarchical, stateful contexts (Dependency) Injection fine for stateless applications BUT stateful applications need bidirectional wiring. Think about aliasing a stateful object into a context @Name("passwordChanger") public class PasswordChanger { } @In EntityManager entitymanager; @In @Out User currentuser; public void changepassword() { entitymanager.merge(currentuser); } Bijection: before the method call, inject the current user; after the method call, save it back into the context. 14

JPA Persistence Context What is the Persistence Context? a HashMap of all the objects I ve loaded and stored holds (at most) one in-memory object for each database row while the PC is active a natural first-level cache can do dirty checking of objects and write SQL as late as possible (automatic or manual flushing) The Persistence Context has a flexible scope default: same scope as the system transaction (JTA) extended: the PC is bound to a stateful session bean 15

Which PC scope to use? Transaction scoped & detached objects LazyInitializationException NonUniqueObjectException Less opportunity for caching An extended persistence context of a SFSB is not available during view rendering (LIE again) very complicated propagation rules No concept of a conversation 16

Seam managed persistence and transactions Seam managed PC is conversation scoped Remains active through conversation, Inject using @In Allows use of manual flush mode CONVERSATION EVENT EVENT RESTORE VIEW APPLY REQUEST VALUES PROCESS VALIDATIONS UPDATE MODEL INVOKE APPLICATION RENDER RESPONSE SYSTEM TRANSACTION PERSISTENCE CONTEXT 17 FLUSH

Navigation Stateful Pageflow powered by jbpm engine (graphical editor) Back button normally disabled Stateless Through JSF or pages.xml pages.xml is very powerful compared to JSF navigation rules (outcomes, application state, raise events on navigation) 18

Work Flow What is it? Very long running (multiple days) Lots of users (tasks can be assigned) Can contain many tasks A task is completed by one user Often a conversation 19

Validation Validate in the user interface? Yes, need to report validation errors back to the user on the correct field BUT normally need to enforce same constraints at the persistence layer and the database public @Entity class Item { @Id @GeneratedValue Long id; String name; } @Length(min=3, max=1000, message="must be between 3 and 1000 characters") String description; 20

Hibernate Validator Many built-in validators: Max, Min, Length, Range, Size, Email, Future, Past, Pattern, Email, CreditCard,... Easy (very) to write custom validators Validation and message/error display with Seam UI components for JSF Works with every JPA provider, if used with Hibernate it generates SQL DDL constraints you can use in your database schema Standardization effort under way - JSR 303 21

Seam provides... Security Email PDF Remoting Asynchronicity (Java SE, EJB3 or Quartz) Google your app using Hibernate Search Integration and Unit Testing JSF components (deep integration into JPA) Components in groovy Webservices > 25 examples Portal support 22

Road Map Background Seam concepts Future 23

Flex as a view layer A community effort Uses Granite Data Services or Blaze Data Services Check out a couple of demos at http://www.rationaldeveloper.com 24

JSF 2 Easy Component Creation & Templating Standardizes Facelets No XML needed to create a component Built in Ajax support Many improvements to JSF lifecycle (performance!) error handling navigation 25

Wicket as a view layer Why? Component orientated like JSF Built in AJAX Decouple design from components Very easy to build custom components Type safe But? Incredibly verbose Not for everyone - you ll either love it or hate 26 it!

What else? Seam 2.1 BETA released on Tuesday so I can sleep again Friendly URLs Identity Management First class support for other other containers (e.g. Websphere, WebLogic) SSO for security Deeper integration with JBoss Portal (interportlet communication) 27

Q&A http://in.relation.to/bloggers/pete http://www.seamframework.org 28